@xmoon76/dsh-pi-tui 0.5.5 → 0.5.6

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.
Files changed (48) hide show
  1. package/README.en.md +30 -47
  2. package/README.md +30 -30
  3. package/cordis.patch.yml +77 -7
  4. package/dist/{bootstrap-DLOydLLj.mjs → bootstrap-DQ4YPL-7.mjs} +12416 -7243
  5. package/dist/builtins.mjs +3 -8
  6. package/dist/{application-runtime-CbBO4bY-.mjs → client-bootstrap-Cr1JCaF5.mjs} +3098 -1747
  7. package/dist/{dist-C7QMk0ws.mjs → dist-CIsR7cz4.mjs} +510 -224
  8. package/dist/{extensions-pcFiH7Qe.mjs → extensions-Bp0L37lP.mjs} +527 -249
  9. package/dist/extensions.mjs +1 -1
  10. package/dist/{host-bootstrap-CKdfLkNS.mjs → host-bootstrap-DilsvA6f.mjs} +106 -13
  11. package/dist/host-foundation-probe--5jtvHVe.mjs +413 -0
  12. package/dist/host-runtime.d.mts +10 -6
  13. package/dist/host-runtime.mjs +877 -10
  14. package/dist/index.d.mts +11 -17
  15. package/dist/index.mjs +13328 -6828
  16. package/dist/local-client.mjs +408 -61
  17. package/dist/{local-discovery-CXnLT4GF.mjs → local-discovery-C9VMjc0K.mjs} +10 -6
  18. package/dist/{local-discovery-DVFFpfBG.mjs → local-discovery-CDaQHA_R.mjs} +1 -1
  19. package/dist/local-host.mjs +188 -36
  20. package/dist/{local-transport-C9aonplC.mjs → local-transport-BVwFYq_Y.mjs} +1 -1
  21. package/dist/{context-summary-D9mhxPXL.mjs → pasted-path-range-CMnxuGPx.mjs} +6166 -227
  22. package/dist/{context-summary-Bz0AGXa1.mjs → pasted-path-range-r6qzV_tC.mjs} +5927 -444
  23. package/dist/{pi-tui-remote-contribution-DRk6Tl3J.mjs → pi-tui-remote-contribution-B0EQsP0N.mjs} +27 -20
  24. package/dist/{pi-tui-terminal-progress-contract-XTQKj-WW.mjs → pi-tui-terminal-progress-contract-MLXZ-i3t.mjs} +2 -2
  25. package/dist/pi-tui-web-access-contract-BN8Cc_Ho.mjs +118 -0
  26. package/dist/{runtime-status-0lp9CM0V.mjs → runtime-status-Cj1nFOdS.mjs} +72 -214
  27. package/dist/{session-4keoXjk0.mjs → session-BKGXyh80.mjs} +7487 -2562
  28. package/dist/{session-B2zqv4wr.mjs → session-CPt_U8_f.mjs} +7486 -2560
  29. package/dist/{startup-Ct2UUjUL.mjs → startup-7BYWuvBU.mjs} +121 -6
  30. package/dist/startup.mjs +1 -1
  31. package/dist/{terminal-progress-source-BhufrZ74.mjs → terminal-progress-source-DrqQhtT8.mjs} +305 -45
  32. package/dist/visual-tools.d.mts +2 -2
  33. package/dist/visual-tools.mjs +26 -31
  34. package/dist/web-preferences.d.mts +29 -0
  35. package/dist/web-preferences.mjs +15 -0
  36. package/dist/web-roster-CjqnUXNk.mjs +285 -0
  37. package/generated/dsh-presets/cordis.patch.yml +5 -3
  38. package/generated/dsh-presets/ptc.patch.yml +7 -7
  39. package/generated/dsh-presets/standard.patch.yml +6 -4
  40. package/package.json +182 -168
  41. package/dist/client-bootstrap-DwSFzcTW.mjs +0 -872
  42. package/dist/custom-items-CKrOBCox.mjs +0 -655
  43. package/dist/dispose-cause-BzcXo4hu.mjs +0 -123
  44. package/dist/host-foundation-probe-CYHsbAw6.mjs +0 -143
  45. package/dist/host-prerequisites-9JBTtVNu.mjs +0 -36
  46. package/dist/runtime-Bh5OsftD.mjs +0 -6798
  47. package/dist/runtime-C5ROZqFj.mjs +0 -2
  48. package/dist/terminal-progress-source-CsBinCJ_.mjs +0 -965
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { S as scopeFromInstalledProfile, _ as installedPackageRootFromEntry, g as computeBuildId, h as bindProcessSeat, m as LocalScopeError, o as ensureLocalHost, v as readInstalledDshVersion, y as readLinuxStarttime } from "./local-discovery-CXnLT4GF.mjs";
2
+ import { S as scopeFromInstalledProfile, _ as installedPackageRootFromEntry, g as computeBuildId, h as bindProcessSeat, m as LocalScopeError, o as ensureLocalHost, v as readInstalledDshVersion, y as readLinuxStarttime } from "./local-discovery-C9VMjc0K.mjs";
3
3
  import { n as createEntryDiag, r as writeEntryRecord, t as attachEntryControl } from "./entry-control-DnduyDiw.mjs";
