@staff0rd/assist 0.298.0 → 0.299.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/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.298.0",
9
+ version: "0.299.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -18926,33 +18926,6 @@ function shutdownSessions(sessions) {
18926
18926
  }
18927
18927
  }
18928
18928
 
18929
- // src/commands/sessions/daemon/autoHealWindowsDaemon.ts
18930
- async function autoHealWindowsDaemon(conn, state, heal, version2) {
18931
- daemonLog(`windows proxy: auto-healing windows daemon (mismatch ${version2})`);
18932
- notifyHealing(state);
18933
- try {
18934
- conn.dispose();
18935
- await heal();
18936
- daemonLog("windows proxy: heal complete, reconnecting to windows daemon");
18937
- await conn.ensure();
18938
- } catch (error) {
18939
- const message = error instanceof Error ? error.message : String(error);
18940
- daemonLog(`windows proxy: auto-heal failed: ${message}`);
18941
- state.broadcast({
18942
- type: "error",
18943
- message: `Windows host auto-update failed: ${message}`
18944
- });
18945
- }
18946
- }
18947
- function notifyHealing(state) {
18948
- for (const client of state.pendingCreators)
18949
- sendTo(client, {
18950
- type: "error",
18951
- message: "Windows host is out of date; updating it now \u2014 reselect the repo once the update finishes."
18952
- });
18953
- state.pendingCreators = [];
18954
- }
18955
-
18956
18929
  // src/commands/sessions/daemon/connectToWindowsDaemon.ts
18957
18930
  import * as net2 from "net";
18958
18931
 
@@ -19359,30 +19332,94 @@ var WindowsConnection = class {
19359
19332
  }
19360
19333
  };
19361
19334
 
19335
+ // src/commands/sessions/daemon/autoHealWindowsDaemon.ts
19336
+ async function autoHealWindowsDaemon(conn, state, heal, version2) {
19337
+ daemonLog(`windows proxy: auto-healing windows daemon (mismatch ${version2})`);
19338
+ notifyHealing(state);
19339
+ try {
19340
+ conn.dispose();
19341
+ await heal();
19342
+ daemonLog("windows proxy: heal complete, reconnecting to windows daemon");
19343
+ await conn.ensure();
19344
+ } catch (error) {
19345
+ const message = error instanceof Error ? error.message : String(error);
19346
+ daemonLog(`windows proxy: auto-heal failed: ${message}`);
19347
+ state.broadcast({
19348
+ type: "error",
19349
+ message: `Windows host auto-update failed: ${message}`
19350
+ });
19351
+ }
19352
+ }
19353
+ function notifyHealing(state) {
19354
+ for (const client of state.pendingCreators)
19355
+ sendTo(client, {
19356
+ type: "error",
19357
+ message: "Windows host is out of date; updating it now \u2014 reselect the repo once the update finishes."
19358
+ });
19359
+ state.pendingCreators = [];
19360
+ }
19361
+
19362
+ // src/commands/sessions/daemon/WindowsVersionHealer.ts
19363
+ var UNRECOVERABLE_MESSAGE = "Windows host is on an incompatible version that auto-update could not resolve; not reconnecting. Update the Windows host manually, then restart.";
19364
+ var WindowsVersionHealer = class {
19365
+ constructor(conn, state, heal) {
19366
+ this.conn = conn;
19367
+ this.state = state;
19368
+ this.heal = heal;
19369
+ }
19370
+ healAttempted = false;
19371
+ healing = false;
19372
+ unrecoverable = false;
19373
+ get blocked() {
19374
+ return this.unrecoverable;
19375
+ }
19376
+ refusal() {
19377
+ return { type: "error", message: UNRECOVERABLE_MESSAGE };
19378
+ }
19379
+ async onMismatch(version2) {
19380
+ if (this.healing || this.unrecoverable) return;
19381
+ if (this.healAttempted) return this.giveUp(version2);
19382
+ this.healing = true;
19383
+ this.healAttempted = true;
19384
+ try {
19385
+ await autoHealWindowsDaemon(this.conn, this.state, this.heal, version2);
19386
+ } finally {
19387
+ this.healing = false;
19388
+ }
19389
+ }
19390
+ giveUp(version2) {
19391
+ this.unrecoverable = true;
19392
+ daemonLog(
19393
+ `windows proxy: version mismatch ${version2} persists after heal; not reconnecting until the WSL daemon restarts`
19394
+ );
19395
+ this.conn.dispose();
19396
+ this.state.broadcast(this.refusal());
19397
+ }
19398
+ };
19399
+
19362
19400
  // src/commands/sessions/daemon/WindowsProxy.ts
19363
19401
  var WindowsProxy = class {
19402
+ state;
19403
+ conn;
19404
+ healer;
19364
19405
  constructor(clients, onSessionsChanged, connect3 = defaultConnect, heal = healWindowsDaemon) {
19365
- this.heal = heal;
19366
19406
  this.state = createState(
19367
19407
  (msg) => broadcast(clients, msg),
19368
19408
  onSessionsChanged,
19369
- (version2) => void this.handleVersionMismatch(version2)
19409
+ (version2) => void this.healer.onMismatch(version2)
19370
19410
  );
19371
19411
  this.conn = new WindowsConnection({
19372
19412
  connect: connect3,
19373
19413
  onLine: (line) => handleInbound(this.state, line),
19374
19414
  onClose: () => this.handleClose()
19375
19415
  });
19416
+ this.healer = new WindowsVersionHealer(this.conn, this.state, heal);
19376
19417
  }
19377
- state;
19378
- conn;
19379
- // why: heal runs once per proxy lifetime; if WSL is the older side, updating Windows can't close the gap, so a repeat mismatch must not loop
19380
- healAttempted = false;
19381
- healing = false;
19382
19418
  sessions() {
19383
19419
  return this.state.windowsSessions;
19384
19420
  }
19385
19421
  discover() {
19422
+ if (this.healer.blocked) return Promise.resolve();
19386
19423
  return discoverWindowsSessions(this.conn);
19387
19424
  }
19388
19425
  replayScrollback(client) {
@@ -19392,7 +19429,8 @@ var WindowsProxy = class {
19392
19429
  // windows-origin cwd is forwarded, as is I/O for a namespaced session id.
19393
19430
  route(client, data) {
19394
19431
  if (isWindowsCreate(data)) {
19395
- void forwardWindowsCreate(this.conn, this.state, client, data);
19432
+ if (this.healer.blocked) sendTo(client, this.healer.refusal());
19433
+ else void forwardWindowsCreate(this.conn, this.state, client, data);
19396
19434
  return true;
19397
19435
  }
19398
19436
  if (isWindowsIo(data)) {
@@ -19405,16 +19443,6 @@ var WindowsProxy = class {
19405
19443
  dispose() {
19406
19444
  this.conn.dispose();
19407
19445
  }
19408
- async handleVersionMismatch(version2) {
19409
- if (this.healing || this.healAttempted) return;
19410
- this.healing = true;
19411
- this.healAttempted = true;
19412
- try {
19413
- await autoHealWindowsDaemon(this.conn, this.state, this.heal, version2);
19414
- } finally {
19415
- this.healing = false;
19416
- }
19417
- }
19418
19446
  handleClose() {
19419
19447
  daemonLog("windows proxy: connection to windows daemon closed");
19420
19448
  for (const client of this.state.pendingCreators)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.298.0",
3
+ "version": "0.299.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {