@xmoon76/dsh-pi-tui 0.5.7 → 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.
Files changed (78) hide show
  1. package/README.en.md +64 -26
  2. package/README.md +64 -26
  3. package/cordis.patch.yml +13 -0
  4. package/dist/acp-stdio.mjs +151 -0
  5. package/dist/{bootstrap-C9nl6e13.mjs → bootstrap-CVyHGQDX.mjs} +22330 -6888
  6. package/dist/browser-CDUSHIIr.mjs +76 -0
  7. package/dist/builtins.mjs +2 -2
  8. package/dist/{client-bootstrap-CGezi85O.mjs → client-bootstrap-4UoeVIHE.mjs} +2407 -1830
  9. package/dist/client-runtime-BHBlVUf5.mjs +1376 -0
  10. package/dist/{daemon-launcher-H_1r5Cqs.mjs → daemon-launcher-DxIgjBHW.mjs} +1551 -57
  11. package/dist/daemon-launcher.d.mts +85 -14
  12. package/dist/daemon-launcher.mjs +2 -2
  13. package/dist/diagnostics-Db5iVcuJ.mjs +123 -0
  14. package/dist/{entry-control-jBfKn1qO.mjs → entry-control-BDLZgg4m.mjs} +1 -1
  15. package/dist/{extensions-6a5vvJUT.mjs → extensions-Dx7ncPNA.mjs} +1 -4
  16. package/dist/extensions.mjs +1 -1
  17. package/dist/handoff-BjoEy3f8.mjs +106 -0
  18. package/dist/history-search-limits-Cx2UvRC2.mjs +16 -0
  19. package/dist/history-search-remote-BHuoellG.mjs +113 -0
  20. package/dist/history-search-remote-BzXdvrxk.mjs +26 -0
  21. package/dist/history-search-seat-BcHJTpeB.mjs +639 -0
  22. package/dist/history-search-seat-rZcq0XV6.mjs +639 -0
  23. package/dist/{host-bootstrap-MVxks641.mjs → host-bootstrap-BfnufpnW.mjs} +37 -72
  24. package/dist/{host-foundation-probe-DK7n5jDu.mjs → host-foundation-probe-DlD8-N_Q.mjs} +2 -2
  25. package/dist/host-runtime.mjs +5611 -290
  26. package/dist/index.d.mts +13 -6
  27. package/dist/index.mjs +22766 -6893
  28. package/dist/installed-dsh-BjUiJSwR.mjs +142 -0
  29. package/dist/interaction-port-D1Yv9zgu.mjs +45 -0
  30. package/dist/local-acp-control-CC5z4Xbq.mjs +304 -0
  31. package/dist/local-acp-endpoint-D1jYdJdv.mjs +41 -0
  32. package/dist/local-acp-listener-Cmgb5M0H.mjs +9493 -0
  33. package/dist/local-acp-status-B_25Q6kU.mjs +101 -0
  34. package/dist/local-client.mjs +719 -93
  35. package/dist/local-daemon-control-BFJAC8Kg.mjs +2199 -0
  36. package/dist/local-daemon-control-Bm3imctD.mjs +2101 -0
  37. package/dist/{local-discovery-BPZw1wEd.mjs → local-discovery-BMhaGIiJ.mjs} +254 -544
  38. package/dist/{local-discovery-BMoNXZjJ.mjs → local-discovery-Ba7_-NNC.mjs} +1 -1
  39. package/dist/{local-discovery-Bq3jLAn1.mjs → local-discovery-QSbFpjK2.mjs} +301 -544
  40. package/dist/local-host.mjs +970 -501
  41. package/dist/local-profile-daemon-admin-otpm69R6.mjs +469 -0
  42. package/dist/{local-scope-DEuGAy8l.mjs → local-scope-5DEKA_lW.mjs} +1075 -31
  43. package/dist/{local-transport-X4ZCe2uE.mjs → local-transport-DeWmdZ5E.mjs} +14 -3
  44. package/dist/{local-web-control-DKWtXIkr.mjs → local-web-control-Dny93N-r.mjs} +10 -7
  45. package/dist/{local-workspace-object-D06GL0UO.mjs → local-workspace-object-D0RVQt8U.mjs} +33 -9
  46. package/dist/model-selection-CYlqg2DV.mjs +83 -0
  47. package/dist/native-client-domains-Dg4srzYt.mjs +2 -0
  48. package/dist/native-client.d.mts +735 -0
  49. package/dist/native-client.mjs +3534 -0
  50. package/dist/{open-CmOBxSjN.mjs → open-QQva8-ar.mjs} +24 -20
  51. package/dist/{pi-tui-remote-contribution-Do8ECrUy.mjs → pi-tui-remote-contribution-565wiLWp.mjs} +741 -150
  52. package/dist/preferences.mjs +1 -1
  53. package/dist/{profile-preferences-migration-CThz4rHH.mjs → profile-preferences-migration-CNOWIdnr.mjs} +1 -1
  54. package/dist/{profile-preferences-migration-BfUGdPZx.mjs → profile-preferences-migration-IrnXcJWK.mjs} +10 -8
  55. package/dist/{prompt-sections-DXmjB58H.mjs → prompt-sections-Bi-9_Gr_.mjs} +28 -10
  56. package/dist/{prompt-sections-DUKmWb8g.mjs → prompt-sections-DFS1dqsY.mjs} +342 -56
  57. package/dist/{dist-BFgC-5tL.mjs → recall-scope-9Nuoto_i.mjs} +353 -1
  58. package/dist/rolldown-runtime-8H4AJuhK.mjs +14 -0
  59. package/dist/schema-CCLvDa7Q.mjs +177 -0
  60. package/dist/{schema-qE_P09zJ.mjs → schema-t97l3aK8.mjs} +56 -3
  61. package/dist/{session-DC0XQr5O.mjs → session-Cs8iLCEx.mjs} +784 -342
  62. package/dist/{session-Cihe8PPS.mjs → session-EBRZF6Ow.mjs} +783 -341
  63. package/dist/session-create-facts-CkfG5DpQ.mjs +20 -0
  64. package/dist/{startup-CarQxWwi.d.mts → startup-Dti3Udne.d.mts} +30 -3
  65. package/dist/{startup-CARqn3kV.mjs → startup-UtFQSDe_.mjs} +90 -15
  66. package/dist/startup.d.mts +2 -2
  67. package/dist/startup.mjs +1 -1
  68. package/dist/task-read-remote-DRtkXDrZ.mjs +1083 -0
  69. package/dist/{terminal-progress-source-D4DHyXDo.mjs → terminal-progress-source-VsczdXA-.mjs} +610 -335
  70. package/dist/{transcript-view-a7cROAaI.mjs → transcript-view-B6vCnukn.mjs} +2284 -1166
  71. package/dist/{transcript-view-hvNVkPtv.mjs → transcript-view-DSSdE2vK.mjs} +2191 -765
  72. package/dist/write-failure-xNKczXH7.mjs +189 -0
  73. package/package.json +25 -8
  74. package/dist/local-acp-listener-CNkguN5-.mjs +0 -2566
  75. package/dist/local-daemon-control-Bg9s2aYi.mjs +0 -1424
  76. package/dist/local-daemon-control-Cu_4FIdd.mjs +0 -1585
  77. package/dist/local-profile-daemon-admin-AXgVH-6y.mjs +0 -91
  78. package/dist/preset-BcWqOtY7.mjs +0 -46