4
4
  import { i as runDetached } from "./tasks-D_z5Yjjr.mjs";
5
5
  import { t as mergeCause } from "./dispose-cause-CNFuUnjR.mjs";
@@ -60,6 +60,11 @@ function abortReason(signal) {
60
60
  if (reason instanceof Error) return reason;
61
61
  return /* @__PURE__ */ new Error("client interaction delivery: the request lifetime ended before a surface answered");
62
62
  }
63
+ /** The root-disposal reason: no Host result is fabricated and no local cancel
64
+ * is forwarded after the owner is gone. */
65
+ function disposedReason() {
66
+ return /* @__PURE__ */ new Error("client interaction delivery: disposed before the official request settled");
67
+ }
63
68
  /**
64
69
  * Create the ONE root interaction delivery owner over the official Client
65
70
  * Remote event seat. The caller must have mounted the official Session client
@@ -68,35 +73,132 @@ function abortReason(signal) {
68
73
  function createSplitClientInteractionDelivery(options) {
69
74
  let current;
70
75
  let disposed = false;
71
- const surfaceWaiters = /* @__PURE__ */ new Set();
72
- const owned = [];
73
- const notifySurfaceWaiters = () => {
74
- for (const waiter of [...surfaceWaiters]) {
75
- surfaceWaiters.delete(waiter);
76
+ /**
77
+ * Marks every PRESENTATION attempt made before a navigation hold / committed
78
+ * subject change as stale. This is a presentation fence only: it never
79
+ * settles or answers the official invocation, and it survives a hold release
80
+ * so a local cancellation produced by the withdrawal can never be mistaken
81
+ * for a late human answer.
82
+ */
83
+ let presentationEpoch = 0;
84
+ let navigationHold;
85
+ /** Wake-ups for a delivery wait (surface attach, subject change, hold, dispose). */
86
+ const waiters = /* @__PURE__ */ new Set();
87
+ /**
88
+ * The committed-Session authority of the CURRENT surface revision's
89
+ * application. `undefined` means "not bound yet": a forwarded request waits
90
+ * rather than presenting into a surface that has no committed subject.
91
+ */
92
+ let committedSessionId;
93
+ let bindingToken;
94
+ let bindingDisposal;
95
+ /**
96
+ * The official invocations this root currently holds. Each entry is created
97
+ * by its own callback stack and removed when that SAME invocation settles,
98
+ * aborts or the root disposes — never a Host pending copy.
99
+ */
100
+ const eligibleRequests = /* @__PURE__ */ new Set();
101
+ const eligibilityListeners = /* @__PURE__ */ new Set();
102
+ const rootLifetime = new AbortController();
103
+ const wakeWaiters = () => {
104
+ for (const waiter of [...waiters]) {
105
+ waiters.delete(waiter);
76
106
  waiter();
77
107
  }
78
108
  };
79
- /** Wait for the current surface attachment or the official request abort. */
80
- const waitForSurface = async (signal) => {
81
- if (current !== void 0) return current;
82
- if (signal?.aborted === true) throw abortReason(signal);
83
- return await new Promise((resolve, reject) => {
84
- const cleanup = () => {
85
- surfaceWaiters.delete(onSurface);
86
- signal?.removeEventListener("abort", onAbort);
87
- };
88
- const onSurface = () => {
89
- if (current === void 0) return;
90
- cleanup();
91
- resolve(current);
92
- };
93
- const onAbort = () => {
94
- cleanup();
95
- reject(abortReason(signal));
96
- };
97
- surfaceWaiters.add(onSurface);
98
- signal?.addEventListener("abort", onAbort, { once: true });
99
- });
109
+ const notifyEligibility = () => {
110
+ for (const listener of [...eligibilityListeners]) try {
111
+ listener();
112
+ } catch {}
113
+ };
114
+ const addEligible = (sessionId, kind) => {
115
+ const token = {
116
+ sessionId,
117
+ kind,
118
+ live: true
119
+ };
120
+ eligibleRequests.add(token);
121
+ notifyEligibility();
122
+ return token;
123
+ };
124
+ const removeEligible = (token) => {
125
+ if (eligibleRequests.delete(token)) notifyEligibility();
126
+ };
127
+ /** The combined official lifetime plus the root lifetime. */
128
+ const lifetimeOf = (signal) => signal === void 0 ? rootLifetime.signal : AbortSignal.any([signal, rootLifetime.signal]);
129
+ /**
130
+ * Whether the application has committed exactly the request's Session.
131
+ * An UNBOUND delivery is the legacy path (TSP split / a composition that
132
+ * never installs the PiTUI split authority): it keeps the pre-G567 forward
133
+ * behavior, and the surface's own admission still applies. The PiTUI split
134
+ * runner binds BEFORE the surface's interaction providers attach.
135
+ */
136
+ const isCommittedSubject = (sessionId) => committedSessionId === void 0 || committedSessionId() === sessionId;
137
+ /** Wake on any state change, then re-check admission. */
138
+ const waitForWake = (lifetime) => new Promise((resolve, reject) => {
139
+ if (lifetime.aborted) {
140
+ reject(abortReason(lifetime));
141
+ return;
142
+ }
143
+ const cleanup = () => {
144
+ waiters.delete(onWake);
145
+ lifetime.removeEventListener("abort", onAbort);
146
+ };
147
+ const onWake = () => {
148
+ cleanup();
149
+ resolve();
150
+ };
151
+ const onAbort = () => {
152
+ cleanup();
153
+ reject(abortReason(lifetime));
154
+ };
155
+ waiters.add(onWake);
156
+ lifetime.addEventListener("abort", onAbort, { once: true });
157
+ });
158
+ /**
159
+ * Wait until the ONE admissible presentation state holds: a surface is
160
+ * attached, no navigation hold is active, and the request's own Session is
161
+ * the committed subject. Aborts on the official request lifetime/root
162
+ * disposal; it never settles the invocation itself.
163
+ */
164
+ const waitForAdmission = async (sessionId, lifetime) => {
165
+ for (;;) {
166
+ if (disposed) throw disposedReason();
167
+ if (lifetime.aborted) throw abortReason(lifetime);
168
+ if (current !== void 0 && navigationHold === void 0 && isCommittedSubject(sessionId)) return;
169
+ await waitForWake(lifetime);
170
+ }
171
+ };
172
+ /**
173
+ * Run ONE presentation attempt of the SAME official invocation. A local
174
+ * result is accepted only while the attempt still belongs to the CURRENT
175
+ * attachment, the SAME presentation epoch, the SAME (absent) hold and the
176
+ * request's committed Session; otherwise it is dropped and the loop waits for
177
+ * the next admissible presentation. The official `next` is never called here.
178
+ */
179
+ const presentWhenAdmissible = async (sessionId, requestSignal, invoke) => {
180
+ const lifetime = lifetimeOf(requestSignal);
181
+ for (;;) {
182
+ await waitForAdmission(sessionId, lifetime);
183
+ const attachment = current;
184
+ if (attachment === void 0) continue;
185
+ const hold = navigationHold;
186
+ const epoch = presentationEpoch;
187
+ let presentation;
188
+ try {
189
+ presentation = Promise.resolve(invoke(attachment));
190
+ } catch (error) {
191
+ presentation = Promise.reject(error);
192
+ }
193
+ try {
194
+ const result = await raceWithAbort(presentation, lifetime);
195
+ if (lifetime.aborted) throw abortReason(lifetime);
196
+ if (current === attachment && navigationHold === hold && presentationEpoch === epoch && isCommittedSubject(sessionId)) return result;
197
+ } catch (error) {
198
+ if (lifetime.aborted) throw abortReason(lifetime);
199
+ if (current === attachment && navigationHold === hold && presentationEpoch === epoch && isCommittedSubject(sessionId)) throw error;
200
+ }
201
+ }
100
202
  };
101
203
  const deliverQuestion = async function(request, next) {
102
204
  const sessionId = options.sessions.scopeOf(this);
@@ -110,16 +212,11 @@ function createSplitClientInteractionDelivery(options) {
110
212
  ...request.signal === void 0 ? {} : { signal: request.signal }
111
213
  };
112
214
  const nextOnce = onceNext(next);
113
- for (;;) {
114
- const attachment = await waitForSurface(request.signal);
115
- try {
116
- const result = await raceWithAbort(Promise.resolve().then(() => attachment.onQuestion(view, nextOnce)), request.signal);
117
- if (current === attachment) return result;
118
- if (request.signal?.aborted === true) return result;
119
- } catch (error) {
120
- if (current === attachment) throw error;
121
- if (request.signal?.aborted === true) throw error;
122
- }
215
+ const eligible = addEligible(sessionId, "question");
216
+ try {
217
+ return await presentWhenAdmissible(sessionId, request.signal, (attachment) => attachment.onQuestion(view, nextOnce));
218
+ } finally {
219
+ removeEligible(eligible);
123
220
  }
124
221
  };
125
222
  const deliverApproval = async function(request, next) {
@@ -133,18 +230,14 @@ function createSplitClientInteractionDelivery(options) {
133
230
  sessionId
134
231
  };
135
232
  const nextOnce = onceNext(next);
136
- for (;;) {
137
- const attachment = await waitForSurface(request.signal);
138
- try {
139
- const result = await raceWithAbort(Promise.resolve().then(() => attachment.onApproval(view, nextOnce)), request.signal);
140
- if (current === attachment) return result;
141
- if (request.signal?.aborted === true) return result;
142
- } catch (error) {
143
- if (current === attachment) throw error;
144
- if (request.signal?.aborted === true) throw error;
145
- }
233
+ const eligible = addEligible(sessionId, "approval");
234
+ try {
235
+ return await presentWhenAdmissible(sessionId, request.signal, (attachment) => attachment.onApproval(view, nextOnce));
236
+ } finally {
237
+ removeEligible(eligible);
146
238
  }
147
239
  };
240
+ const owned = [];
148
241
  owned.push(options.remote.$on("user-questions/request", deliverQuestion));
149
242
  owned.push(options.remote.$on("approval/request", deliverApproval));
150
243
  return {
@@ -155,17 +248,79 @@ function createSplitClientInteractionDelivery(options) {
155
248
  ...input
156
249
  };
157
250
  current = attachment;
158
- notifySurfaceWaiters();
251
+ wakeWaiters();
159
252
  return () => {
160
253
  if (current !== attachment) return;
161
254
  current = void 0;
255
+ wakeWaiters();
256
+ };
257
+ },
258
+ currentEligibleRequests() {
259
+ return [...eligibleRequests];
260
+ },
261
+ subscribeEligibility(listener) {
262
+ eligibilityListeners.add(listener);
263
+ return () => {
264
+ eligibilityListeners.delete(listener);
162
265
  };
163
266
  },
267
+ bindCommittedSession(currentSessionId, subscribeCommittedSession) {
268
+ if (disposed) throw new Error("client interaction delivery: disposed");
269
+ bindingDisposal?.();
270
+ bindingDisposal = void 0;
271
+ bindingToken = void 0;
272
+ committedSessionId = void 0;
273
+ const token = {};
274
+ const off = subscribeCommittedSession(() => {
275
+ if (bindingToken !== token) return;
276
+ presentationEpoch += 1;
277
+ wakeWaiters();
278
+ });
279
+ bindingToken = token;
280
+ committedSessionId = currentSessionId;
281
+ bindingDisposal = off;
282
+ presentationEpoch += 1;
283
+ wakeWaiters();
284
+ return () => {
285
+ if (bindingToken !== token) return;
286
+ bindingToken = void 0;
287
+ bindingDisposal = void 0;
288
+ committedSessionId = void 0;
289
+ presentationEpoch += 1;
290
+ off();
291
+ wakeWaiters();
292
+ };
293
+ },
294
+ beginNavigationHold() {
295
+ if (disposed) throw new Error("client interaction delivery: disposed");
296
+ if (navigationHold !== void 0) throw new Error("client interaction delivery: a navigation hold is already active");
297
+ presentationEpoch += 1;
298
+ let released = false;
299
+ const handle = { release: () => {
300
+ if (released) return;
301
+ released = true;
302
+ if (navigationHold !== handle) return;
303
+ navigationHold = void 0;
304
+ wakeWaiters();
305
+ } };
306
+ navigationHold = handle;
307
+ wakeWaiters();
308
+ return handle;
309
+ },
164
310
  dispose() {
165
311
  if (disposed) return;
166
312
  disposed = true;
167
313
  current = void 0;
168
- runSyncDisposalSteps("client interaction delivery disposal", [...owned.splice(0).map((off) => () => {
314
+ navigationHold = void 0;
315
+ committedSessionId = void 0;
316
+ bindingToken = void 0;
317
+ const binding = bindingDisposal;
318
+ bindingDisposal = void 0;
319
+ eligibleRequests.clear();
320
+ notifyEligibility();
321
+ rootLifetime.abort(disposedReason());
322
+ wakeWaiters();
323
+ runSyncDisposalSteps("client interaction delivery disposal", [() => binding?.(), ...owned.splice(0).map((off) => () => {
169
324
  off();
170
325
  })]);
171
326
  }
@@ -221,11 +376,13 @@ function createLocalClientSurfaceBridge(stop) {
221
376
  *
222
377
  * The Client PID owns a real Cordis root and mounts only the Client-local
223
378
  * subtree plus the official Node Client transport. Its one scope is the
224
- * canonical DSH profile: it first claims the kernel single-TUI seat, then
225
- * discovers (or safely ensures) the Host, authenticates it through the
226
- * official `/connect` cookie, verifies the authenticated identity, and only
227
- * then installs the official three-layer transport on the same A0 Client
228
- * Context.
379
+ * canonical DSH profile: the frozen `qualification` mode first claims the
380
+ * qualification-only kernel Client seat (the real `surface` and `peer` modes
381
+ * do not), then discovers (or safely ensures) the Host, authenticates it
382
+ * through the official `/connect` cookie, verifies the authenticated
383
+ * identity, and only then installs the official three-layer transport on the
384
+ * same A0 Client Context. The Host Singleton keeps its own separate kernel
385
+ * seat in every mode.
229
386
  *
230
387
  * Client admission compares the required local wire protocol and the exact
231
388
  * DSH runtime version, not the package bundle/build fingerprint. A different
@@ -347,7 +504,8 @@ const OLD_CLIENT_ENVIRONMENT = [
347
504
  "SPLIT_PROCESS_CLIENT_FORCE_STARTUP_FATAL",
348
505
  "SPLIT_PROCESS_CLIENT_FORCE_REFRESH_UNRESPONSIVE_ONCE",
349
506
  "SPLIT_PROCESS_CLIENT_DROP_PROMPT_ACK",
350
- "SPLIT_PROCESS_CLIENT_OMIT_COOKIE"
507
+ "SPLIT_PROCESS_CLIENT_OMIT_COOKIE",
508
+ "SPLIT_PROCESS_CLIENT_WORKSPACE_INTENT_PATH"
351
509
  ];
352
510
  function failureMessage(error) {
353
511
  return error instanceof Error ? error.message : String(error);
@@ -594,7 +752,8 @@ function routeReexecTermination(handoffAccepted, child, signal, cancelPending) {
594
752
  return true;
595
753
  }
596
754
  /**
597
- * Finish the ONE Client process: close the kernel seat, and only after a fully
755
+ * Finish the ONE Client process: release the process seat this mode actually
756
+ * holds (qualification) or close the no-op seat, and only after a fully
598
757
  * successful teardown re-validate the replacement package and run the child.
599
758
  * A failed teardown, seat close, target re-check or spawn never starts C1 and
600
759
  * never touches the Host. Returns the replacement exit code when a handoff was
@@ -898,7 +1057,7 @@ async function runLocalClientEntry(options) {
898
1057
  pid: process.pid,
899
1058
  phase: "startup"
900
1059
  });
901
- const seat = options.mode === "peer" ? { close: async () => {} } : await bindProcessSeat(scope.clientSeatSocketName, "CLIENT_ALREADY_ACTIVE");
1060
+ const seat = options.mode === "qualification" ? await bindProcessSeat(scope.clientSeatSocketName, "CLIENT_ALREADY_ACTIVE") : { close: async () => {} };
902
1061
  let context;
903
1062
  let loaderFiber;
904
1063
  let startupGate;
@@ -1150,8 +1309,8 @@ async function runLocalClientEntry(options) {
1150
1309
  pid: process.pid,
1151
1310
  phase: "context-ready"
1152
1311
  });
1153
- const transportModule = await import("./local-transport-C9aonplC.mjs");
1154
- const { mountSurfaceClientDomainPrerequisites, startLocalClient } = await import("./client-bootstrap-DwSFzcTW.mjs");
1312
+ const transportModule = await import("./local-transport-BVwFYq_Y.mjs");
1313
+ const { mountSurfaceClientDomainPrerequisites, startLocalClient } = await import("./client-bootstrap-Cr1JCaF5.mjs");
1155
1314
  const onTransportFatal = (error) => {
1156
1315
  terminalError ??= error;
1157
1316
  if (compositionDone) runDetached("local client: terminal transport identity failure", () => stop(1, terminalError), { diag });
@@ -1325,6 +1484,171 @@ async function runLocalClientEntry(options) {
1325
1484
  });
1326
1485
  return false;
1327
1486
  }
1487
+ if (request.op === "qualification-web-access") {
1488
+ const enabled = request.webAccessEnabled;
1489
+ const webAccess = remoteService?.piTuiWebAccess;
1490
+ if (webAccess === void 0) throw new Error("local client entry: the qualification Peer has no piTuiWebAccess namespace");
1491
+ const result = enabled === void 0 ? await webAccess.getStatus() : await webAccess.setEnabled(enabled);
1492
+ emit({
1493
+ m4a0: "qualification",
1494
+ op: "web-access",
1495
+ processRole: "client",
1496
+ pid: process.pid,
1497
+ action: enabled === void 0 ? "getStatus" : "setEnabled",
1498
+ ...enabled === void 0 ? {} : { enabled },
1499
+ ok: result.ok === true,
1500
+ ...result.ok ? { status: result.value } : {
1501
+ errorCode: result.error?.code,
1502
+ ...result.error?.message === void 0 ? {} : { error: result.error.message.slice(0, 300) }
1503
+ },
1504
+ ...request.requestId === void 0 ? {} : { requestId: request.requestId }
1505
+ });
1506
+ return false;
1507
+ }
1508
+ if (request.op === "qualification-workspace-create") {
1509
+ const workspace = remoteService?.workspace;
1510
+ if (workspace === void 0) throw new Error("local client entry: the qualification Peer has no workspace namespace");
1511
+ const path = request.workspacePath;
1512
+ if (typeof path !== "string" || path === "") throw new Error("local client entry: qualification-workspace-create requires an absolute workspacePath");
1513
+ const result = await workspace.create({ path });
1514
+ const value = result.ok ? result.value : void 0;
1515
+ emit({
1516
+ m4a0: "qualification",
1517
+ op: "workspace-create",
1518
+ processRole: "client",
1519
+ pid: process.pid,
1520
+ ok: result.ok === true,
1521
+ ...value === void 0 ? { errorCode: result.error?.code } : {
1522
+ created: value.created === true,
1523
+ ...typeof value.workspace?.workspaceId === "string" ? { workspaceId: value.workspace.workspaceId } : {}
1524
+ },
1525
+ ...request.requestId === void 0 ? {} : { requestId: request.requestId }
1526
+ });
1527
+ return false;
1528
+ }
1529
+ if (request.op === "qualification-web-autostart") {
1530
+ const settings = remoteService?.settings;
1531
+ if (settings === void 0) throw new Error("local client entry: the qualification Peer has no settings namespace");
1532
+ const preferenceOf = (value) => {
1533
+ const entry = (value?.namespaces)?.find((candidate) => candidate.ns === "pi-tui-web-preferences");
1534
+ if (entry === void 0) return void 0;
1535
+ const projected = entry.value;
1536
+ if (typeof projected?.autoStart !== "boolean" || typeof entry.revision !== "number") return void 0;
1537
+ const user = entry.user;
1538
+ return {
1539
+ autoStart: projected.autoStart,
1540
+ revision: entry.revision,
1541
+ userOverridden: user?.autoStart !== void 0
1542
+ };
1543
+ };
1544
+ const before = await settings.describe();
1545
+ const current = before.ok ? preferenceOf(before.value) : void 0;
1546
+ if (current === void 0) {
1547
+ emit({
1548
+ m4a0: "qualification",
1549
+ op: "web-autostart",
1550
+ processRole: "client",
1551
+ pid: process.pid,
1552
+ ok: false,
1553
+ errorCode: "preference/unavailable",
1554
+ ...request.requestId === void 0 ? {} : { requestId: request.requestId }
1555
+ });
1556
+ return false;
1557
+ }
1558
+ const requested = request.webAutoStart;
1559
+ if (requested === void 0) {
1560
+ emit({
1561
+ m4a0: "qualification",
1562
+ op: "web-autostart",
1563
+ processRole: "client",
1564
+ pid: process.pid,
1565
+ action: "read",
1566
+ ...current,
1567
+ ok: true,
1568
+ ...request.requestId === void 0 ? {} : { requestId: request.requestId }
1569
+ });
1570
+ return false;
1571
+ }
1572
+ if (typeof requested !== "boolean") throw new Error("local client entry: qualification-web-autostart requires a boolean webAutoStart");
1573
+ const write = await settings.mutate("pi-tui-web-preferences", [{
1574
+ op: "set",
1575
+ path: ["autoStart"],
1576
+ value: requested
1577
+ }], current.revision);
1578
+ const after = await settings.describe();
1579
+ const settled = after.ok ? preferenceOf(after.value) : void 0;
1580
+ emit({
1581
+ m4a0: "qualification",
1582
+ op: "web-autostart",
1583
+ processRole: "client",
1584
+ pid: process.pid,
1585
+ action: "write",
1586
+ requested,
1587
+ ok: write.ok && settled !== void 0,
1588
+ ...settled === void 0 ? {} : settled,
1589
+ readBack: settled?.autoStart === requested,
1590
+ ...write.ok ? {} : {
1591
+ errorCode: write.error?.code,
1592
+ ...write.error?.message === void 0 ? {} : { error: write.error.message.slice(0, 300) }
1593
+ },
1594
+ ...request.requestId === void 0 ? {} : { requestId: request.requestId }
1595
+ });
1596
+ return false;
1597
+ }
1598
+ if (request.op === "qualification-web-access-url") {
1599
+ const webAccess = remoteService?.piTuiWebAccess;
1600
+ if (webAccess === void 0) throw new Error("local client entry: the qualification Peer has no piTuiWebAccess namespace");
1601
+ const result = await webAccess.getAuthenticatedUrl();
1602
+ if (!result.ok) {
1603
+ emit({
1604
+ m4a0: "qualification",
1605
+ op: "web-access-url",
1606
+ processRole: "client",
1607
+ pid: process.pid,
1608
+ ok: false,
1609
+ ...result.error?.code === void 0 ? {} : { errorCode: result.error.code },
1610
+ ...result.error?.message === void 0 ? {} : { error: result.error.message.slice(0, 300) },
1611
+ ...request.requestId === void 0 ? {} : { requestId: request.requestId }
1612
+ });
1613
+ return false;
1614
+ }
1615
+ const url = new URL(result.value.url);
1616
+ const exchange = await fetch(url, { redirect: "manual" });
1617
+ await exchange.body?.cancel();
1618
+ const cookies = exchange.headers.getSetCookie().map((header) => header.split(";")[0] ?? "").filter((pair) => pair !== "");
1619
+ const cookieHeader = cookies.join("; ");
1620
+ let pageStatus;
1621
+ let pageBytes = 0;
1622
+ if (cookieHeader !== "") {
1623
+ const page = await fetch(`${url.origin}/`, {
1624
+ redirect: "manual",
1625
+ headers: { cookie: cookieHeader }
1626
+ });
1627
+ const body = await page.text();
1628
+ pageStatus = page.status;
1629
+ pageBytes = body.length;
1630
+ }
1631
+ emit({
1632
+ m4a0: "qualification",
1633
+ op: "web-access-url",
1634
+ processRole: "client",
1635
+ pid: process.pid,
1636
+ ok: true,
1637
+ loopback: url.hostname === "127.0.0.1",
1638
+ protocol: url.protocol,
1639
+ pathname: url.pathname,
1640
+ tokenParams: url.searchParams.getAll("token").length,
1641
+ paramNames: [...url.searchParams.keys()],
1642
+ exchangeStatus: exchange.status,
1643
+ cookieNames: cookies.map((pair) => pair.split("=")[0]),
1644
+ ...pageStatus === void 0 ? {} : {
1645
+ pageStatus,
1646
+ pageBytes
1647
+ },
1648
+ ...request.requestId === void 0 ? {} : { requestId: request.requestId }
1649
+ });
1650
+ return false;
1651
+ }
1328
1652
  if (request.op === "shutdown") {
1329
1653
  await stop(0);
1330
1654
  return true;
@@ -1374,7 +1698,7 @@ async function runLocalClientEntry(options) {
1374
1698
  runDetached("local client: surface exit", () => stop(code), { diag });
1375
1699
  });
1376
1700
  activeBridge = bridge;
1377
- const { applyRunnerWithRuntime } = await import("./bootstrap-DLOydLLj.mjs");
1701
+ const { applyRunnerWithRuntime } = await import("./bootstrap-DQ4YPL-7.mjs");
1378
1702
  let runnerFiber;
1379
1703
  try {
1380
1704
  runnerFiber = clientContext.plugin((pluginContext) => {
@@ -1570,10 +1894,33 @@ async function runLocalClientEntry(options) {
1570
1894
  }
1571
1895
  if (request.op === "qualification-host-foundation") {
1572
1896
  if (context === void 0) throw new Error("local client entry: the qualification probe has no Client Context");
1573
- const { runHostFoundationProbe } = await import("./host-foundation-probe-CYHsbAw6.mjs");
1897
+ const qualificationRequest = request;
1898
+ const workspacePath = qualificationRequest.workspacePath;
1899
+ if (workspacePath !== void 0 && (typeof workspacePath !== "string" || workspacePath === "")) throw new Error("local client entry: a supplied workspacePath must be a non-empty string");
1900
+ const workspaceResume = qualificationRequest.workspaceResume;
1901
+ if (workspaceResume !== void 0 && workspaceResume !== true) throw new Error("local client entry: workspaceResume must be the boolean true when supplied");
1902
+ if (workspaceResume === true && workspacePath === void 0) throw new Error("local client entry: the generation-resume control requires a workspacePath");
1903
+ const schedule = qualificationRequest.schedule;
1904
+ if (schedule !== void 0 && schedule !== true) throw new Error("local client entry: schedule must be the boolean true when supplied");
1905
+ const { runHostFoundationProbe } = await import("./host-foundation-probe--5jtvHVe.mjs");
1574
1906
  const proof = await runHostFoundationProbe(context, {
1575
1907
  dshAnchor: options.dshAnchor,
1576
1908
  host,
1909
+ ...workspacePath === void 0 ? {} : { workspacePath },
1910
+ ...schedule === true ? { schedule: true } : {},
1911
+ ...workspaceResume !== true ? {} : {
1912
+ readGeneration: () => transport?.status().generationId,
1913
+ dropCarrier: () => {
1914
+ transport?.dropWebSocketsForQualification();
1915
+ emit({
1916
+ m4a0: "qualification",
1917
+ op: "drop-websocket",
1918
+ label: "workspace-hold",
1919
+ processRole: "client",
1920
+ pid: process.pid
1921
+ });
1922
+ }
1923
+ },
1577
1924
  ...request.requestId === void 0 ? {} : { requestId: request.requestId }
1578
1925
  });
1579
1926
  emit({
@@ -11,10 +11,10 @@ import { spawn } from "node:child_process";
11
11
  *
12
12
  * The ordinary DSH profile is the scope authority: this module derives a
13
13
  * stable id from the canonical profile directory and the current UID, then
14
- * owns the private run directory and the two Linux abstract-socket seats. The
15
- * installed-build fingerprint remains the Host's own publication/identity
16
- * material; `LOCAL_PROTOCOL` below is the Host/Client compatibility contract
17
- * and is independent of package builds.
14
+ * owns the private run directory, the Host Singleton seat and the
15
+ * qualification-only Client seat. The installed-build fingerprint remains the
16
+ * Host's own publication/identity material; `LOCAL_PROTOCOL` below is the
17
+ * Host/Client compatibility contract and is independent of package builds.
18
18
  *
19
19
  * The abstract sockets are admission primitives only. No business traffic
20
20
  * travels over them, and no PID file, registry record or `O_EXCL` marker can
@@ -30,7 +30,9 @@ const LOCAL_PROTOCOL = "dsh-pi-tui/local/1";
30
30
  /** Private scope directory below the official DSH home. */
31
31
  const RUN_ROOT_NAME = "run";
32
32
  const SCOPE_ROOT_NAME = "dsh-pi-tui";
33
- /** Linux abstract-socket prefixes; both names stay well below `sun_path`. */
33
+ /** Linux abstract-socket prefixes; both names stay well below `sun_path`. The
34
+ * Host prefix is the singleton admission seat; the Client prefix is held by
35
+ * the frozen `qualification` mode only. */
34
36
  const HOST_SEAT_PREFIX = "\0dsh-pi-tui-h-";
35
37
  const CLIENT_SEAT_PREFIX = "\0dsh-pi-tui-c-";
36
38
  /** A failure that carries one stable B1 classification code. */
@@ -249,7 +251,9 @@ function readLinuxStarttime(pid = process.pid) {
249
251
  /**
250
252
  * Claim one kernel abstract-socket seat. `EADDRINUSE` means another process
251
253
  * of this scope already holds the seat and is the sole winner; any other
252
- * listen error is a real failure. The returned close is idempotent.
254
+ * listen error is a real failure. The Host Singleton and the frozen
255
+ * `qualification` Client are the two live users; a real `surface` Client holds
256
+ * no seat. The returned close is idempotent.
253
257
  */
254
258
  function bindProcessSeat(name, conflictCode) {
255
259
  assertLinux();
@@ -1,2 +1,2 @@
1
- import { d as writeLaunchMaterial, f as writeLocalRecord } from "./local-discovery-CXnLT4GF.mjs";
1
+ import { d as writeLaunchMaterial, f as writeLocalRecord } from "./local-discovery-C9VMjc0K.mjs";
2
2
  export { writeLaunchMaterial, writeLocalRecord };