@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.
Files changed (77) hide show
  1. package/README.en.md +61 -25
  2. package/README.md +61 -25
  3. package/cordis.patch.yml +13 -0
  4. package/dist/acp-stdio.mjs +151 -0
  5. package/dist/{bootstrap-CMIjGyuk.mjs → bootstrap-CVyHGQDX.mjs} +21901 -6575
  6. package/dist/browser-CDUSHIIr.mjs +76 -0
  7. package/dist/builtins.mjs +2 -2
  8. package/dist/{client-bootstrap-BjGPc-DM.mjs → client-bootstrap-4UoeVIHE.mjs} +2488 -2734
  9. package/dist/client-runtime-BHBlVUf5.mjs +1376 -0
  10. package/dist/{daemon-launcher-Dult7Jxv.mjs → daemon-launcher-DxIgjBHW.mjs} +1549 -172
  11. package/dist/daemon-launcher.d.mts +85 -14
  12. package/dist/daemon-launcher.mjs +2 -2
  13. package/dist/{local-profile-daemon-admin-BmQSdzT0.mjs → diagnostics-Db5iVcuJ.mjs} +3 -90
  14. package/dist/{entry-control-DjNsE3I0.mjs → entry-control-BDLZgg4m.mjs} +1 -1
  15. package/dist/{extensions-B4uLpSTv.mjs → extensions-Dx7ncPNA.mjs} +1 -1
  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-DMNTmNrH.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 +22334 -6695
  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 +292 -63
  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-uOBfFq5j.mjs → local-discovery-BMhaGIiJ.mjs} +254 -544
  38. package/dist/{local-discovery-egN4_gsQ.mjs → local-discovery-Ba7_-NNC.mjs} +1 -1
  39. package/dist/{local-discovery-DOSsCh9q.mjs → local-discovery-QSbFpjK2.mjs} +301 -544
  40. package/dist/local-host.mjs +952 -501
  41. package/dist/local-profile-daemon-admin-otpm69R6.mjs +469 -0
  42. package/dist/{local-scope-DamiMqPd.mjs → local-scope-5DEKA_lW.mjs} +1023 -96
  43. package/dist/{local-transport-Iwo0mtu3.mjs → local-transport-DeWmdZ5E.mjs} +14 -3
  44. package/dist/{local-web-control-DMrjwCkl.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-C6tSs86s.mjs → session-Cs8iLCEx.mjs} +784 -342
  62. package/dist/{session-CstInGIA.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-EG5UqIcd.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-CpfpQO_h.mjs → terminal-progress-source-VsczdXA-.mjs} +610 -332
  70. package/dist/{transcript-view-CuJYWkhp.mjs → transcript-view-B6vCnukn.mjs} +2096 -977
  71. package/dist/{transcript-view-C1YtJ49Y.mjs → transcript-view-DSSdE2vK.mjs} +2078 -651
  72. package/dist/write-failure-xNKczXH7.mjs +189 -0
  73. package/package.json +20 -3
  74. package/dist/local-acp-listener-B65J0Bx4.mjs +0 -3115
  75. package/dist/local-daemon-control-C14q9KnD.mjs +0 -1588
  76. package/dist/local-daemon-control-TCnERL7n.mjs +0 -1424
  77. package/dist/preset-BcWqOtY7.mjs +0 -46
@@ -1,13 +1,28 @@
1
1
  import { t as Diag } from "./diagnostics-D5jwc-q1.mjs";
2
- import { u as TuiDaemonClientStartup } from "./startup-CarQxWwi.mjs";
2
+ import { m as TuiDaemonClientStartup } from "./startup-Dti3Udne.mjs";
3
3
  import { spawn } from "node:child_process";
4
4
  import { Context } from "@deepseek-ai/cordis";
5
5
 
6
6
  //#region src/app/remote-process/daemon-launcher.d.ts
7
+ /**
8
+ * The read-only ACP stdio launch target, structurally identical to the
9
+ * `local-daemon-control` DTO. It is declared here so the public
10
+ * `daemon-launcher.d.mts` stays free of internal module paths while the real
11
+ * producer remains `readAcpStdioTarget`.
12
+ */
13
+ type AcpStdioTarget = {
14
+ readonly kind: 'ready';
15
+ readonly socketPath: string;
16
+ readonly instanceId: string;
17
+ } | {
18
+ readonly kind: 'host-unavailable' | 'acp-disabled' | 'acp-unavailable';
19
+ };
7
20
  /** Stable Loader row id / Cordis plugin name. */
