@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.
- package/README.en.md +64 -26
- package/README.md +64 -26
- package/cordis.patch.yml +13 -0
- package/dist/acp-stdio.mjs +151 -0
- package/dist/{bootstrap-C9nl6e13.mjs → bootstrap-CVyHGQDX.mjs} +22330 -6888
- package/dist/browser-CDUSHIIr.mjs +76 -0
- package/dist/builtins.mjs +2 -2
- package/dist/{client-bootstrap-CGezi85O.mjs → client-bootstrap-4UoeVIHE.mjs} +2407 -1830
- package/dist/client-runtime-BHBlVUf5.mjs +1376 -0
- package/dist/{daemon-launcher-H_1r5Cqs.mjs → daemon-launcher-DxIgjBHW.mjs} +1551 -57
- package/dist/daemon-launcher.d.mts +85 -14
- package/dist/daemon-launcher.mjs +2 -2
- package/dist/diagnostics-Db5iVcuJ.mjs +123 -0
- package/dist/{entry-control-jBfKn1qO.mjs → entry-control-BDLZgg4m.mjs} +1 -1
- package/dist/{extensions-6a5vvJUT.mjs → extensions-Dx7ncPNA.mjs} +1 -4
- package/dist/extensions.mjs +1 -1
- package/dist/handoff-BjoEy3f8.mjs +106 -0
- package/dist/history-search-limits-Cx2UvRC2.mjs +16 -0
- package/dist/history-search-remote-BHuoellG.mjs +113 -0
- package/dist/history-search-remote-BzXdvrxk.mjs +26 -0
- package/dist/history-search-seat-BcHJTpeB.mjs +639 -0
- package/dist/history-search-seat-rZcq0XV6.mjs +639 -0
- package/dist/{host-bootstrap-MVxks641.mjs → host-bootstrap-BfnufpnW.mjs} +37 -72
- package/dist/{host-foundation-probe-DK7n5jDu.mjs → host-foundation-probe-DlD8-N_Q.mjs} +2 -2
- package/dist/host-runtime.mjs +5611 -290
- package/dist/index.d.mts +13 -6
- package/dist/index.mjs +22766 -6893
- package/dist/installed-dsh-BjUiJSwR.mjs +142 -0
- package/dist/interaction-port-D1Yv9zgu.mjs +45 -0
- package/dist/local-acp-control-CC5z4Xbq.mjs +304 -0
- package/dist/local-acp-endpoint-D1jYdJdv.mjs +41 -0
- package/dist/local-acp-listener-Cmgb5M0H.mjs +9493 -0
- package/dist/local-acp-status-B_25Q6kU.mjs +101 -0
- package/dist/local-client.mjs +719 -93
- package/dist/local-daemon-control-BFJAC8Kg.mjs +2199 -0
- package/dist/local-daemon-control-Bm3imctD.mjs +2101 -0
- package/dist/{local-discovery-BPZw1wEd.mjs → local-discovery-BMhaGIiJ.mjs} +254 -544
- package/dist/{local-discovery-BMoNXZjJ.mjs → local-discovery-Ba7_-NNC.mjs} +1 -1
- package/dist/{local-discovery-Bq3jLAn1.mjs → local-discovery-QSbFpjK2.mjs} +301 -544
- package/dist/local-host.mjs +970 -501
- package/dist/local-profile-daemon-admin-otpm69R6.mjs +469 -0
- package/dist/{local-scope-DEuGAy8l.mjs → local-scope-5DEKA_lW.mjs} +1075 -31
- package/dist/{local-transport-X4ZCe2uE.mjs → local-transport-DeWmdZ5E.mjs} +14 -3
- package/dist/{local-web-control-DKWtXIkr.mjs → local-web-control-Dny93N-r.mjs} +10 -7
- package/dist/{local-workspace-object-D06GL0UO.mjs → local-workspace-object-D0RVQt8U.mjs} +33 -9
- package/dist/model-selection-CYlqg2DV.mjs +83 -0
- package/dist/native-client-domains-Dg4srzYt.mjs +2 -0
- package/dist/native-client.d.mts +735 -0
- package/dist/native-client.mjs +3534 -0
- package/dist/{open-CmOBxSjN.mjs → open-QQva8-ar.mjs} +24 -20
- package/dist/{pi-tui-remote-contribution-Do8ECrUy.mjs → pi-tui-remote-contribution-565wiLWp.mjs} +741 -150
- package/dist/preferences.mjs +1 -1
- package/dist/{profile-preferences-migration-CThz4rHH.mjs → profile-preferences-migration-CNOWIdnr.mjs} +1 -1
- package/dist/{profile-preferences-migration-BfUGdPZx.mjs → profile-preferences-migration-IrnXcJWK.mjs} +10 -8
- package/dist/{prompt-sections-DXmjB58H.mjs → prompt-sections-Bi-9_Gr_.mjs} +28 -10
- package/dist/{prompt-sections-DUKmWb8g.mjs → prompt-sections-DFS1dqsY.mjs} +342 -56
- package/dist/{dist-BFgC-5tL.mjs → recall-scope-9Nuoto_i.mjs} +353 -1
- package/dist/rolldown-runtime-8H4AJuhK.mjs +14 -0
- package/dist/schema-CCLvDa7Q.mjs +177 -0
- package/dist/{schema-qE_P09zJ.mjs → schema-t97l3aK8.mjs} +56 -3
- package/dist/{session-DC0XQr5O.mjs → session-Cs8iLCEx.mjs} +784 -342
- package/dist/{session-Cihe8PPS.mjs → session-EBRZF6Ow.mjs} +783 -341
- package/dist/session-create-facts-CkfG5DpQ.mjs +20 -0
- package/dist/{startup-CarQxWwi.d.mts → startup-Dti3Udne.d.mts} +30 -3
- package/dist/{startup-CARqn3kV.mjs → startup-UtFQSDe_.mjs} +90 -15
- package/dist/startup.d.mts +2 -2
- package/dist/startup.mjs +1 -1
- package/dist/task-read-remote-DRtkXDrZ.mjs +1083 -0
- package/dist/{terminal-progress-source-D4DHyXDo.mjs → terminal-progress-source-VsczdXA-.mjs} +610 -335
- package/dist/{transcript-view-a7cROAaI.mjs → transcript-view-B6vCnukn.mjs} +2284 -1166
- package/dist/{transcript-view-hvNVkPtv.mjs → transcript-view-DSSdE2vK.mjs} +2191 -765
- package/dist/write-failure-xNKczXH7.mjs +189 -0
- package/package.json +25 -8
- package/dist/local-acp-listener-CNkguN5-.mjs +0 -2566
- package/dist/local-daemon-control-Bg9s2aYi.mjs +0 -1424
- package/dist/local-daemon-control-Cu_4FIdd.mjs +0 -1585
- package/dist/local-profile-daemon-admin-AXgVH-6y.mjs +0 -91
- package/dist/preset-BcWqOtY7.mjs +0 -46
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import { t as Diag } from "./diagnostics-D5jwc-q1.mjs";
|
|
2
|
-
import {
|
|
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
|
|
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
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
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 };
|
package/dist/daemon-launcher.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
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 };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { o as safeErrorMessage } from "./tasks-D_z5Yjjr.mjs";
|
|
2
|
+
import { closeSync, mkdirSync, openSync, writeSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
//#region src/runtime/process/diagnostics.ts
|
|
6
|
+
/**
|
|
7
|
+
* Structured process diagnostics for the TUI.
|
|
8
|
+
*
|
|
9
|
+
* The TUI cannot rely on `ctx.logger` for human-visible troubleshooting:
|
|
10
|
+
* no dsh server-side package registers a logger exporter, so those lines
|
|
11
|
+
* only fill cordis's in-memory buffer. This module owns a dedicated
|
|
12
|
+
* diagnostics channel instead — one line per event, written to stderr
|
|
13
|
+
* (warn/error by default, matching the legacy `[tui]` fd-2 lines) and to a
|
|
14
|
+
* log file (info by default) under `$DSH_HOME/logs/`.
|
|
15
|
+
*
|
|
16
|
+
* Configuration (env):
|
|
17
|
+
* - `DSH_PI_TUI_LOG` — log file path, or `off` to disable the file sink.
|
|
18
|
+
* - `DSH_PI_TUI_LOG_LEVEL` — one of debug/info/warn/error (default `info`).
|
|
19
|
+
*
|
|
20
|
+
* Writes are best-effort and never throw; a failed file sink is disabled
|
|
21
|
+
* silently so diagnostics can never take the TUI down.
|
|
22
|
+
* @module @xmoon76/dsh-pi-tui/runtime/process/diagnostics
|
|
23
|
+
*/
|
|
24
|
+
const LEVEL_RANK = {
|
|
25
|
+
debug: 0,
|
|
26
|
+
info: 1,
|
|
27
|
+
warn: 2,
|
|
28
|
+
error: 3
|
|
29
|
+
};
|
|
30
|
+
/** `2026-08-15T10:00:00.000+08:00` — local wall time with the zone offset. */
|
|
31
|
+
function formatDiagTime(date) {
|
|
32
|
+
const pad = (value, width = 2) => String(value).padStart(width, "0");
|
|
33
|
+
const offsetMinutes = -date.getTimezoneOffset();
|
|
34
|
+
const offset = `${offsetMinutes >= 0 ? "+" : "-"}${pad(Math.floor(Math.abs(offsetMinutes) / 60))}:${pad(Math.abs(offsetMinutes) % 60)}`;
|
|
35
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}${offset}`;
|
|
36
|
+
}
|
|
37
|
+
/** Render a single field value for the `k=v` line format. */
|
|
38
|
+
function formatField(value) {
|
|
39
|
+
if (typeof value === "string") return value;
|
|
40
|
+
if (typeof value === "number" || typeof value === "boolean" || value === null || value === void 0) return String(value);
|
|
41
|
+
try {
|
|
42
|
+
return JSON.stringify(value) ?? String(value);
|
|
43
|
+
} catch {
|
|
44
|
+
return safeErrorMessage(value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** The dsh home directory (`$DSH_HOME`, defaulting to `~/.dsh`). */
|
|
48
|
+
function dshHome(env) {
|
|
49
|
+
const explicit = env.DSH_HOME;
|
|
50
|
+
if (explicit !== void 0 && explicit !== "") return explicit;
|
|
51
|
+
return join(homedir(), ".dsh");
|
|
52
|
+
}
|
|
53
|
+
/** Build the default diagnostics log path: `$DSH_HOME/logs/pi-tui-<pid>.log`. */
|
|
54
|
+
function defaultDiagLogPath(env) {
|
|
55
|
+
const configured = env.DSH_PI_TUI_LOG;
|
|
56
|
+
if (configured === "off" || configured === "") return void 0;
|
|
57
|
+
if (configured !== void 0) return configured;
|
|
58
|
+
return join(dshHome(env), "logs", `pi-tui-${process.pid}.log`);
|
|
59
|
+
}
|
|
60
|
+
/** Resolve the effective file level from `DSH_PI_TUI_LOG_LEVEL`. */
|
|
61
|
+
function diagLevelFromEnv(env) {
|
|
62
|
+
const configured = env.DSH_PI_TUI_LOG_LEVEL;
|
|
63
|
+
if (configured === "debug" || configured === "info" || configured === "warn" || configured === "error") return configured;
|
|
64
|
+
return "info";
|
|
65
|
+
}
|
|
66
|
+
/** Create the diagnostics channel from the process environment. */
|
|
67
|
+
function diagFromEnv(env) {
|
|
68
|
+
return createDiag({
|
|
69
|
+
fileLevel: diagLevelFromEnv(env),
|
|
70
|
+
filePath: defaultDiagLogPath(env)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/** Create one diagnostics channel. Writes are best-effort, never throw. */
|
|
74
|
+
function createDiag(options = {}) {
|
|
75
|
+
const fileLevel = options.fileLevel ?? "info";
|
|
76
|
+
const stderrLevel = options.stderrLevel ?? "warn";
|
|
77
|
+
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
78
|
+
const sinks = [...options.sinks ?? []];
|
|
79
|
+
let fileHandle;
|
|
80
|
+
let fileDisabled = false;
|
|
81
|
+
if (options.filePath !== void 0) try {
|
|
82
|
+
const dir = options.filePath.slice(0, Math.max(options.filePath.lastIndexOf("/"), 0));
|
|
83
|
+
if (dir !== "") mkdirSync(dir, { recursive: true });
|
|
84
|
+
fileHandle = openSync(options.filePath, "a");
|
|
85
|
+
} catch {
|
|
86
|
+
fileDisabled = true;
|
|
87
|
+
}
|
|
88
|
+
const emit = (level, message, fields) => {
|
|
89
|
+
const stamp = formatDiagTime(now());
|
|
90
|
+
const suffix = fields === void 0 ? "" : ` ${Object.entries(fields).map(([key, value]) => `${key}=${formatField(value)}`).join(" ")}`;
|
|
91
|
+
const line = `[tui] ${stamp} ${level.toUpperCase()} ${message}${suffix}\n`;
|
|
92
|
+
for (const sink of sinks) try {
|
|
93
|
+
sink.write(line);
|
|
94
|
+
} catch {}
|
|
95
|
+
if (stderrLevel !== "off" && LEVEL_RANK[level] >= LEVEL_RANK[stderrLevel]) try {
|
|
96
|
+
writeSync(2, line);
|
|
97
|
+
} catch {}
|
|
98
|
+
if (fileHandle !== void 0 && !fileDisabled && LEVEL_RANK[level] >= LEVEL_RANK[fileLevel]) try {
|
|
99
|
+
writeSync(fileHandle, line);
|
|
100
|
+
} catch {
|
|
101
|
+
fileDisabled = true;
|
|
102
|
+
try {
|
|
103
|
+
writeSync(2, `[tui] ${formatDiagTime(now())} WARN diag file sink disabled\n`);
|
|
104
|
+
} catch {}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
debug: (message, fields) => emit("debug", message, fields),
|
|
109
|
+
info: (message, fields) => emit("info", message, fields),
|
|
110
|
+
warn: (message, fields) => emit("warn", message, fields),
|
|
111
|
+
error: (message, fields) => emit("error", message, fields),
|
|
112
|
+
dispose: () => {
|
|
113
|
+
if (fileHandle !== void 0) {
|
|
114
|
+
try {
|
|
115
|
+
closeSync(fileHandle);
|
|
116
|
+
} catch {}
|
|
117
|
+
fileHandle = void 0;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { diagFromEnv as n, dshHome as r, createDiag as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./local-scope-
|
|
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-
|
|
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";
|
|
@@ -17722,7 +17722,6 @@ const SESSIONLESS_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
17722
17722
|
"focus",
|
|
17723
17723
|
"footer",
|
|
17724
17724
|
"settings",
|
|
17725
|
-
"help",
|
|
17726
17725
|
"attach",
|
|
17727
17726
|
"image",
|
|
17728
17727
|
"login",
|
|
@@ -17821,7 +17820,6 @@ const LOCAL_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
17821
17820
|
"focus",
|
|
17822
17821
|
"footer",
|
|
17823
17822
|
"fork",
|
|
17824
|
-
"help",
|
|
17825
17823
|
"attach",
|
|
17826
17824
|
"image",
|
|
17827
17825
|
"keybindings",
|
|
@@ -18070,7 +18068,6 @@ const READ_ONLY_LOCAL_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
18070
18068
|
"reload",
|
|
18071
18069
|
"exit",
|
|
18072
18070
|
"quit",
|
|
18073
|
-
"help",
|
|
18074
18071
|
"keybindings",
|
|
18075
18072
|
"copy",
|
|
18076
18073
|
"attach",
|
package/dist/extensions.mjs
CHANGED
|
@@ -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-
|
|
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 };
|