@xmoon76/dsh-pi-tui 0.5.8 → 0.5.9
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.en.md +61 -25
- package/README.md +61 -25
- package/cordis.patch.yml +13 -0
- package/dist/acp-stdio.mjs +151 -0
- package/dist/{bootstrap-CMIjGyuk.mjs → bootstrap-CVyHGQDX.mjs} +21901 -6575
- package/dist/browser-CDUSHIIr.mjs +76 -0
- package/dist/builtins.mjs +2 -2
- package/dist/{client-bootstrap-BjGPc-DM.mjs → client-bootstrap-4UoeVIHE.mjs} +2488 -2734
- package/dist/client-runtime-BHBlVUf5.mjs +1376 -0
- package/dist/{daemon-launcher-Dult7Jxv.mjs → daemon-launcher-DxIgjBHW.mjs} +1549 -172
- package/dist/daemon-launcher.d.mts +85 -14
- package/dist/daemon-launcher.mjs +2 -2
- package/dist/{local-profile-daemon-admin-BmQSdzT0.mjs → diagnostics-Db5iVcuJ.mjs} +3 -90
- package/dist/{entry-control-DjNsE3I0.mjs → entry-control-BDLZgg4m.mjs} +1 -1
- package/dist/{extensions-B4uLpSTv.mjs → extensions-Dx7ncPNA.mjs} +1 -1
- package/dist/extensions.mjs +1 -1
- package/dist/handoff-BjoEy3f8.mjs +106 -0
- package/dist/history-search-limits-Cx2UvRC2.mjs +16 -0
- package/dist/history-search-remote-BHuoellG.mjs +113 -0
- package/dist/history-search-remote-BzXdvrxk.mjs +26 -0
- package/dist/history-search-seat-BcHJTpeB.mjs +639 -0
- package/dist/history-search-seat-rZcq0XV6.mjs +639 -0
- package/dist/{host-bootstrap-MVxks641.mjs → host-bootstrap-BfnufpnW.mjs} +37 -72
- package/dist/{host-foundation-probe-DMNTmNrH.mjs → host-foundation-probe-DlD8-N_Q.mjs} +2 -2
- package/dist/host-runtime.mjs +5611 -290
- package/dist/index.d.mts +13 -6
- package/dist/index.mjs +22334 -6695
- package/dist/installed-dsh-BjUiJSwR.mjs +142 -0
- package/dist/interaction-port-D1Yv9zgu.mjs +45 -0
- package/dist/local-acp-control-CC5z4Xbq.mjs +304 -0
- package/dist/local-acp-endpoint-D1jYdJdv.mjs +41 -0
- package/dist/local-acp-listener-Cmgb5M0H.mjs +9493 -0
- package/dist/local-acp-status-B_25Q6kU.mjs +101 -0
- package/dist/local-client.mjs +292 -63
- package/dist/local-daemon-control-BFJAC8Kg.mjs +2199 -0
- package/dist/local-daemon-control-Bm3imctD.mjs +2101 -0
- package/dist/{local-discovery-uOBfFq5j.mjs → local-discovery-BMhaGIiJ.mjs} +254 -544
- package/dist/{local-discovery-egN4_gsQ.mjs → local-discovery-Ba7_-NNC.mjs} +1 -1
- package/dist/{local-discovery-DOSsCh9q.mjs → local-discovery-QSbFpjK2.mjs} +301 -544
- package/dist/local-host.mjs +952 -501
- package/dist/local-profile-daemon-admin-otpm69R6.mjs +469 -0
- package/dist/{local-scope-DamiMqPd.mjs → local-scope-5DEKA_lW.mjs} +1023 -96
- package/dist/{local-transport-Iwo0mtu3.mjs → local-transport-DeWmdZ5E.mjs} +14 -3
- package/dist/{local-web-control-DMrjwCkl.mjs → local-web-control-Dny93N-r.mjs} +10 -7
- package/dist/{local-workspace-object-D06GL0UO.mjs → local-workspace-object-D0RVQt8U.mjs} +33 -9
- package/dist/model-selection-CYlqg2DV.mjs +83 -0
- package/dist/native-client-domains-Dg4srzYt.mjs +2 -0
- package/dist/native-client.d.mts +735 -0
- package/dist/native-client.mjs +3534 -0
- package/dist/{open-CmOBxSjN.mjs → open-QQva8-ar.mjs} +24 -20
- package/dist/{pi-tui-remote-contribution-Do8ECrUy.mjs → pi-tui-remote-contribution-565wiLWp.mjs} +741 -150
- package/dist/preferences.mjs +1 -1
- package/dist/{profile-preferences-migration-CThz4rHH.mjs → profile-preferences-migration-CNOWIdnr.mjs} +1 -1
- package/dist/{profile-preferences-migration-BfUGdPZx.mjs → profile-preferences-migration-IrnXcJWK.mjs} +10 -8
- package/dist/{prompt-sections-DXmjB58H.mjs → prompt-sections-Bi-9_Gr_.mjs} +28 -10
- package/dist/{prompt-sections-DUKmWb8g.mjs → prompt-sections-DFS1dqsY.mjs} +342 -56
- package/dist/{dist-BFgC-5tL.mjs → recall-scope-9Nuoto_i.mjs} +353 -1
- package/dist/rolldown-runtime-8H4AJuhK.mjs +14 -0
- package/dist/schema-CCLvDa7Q.mjs +177 -0
- package/dist/{schema-qE_P09zJ.mjs → schema-t97l3aK8.mjs} +56 -3
- package/dist/{session-C6tSs86s.mjs → session-Cs8iLCEx.mjs} +784 -342
- package/dist/{session-CstInGIA.mjs → session-EBRZF6Ow.mjs} +783 -341
- package/dist/session-create-facts-CkfG5DpQ.mjs +20 -0
- package/dist/{startup-CarQxWwi.d.mts → startup-Dti3Udne.d.mts} +30 -3
- package/dist/{startup-EG5UqIcd.mjs → startup-UtFQSDe_.mjs} +90 -15
- package/dist/startup.d.mts +2 -2
- package/dist/startup.mjs +1 -1
- package/dist/task-read-remote-DRtkXDrZ.mjs +1083 -0
- package/dist/{terminal-progress-source-CpfpQO_h.mjs → terminal-progress-source-VsczdXA-.mjs} +610 -332
- package/dist/{transcript-view-CuJYWkhp.mjs → transcript-view-B6vCnukn.mjs} +2096 -977
- package/dist/{transcript-view-C1YtJ49Y.mjs → transcript-view-DSSdE2vK.mjs} +2078 -651
- package/dist/write-failure-xNKczXH7.mjs +189 -0
- package/package.json +20 -3
- package/dist/local-acp-listener-B65J0Bx4.mjs +0 -3115
- package/dist/local-daemon-control-C14q9KnD.mjs +0 -1588
- package/dist/local-daemon-control-TCnERL7n.mjs +0 -1424
- package/dist/preset-BcWqOtY7.mjs +0 -46
package/dist/local-client.mjs
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { E as ensureWin32PrivateDirectory, N as win32PrivateDirectorySafe, P as win32PrivateFileStatus, _ as scopeFromInstalledProfile, b as parseProcessStatStarttime, d as installedPackageRootFromEntry, h as readProcessStartDiagnostic, n as LocalScopeError, o as bindProfileKernelSeat, p as readInstalledDshVersion, r as NO_PROCESS_SEAT, s as computeBuildId, x as readKernelProcess } from "./local-scope-5DEKA_lW.mjs";
|
|
3
3
|
import { t as runSyncDisposalSteps } from "./disposal-BYBbEpVY.mjs";
|
|
4
|
-
import { n as createEntryDiag, r as writeEntryRecord, t as attachEntryControl } from "./entry-control-
|
|
4
|
+
import { n as createEntryDiag, r as writeEntryRecord, t as attachEntryControl } from "./entry-control-BDLZgg4m.mjs";
|
|
5
|
+
import { a as scrubProgramResumeEnvironment, i as encodeProgramResumeHandoff, n as PROGRAM_RESUME_TOKEN_ENV, o as takeProgramResumeHandoff, t as PROGRAM_RESUME_HANDOFF_ENV } from "./handoff-BjoEy3f8.mjs";
|
|
5
6
|
import { i as runDetached, o as safeErrorMessage } from "./tasks-D_z5Yjjr.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import { c as ensureLocalHost, m as sameLocalInstanceRecord, p as readLocalRecord, r as assertRecordedHostKernelIdentityCurrent } from "./local-discovery-
|
|
7
|
+
import { a as observeHostWorkspaceObject, i as isSupportedWin32WorkspacePath, r as isBoundedWorkspaceObjectPath } from "./local-workspace-object-D0RVQt8U.mjs";
|
|
8
|
+
import { c as ensureLocalHost, m as sameLocalInstanceRecord, p as readLocalRecord, r as assertRecordedHostKernelIdentityCurrent } from "./local-discovery-QSbFpjK2.mjs";
|
|
8
9
|
import { t as mergeCause } from "./dispose-cause-CNFuUnjR.mjs";
|
|
9
|
-
import { a as
|
|
10
|
+
import { a as programResumeAdmitted, c as clientProgramResumeWithdrawal, n as profileDaemonAdminRun, s as clientProgramResumeCapability, t as createProfileDaemonAdmin } from "./local-profile-daemon-admin-otpm69R6.mjs";
|
|
11
|
+
import { r as dshHome } from "./diagnostics-Db5iVcuJ.mjs";
|
|
12
|
+
import { a as questionIntentSubtype } from "./interaction-port-D1Yv9zgu.mjs";
|
|
10
13
|
import { createRequire } from "node:module";
|
|
11
14
|
import { randomUUID } from "node:crypto";
|
|
12
15
|
import { chmodSync, closeSync, constants, existsSync, fchmodSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, rmSync, statSync, writeSync } from "node:fs";
|
|
@@ -254,6 +257,7 @@ function ensurePrivateClientDirectory(path, uid) {
|
|
|
254
257
|
* directory when missing. The shared `logs` directory is never chmodded.
|
|
255
258
|
*/
|
|
256
259
|
function prepareDiagnosticDirectory(env) {
|
|
260
|
+
if (process.platform === "win32") return prepareWin32DiagnosticDirectory(env);
|
|
257
261
|
const home = realpathSync(dshHome(env));
|
|
258
262
|
const uid = typeof process.getuid === "function" ? process.getuid() : void 0;
|
|
259
263
|
const homeInfo = statSync(home);
|
|
@@ -276,6 +280,30 @@ function prepareDiagnosticDirectory(env) {
|
|
|
276
280
|
return directory;
|
|
277
281
|
}
|
|
278
282
|
/**
|
|
283
|
+
* Windows diagnostic directory: the user-chosen DSH home and shared `logs`
|
|
284
|
+
* directory are used as they are, including a legitimate junction/symlink that
|
|
285
|
+
* resolves to an ordinary directory. Their owner-chosen ACL is NEVER modified.
|
|
286
|
+
* Only the product-owned `pi-tui-client` child is managed: when newly created it
|
|
287
|
+
* receives a protected owner-only DACL; an existing child is reused only under
|
|
288
|
+
* the shared existing-object predicate, and an unsafe one fails closed.
|
|
289
|
+
*/
|
|
290
|
+
function prepareWin32DiagnosticDirectory(env) {
|
|
291
|
+
const home = realpathSync(dshHome(env));
|
|
292
|
+
if (!statSync(home).isDirectory()) throw new DiagnosticWriteRefusal("ENOTDIR");
|
|
293
|
+
const logs = join(home, "logs");
|
|
294
|
+
try {
|
|
295
|
+
lstatSync(logs);
|
|
296
|
+
} catch (error) {
|
|
297
|
+
if (controlledErrno(error) !== "ENOENT") throw error;
|
|
298
|
+
mkdirSync(logs);
|
|
299
|
+
}
|
|
300
|
+
const logsReal = realpathSync(logs);
|
|
301
|
+
if (!statSync(logsReal).isDirectory()) throw new DiagnosticWriteRefusal("ENOTDIR");
|
|
302
|
+
const directory = join(logsReal, "pi-tui-client");
|
|
303
|
+
ensureWin32PrivateDirectory(directory);
|
|
304
|
+
return directory;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
279
307
|
* Write the whole UTF-8 buffer. `writeSync` may legally return a short count
|
|
280
308
|
* for a regular file (for example a full disk); a short/zero write is an IO
|
|
281
309
|
* failure, never a successful `written` result.
|
|
@@ -311,17 +339,21 @@ function writeClientFatalDiagnostic(error, phase, env) {
|
|
|
311
339
|
let fd;
|
|
312
340
|
let created = false;
|
|
313
341
|
try {
|
|
314
|
-
fd = openSync(target, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 384);
|
|
342
|
+
fd = openSync(target, process.platform === "win32" ? constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL : constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 384);
|
|
315
343
|
created = true;
|
|
316
344
|
let info = fstatSync(fd);
|
|
317
345
|
if (!info.isFile()) throw new DiagnosticWriteRefusal("EPERM");
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
info
|
|
346
|
+
if (process.platform === "win32") {
|
|
347
|
+
if (win32PrivateFileStatus(target) !== "private") throw new DiagnosticWriteRefusal("EPERM");
|
|
348
|
+
} else {
|
|
349
|
+
const uid = typeof process.getuid === "function" ? process.getuid() : void 0;
|
|
350
|
+
if (uid !== void 0 && info.uid !== uid) throw new DiagnosticWriteRefusal("EPERM");
|
|
351
|
+
if ((info.mode & 511) !== 384) {
|
|
352
|
+
fchmodSync(fd, 384);
|
|
353
|
+
info = fstatSync(fd);
|
|
354
|
+
}
|
|
355
|
+
if (!info.isFile() || (info.mode & 511) !== 384 || uid !== void 0 && info.uid !== uid) throw new DiagnosticWriteRefusal("EPERM");
|
|
323
356
|
}
|
|
324
|
-
if (!info.isFile() || (info.mode & 511) !== 384 || uid !== void 0 && info.uid !== uid) throw new DiagnosticWriteRefusal("EPERM");
|
|
325
357
|
writeAllBytes(fd, clientFatalErrorDetails(error, phase).text);
|
|
326
358
|
closeSync(fd);
|
|
327
359
|
fd = void 0;
|
|
@@ -359,12 +391,14 @@ function writeClientFatalDiagnostic(error, phase, env) {
|
|
|
359
391
|
*
|
|
360
392
|
* Linux uses its long-lived kernel view: the authenticated Host
|
|
361
393
|
* `/proc/<pid>/stat` starttime and `/proc/<pid>/root` directory object. macOS
|
|
362
|
-
* cannot read another process's `/proc` view, so the Host process
|
|
363
|
-
* answers through the Owner-only read-only workspace-object route
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
* Browser.
|
|
394
|
+
* and Windows cannot read another process's `/proc` view, so the Host process
|
|
395
|
+
* itself answers through the Owner-only read-only workspace-object route
|
|
396
|
+
* (schema 2 for macOS, schema 3 for Windows). All platforms require the SAME
|
|
397
|
+
* directory object the Client started in — a path spelling alone is never
|
|
398
|
+
* evidence — and a failed/unverifiable observation only means the user must
|
|
399
|
+
* choose a Host Workspace through the existing Browser. Windows additionally
|
|
400
|
+
* requires the launch object captured at launch and an ordinary local
|
|
401
|
+
* fixed-NTFS path; a missing capture is never filled by a later cwd stat.
|
|
368
402
|
*
|
|
369
403
|
* @module @xmoon76/dsh-pi-tui/app/remote-process/local-workspace-equivalence
|
|
370
404
|
*/
|
|
@@ -401,10 +435,10 @@ async function classifyLaunchWorkspace(identity, launchCwd, options = {}) {
|
|
|
401
435
|
kind: "unverified",
|
|
402
436
|
reason: "the local Host identity is unavailable"
|
|
403
437
|
};
|
|
404
|
-
if (platform === "darwin") return await
|
|
438
|
+
if (platform === "darwin" || platform === "win32") return await classifyHostObservedLaunchWorkspace(identity, launchCwd, options, platform);
|
|
405
439
|
if (platform !== "linux") return {
|
|
406
440
|
kind: "unverified",
|
|
407
|
-
reason: "the Host/Client directory equivalence check is only available on Linux and
|
|
441
|
+
reason: "the Host/Client directory equivalence check is only available on Linux, macOS and Windows"
|
|
408
442
|
};
|
|
409
443
|
if (identity.schema !== 1) return {
|
|
410
444
|
kind: "unverified",
|
|
@@ -486,15 +520,21 @@ function classifyLinuxLaunchWorkspace(identity, launchCwd, options) {
|
|
|
486
520
|
};
|
|
487
521
|
}
|
|
488
522
|
/**
|
|
489
|
-
* The macOS
|
|
490
|
-
* Owner-only route, and BOTH the kernel identity and
|
|
491
|
-
* generation must be unchanged before and after the
|
|
523
|
+
* The Host-observed proof (macOS and Windows): the Host itself stats the same
|
|
524
|
+
* absolute path through the Owner-only route, and BOTH the kernel identity and
|
|
525
|
+
* the official Connection generation must be unchanged before and after the
|
|
526
|
+
* observation. Windows additionally requires the launch object captured at
|
|
527
|
+
* launch and an ordinary local fixed-NTFS path on both sides.
|
|
492
528
|
*/
|
|
493
|
-
async function
|
|
494
|
-
if (identity.schema !== 2) return {
|
|
529
|
+
async function classifyHostObservedLaunchWorkspace(identity, launchCwd, options, platform) {
|
|
530
|
+
if (platform === "darwin" && identity.schema !== 2) return {
|
|
495
531
|
kind: "unverified",
|
|
496
532
|
reason: "the Host publication is not a macOS schema 2 record"
|
|
497
533
|
};
|
|
534
|
+
if (platform === "win32" && identity.schema !== 3) return {
|
|
535
|
+
kind: "unverified",
|
|
536
|
+
reason: "the Host publication is not a Windows schema 3 record"
|
|
537
|
+
};
|
|
498
538
|
if (identity.hostPid < 1) return {
|
|
499
539
|
kind: "unverified",
|
|
500
540
|
reason: "the authenticated Host identity is incomplete"
|
|
@@ -517,15 +557,24 @@ async function classifyDarwinLaunchWorkspace(identity, launchCwd, options) {
|
|
|
517
557
|
reason: "the official Host Connection generation is not ready"
|
|
518
558
|
};
|
|
519
559
|
const capturedGeneration = generation.generationId;
|
|
520
|
-
if (!recordIsCurrent(identity, readKernel, readRecord, scope)) return {
|
|
560
|
+
if (!recordIsCurrent(identity, readKernel, readRecord, scope, platform)) return {
|
|
521
561
|
kind: "unverified",
|
|
522
562
|
reason: "the current Host publication does not match the authenticated identity"
|
|
523
563
|
};
|
|
524
|
-
const launchObject = options.launchObject ?? statDirectoryObject(".");
|
|
564
|
+
const launchObject = platform === "win32" ? options.launchObject : options.launchObject ?? statDirectoryObject(".");
|
|
525
565
|
if (launchObject === void 0) return {
|
|
526
566
|
kind: "unverified",
|
|
527
|
-
reason: "the Client launch object cannot be inspected"
|
|
567
|
+
reason: platform === "win32" ? "the Windows Client launch directory object was not captured at launch" : "the Client launch object cannot be inspected"
|
|
528
568
|
};
|
|
569
|
+
let win32Supported;
|
|
570
|
+
if (platform === "win32") {
|
|
571
|
+
const supported = options.supportedWorkspacePath ?? ((path) => isBoundedWorkspaceObjectPath(path, "win32") && isSupportedWin32WorkspacePath(path));
|
|
572
|
+
if (!supported(launchCwd)) return {
|
|
573
|
+
kind: "unverified",
|
|
574
|
+
reason: "the launch directory is not an ordinary path on a supported local fixed NTFS volume"
|
|
575
|
+
};
|
|
576
|
+
win32Supported = () => supported(launchCwd);
|
|
577
|
+
}
|
|
529
578
|
const client = statDirectoryObject(launchCwd);
|
|
530
579
|
if (client === void 0) return {
|
|
531
580
|
kind: "unverified",
|
|
@@ -557,7 +606,7 @@ async function classifyDarwinLaunchWorkspace(identity, launchCwd, options) {
|
|
|
557
606
|
kind: "unverified",
|
|
558
607
|
reason: "the launch path changed while the Host object was observed"
|
|
559
608
|
};
|
|
560
|
-
if (!recordIsCurrent(identity, readKernel, readRecord, scope) || transport.status().generationId !== capturedGeneration) return {
|
|
609
|
+
if (!recordIsCurrent(identity, readKernel, readRecord, scope, platform) || transport.status().generationId !== capturedGeneration) return {
|
|
561
610
|
kind: "unverified",
|
|
562
611
|
reason: "the Host identity or Connection generation changed during the observation"
|
|
563
612
|
};
|
|
@@ -566,7 +615,8 @@ async function classifyDarwinLaunchWorkspace(identity, launchCwd, options) {
|
|
|
566
615
|
if (Boolean(signal?.aborted)) return false;
|
|
567
616
|
const now = transport.status();
|
|
568
617
|
if (now.transport !== "connected" || now.generationId !== capturedGeneration) return false;
|
|
569
|
-
if (!recordIsCurrent(identity, readKernel, readRecord, scope)) return false;
|
|
618
|
+
if (!recordIsCurrent(identity, readKernel, readRecord, scope, platform)) return false;
|
|
619
|
+
if (win32Supported !== void 0 && !win32Supported()) return false;
|
|
570
620
|
const clientNow = statDirectoryObject(launchCwd);
|
|
571
621
|
if (clientNow === void 0 || clientNow.device !== launchObject.device || clientNow.inode !== launchObject.inode) return false;
|
|
572
622
|
if (Boolean(signal?.aborted)) return false;
|
|
@@ -576,7 +626,7 @@ async function classifyDarwinLaunchWorkspace(identity, launchCwd, options) {
|
|
|
576
626
|
const clientAfter = statDirectoryObject(launchCwd);
|
|
577
627
|
if (clientAfter === void 0 || clientAfter.device !== launchObject.device || clientAfter.inode !== launchObject.inode) return false;
|
|
578
628
|
if (transport.status().generationId !== capturedGeneration) return false;
|
|
579
|
-
return recordIsCurrent(identity, readKernel, readRecord, scope);
|
|
629
|
+
return recordIsCurrent(identity, readKernel, readRecord, scope, platform);
|
|
580
630
|
} catch {
|
|
581
631
|
return false;
|
|
582
632
|
}
|
|
@@ -594,9 +644,9 @@ async function classifyDarwinLaunchWorkspace(identity, launchCwd, options) {
|
|
|
594
644
|
/** The live Host publication and kernel identity are still the authenticated
|
|
595
645
|
* ones. Any exception (unreadable registry, unknown kernel read) is `false`,
|
|
596
646
|
* never an assumed success. */
|
|
597
|
-
function recordIsCurrent(identity, readKernel, readRecord, scope) {
|
|
647
|
+
function recordIsCurrent(identity, readKernel, readRecord, scope, platform) {
|
|
598
648
|
try {
|
|
599
|
-
assertRecordedHostKernelIdentityCurrent(identity, readKernel);
|
|
649
|
+
assertRecordedHostKernelIdentityCurrent(identity, readKernel, platform);
|
|
600
650
|
const recorded = readRecord(scope);
|
|
601
651
|
return recorded !== void 0 && sameLocalInstanceRecord(recorded, identity);
|
|
602
652
|
} catch {
|
|
@@ -686,12 +736,7 @@ function createSplitClientInteractionDelivery(options) {
|
|
|
686
736
|
let committedSessionId;
|
|
687
737
|
let bindingToken;
|
|
688
738
|
let bindingDisposal;
|
|
689
|
-
|
|
690
|
-
* The official invocations this root currently holds. Each entry is created
|
|
691
|
-
* by its own callback stack and removed when that SAME invocation settles,
|
|
692
|
-
* aborts or the root disposes — never a Host pending copy.
|
|
693
|
-
*/
|
|
694
|
-
const eligibleRequests = /* @__PURE__ */ new Set();
|
|
739
|
+
const eligibleRequests = /* @__PURE__ */ new Map();
|
|
695
740
|
const eligibilityListeners = /* @__PURE__ */ new Set();
|
|
696
741
|
const rootLifetime = new AbortController();
|
|
697
742
|
const wakeWaiters = () => {
|
|
@@ -705,18 +750,54 @@ function createSplitClientInteractionDelivery(options) {
|
|
|
705
750
|
listener();
|
|
706
751
|
} catch {}
|
|
707
752
|
};
|
|
708
|
-
const
|
|
753
|
+
const removeEligible = (token) => {
|
|
754
|
+
const entry = eligibleRequests.get(token);
|
|
755
|
+
if (entry === void 0) return;
|
|
756
|
+
eligibleRequests.delete(token);
|
|
757
|
+
entry.offAbort?.();
|
|
758
|
+
notifyEligibility();
|
|
759
|
+
};
|
|
760
|
+
const addEligible = (sessionId, kind, subtype, signal) => {
|
|
709
761
|
const token = {
|
|
710
762
|
sessionId,
|
|
711
763
|
kind,
|
|
764
|
+
...subtype === void 0 ? {} : { subtype },
|
|
712
765
|
live: true
|
|
713
766
|
};
|
|
714
|
-
|
|
767
|
+
const generation = options.generation.getSnapshot();
|
|
768
|
+
if (generation === void 0 || signal?.aborted === true) return token;
|
|
769
|
+
const entry = {
|
|
770
|
+
token,
|
|
771
|
+
generation,
|
|
772
|
+
signal,
|
|
773
|
+
offAbort: void 0
|
|
774
|
+
};
|
|
775
|
+
eligibleRequests.set(token, entry);
|
|
776
|
+
if (signal !== void 0 && !signal.aborted) {
|
|
777
|
+
const onAbort = () => {
|
|
778
|
+
removeEligible(token);
|
|
779
|
+
};
|
|
780
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
781
|
+
entry.offAbort = () => {
|
|
782
|
+
signal.removeEventListener("abort", onAbort);
|
|
783
|
+
};
|
|
784
|
+
}
|
|
715
785
|
notifyEligibility();
|
|
716
786
|
return token;
|
|
717
787
|
};
|
|
718
|
-
|
|
719
|
-
|
|
788
|
+
/** The getter and notification view always use the LIVE official generation
|
|
789
|
+
* and request signal. A lost/replaced generation retires its tokens even if
|
|
790
|
+
* the original invocation's finally has not run yet. */
|
|
791
|
+
const pruneEligible = () => {
|
|
792
|
+
const generation = options.generation.getSnapshot();
|
|
793
|
+
let changed = false;
|
|
794
|
+
for (const [token, entry] of [...eligibleRequests]) {
|
|
795
|
+
if (generation !== void 0 && Object.is(entry.generation, generation) && entry.signal?.aborted !== true) continue;
|
|
796
|
+
eligibleRequests.delete(token);
|
|
797
|
+
entry.offAbort?.();
|
|
798
|
+
changed = true;
|
|
799
|
+
}
|
|
800
|
+
if (changed) notifyEligibility();
|
|
720
801
|
};
|
|
721
802
|
/** The combined official lifetime plus the root lifetime. */
|
|
722
803
|
const lifetimeOf = (signal) => signal === void 0 ? rootLifetime.signal : AbortSignal.any([signal, rootLifetime.signal]);
|
|
@@ -836,7 +917,7 @@ function createSplitClientInteractionDelivery(options) {
|
|
|
836
917
|
...request.signal === void 0 ? {} : { signal: request.signal }
|
|
837
918
|
};
|
|
838
919
|
const nextOnce = onceNext(next);
|
|
839
|
-
const eligible = addEligible(sessionId, "question");
|
|
920
|
+
const eligible = addEligible(sessionId, "question", questionIntentSubtype(request.questions) === "plan-review" ? "plan-review" : void 0, request.signal);
|
|
840
921
|
try {
|
|
841
922
|
return await presentWhenAdmissible(sessionId, request.signal, (attachment) => attachment.onQuestion(view, nextOnce));
|
|
842
923
|
} finally {
|
|
@@ -854,7 +935,7 @@ function createSplitClientInteractionDelivery(options) {
|
|
|
854
935
|
sessionId
|
|
855
936
|
};
|
|
856
937
|
const nextOnce = onceNext(next);
|
|
857
|
-
const eligible = addEligible(sessionId, "approval");
|
|
938
|
+
const eligible = addEligible(sessionId, "approval", void 0, request.signal);
|
|
858
939
|
try {
|
|
859
940
|
return await presentWhenAdmissible(sessionId, request.signal, (attachment) => attachment.onApproval(view, nextOnce));
|
|
860
941
|
} finally {
|
|
@@ -862,6 +943,7 @@ function createSplitClientInteractionDelivery(options) {
|
|
|
862
943
|
}
|
|
863
944
|
};
|
|
864
945
|
const owned = [];
|
|
946
|
+
owned.push(options.generation.subscribe(pruneEligible));
|
|
865
947
|
owned.push(options.remote.$on("user-questions/request", deliverQuestion));
|
|
866
948
|
owned.push(options.remote.$on("approval/request", deliverApproval));
|
|
867
949
|
return {
|
|
@@ -880,7 +962,8 @@ function createSplitClientInteractionDelivery(options) {
|
|
|
880
962
|
};
|
|
881
963
|
},
|
|
882
964
|
currentEligibleRequests() {
|
|
883
|
-
|
|
965
|
+
pruneEligible();
|
|
966
|
+
return [...eligibleRequests.values()].map((entry) => entry.token);
|
|
884
967
|
},
|
|
885
968
|
subscribeEligibility(listener) {
|
|
886
969
|
eligibilityListeners.add(listener);
|
|
@@ -940,6 +1023,7 @@ function createSplitClientInteractionDelivery(options) {
|
|
|
940
1023
|
bindingToken = void 0;
|
|
941
1024
|
const binding = bindingDisposal;
|
|
942
1025
|
bindingDisposal = void 0;
|
|
1026
|
+
for (const entry of eligibleRequests.values()) entry.offAbort?.();
|
|
943
1027
|
eligibleRequests.clear();
|
|
944
1028
|
notifyEligibility();
|
|
945
1029
|
rootLifetime.abort(disposedReason());
|
|
@@ -1031,8 +1115,9 @@ const CLIENT_LAUNCH_CWD = process.cwd();
|
|
|
1031
1115
|
/** The DIRECTORY OBJECT the Client started in, captured at the same instant as
|
|
1032
1116
|
* `CLIENT_LAUNCH_CWD`. A later rename+recreation of the path must not be
|
|
1033
1117
|
* mistaken for the launch directory (external review EXT-P1). An unreadable
|
|
1034
|
-
* capture stays `undefined`; the classifier then falls back to its own
|
|
1035
|
-
* `stat('.')` object
|
|
1118
|
+
* capture stays `undefined`; the POSIX classifier then falls back to its own
|
|
1119
|
+
* real `stat('.')` object, while the Windows classifier requires the captured
|
|
1120
|
+
* object and fails closed. */
|
|
1036
1121
|
const CLIENT_LAUNCH_OBJECT = (() => {
|
|
1037
1122
|
try {
|
|
1038
1123
|
const stat = statSync(".", { bigint: true });
|
|
@@ -1100,6 +1185,35 @@ function createSurfaceRecordSink() {
|
|
|
1100
1185
|
const directory = realpathSync(dirname(target));
|
|
1101
1186
|
const directoryStats = statSync(directory);
|
|
1102
1187
|
if (!directoryStats.isDirectory()) throw new Error("local client entry: the surface record directory is not a directory");
|
|
1188
|
+
if (process.platform === "win32") {
|
|
1189
|
+
if (!win32PrivateDirectorySafe(directory)) throw new Error("local client entry: the surface record directory is not a private owner-only directory");
|
|
1190
|
+
const existing = win32PrivateFileStatus(target);
|
|
1191
|
+
if (existing === "unsafe") throw new Error("local client entry: the surface record file is not a private regular file");
|
|
1192
|
+
let fd;
|
|
1193
|
+
let newlyCreated = false;
|
|
1194
|
+
try {
|
|
1195
|
+
fd = openSync(target, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_APPEND, 384);
|
|
1196
|
+
newlyCreated = true;
|
|
1197
|
+
} catch (error) {
|
|
1198
|
+
if (existing !== "private" || error.code !== "EEXIST") throw error;
|
|
1199
|
+
fd = openSync(target, constants.O_WRONLY | constants.O_APPEND, 384);
|
|
1200
|
+
}
|
|
1201
|
+
try {
|
|
1202
|
+
if (!fstatSync(fd).isFile()) throw new Error("local client entry: the surface record file must be a private regular file");
|
|
1203
|
+
if (newlyCreated && win32PrivateFileStatus(target) !== "private") throw new Error("local client entry: the surface record file must be a private regular file");
|
|
1204
|
+
} catch (error) {
|
|
1205
|
+
closeSync(fd);
|
|
1206
|
+
throw error;
|
|
1207
|
+
}
|
|
1208
|
+
return {
|
|
1209
|
+
emit: (record) => {
|
|
1210
|
+
writeSync(fd, `${JSON.stringify(record)}\n`);
|
|
1211
|
+
},
|
|
1212
|
+
close: () => {
|
|
1213
|
+
closeSync(fd);
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1103
1217
|
const uid = typeof process.getuid === "function" ? process.getuid() : void 0;
|
|
1104
1218
|
if (uid !== void 0 && directoryStats.uid !== uid) throw new Error("local client entry: the surface record directory is not owned by this process user");
|
|
1105
1219
|
if (existsSync(target) && lstatSync(target).isSymbolicLink()) throw new Error("local client entry: the surface record file must not be a symlink");
|
|
@@ -1286,6 +1400,11 @@ function clientFatalPrimaryWithCleanup(failure, cleanupErrors) {
|
|
|
1286
1400
|
function isRecord(value) {
|
|
1287
1401
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1288
1402
|
}
|
|
1403
|
+
/** Whether the installed target manifest implements the v1 Client handoff. */
|
|
1404
|
+
function clientHandoffCapability(manifest) {
|
|
1405
|
+
const capabilities = manifest.dshPiTuiInternalCapabilities;
|
|
1406
|
+
return isRecord(capabilities) && capabilities.osc7577ClientHandoff === 1;
|
|
1407
|
+
}
|
|
1289
1408
|
/**
|
|
1290
1409
|
* Validate one replacement Client package root and derive its production build
|
|
1291
1410
|
* fingerprint. The same checks apply to the package currently installed in the
|
|
@@ -1329,7 +1448,8 @@ function inspectClientReexecTarget(packageRoot, dshVersion) {
|
|
|
1329
1448
|
packageRoot: root,
|
|
1330
1449
|
entry,
|
|
1331
1450
|
buildId: computeBuildId(root, dshVersion),
|
|
1332
|
-
bundleVersion: manifest.version
|
|
1451
|
+
bundleVersion: manifest.version,
|
|
1452
|
+
programResumeHandoff: clientHandoffCapability(manifest)
|
|
1333
1453
|
};
|
|
1334
1454
|
}
|
|
1335
1455
|
/** Resolve the replacement package through the ACTIVE official profile. */
|
|
@@ -1379,7 +1499,8 @@ function prepareClientReexec(options) {
|
|
|
1379
1499
|
targetPackageRoot: target.packageRoot,
|
|
1380
1500
|
targetEntry: target.entry,
|
|
1381
1501
|
targetBuildId: target.buildId,
|
|
1382
|
-
targetBundleVersion: target.bundleVersion
|
|
1502
|
+
targetBundleVersion: target.bundleVersion,
|
|
1503
|
+
targetProgramResumeHandoff: target.programResumeHandoff
|
|
1383
1504
|
};
|
|
1384
1505
|
}
|
|
1385
1506
|
/**
|
|
@@ -1466,10 +1587,11 @@ function createClientReexecRequestHandler(options) {
|
|
|
1466
1587
|
};
|
|
1467
1588
|
}
|
|
1468
1589
|
/** Build the environment of the ONE replacement Client child. */
|
|
1469
|
-
function createClientReexecChildEnvironment(intent, source = process.env) {
|
|
1590
|
+
function createClientReexecChildEnvironment(intent, source = process.env, programResume) {
|
|
1470
1591
|
const env = { ...source };
|
|
1471
1592
|
const injectedFailure = source.SPLIT_PROCESS_CLIENT_REEXEC_CHILD_FAILURE;
|
|
1472
1593
|
for (const name of OLD_CLIENT_ENVIRONMENT) delete env[name];
|
|
1594
|
+
scrubProgramResumeEnvironment(env);
|
|
1473
1595
|
delete env.SPLIT_PROCESS_CLIENT_PRESET;
|
|
1474
1596
|
delete env.SPLIT_PROCESS_CLIENT_LAUNCH_V1;
|
|
1475
1597
|
env.SPLIT_PROCESS_CLIENT_MODE = "surface";
|
|
@@ -1478,6 +1600,10 @@ function createClientReexecChildEnvironment(intent, source = process.env) {
|
|
|
1478
1600
|
env.SPLIT_PROCESS_PROFILE = intent.profile;
|
|
1479
1601
|
if (intent.sessionId === void 0) delete env.SPLIT_PROCESS_CLIENT_SESSION;
|
|
1480
1602
|
else env.SPLIT_PROCESS_CLIENT_SESSION = intent.sessionId;
|
|
1603
|
+
if (intent.targetProgramResumeHandoff === true && programResume !== void 0) {
|
|
1604
|
+
env[PROGRAM_RESUME_TOKEN_ENV] = programResume.token;
|
|
1605
|
+
env[PROGRAM_RESUME_HANDOFF_ENV] = encodeProgramResumeHandoff(programResume.facts);
|
|
1606
|
+
}
|
|
1481
1607
|
if (injectedFailure !== void 0 && injectedFailure !== "") env.SPLIT_PROCESS_CLIENT_FORCE_FAILURE = injectedFailure;
|
|
1482
1608
|
return env;
|
|
1483
1609
|
}
|
|
@@ -1595,7 +1721,7 @@ async function finishClientEntryShutdown(options) {
|
|
|
1595
1721
|
options.stderr(handoffStartupFailureLine(error));
|
|
1596
1722
|
return 1;
|
|
1597
1723
|
}
|
|
1598
|
-
if (target.buildId !== reexec.intent.targetBuildId || target.entry !== reexec.intent.targetEntry) {
|
|
1724
|
+
if (target.buildId !== reexec.intent.targetBuildId || target.entry !== reexec.intent.targetEntry || target.programResumeHandoff !== (reexec.intent.targetProgramResumeHandoff === true)) {
|
|
1599
1725
|
const changed = /* @__PURE__ */ new Error("local client reexec: the replacement Client package changed between the preflight and the spawn");
|
|
1600
1726
|
options.emit({
|
|
1601
1727
|
m4r: "handoff-failed",
|
|
@@ -1611,7 +1737,7 @@ async function finishClientEntryShutdown(options) {
|
|
|
1611
1737
|
const spawnChild = options.spawnChild ?? spawnClientReexecChild;
|
|
1612
1738
|
let exit;
|
|
1613
1739
|
try {
|
|
1614
|
-
exit = await spawnChild(target.entry, createClientReexecChildEnvironment(reexec.intent), (child) => options.onChildSpawned?.(child));
|
|
1740
|
+
exit = await spawnChild(target.entry, createClientReexecChildEnvironment(reexec.intent, process.env, reexec.programResume), (child) => options.onChildSpawned?.(child));
|
|
1615
1741
|
} catch (error) {
|
|
1616
1742
|
options.emit({
|
|
1617
1743
|
m4r: "handoff-failed",
|
|
@@ -1814,6 +1940,7 @@ function observeQualificationSocket(socket, emit) {
|
|
|
1814
1940
|
* caller.
|
|
1815
1941
|
*/
|
|
1816
1942
|
async function runLocalClientEntry(options) {
|
|
1943
|
+
const programResumeCapture = takeProgramResumeHandoff(process.env);
|
|
1817
1944
|
const expectedHostInstanceId = expectedHostInstanceFromEnvironment(options.mode);
|
|
1818
1945
|
assertHandoffSignalExclusivity(options.mode, expectedHostInstanceId);
|
|
1819
1946
|
const launchEnvelope = options.mode === "surface" ? readClientLaunchEnvelope() : void 0;
|
|
@@ -1824,6 +1951,42 @@ async function runLocalClientEntry(options) {
|
|
|
1824
1951
|
const invokedEntry = process.argv[1];
|
|
1825
1952
|
const packageRoot = installedPackageRootFromEntry(invokedEntry === void 0 ? import.meta.url : pathToFileURL(invokedEntry).href);
|
|
1826
1953
|
const profileDir = hostModules.resolveProfileDir(options.profile, dshHome);
|
|
1954
|
+
const programResumeHandle = options.mode === "surface" && programResumeAdmitted(process.env) && (launchEnvelope !== void 0 || expectedHostInstanceId !== void 0) ? (() => {
|
|
1955
|
+
const input = {
|
|
1956
|
+
token: programResumeCapture.token,
|
|
1957
|
+
handoff: programResumeCapture.handoff,
|
|
1958
|
+
expectedHome: dshHome,
|
|
1959
|
+
expectedProfile: options.profile,
|
|
1960
|
+
isReexec: expectedHostInstanceId !== void 0,
|
|
1961
|
+
parentPid: process.ppid,
|
|
1962
|
+
env: process.env,
|
|
1963
|
+
execArgv: process.execArgv,
|
|
1964
|
+
stdinIsTTY: process.stdin.isTTY === true,
|
|
1965
|
+
stdoutIsTTY: process.stdout.isTTY === true,
|
|
1966
|
+
platform: process.platform
|
|
1967
|
+
};
|
|
1968
|
+
let reporter;
|
|
1969
|
+
const attach = (next) => {
|
|
1970
|
+
reporter = next;
|
|
1971
|
+
};
|
|
1972
|
+
const unsupportedReloadAccepted = () => {
|
|
1973
|
+
reporter?.unsupportedReloadAccepted();
|
|
1974
|
+
};
|
|
1975
|
+
const capability = clientProgramResumeCapability(input);
|
|
1976
|
+
if (capability !== void 0) return {
|
|
1977
|
+
capability,
|
|
1978
|
+
attach,
|
|
1979
|
+
unsupportedReloadAccepted,
|
|
1980
|
+
forReexec: () => capability
|
|
1981
|
+
};
|
|
1982
|
+
const withdrawal = clientProgramResumeWithdrawal(input);
|
|
1983
|
+
return withdrawal === void 0 ? void 0 : {
|
|
1984
|
+
withdrawal,
|
|
1985
|
+
attach,
|
|
1986
|
+
unsupportedReloadAccepted,
|
|
1987
|
+
forReexec: () => void 0
|
|
1988
|
+
};
|
|
1989
|
+
})() : void 0;
|
|
1827
1990
|
const installedDshVersion = readInstalledDshVersion(options.dshAnchor);
|
|
1828
1991
|
const scope = scopeFromInstalledProfile({
|
|
1829
1992
|
dshHome,
|
|
@@ -1931,6 +2094,7 @@ async function runLocalClientEntry(options) {
|
|
|
1931
2094
|
});
|
|
1932
2095
|
let terminalError;
|
|
1933
2096
|
let compositionDone = false;
|
|
2097
|
+
let dropGenerationObservation;
|
|
1934
2098
|
const stop = (code, failure) => {
|
|
1935
2099
|
if (stopping !== void 0) return stopping;
|
|
1936
2100
|
startupAbort.abort(failure ?? /* @__PURE__ */ new Error("local client entry: stop requested during startup"));
|
|
@@ -2160,8 +2324,8 @@ async function runLocalClientEntry(options) {
|
|
|
2160
2324
|
pid: process.pid,
|
|
2161
2325
|
phase: "context-ready"
|
|
2162
2326
|
});
|
|
2163
|
-
const transportModule = await import("./local-transport-
|
|
2164
|
-
const { mountSurfaceClientDomainPrerequisites, startLocalClient } = await import("./client-bootstrap-
|
|
2327
|
+
const transportModule = await import("./local-transport-DeWmdZ5E.mjs");
|
|
2328
|
+
const { mountSurfaceClientDomainPrerequisites, startLocalClient } = await import("./client-bootstrap-4UoeVIHE.mjs");
|
|
2165
2329
|
const onTransportFatal = (error) => {
|
|
2166
2330
|
terminalError ??= error;
|
|
2167
2331
|
if (compositionDone) runDetached("local client: terminal transport identity failure", () => stop(1, terminalError), { diag });
|
|
@@ -2212,7 +2376,8 @@ async function runLocalClientEntry(options) {
|
|
|
2212
2376
|
const remoteService = clientContext.get("remote");
|
|
2213
2377
|
if (options.mode === "surface") interactionDelivery = createSplitClientInteractionDelivery({
|
|
2214
2378
|
remote,
|
|
2215
|
-
sessions: domainPrerequisites.sessions
|
|
2379
|
+
sessions: domainPrerequisites.sessions,
|
|
2380
|
+
generation: installedTransport.connection.generation
|
|
2216
2381
|
});
|
|
2217
2382
|
else peerSeat = createPeerInteractionSeat(remote, domainPrerequisites.sessions, emit);
|
|
2218
2383
|
const agentResolver = clientContext.get("typert")?.contexts.getClient("agent");
|
|
@@ -2720,7 +2885,7 @@ async function runLocalClientEntry(options) {
|
|
|
2720
2885
|
runDetached("local client: surface exit", () => stop(code), { diag });
|
|
2721
2886
|
});
|
|
2722
2887
|
activeBridge = bridge;
|
|
2723
|
-
const { applyRunnerWithRuntime } = await import("./bootstrap-
|
|
2888
|
+
const { applyRunnerWithRuntime } = await import("./bootstrap-CVyHGQDX.mjs");
|
|
2724
2889
|
const launchWorkspace = await classifyLaunchWorkspace(host.identity, CLIENT_LAUNCH_CWD, {
|
|
2725
2890
|
...CLIENT_LAUNCH_OBJECT === void 0 ? {} : { launchObject: CLIENT_LAUNCH_OBJECT },
|
|
2726
2891
|
scope,
|
|
@@ -2740,7 +2905,9 @@ async function runLocalClientEntry(options) {
|
|
|
2740
2905
|
initialSurface: input.mountKind === "initial"
|
|
2741
2906
|
},
|
|
2742
2907
|
presencePeerScope: clientContext,
|
|
2743
|
-
...
|
|
2908
|
+
...programResumeHandle === void 0 ? {} : { programResume: programResumeHandle },
|
|
2909
|
+
...reexecHandler === void 0 ? {} : { requestClientReload: () => reexecHandler.request("manual") },
|
|
2910
|
+
normalPublicLaunch: launchEnvelope !== void 0 && expectedHostInstanceId === void 0 && input.mountKind === "initial"
|
|
2744
2911
|
}, launchWorkspace);
|
|
2745
2912
|
});
|
|
2746
2913
|
await runnerFiber;
|
|
@@ -2763,6 +2930,7 @@ async function runLocalClientEntry(options) {
|
|
|
2763
2930
|
activeBridge?.requestStop(code);
|
|
2764
2931
|
});
|
|
2765
2932
|
if (process.env.SPLIT_PROCESS_CLIENT_HMR_PROBE === "1") {
|
|
2933
|
+
if (process.platform === "win32") throw new Error("local client entry: the SIGUSR2 surface HMR qualification is unavailable on Windows");
|
|
2766
2934
|
if (process.env.SPLIT_PROCESS_CLIENT_PRIVATE_RPC_PROOF === "1" || process.env.SPLIT_PROCESS_CLIENT_REEXEC_PROBE === "1" || process.env.SPLIT_PROCESS_CLIENT_HOLD_SERIALIZE !== void 0 && process.env.SPLIT_PROCESS_CLIENT_HOLD_SERIALIZE !== "") throw new Error("local client entry: the HMR qualification signal is mutually exclusive with the T34/T36/reexec SIGUSR2 modes");
|
|
2767
2935
|
process.on("SIGUSR2", () => {
|
|
2768
2936
|
if (handle === void 0) return;
|
|
@@ -2795,9 +2963,10 @@ async function runLocalClientEntry(options) {
|
|
|
2795
2963
|
canRequest: () => stopping === void 0,
|
|
2796
2964
|
onAccepted: (accepted) => {
|
|
2797
2965
|
reexecIntent = accepted;
|
|
2966
|
+
if (accepted.targetProgramResumeHandoff !== true) programResumeHandle?.unsupportedReloadAccepted();
|
|
2798
2967
|
}
|
|
2799
2968
|
});
|
|
2800
|
-
if (reexecProbe) process.on("SIGUSR2", () => {
|
|
2969
|
+
if (reexecProbe && process.platform !== "win32") process.on("SIGUSR2", () => {
|
|
2801
2970
|
reexecHandler?.request("qualification");
|
|
2802
2971
|
});
|
|
2803
2972
|
const onTerminalEnd = () => {
|
|
@@ -2805,7 +2974,7 @@ async function runLocalClientEntry(options) {
|
|
|
2805
2974
|
};
|
|
2806
2975
|
process.stdin.on("end", onTerminalEnd);
|
|
2807
2976
|
process.stdin.on("close", onTerminalEnd);
|
|
2808
|
-
process.on("SIGUSR1", () => {
|
|
2977
|
+
if (process.platform !== "win32") process.on("SIGUSR1", () => {
|
|
2809
2978
|
transport?.dropWebSocketsForQualification();
|
|
2810
2979
|
emit({
|
|
2811
2980
|
m4b2s: "qualification",
|
|
@@ -2923,7 +3092,63 @@ async function runLocalClientEntry(options) {
|
|
|
2923
3092
|
return true;
|
|
2924
3093
|
}
|
|
2925
3094
|
if (request.op === "qualification-drop-websocket") {
|
|
2926
|
-
|
|
3095
|
+
dropGenerationObservation?.dispose();
|
|
3096
|
+
dropGenerationObservation = void 0;
|
|
3097
|
+
const connection = transport?.connection;
|
|
3098
|
+
const previous = connection?.generation.getSnapshot();
|
|
3099
|
+
let ackEmitted = false;
|
|
3100
|
+
let clearObserved = false;
|
|
3101
|
+
let published = false;
|
|
3102
|
+
let disposed = false;
|
|
3103
|
+
let dispatchStarted = false;
|
|
3104
|
+
const cleanups = [];
|
|
3105
|
+
const dispose = () => {
|
|
3106
|
+
if (disposed) return;
|
|
3107
|
+
disposed = true;
|
|
3108
|
+
for (const cleanup of cleanups.splice(0)) cleanup();
|
|
3109
|
+
if (dropGenerationObservation?.dispose === dispose) dropGenerationObservation = void 0;
|
|
3110
|
+
};
|
|
3111
|
+
const publish = () => {
|
|
3112
|
+
if (disposed || published || !ackEmitted || !clearObserved) return;
|
|
3113
|
+
published = true;
|
|
3114
|
+
emit({
|
|
3115
|
+
m4a0: "qualification",
|
|
3116
|
+
op: "drop-generation-cleared",
|
|
3117
|
+
processRole: "client",
|
|
3118
|
+
pid: process.pid,
|
|
3119
|
+
...request.requestId === void 0 ? {} : { requestId: request.requestId },
|
|
3120
|
+
previousGenerationId: previous.id
|
|
3121
|
+
});
|
|
3122
|
+
dispose();
|
|
3123
|
+
};
|
|
3124
|
+
if (connection !== void 0 && previous !== void 0 && Number.isInteger(previous.id)) {
|
|
3125
|
+
const unsubscribe = connection.generation.subscribe(() => {
|
|
3126
|
+
if (!dispatchStarted || disposed) return;
|
|
3127
|
+
const current = connection.generation.getSnapshot();
|
|
3128
|
+
if (current === void 0) {
|
|
3129
|
+
clearObserved = true;
|
|
3130
|
+
publish();
|
|
3131
|
+
} else if (current.id !== previous.id) dispose();
|
|
3132
|
+
});
|
|
3133
|
+
cleanups.push(unsubscribe);
|
|
3134
|
+
if (connection.generation.getSnapshot()?.id !== previous.id) dispose();
|
|
3135
|
+
else {
|
|
3136
|
+
const timer = setTimeout(() => dispose(), 3e4);
|
|
3137
|
+
cleanups.push(() => clearTimeout(timer));
|
|
3138
|
+
const onAbort = () => dispose();
|
|
3139
|
+
startupAbort.signal.addEventListener("abort", onAbort, { once: true });
|
|
3140
|
+
cleanups.push(() => startupAbort.signal.removeEventListener("abort", onAbort));
|
|
3141
|
+
if (startupAbort.signal.aborted) dispose();
|
|
3142
|
+
else dropGenerationObservation = { dispose };
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
try {
|
|
3146
|
+
dispatchStarted = true;
|
|
3147
|
+
transport?.dropWebSocketsForQualification();
|
|
3148
|
+
} catch (error) {
|
|
3149
|
+
dispose();
|
|
3150
|
+
throw error;
|
|
3151
|
+
}
|
|
2927
3152
|
emit({
|
|
2928
3153
|
m4a0: "qualification",
|
|
2929
3154
|
op: "drop-websocket",
|
|
@@ -2931,6 +3156,8 @@ async function runLocalClientEntry(options) {
|
|
|
2931
3156
|
pid: process.pid,
|
|
2932
3157
|
...request.requestId === void 0 ? {} : { requestId: request.requestId }
|
|
2933
3158
|
});
|
|
3159
|
+
ackEmitted = true;
|
|
3160
|
+
publish();
|
|
2934
3161
|
return false;
|
|
2935
3162
|
}
|
|
2936
3163
|
if (request.op === "qualification-host-foundation") {
|
|
@@ -2943,7 +3170,7 @@ async function runLocalClientEntry(options) {
|
|
|
2943
3170
|
if (workspaceResume === true && workspacePath === void 0) throw new Error("local client entry: the generation-resume control requires a workspacePath");
|
|
2944
3171
|
const schedule = qualificationRequest.schedule;
|
|
2945
3172
|
if (schedule !== void 0 && schedule !== true) throw new Error("local client entry: schedule must be the boolean true when supplied");
|
|
2946
|
-
const { runHostFoundationProbe } = await import("./host-foundation-probe-
|
|
3173
|
+
const { runHostFoundationProbe } = await import("./host-foundation-probe-DlD8-N_Q.mjs");
|
|
2947
3174
|
const proof = await runHostFoundationProbe(context, {
|
|
2948
3175
|
dshAnchor: options.dshAnchor,
|
|
2949
3176
|
host,
|
|
@@ -3075,12 +3302,14 @@ async function runLocalClientEntry(options) {
|
|
|
3075
3302
|
if (timedOut || transportCleanupFailed) forceExitAfterCleanupFailure();
|
|
3076
3303
|
} finally {
|
|
3077
3304
|
process.stdin.pause();
|
|
3305
|
+
const programResumeForReexec = programResumeHandle?.forReexec();
|
|
3078
3306
|
const reexecExitCode = await finishClientEntryShutdown({
|
|
3079
3307
|
seat,
|
|
3080
3308
|
...reexecIntent === void 0 ? {} : { reexec: {
|
|
3081
3309
|
intent: reexecIntent,
|
|
3082
3310
|
teardownSucceeded: reexecTeardownSucceeded,
|
|
3083
|
-
cancelled: () => reexecCancelled
|
|
3311
|
+
cancelled: () => reexecCancelled,
|
|
3312
|
+
...programResumeForReexec === void 0 ? {} : { programResume: programResumeForReexec }
|
|
3084
3313
|
} },
|
|
3085
3314
|
emit,
|
|
3086
3315
|
stderr: (line) => {
|