8
21
  declare const name = "pi-tui-daemon-launcher";
9
22
  /** The daemon Coordinator only exists when the daemon backend published its service. */
10
23
  declare const inject: string[];
24
+ /** The private ACP stdio Adapter target channel. The Parent overwrites it. */
25
+ declare const ACP_STDIO_SOCKET_ENV = "DSH_PI_TUI_ACP_STDIO_SOCKET_V1";
11
26
  /** The launcher-provided Profile facts the Coordinator needs (official shape). */
12
27
  interface ProfileContextLike {
13
28
  readonly name: string;
@@ -15,16 +30,15 @@ interface ProfileContextLike {
15
30
  readonly home: string;
16
31
  readonly installAnchor: string;
17
32
  readonly cwd: string;
33
+ readonly overlays?: readonly unknown[];
34
+ readonly telemetryDisabledEnv?: string | undefined;
18
35
  }
19
36
  /** The one-shot public launch envelope encoded for the Client child. */
20
37
  declare function encodeLaunchEnvelope(startup: TuiDaemonClientStartup): string;
21
- /**
22
- * Resolve the installed Client entry from THIS package root and prove its real
23
- * target is a regular file. A shared npm package, a root-owned system install
24
- * and a legal entry symlink are normal installs; only a missing or non-regular
25
- * target is a hard failure — never a fallback to a source tree or `tsx`.
26
- */
27
38
  declare function resolveClientEntry(packageRoot: string): string;
39
+ /** Resolve the internal ACP stdio Adapter entry with the same installed-package
40
+ * proof as the Client entry. It is never a public bin or export. */
41
+ declare function resolveAcpStdioEntry(packageRoot: string): string;
28
42
  /**
29
43
  * Resolve this installed bundle's package root through the OFFICIAL profile
30
44
  * resolution. The launcher module itself may be reached through a symlinked
@@ -40,6 +54,14 @@ declare function resolveProfilePackageRoot(profileDir: string): string;
40
54
  * Host-entry markers and the one-shot public selector are never propagated.
41
55
  */
42
56
  declare function buildChildEnvironment(profileContext: ProfileContextLike, launchEnvelope: string, source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
57
+ /**
58
+ * Build the ACP stdio Adapter child environment at the ONE new-spawn boundary.
59
+ * The adapter is a pure Node stream relay: it receives the Parent-selected
60
+ * public UDS path and no Split Client/Host role, launch envelope, Cookie or
61
+ * token. Every inherited internal role fact is stripped before the one
62
+ * authoritative socket value is written.
63
+ */
64
+ declare function buildAcpStdioEnvironment(socketPath: string, source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
43
65
  /** Injectable spawn for a structural (L2/L3) test; production uses `child_process.spawn`. */
44
66
  type SpawnImpl = typeof spawn;
45
67
  /**
@@ -60,9 +82,12 @@ declare class DaemonCoordinator {
60
82
  /** A sanitized human line for the supervisor TTY when the Client cannot be
61
83
  * spawned at all (never a JSON record, never a raw error/message/path). */
62
84
  private readonly reportFatal;
85
+ /** Optional ACP-specific formatter; the default keeps the Client wording. */
86
+ private readonly failureLine;
87
+ private readonly spawnFailureExitCode;
63
88
  private readonly shutdownBudgetMs;
64
89
  private child;
65
- private childExit;
90
+ private childExited;
66
91
  private started;
67
92
  private disposed;
68
93
  private settled;
@@ -76,6 +101,8 @@ declare class DaemonCoordinator {
76
101
  appExit: (code: number) => void;
77
102
  diag: Diag;
78
103
  reportFatal?: (line: string) => void;
104
+ failureLine?: (safeErrno: string) => string;
105
+ spawnFailureExitCode?: number;
79
106
  shutdownBudgetMs?: number;
80
107
  });
81
108
  /** Spawn the ONE foreground Client. No-op after a prior start or dispose. */
@@ -83,14 +110,58 @@ declare class DaemonCoordinator {
83
110
  private settle;
84
111
  /**
85
112
  * The SINGLE stop owner, AWAITABLE. A spawn not yet started is cancelled; a
86
- * live child is asked to stop once (SIGTERM) and dispose() resolves only after
87
- * the child actually exited, so the parent Fiber disposer holds the child's
88
- * cleanup rather than the parent process exiting underneath it. The wait is
89
- * bounded to fit the official ~5s shutdown deadline; a child that does not exit
90
- * within it is escalated to SIGKILL and awaited briefly. Idempotent.
113
+ * live child is asked to stop once and dispose() resolves only after the child
114
+ * actually exited, so the parent Fiber disposer holds the child's cleanup
115
+ * rather than the parent process exiting underneath it. On POSIX the bounded
116
+ * SIGTERM→SIGKILL sequence fits the official ~5s shutdown deadline. Windows
117
+ * has no catchable POSIX SIGTERM: the direct child is forcibly terminated once
118
+ * and only its ACTUAL exit inside the same budget is success; no graceful claim
119
+ * is made. Idempotent.
91
120
  */
92
121
  dispose(): Promise<boolean>;
93
122
  }
123
+ /** The injected seams of one trusted-profile ACP stdio launch. */
124
+ interface AcpStdioRunnerOptions {
125
+ readonly profileName: string;
126
+ readonly preflight: (signal: AbortSignal) => Promise<AcpStdioTarget>;
127
+ readonly resolveEntry: () => string;
128
+ readonly spawnImpl: SpawnImpl;
129
+ readonly appExit: (code: number) => void;
130
+ readonly diag: Diag;
131
+ readonly writeStderr?: (line: string) => void;
132
+ readonly shutdownBudgetMs?: number;
133
+ }
134
+ /**
135
+ * The ONE trusted-profile ACP stdio launch lifecycle: one read-only target
136
+ * preflight followed by at most one internal Adapter child. The launch promise
137
+ * is created before the cold-ready callback can run, so a reentrant callback or
138
+ * a fiber disposal can never start a second launch. Disposal aborts the
139
+ * preflight, awaits its settlement, then disposes the one child.
140
+ */
141
+ declare class AcpStdioRunner {
142
+ private readonly options;
143
+ private readonly controller;
144
+ private readonly startGate;
145
+ private releaseStartGate;
146
+ private launchPromise;
147
+ private coordinator;
148
+ private started;
149
+ private disposed;
150
+ private settled;
151
+ private disposePromise;
152
+ constructor(options: AcpStdioRunnerOptions);
153
+ /** Create the ONE launch promise now; it waits for {@link start}. */
154
+ prepare(): Promise<void>;
155
+ /** Release the cold-ready gate exactly once. */
156
+ start(): void;
157
+ private writeStderr;
158
+ private report;
159
+ private finish;
160
+ private fail;
161
+ private launch;
162
+ /** Abort the preflight, await the ONE launch promise and dispose any child. */
163
+ dispose(): Promise<boolean>;
164
+ }
94
165
  /** The result of one management operation, as written to the real TTY. */
95
166
  interface DaemonManagementResult {
96
167
  readonly code: number;
@@ -156,4 +227,4 @@ declare function createLoaderDumpScheduler(produce: () => string, write: (text:
156
227
  * real cold-ready commit and are owned by this row's Fiber. */
157
228
  declare function apply(ctx: Context): void;
158
229
  //#endregion
159
- export { DaemonControlRunner, DaemonCoordinator, DaemonManagementExecutor, DaemonManagementResult, LoaderDumpScheduler, SpawnImpl, apply, buildChildEnvironment, createLoaderDumpScheduler, encodeLaunchEnvelope, inject, name, resolveClientEntry, resolveProfilePackageRoot, writeQualificationDump };
230
+ export { ACP_STDIO_SOCKET_ENV, AcpStdioRunner, AcpStdioRunnerOptions, DaemonControlRunner, DaemonCoordinator, DaemonManagementExecutor, DaemonManagementResult, LoaderDumpScheduler, SpawnImpl, apply, buildAcpStdioEnvironment, buildChildEnvironment, createLoaderDumpScheduler, encodeLaunchEnvelope, inject, name, resolveAcpStdioEntry, resolveClientEntry, resolveProfilePackageRoot, writeQualificationDump };
@@ -1,2 +1,2 @@
1
- import { a as createLoaderDumpScheduler, c as name, d as writeQualificationDump, i as buildChildEnvironment, l as resolveClientEntry, n as DaemonCoordinator, o as encodeLaunchEnvelope, r as apply, s as inject, t as DaemonControlRunner, u as resolveProfilePackageRoot } from "./daemon-launcher-Dult7Jxv.mjs";
2
- export { DaemonControlRunner, DaemonCoordinator, apply, buildChildEnvironment, createLoaderDumpScheduler, encodeLaunchEnvelope, inject, name, resolveClientEntry, resolveProfilePackageRoot, writeQualificationDump };
1
+ import { a as apply, c as createLoaderDumpScheduler, d as name, f as resolveAcpStdioEntry, h as writeQualificationDump, i as DaemonCoordinator, l as encodeLaunchEnvelope, m as resolveProfilePackageRoot, n as AcpStdioRunner, o as buildAcpStdioEnvironment, p as resolveClientEntry, r as DaemonControlRunner, s as buildChildEnvironment, t as ACP_STDIO_SOCKET_ENV, u as inject } from "./daemon-launcher-DxIgjBHW.mjs";
2
+ export { ACP_STDIO_SOCKET_ENV, AcpStdioRunner, DaemonControlRunner, DaemonCoordinator, apply, buildAcpStdioEnvironment, buildChildEnvironment, createLoaderDumpScheduler, encodeLaunchEnvelope, inject, name, resolveAcpStdioEntry, resolveClientEntry, resolveProfilePackageRoot, writeQualificationDump };
@@ -1,12 +1,7 @@
1
- import { d as readInstalledDshVersion } from "./local-scope-DamiMqPd.mjs";
2
- import "./entry-control-DjNsE3I0.mjs";
3
1
  import { o as safeErrorMessage } from "./tasks-D_z5Yjjr.mjs";
4
- import { createRequire } from "node:module";
5
- import { closeSync, mkdirSync, openSync, readFileSync, realpathSync, writeSync } from "node:fs";
6
- import { dirname, join } from "node:path";
7
- import "node:url";
2
+ import { closeSync, mkdirSync, openSync, writeSync } from "node:fs";
3
+ import { join } from "node:path";
8
4
  import { homedir } from "node:os";
9
- import "node:child_process";
10
5
  //#region src/runtime/process/diagnostics.ts
11
6
  /**
12
7
  * Structured process diagnostics for the TUI.
@@ -125,86 +120,4 @@ function createDiag(options = {}) {
125
120
  };
126
121
  }
127
122
  //#endregion
128
- //#region src/app/remote-process/daemon-launcher.ts
129
- /**
130
- * Resolve this installed bundle's package root through the OFFICIAL profile
131
- * resolution. The launcher module itself may be reached through a symlinked
132
- * `dist`, so its own module URL is not a reliable package-root locator.
133
- * Exported for the M6 UX PR2 Direct-side admin port, which must reuse the SAME
134
- * official Profile resolution as this CLI path — never a second copy.
135
- */
136
- function resolveProfilePackageRoot(profileDir) {
137
- let manifestPath;
138
- try {
139
- manifestPath = createRequire(join(profileDir, "package.json")).resolve("@xmoon76/dsh-pi-tui/package.json");
140
- } catch (error) {
141
- throw new Error("pi-tui daemon launcher: the official profile does not resolve the installed @xmoon76/dsh-pi-tui", { cause: error });
142
- }
143
- const root = realpathSync(dirname(manifestPath));
144
- let manifest;
145
- try {
146
- manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
147
- } catch (error) {
148
- throw new Error("pi-tui daemon launcher: the installed package manifest is not readable", { cause: error });
149
- }
150
- 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");
151
- return root;
152
- }
153
- //#endregion
154
- //#region src/app/remote-process/local-profile-daemon-admin.ts
155
- /**
156
- * Bind the EXACT official Profile facts to the existing control plane.
157
- *
158
- * The profile is captured by value here: callers pass the profile their process
159
- * composition already verified (the Host `profileContext` on Direct, the split
160
- * Client entry's official `profileDir`/`dshHome`/`packageRoot`/anchor facts on
161
- * Daemon). Nothing is re-resolved from argv, cwd or an environment guess later.
162
- * @param profile - the official Profile facts this process belongs to.
163
- * @param deps - the bound run seam.
164
- * @returns the port the Settings follow-up and the final exit root consume.
165
- */
166
- function createProfileDaemonAdmin(profile, deps) {
167
- const bound = Object.freeze({ ...profile });
168
- return Object.freeze({
169
- profile: bound.name,
170
- run: (verb) => deps.run(verb)
171
- });
172
- }
173
- /**
174
- * The production run seam for ONE official Profile. The existing
175
- * `local-daemon-control` module is imported lazily so that neither a cold
176
- * launch nor a Settings read pulls the OS managers into the process graph; it
177
- * also keeps `src/app/bootstrap.ts` free of a static manager dependency.
178
- * @param profile - the official Profile facts.
179
- * @returns the unbound run function the port is built over.
180
- */
181
- function profileDaemonAdminRun(profile, deps = {}) {
182
- return async (verb) => {
183
- const { runDaemonControl } = await import("./local-daemon-control-TCnERL7n.mjs");
184
- return await runDaemonControl({ verb }, profile, deps);
185
- };
186
- }
187
- /**
188
- * Resolve the Direct-side admin Profile from the SAME official Host
189
- * `profileContext` the CLI cold-control path consumes, with the SAME
190
- * installed-package resolution (`daemon-launcher.resolveProfilePackageRoot` +
191
- * `readInstalledDshVersion`). This proves the local install capability WITHOUT
192
- * loading the OS managers: it reads the profile manifest and the installed DSH
193
- * version only, never a Host/manager probe.
194
- * @param profileContext - the official Host profile facts.
195
- * @returns the bound Profile facts, or `undefined` when the installed profile
196
- * cannot be proven — the caller then offers no install/stop action (fail
197
- * closed) instead of falling back to a guessed identity.
198
- */ function resolveDirectDaemonAdminProfile(profileContext) {
199
- const packageRoot = resolveProfilePackageRoot(profileContext.dir);
200
- return {
201
- name: profileContext.name,
202
- dir: profileContext.dir,
203
- home: profileContext.home,
204
- installAnchor: profileContext.installAnchor,
205
- packageRoot,
206
- dshVersion: readInstalledDshVersion(profileContext.installAnchor)
207
- };
208
- }
209
- //#endregion
210
- export { dshHome as a, diagFromEnv as i, profileDaemonAdminRun as n, resolveDirectDaemonAdminProfile as r, createProfileDaemonAdmin as t };
123
+ export { diagFromEnv as n, dshHome as r, createDiag as t };
@@ -1,4 +1,4 @@
1
- import "./local-scope-DamiMqPd.mjs";
1
+ import "./local-scope-5DEKA_lW.mjs";
2
2
  //#region src/app/remote-process/entry-control.ts
3
3
  /** The single opt-in for the raw M4-A0 JSONL stream, frozen at process start. */
4
4
  const ENTRY_RECORDS_ENABLED = process.env.DSH_PI_TUI_ENTRY_RECORDS === "1";
@@ -1,4 +1,4 @@
1
- import { i as TUI_STARTUP_SERVICE } from "./startup-EG5UqIcd.mjs";
1
+ import { i as TUI_STARTUP_SERVICE } from "./startup-UtFQSDe_.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import * as fs from "node:fs";
4
4
  import { readFileSync } from "node:fs";
@@ -1,2 +1,2 @@
1
- import { a as API_VERSION, i as PI_TUI_EXTENSIONS_SERVICE, n as inject, o as describeKey, r as name, t as apply } from "./extensions-B4uLpSTv.mjs";
1
+ import { a as API_VERSION, i as PI_TUI_EXTENSIONS_SERVICE, n as inject, o as describeKey, r as name, t as apply } from "./extensions-Dx7ncPNA.mjs";
2
2
  export { API_VERSION, PI_TUI_EXTENSIONS_SERVICE, apply, describeKey, inject, name };
@@ -0,0 +1,106 @@
1
+ //#region src/client/program-resume/handoff.ts
2
+ /**
3
+ * The private program-resume handoff between the daemon supervisor and its
4
+ * foreground Client, plus the environment keys the OSC 7577 sender owns.
5
+ *
6
+ * The handoff carries only non-secret launch facts. The capability token rides
7
+ * in its own protocol environment variable and is never duplicated into this
8
+ * JSON, a log, argv, a Session or a Host DTO.
9
+ *
10
+ * @module @xmoon76/dsh-pi-tui/client/program-resume/handoff
11
+ */
12
+ /** The protocol's capability environment variable. */
13
+ const PROGRAM_RESUME_TOKEN_ENV = "OSC7577_TOKEN";
14
+ /** The private, versioned supervisor -> foreground Client fact channel. */
15
+ const PROGRAM_RESUME_HANDOFF_ENV = "SPLIT_PROCESS_OSC7577_V1";
16
+ /** A hard ceiling on the decoded handoff (it carries paths, not payloads). */
17
+ const MAX_HANDOFF_BYTES = 16384;
18
+ function isRecord(value) {
19
+ return value !== null && typeof value === "object" && !Array.isArray(value);
20
+ }
21
+ /**
22
+ * Read and delete both OSC 7577 environment fields in ONE synchronous step.
23
+ * The caller decides whether the captured values are trustworthy; the raw
24
+ * strings never remain ambient for a later child.
25
+ */
26
+ function takeProgramResumeHandoff(env) {
27
+ const token = env[PROGRAM_RESUME_TOKEN_ENV];
28
+ const handoff = env[PROGRAM_RESUME_HANDOFF_ENV];
29
+ delete env[PROGRAM_RESUME_TOKEN_ENV];
30
+ delete env[PROGRAM_RESUME_HANDOFF_ENV];
31
+ return {
32
+ token,
33
+ handoff
34
+ };
35
+ }
36
+ /** Encode the non-secret facts for the foreground Client environment. */
37
+ function encodeProgramResumeHandoff(facts) {
38
+ return JSON.stringify({
39
+ version: facts.version,
40
+ ownerPid: facts.ownerPid,
41
+ home: facts.home,
42
+ profile: facts.profile,
43
+ backend: facts.backend,
44
+ cwd: facts.cwd,
45
+ nodePath: facts.nodePath,
46
+ cliPath: facts.cliPath
47
+ });
48
+ }
49
+ /**
50
+ * Decode the private handoff strictly: bounded JSON, exactly the v1 keys and
51
+ * primitive types. Path/admission proof belongs to the caller (it needs the
52
+ * officially resolved home/profile and the live process facts).
53
+ * @returns the decoded facts, or undefined for any malformed shape.
54
+ */
55
+ function decodeProgramResumeHandoff(raw) {
56
+ if (raw === "" || Buffer.byteLength(raw, "utf8") > MAX_HANDOFF_BYTES) return void 0;
57
+ let parsed;
58
+ try {
59
+ parsed = JSON.parse(raw);
60
+ } catch {
61
+ return;
62
+ }
63
+ if (!isRecord(parsed)) return void 0;
64
+ const keys = Object.keys(parsed).sort();
65
+ const expected = [
66
+ "backend",
67
+ "cliPath",
68
+ "cwd",
69
+ "home",
70
+ "nodePath",
71
+ "ownerPid",
72
+ "profile",
73
+ "version"
74
+ ];
75
+ if (keys.length !== expected.length || keys.some((key, index) => key !== expected[index])) return void 0;
76
+ if (parsed.version !== 1) return void 0;
77
+ if (typeof parsed.ownerPid !== "number" || !Number.isSafeInteger(parsed.ownerPid) || parsed.ownerPid <= 0) return void 0;
78
+ const home = parsed.home;
79
+ const profile = parsed.profile;
80
+ const cwd = parsed.cwd;
81
+ const nodePath = parsed.nodePath;
82
+ const cliPath = parsed.cliPath;
83
+ if (typeof home !== "string" || home === "") return void 0;
84
+ if (typeof profile !== "string" || profile === "") return void 0;
85
+ if (typeof cwd !== "string" || cwd === "") return void 0;
86
+ if (typeof nodePath !== "string" || nodePath === "") return void 0;
87
+ if (typeof cliPath !== "string" || cliPath === "") return void 0;
88
+ if (parsed.backend !== "direct" && parsed.backend !== "daemon") return void 0;
89
+ return {
90
+ version: 1,
91
+ ownerPid: parsed.ownerPid,
92
+ home,
93
+ profile,
94
+ backend: parsed.backend,
95
+ cwd,
96
+ nodePath,
97
+ cliPath
98
+ };
99
+ }
100
+ /** Remove both fields from a child-environment copy. */
101
+ function scrubProgramResumeEnvironment(env) {
102
+ delete env[PROGRAM_RESUME_TOKEN_ENV];
103
+ delete env[PROGRAM_RESUME_HANDOFF_ENV];
104
+ }
105
+ //#endregion
106
+ export { scrubProgramResumeEnvironment as a, encodeProgramResumeHandoff as i, PROGRAM_RESUME_TOKEN_ENV as n, takeProgramResumeHandoff as o, decodeProgramResumeHandoff as r, PROGRAM_RESUME_HANDOFF_ENV as t };
@@ -0,0 +1,16 @@
1
+ //#region src/runtime/history-search-limits.ts
2
+ /** One exact-text chunk never exceeds this many UTF-16 code units. */
3
+ const HISTORY_SEARCH_READ_TEXT_LIMIT_MAX = 16384;
4
+ /** The fixed serialized UTF-8 byte budget of one session-recall answer. */
5
+ const HISTORY_SESSION_RECALL_MAX_BYTES = 65536;
6
+ /**
7
+ * The conservative per-row raw UTF-16 prefilter. This is ONE candidate window
8
+ * beyond which a single row cannot possibly fit the serialized 64 KiB answer
9
+ * (the envelope alone consumes bytes); it is NOT a claim that every row below
10
+ * it fits. The actual fit is decided on the real serialized envelope, so a long
11
+ * ASCII row can be recalled whole while an escaping-heavy CJK/control row is
12
+ * skipped whole.
13
+ */
14
+ const HISTORY_SESSION_RECALL_MAX_TEXT_CHARS = 65536;
15
+ //#endregion
16
+ export { HISTORY_SESSION_RECALL_MAX_BYTES as n, HISTORY_SESSION_RECALL_MAX_TEXT_CHARS as r, HISTORY_SEARCH_READ_TEXT_LIMIT_MAX as t };
@@ -0,0 +1,113 @@
1
+ import { a as remoteFailureMessage, i as remoteFailureCode } from "./write-failure-xNKczXH7.mjs";
2
+ //#region src/runtime/remote/history-search-remote.ts
3
+ /** The authenticated Owner peer refused the read before the Host service ran. */
4
+ var RemoteHistorySearchDeniedError = class extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = "RemoteHistorySearchDeniedError";
8
+ }
9
+ };
10
+ /** A dispatched read failed; `code` is the pinned Remote code when there was one. */
11
+ var RemoteHistorySearchFailedError = class extends Error {
12
+ code;
13
+ constructor(code, message) {
14
+ super(message);
15
+ this.name = "RemoteHistorySearchFailedError";
16
+ this.code = code;
17
+ }
18
+ };
19
+ /** The read belonged to a connection/generation that is no longer current. */
20
+ var RemoteHistorySearchSupersededError = class extends Error {
21
+ constructor(message) {
22
+ super(message);
23
+ this.name = "RemoteHistorySearchSupersededError";
24
+ }
25
+ };
26
+ /**
27
+ * The ONE Remote implementation of the history read port. The Host's own typed
28
+ * `unavailable` answer is preserved; only an unregistered namespace or the
29
+ * official `gateway/invocation-unavailable` answer is synthesized as
30
+ * `service-missing`.
31
+ */
32
+ var RemoteHistorySearchPort = class {
33
+ namespaceOf;
34
+ generation;
35
+ constructor(namespace, generation) {
36
+ this.namespaceOf = typeof namespace === "function" ? namespace : () => namespace;
37
+ this.generation = generation;
38
+ }
39
+ async search(request, signal) {
40
+ const namespace = this.namespaceOf();
41
+ if (namespace === void 0) return {
42
+ kind: "unavailable",
43
+ reason: "service-missing"
44
+ };
45
+ return await this.settle((captured) => namespace.search(request, captured), signal, {
46
+ kind: "unavailable",
47
+ reason: "service-missing"
48
+ });
49
+ }
50
+ async readText(request, signal) {
51
+ const namespace = this.namespaceOf();
52
+ if (namespace === void 0) return {
53
+ kind: "unavailable",
54
+ reason: "service-missing"
55
+ };
56
+ return await this.settle((captured) => namespace.readText(request, captured), signal, {
57
+ kind: "unavailable",
58
+ reason: "service-missing"
59
+ });
60
+ }
61
+ async readSessionRecall(request, signal) {
62
+ const namespace = this.namespaceOf();
63
+ const read = namespace?.readSessionRecall;
64
+ if (namespace === void 0 || read === void 0) return {
65
+ kind: "unavailable",
66
+ reason: "service-missing"
67
+ };
68
+ return await this.settle((captured) => read.call(namespace, request, captured), signal, {
69
+ kind: "unavailable",
70
+ reason: "service-missing"
71
+ });
72
+ }
73
+ async readBlankDirectoryRecall(request, signal) {
74
+ const namespace = this.namespaceOf();
75
+ const read = namespace?.readBlankDirectoryRecall;
76
+ if (namespace === void 0 || read === void 0) return {
77
+ kind: "unavailable",
78
+ reason: "service-missing"
79
+ };
80
+ return await this.settle((captured) => read.call(namespace, request, captured), signal, {
81
+ kind: "unavailable",
82
+ reason: "service-missing"
83
+ });
84
+ }
85
+ async settle(dispatch, signal, missing) {
86
+ signal.throwIfAborted();
87
+ const captured = this.generation.getSnapshot();
88
+ if (captured === void 0) throw new RemoteHistorySearchSupersededError("the Remote connection is not connected");
89
+ let result;
90
+ try {
91
+ result = await dispatch(signal);
92
+ signal.throwIfAborted();
93
+ } catch (error) {
94
+ signal.throwIfAborted();
95
+ if (!Object.is(captured, this.generation.getSnapshot())) throw new RemoteHistorySearchSupersededError("the Remote connection was replaced during the history read");
96
+ const code = remoteFailureCode(error);
97
+ if (code === "remote-access/denied") throw new RemoteHistorySearchDeniedError(remoteFailureMessage(error));
98
+ if (code === "gateway/cancelled") throw new RemoteHistorySearchSupersededError("the Remote history read was cancelled by the carrier");
99
+ throw new RemoteHistorySearchFailedError(code, remoteFailureMessage(error));
100
+ }
101
+ if (!Object.is(captured, this.generation.getSnapshot())) throw new RemoteHistorySearchSupersededError("the Remote connection was replaced during the history read");
102
+ if (!result.ok) {
103
+ const code = remoteFailureCode(result.error);
104
+ if (code === "gateway/invocation-unavailable") return missing;
105
+ if (code === "remote-access/denied") throw new RemoteHistorySearchDeniedError(remoteFailureMessage(result.error));
106
+ if (code === "gateway/cancelled") throw new RemoteHistorySearchSupersededError("the Remote history read was cancelled by the carrier");
107
+ throw new RemoteHistorySearchFailedError(code, remoteFailureMessage(result.error));
108
+ }
109
+ return result.value;
110
+ }
111
+ };
112
+ //#endregion
113
+ export { RemoteHistorySearchSupersededError as i, RemoteHistorySearchFailedError as n, RemoteHistorySearchPort as r, RemoteHistorySearchDeniedError as t };
@@ -0,0 +1,26 @@
1
+ //#region src/runtime/remote/history-search-remote.ts
2
+ /** The authenticated Owner peer refused the read before the Host service ran. */
3
+ var RemoteHistorySearchDeniedError = class extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = "RemoteHistorySearchDeniedError";
7
+ }
8
+ };
9
+ /** A dispatched read failed; `code` is the pinned Remote code when there was one. */
10
+ var RemoteHistorySearchFailedError = class extends Error {
11
+ code;
12
+ constructor(code, message) {
13
+ super(message);
14
+ this.name = "RemoteHistorySearchFailedError";
15
+ this.code = code;
16
+ }
17
+ };
18
+ /** The read belonged to a connection/generation that is no longer current. */
19
+ var RemoteHistorySearchSupersededError = class extends Error {
20
+ constructor(message) {
21
+ super(message);
22
+ this.name = "RemoteHistorySearchSupersededError";
23
+ }
24
+ };
25
+ //#endregion
26
+ export { RemoteHistorySearchFailedError as n, RemoteHistorySearchSupersededError as r, RemoteHistorySearchDeniedError as t };