@@ -0,0 +1,469 @@
1
+ import { p as readInstalledDshVersion } from "./local-scope-5DEKA_lW.mjs";
2
+ import "./entry-control-BDLZgg4m.mjs";
3
+ import { r as decodeProgramResumeHandoff } from "./handoff-BjoEy3f8.mjs";
4
+ import { t as canonicalFullSessionId } from "./browser-CDUSHIIr.mjs";
5
+ import { createRequire } from "node:module";
6
+ import { createHash } from "node:crypto";
7
+ import { accessSync, constants, readFileSync, realpathSync, statSync } from "node:fs";
8
+ import { dirname, isAbsolute, join, sep } from "node:path";
9
+ import "node:url";
10
+ import "node:os";
11
+ import "node:child_process";
12
+ //#region src/client/program-resume/codec.ts
13
+ /**
14
+ * The OSC 7577 Program Resume Protocol v0.5 encoder (sender side).
15
+ *
16
+ * Pure computation only: no terminal IO, no process state and no clock. The
17
+ * caller supplies the owning pid, the current Unix second and the already
18
+ * validated resume command. Every argument is standard Base64 of UTF-8 and
19
+ * the frame is `ESC ] 7577 ; body :mac=<sha256> ESC \`.
20
+ *
21
+ * The MAC is a plain SHA-256 of `body:token`, NOT an HMAC. A valid frame is an
22
+ * offer to the terminal, never an acknowledgement.
23
+ *
24
+ * @module @xmoon76/dsh-pi-tui/client/program-resume/codec
25
+ */
26
+ /** The protocol's application budget: complete frame bytes including OSC/ST. */
27
+ const PROGRAM_RESUME_MAX_WIRE_BYTES = 2048;
28
+ /** The protocol token grammar. */
29
+ const TOKEN = /^[A-Za-z0-9_-]{22,64}$/u;
30
+ /** C0, DEL and C1 are forbidden in decoded text. */
31
+ const FORBIDDEN_TEXT = /[\u0000-\u001F\u007F-\u009F]/u;
32
+ const OSC_PREFIX = "\x1B]7577;";
33
+ const ST = "\x1B\\";
34
+ /** Whether `value` is a legal protocol capability token. */
35
+ function isProgramResumeToken(value) {
36
+ return value !== void 0 && TOKEN.test(value);
37
+ }
38
+ /** A positive safe integer rendered without signs or decimals. */
39
+ function positiveInteger(value, field) {
40
+ if (!Number.isSafeInteger(value) || value <= 0) throw new Error(`program resume: ${field} must be a positive safe integer`);
41
+ return value;
42
+ }
43
+ /** Standard Base64 of one UTF-8 argument, rejecting invalid Unicode/control. */
44
+ function encodeText(value, field, allowEmpty) {
45
+ if (!allowEmpty && value === "") throw new Error(`program resume: ${field} must not be empty`);
46
+ if (FORBIDDEN_TEXT.test(value)) throw new Error(`program resume: ${field} contains a control character`);
47
+ const bytes = Buffer.from(value, "utf8");
48
+ if (bytes.toString("utf8") !== value) throw new Error(`program resume: ${field} is not valid Unicode text`);
49
+ return bytes.toString("base64");
50
+ }
51
+ /** The resume command's first element: an absolute path or a bare command name. */
52
+ function encodeExecutable(value) {
53
+ if (value === "" || value.startsWith("-")) throw new Error("program resume: argv[0] must be a command name or absolute path");
54
+ if (!isAbsolute(value) && value.includes("/")) throw new Error("program resume: a relative argv[0] path is forbidden");
55
+ return encodeText(value, "argv[0]", false);
56
+ }
57
+ function encodeArgv(argv) {
58
+ if (argv.length === 0 || argv.length > 64) throw new Error(`program resume: argv must contain 1..${String(64)} elements`);
59
+ const encoded = [encodeExecutable(argv[0])];
60
+ for (let index = 1; index < argv.length; index += 1) encoded.push(encodeText(argv[index], `argv[${String(index)}]`, true));
61
+ return encoded.join(",");
62
+ }
63
+ function macOf(body, token) {
64
+ if (!isProgramResumeToken(token)) throw new Error("program resume: the token is not a legal capability token");
65
+ return createHash("sha256").update(`${body}:${token}`, "utf8").digest("hex");
66
+ }
67
+ function frameOf(body, token) {
68
+ const frame = `${OSC_PREFIX}${body}:mac=${macOf(body, token)}${ST}`;
69
+ if (Buffer.byteLength(frame, "utf8") > 2048) throw new Error(`program resume: the complete frame exceeds ${String(PROGRAM_RESUME_MAX_WIRE_BYTES)} bytes`);
70
+ return frame;
71
+ }
72
+ /**
73
+ * Encode one resume report. Throws rather than truncating or emitting a
74
+ * partial frame; the caller may send a legal clear instead.
75
+ */
76
+ function encodeProgramResumeReport(input) {
77
+ const pid = positiveInteger(input.pid, "pid");
78
+ const time = positiveInteger(input.time, "time");
79
+ const cwdValue = input.cwd;
80
+ let cwd = "";
81
+ if (cwdValue !== void 0) {
82
+ if (!isAbsolute(cwdValue)) throw new Error("program resume: cwd must be absolute");
83
+ cwd = `:cwd=${encodeText(cwdValue, "cwd", false)}`;
84
+ }
85
+ return frameOf(`pid=${String(pid)}:time=${String(time)}:argv=${encodeArgv(input.argv)}${cwd}`, input.token);
86
+ }
87
+ /**
88
+ * Encode one clear report. A clear removes the matching record; it is the
89
+ * only legal replacement for a resume command the product cannot express.
90
+ */
91
+ function encodeProgramResumeClear(input) {
92
+ const pid = positiveInteger(input.pid, "pid");
93
+ const time = positiveInteger(input.time, "time");
94
+ return frameOf(`pid=${String(pid)}:time=${String(time)}:clear=1`, input.token);
95
+ }
96
+ //#endregion
97
+ //#region src/client/program-resume/target.ts
98
+ /**
99
+ * The authoritative OSC 7577 resume target: exact launch scope -> the public
100
+ * cold-open command. This module is Client-local and performs only boot-time
101
+ * proof; Session identity stays with the production ownership core.
102
+ *
103
+ * A target is produced only when EVERY launch fact is losslessly expressible:
104
+ * the real official Profile, absolute DSH home, the actual backend, the real
105
+ * CLI launch cwd, the current Node executable and the exact official DSH JS
106
+ * entry. Overlays, an explicit preset, telemetry overrides, special Node flags,
107
+ * a multiplexer/SSH topology, a non-TTY launch or an untrusted token source
108
+ * disable the sender instead of guessing.
109
+ *
110
+ * @module @xmoon76/dsh-pi-tui/client/program-resume/target
111
+ */
112
+ /** The fixed protocol command prefix; `/usr/bin/env` is a real executable. */
113
+ const ENV = "/usr/bin/env";
114
+ const FORBIDDEN_PATH_TEXT = /[\u0000-\u001F\u007F-\u009F]/u;
115
+ /** A readable regular file. */
116
+ function regularFile(path) {
117
+ try {
118
+ if (!statSync(path).isFile()) return false;
119
+ accessSync(path, constants.R_OK);
120
+ return true;
121
+ } catch {
122
+ return false;
123
+ }
124
+ }
125
+ /** An executable regular file. */
126
+ function executableFile(path) {
127
+ try {
128
+ if (!statSync(path).isFile()) return false;
129
+ accessSync(path, constants.X_OK);
130
+ return true;
131
+ } catch {
132
+ return false;
133
+ }
134
+ }
135
+ /** A readable/traversable directory. */
136
+ function directory(path) {
137
+ try {
138
+ if (!statSync(path).isDirectory()) return false;
139
+ accessSync(path, constants.X_OK);
140
+ return true;
141
+ } catch {
142
+ return false;
143
+ }
144
+ }
145
+ /** Resolve the exact official CLI entry from the installed DSH manifest. */
146
+ function resolveOfficialCliEntry(installAnchor, expectedEntry) {
147
+ if (!isAbsolute(installAnchor)) return void 0;
148
+ let manifestPath;
149
+ let manifest;
150
+ try {
151
+ manifestPath = realpathSync(installAnchor);
152
+ manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
153
+ } catch {
154
+ return;
155
+ }
156
+ if (manifest === null || typeof manifest !== "object" || Array.isArray(manifest)) return void 0;
157
+ const record = manifest;
158
+ if (record.name !== "@deepseek-ai/dsh" || typeof record.version !== "string") return void 0;
159
+ const bin = record.bin;
160
+ const relative = bin !== null && typeof bin === "object" && !Array.isArray(bin) ? bin.dsh : void 0;
161
+ if (typeof relative !== "string" || relative === "" || isAbsolute(relative)) return void 0;
162
+ const root = dirname(manifestPath);
163
+ let entry;
164
+ try {
165
+ entry = realpathSync(join(root, relative));
166
+ } catch {
167
+ return;
168
+ }
169
+ if (entry !== root && !entry.startsWith(`${root}${sep}`)) return void 0;
170
+ if (!regularFile(entry)) return void 0;
171
+ if (expectedEntry !== void 0) try {
172
+ if (realpathSync(expectedEntry) !== entry) return void 0;
173
+ } catch {
174
+ return;
175
+ }
176
+ return entry;
177
+ }
178
+ /** The inherited process-layer value, or undefined. */
179
+ function processLayer(launch, name) {
180
+ const entry = launch.getFrom(name, ["process"]);
181
+ return entry === void 0 || entry.value === "" ? void 0 : entry.value;
182
+ }
183
+ /** Whether the launch topology may report at all. */
184
+ function topologyAdmitted(env, launch) {
185
+ if (processLayer(launch, "SSH_CONNECTION") !== void 0 || processLayer(launch, "SSH_TTY") !== void 0) return false;
186
+ for (const name of [
187
+ "TMUX",
188
+ "STY",
189
+ "ZELLIJ"
190
+ ]) {
191
+ const value = env[name];
192
+ if (value !== void 0 && value !== "") return false;
193
+ }
194
+ return true;
195
+ }
196
+ /** The frozen resume argv cannot carry either official preset input form. */
197
+ function presetAdmitted(presetId, env) {
198
+ return (presetId === void 0 || presetId === "") && (env.DSH_PI_TUI_PRESET?.trim() ?? "") === "";
199
+ }
200
+ /** The one official-profile admission shared by Direct and the daemon supervisor. */
201
+ function profileAdmitted(input) {
202
+ if (input.platform !== "linux" && input.platform !== "darwin") return false;
203
+ if (!input.stdinIsTTY || !input.stdoutIsTTY) return false;
204
+ if (!presetAdmitted(input.presetId, input.env)) return false;
205
+ if (input.profileContext.overlays.length !== 0) return false;
206
+ if ((input.profileContext.telemetryDisabledEnv ?? "") !== "") return false;
207
+ if (input.execArgv.length !== 0) return false;
208
+ if (processLayer(input.launch, "NODE_OPTIONS") !== void 0) return false;
209
+ const flatNodeOptions = input.env.NODE_OPTIONS;
210
+ if (flatNodeOptions !== void 0 && flatNodeOptions !== "") return false;
211
+ if (!topologyAdmitted(input.env, input.launch)) return false;
212
+ return true;
213
+ }
214
+ /** An absolute, control-free path string. */
215
+ function pathTextAdmitted(value) {
216
+ return isAbsolute(value) && !FORBIDDEN_PATH_TEXT.test(value);
217
+ }
218
+ /** Validate the profile name/path text the command must carry verbatim. */
219
+ function scopeTextAdmitted(input) {
220
+ if (input.name === "" || input.name.startsWith("-") || FORBIDDEN_PATH_TEXT.test(input.name)) return false;
221
+ return pathTextAdmitted(input.home) && pathTextAdmitted(input.cwd) && directory(input.home) && directory(input.cwd);
222
+ }
223
+ /** Build the non-secret facts once the caller has the trusted token. */
224
+ function capabilityOf(input) {
225
+ if (!isProgramResumeToken(input.token)) return void 0;
226
+ if (!Number.isSafeInteger(input.ownerPid) || input.ownerPid <= 0) return void 0;
227
+ if (!pathTextAdmitted(input.nodePath) || !pathTextAdmitted(input.cliPath)) return void 0;
228
+ if (!executableFile(ENV) || !executableFile(input.nodePath) || !regularFile(input.cliPath)) return void 0;
229
+ if (!scopeTextAdmitted(input.profileContext)) return void 0;
230
+ return {
231
+ token: input.token,
232
+ facts: {
233
+ version: 1,
234
+ ownerPid: input.ownerPid,
235
+ home: input.profileContext.home,
236
+ profile: input.profileContext.name,
237
+ backend: input.backend,
238
+ cwd: input.profileContext.cwd,
239
+ nodePath: input.nodePath,
240
+ cliPath: input.cliPath
241
+ }
242
+ };
243
+ }
244
+ /** The Direct CLI's capability: token must come from the inherited layer only. */
245
+ function directProgramResumeCapability(input) {
246
+ if (!profileAdmitted(input)) return void 0;
247
+ const token = processLayer(input.launch, "OSC7577_TOKEN");
248
+ if (token === void 0) return void 0;
249
+ const argv1 = input.argv[1];
250
+ if (argv1 === void 0) return void 0;
251
+ const cli = resolveOfficialCliEntry(input.profileContext.installAnchor, argv1);
252
+ if (cli === void 0) return void 0;
253
+ return capabilityOf({
254
+ profileContext: input.profileContext,
255
+ launch: input.launch,
256
+ token,
257
+ backend: "direct",
258
+ ownerPid: process.pid,
259
+ nodePath: input.execPath,
260
+ cliPath: cli
261
+ });
262
+ }
263
+ /** Validate the inherited daemon facts without deciding whether they may report. */
264
+ function clientProgramResumeFacts(input) {
265
+ if (input.handoff === void 0) return void 0;
266
+ if (input.platform !== "linux" && input.platform !== "darwin") return void 0;
267
+ if (!input.stdinIsTTY || !input.stdoutIsTTY) return void 0;
268
+ if (input.execArgv.length !== 0) return void 0;
269
+ const nodeOptions = input.env.NODE_OPTIONS;
270
+ if (nodeOptions !== void 0 && nodeOptions !== "") return void 0;
271
+ for (const name of [
272
+ "TMUX",
273
+ "STY",
274
+ "ZELLIJ",
275
+ "SSH_CONNECTION",
276
+ "SSH_TTY"
277
+ ]) {
278
+ const value = input.env[name];
279
+ if (value !== void 0 && value !== "") return void 0;
280
+ }
281
+ const facts = decodeProgramResumeHandoff(input.handoff);
282
+ if (facts === void 0 || facts.backend !== "daemon") return void 0;
283
+ if (facts.profile !== input.expectedProfile) return void 0;
284
+ if (facts.profile === "" || facts.profile.startsWith("-") || FORBIDDEN_PATH_TEXT.test(facts.profile)) return void 0;
285
+ if (!pathTextAdmitted(facts.home) || !pathTextAdmitted(facts.cwd)) return void 0;
286
+ if (!pathTextAdmitted(facts.nodePath) || !pathTextAdmitted(facts.cliPath)) return void 0;
287
+ if (facts.ownerPid === process.pid) return void 0;
288
+ if (!input.isReexec && facts.ownerPid !== input.parentPid) return void 0;
289
+ let home;
290
+ let expectedHome;
291
+ try {
292
+ home = realpathSync(facts.home);
293
+ expectedHome = realpathSync(input.expectedHome);
294
+ } catch {
295
+ return;
296
+ }
297
+ if (home !== expectedHome) return void 0;
298
+ if (!directory(join(home, "profiles", input.expectedProfile))) return void 0;
299
+ if (!directory(facts.cwd) || !executableFile(ENV) || !executableFile(facts.nodePath) || !regularFile(facts.cliPath)) return void 0;
300
+ return {
301
+ ...facts,
302
+ home
303
+ };
304
+ }
305
+ function clientProgramResumeCapability(input) {
306
+ if (!isProgramResumeToken(input.token) || !presetAdmitted(void 0, input.env)) return void 0;
307
+ const facts = clientProgramResumeFacts(input);
308
+ return facts === void 0 ? void 0 : {
309
+ token: input.token,
310
+ facts
311
+ };
312
+ }
313
+ /**
314
+ * Authorize one clear for a record inherited by an accepted daemon reexec whose
315
+ * current launch preset cannot be represented. This never creates a target.
316
+ */
317
+ function clientProgramResumeWithdrawal(input) {
318
+ if (!input.isReexec || !isProgramResumeToken(input.token)) return void 0;
319
+ if ((input.env.DSH_PI_TUI_PRESET?.trim() ?? "") === "") return void 0;
320
+ const facts = clientProgramResumeFacts(input);
321
+ return facts === void 0 ? void 0 : {
322
+ token: input.token,
323
+ ownerPid: facts.ownerPid
324
+ };
325
+ }
326
+ /**
327
+ * Freeze the exact cold-open command for one committed canonical Session.
328
+ * @param capability - the already-admitted launch capability.
329
+ * @param sessionId - the committed main-owner Session id.
330
+ * @returns the command, or undefined when the id is not canonical.
331
+ */
332
+ function programResumeTarget(capability, sessionId) {
333
+ if (sessionId === void 0 || !canonicalFullSessionId(sessionId)) return void 0;
334
+ const facts = capability.facts;
335
+ return {
336
+ token: capability.token,
337
+ ownerPid: facts.ownerPid,
338
+ cwd: facts.cwd,
339
+ argv: [
340
+ ENV,
341
+ `DSH_HOME=${facts.home}`,
342
+ `DSH_PI_TUI_BACKEND=${facts.backend}`,
343
+ facts.nodePath,
344
+ facts.cliPath,
345
+ "--profile",
346
+ facts.profile,
347
+ "--session",
348
+ sessionId
349
+ ]
350
+ };
351
+ }
352
+ //#endregion
353
+ //#region src/app/renderer-opt-in.ts
354
+ /**
355
+ * The ONE experimental renderer opt-in predicate. It lives outside the
356
+ * `app/bootstrap/**` composition zone so every application owner can share the
357
+ * exact rule without importing bootstrap helpers.
358
+ *
359
+ * @module @xmoon76/dsh-pi-tui/app/renderer-opt-in
360
+ */
361
+ /** Whether this boot explicitly asked for the experimental TSP renderer. */
362
+ function tspRequested(env) {
363
+ return env.DSH_PI_TUI_RENDERER === "tsp";
364
+ }
365
+ //#endregion
366
+ //#region src/app/program-resume-admission.ts
367
+ /**
368
+ * The ONE OSC 7577 admission gate shared by the Direct root, the daemon
369
+ * supervisor and the Client entry. `DSH_PI_TUI_RENDERER=tsp` is an explicit
370
+ * renderer opt-in: even when the SDK later declines and PiTui fallback mounts,
371
+ * the boot is still a TSP attempt and must not publish a program-resume record.
372
+ *
373
+ * @module @xmoon76/dsh-pi-tui/app/program-resume-admission
374
+ */
375
+ /** True only when this boot never requested the experimental TSP renderer. */
376
+ function programResumeAdmitted(env) {
377
+ return !tspRequested(env);
378
+ }
379
+ /**
380
+ * Build a capability only when this boot is admitted. A TSP opt-in never
381
+ * invokes the builder, so the fallback cannot create a reporter later.
382
+ */
383
+ function admitProgramResume(env, build) {
384
+ return programResumeAdmitted(env) ? build() : void 0;
385
+ }
386
+ //#endregion
387
+ //#region src/app/remote-process/daemon-launcher.ts
388
+ /**
389
+ * Resolve this installed bundle's package root through the OFFICIAL profile
390
+ * resolution. The launcher module itself may be reached through a symlinked
391
+ * `dist`, so its own module URL is not a reliable package-root locator.
392
+ * Exported for the M6 UX PR2 Direct-side admin port, which must reuse the SAME
393
+ * official Profile resolution as this CLI path — never a second copy.
394
+ */
395
+ function resolveProfilePackageRoot(profileDir) {
396
+ let manifestPath;
397
+ try {
398
+ manifestPath = createRequire(join(profileDir, "package.json")).resolve("@xmoon76/dsh-pi-tui/package.json");
399
+ } catch (error) {
400
+ throw new Error("pi-tui daemon launcher: the official profile does not resolve the installed @xmoon76/dsh-pi-tui", { cause: error });
401
+ }
402
+ const root = realpathSync(dirname(manifestPath));
403
+ let manifest;
404
+ try {
405
+ manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
406
+ } catch (error) {
407
+ throw new Error("pi-tui daemon launcher: the installed package manifest is not readable", { cause: error });
408
+ }
409
+ if (manifest === null || typeof manifest !== "object" || manifest.name !== "@xmoon76/dsh-pi-tui") throw new Error("pi-tui daemon launcher: the official profile resolves a different package");
410
+ return root;
411
+ }
412
+ //#endregion
413
+ //#region src/app/remote-process/local-profile-daemon-admin.ts
414
+ /**
415
+ * Bind the EXACT official Profile facts to the existing control plane.
416
+ *
417
+ * The profile is captured by value here: callers pass the profile their process
418
+ * composition already verified (the Host `profileContext` on Direct, the split
419
+ * Client entry's official `profileDir`/`dshHome`/`packageRoot`/anchor facts on
420
+ * Daemon). Nothing is re-resolved from argv, cwd or an environment guess later.
421
+ * @param profile - the official Profile facts this process belongs to.
422
+ * @param deps - the bound run seam.
423
+ * @returns the port the Settings follow-up and the final exit root consume.
424
+ */
425
+ function createProfileDaemonAdmin(profile, deps) {
426
+ const bound = Object.freeze({ ...profile });
427
+ return Object.freeze({
428
+ profile: bound.name,
429
+ run: (verb) => deps.run(verb)
430
+ });
431
+ }
432
+ /**
433
+ * The production run seam for ONE official Profile. The existing
434
+ * `local-daemon-control` module is imported lazily so that neither a cold
435
+ * launch nor a Settings read pulls the OS managers into the process graph; it
436
+ * also keeps `src/app/bootstrap.ts` free of a static manager dependency.
437
+ * @param profile - the official Profile facts.
438
+ * @returns the unbound run function the port is built over.
439
+ */
440
+ function profileDaemonAdminRun(profile, deps = {}) {
441
+ return async (verb) => {
442
+ const { runDaemonControl } = await import("./local-daemon-control-Bm3imctD.mjs");
443
+ return await runDaemonControl({ verb }, profile, deps);
444
+ };
445
+ }
446
+ /**
447
+ * Resolve the Direct-side admin Profile from the SAME official Host
448
+ * `profileContext` the CLI cold-control path consumes, with the SAME
449
+ * installed-package resolution (`daemon-launcher.resolveProfilePackageRoot` +
450
+ * `readInstalledDshVersion`). This proves the local install capability WITHOUT
451
+ * loading the OS managers: it reads the profile manifest and the installed DSH
452
+ * version only, never a Host/manager probe.
453
+ * @param profileContext - the official Host profile facts.
454
+ * @returns the bound Profile facts, or `undefined` when the installed profile
455
+ * cannot be proven — the caller then offers no install/stop action (fail
456
+ * closed) instead of falling back to a guessed identity.
457
+ */ function resolveDirectDaemonAdminProfile(profileContext) {
458
+ const packageRoot = resolveProfilePackageRoot(profileContext.dir);
459
+ return {
460
+ name: profileContext.name,
461
+ dir: profileContext.dir,
462
+ home: profileContext.home,
463
+ installAnchor: profileContext.installAnchor,
464
+ packageRoot,
465
+ dshVersion: readInstalledDshVersion(profileContext.installAnchor)
466
+ };
467
+ }
468
+ //#endregion
469
+ export { programResumeAdmitted as a, clientProgramResumeWithdrawal as c, encodeProgramResumeClear as d, encodeProgramResumeReport as f, admitProgramResume as i, directProgramResumeCapability as l, profileDaemonAdminRun as n, tspRequested as o, resolveDirectDaemonAdminProfile as r, clientProgramResumeCapability as s, createProfileDaemonAdmin as t, programResumeTarget as u };