@xmoon76/dsh-pi-tui 0.5.6 → 0.5.8
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/LICENSE +33 -0
- package/README.en.md +103 -814
- package/README.md +102 -711
- package/cordis.patch.yml +186 -0
- package/dist/acp-preferences.d.mts +29 -0
- package/dist/acp-preferences.mjs +15 -0
- package/dist/{bootstrap-DQ4YPL-7.mjs → bootstrap-CMIjGyuk.mjs} +33515 -7587
- package/dist/builtins.mjs +3 -3
- package/dist/{client-bootstrap-Cr1JCaF5.mjs → client-bootstrap-BjGPc-DM.mjs} +4637 -492
- package/dist/client-extension-loader-probe-BUw7q8bJ.mjs +119 -0
- package/dist/command-trust-DChWUamk.mjs +406 -0
- package/dist/daemon-launcher-Dult7Jxv.mjs +1932 -0
- package/dist/daemon-launcher.d.mts +159 -0
- package/dist/daemon-launcher.mjs +2 -0
- package/dist/diagnostics-D5jwc-q1.d.mts +11 -0
- package/dist/{dist-CIsR7cz4.mjs → dist-BFgC-5tL.mjs} +938 -487
- package/dist/entry-control-DjNsE3I0.mjs +190 -0
- package/dist/extension/advanced.d.mts +1 -1
- package/dist/extension/unstable.d.mts +1 -1
- package/dist/extension-config-probe-BDdvutkG.mjs +95 -0
- package/dist/extension-config.d.mts +29 -0
- package/dist/extension-config.mjs +22 -0
- package/dist/{extensions-Bp0L37lP.mjs → extensions-B4uLpSTv.mjs} +1109 -100
- package/dist/{extensions-Bte3XOt5.d.mts → extensions-C8eAM0gX.d.mts} +1 -1
- package/dist/extensions.d.mts +2 -2
- package/dist/extensions.mjs +1 -1
- package/dist/{host-bootstrap-DilsvA6f.mjs → host-bootstrap-MVxks641.mjs} +129 -24
- package/dist/{host-foundation-probe--5jtvHVe.mjs → host-foundation-probe-DMNTmNrH.mjs} +2 -2
- package/dist/host-runtime.d.mts +11 -5
- package/dist/host-runtime.mjs +4171 -920
- package/dist/index.d.mts +86 -174
- package/dist/index.mjs +38087 -9967
- package/dist/local-acp-listener-B65J0Bx4.mjs +3115 -0
- package/dist/local-client.mjs +1158 -59
- package/dist/local-daemon-control-C14q9KnD.mjs +1588 -0
- package/dist/local-daemon-control-TCnERL7n.mjs +1424 -0
- package/dist/local-discovery-DOSsCh9q.mjs +2883 -0
- package/dist/local-discovery-egN4_gsQ.mjs +2 -0
- package/dist/local-discovery-uOBfFq5j.mjs +2764 -0
- package/dist/local-host.mjs +812 -89
- package/dist/local-profile-daemon-admin-BmQSdzT0.mjs +210 -0
- package/dist/local-scope-DamiMqPd.mjs +1340 -0
- package/dist/{local-transport-BVwFYq_Y.mjs → local-transport-Iwo0mtu3.mjs} +313 -38
- package/dist/local-web-control-DMrjwCkl.mjs +454 -0
- package/dist/local-workspace-object-D06GL0UO.mjs +248 -0
- package/dist/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
- package/dist/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
- package/dist/open-CmOBxSjN.mjs +63 -0
- package/dist/persisted-setting-probe-DWZLtWoB.mjs +145 -0
- package/dist/pi-tui-acp-access-contract-BdLwduU6.mjs +75 -0
- package/dist/pi-tui-remote-contribution-Do8ECrUy.mjs +1492 -0
- package/dist/pi-tui-terminal-progress-contract-B3RoEzjK.mjs +146 -0
- package/dist/preferences.d.mts +17 -0
- package/dist/preferences.mjs +20 -0
- package/dist/preset-BcWqOtY7.mjs +46 -0
- package/dist/profile-preferences-migration-BfUGdPZx.mjs +500 -0
- package/dist/profile-preferences-migration-CThz4rHH.mjs +2 -0
- package/dist/prompt-sections-DUKmWb8g.mjs +2232 -0
- package/dist/prompt-sections-DXmjB58H.mjs +634 -0
- package/dist/{public-types-Dgf1bDke.d.mts → public-types-C1YgFtwC.d.mts} +56 -3
- package/dist/row-id-DPbyt9Nn.mjs +24 -0
- package/dist/{runtime-status-Cj1nFOdS.mjs → runtime-status-v-FTnWcD.mjs} +49 -3
- package/dist/schema-BTGYn8_X.d.mts +54 -0
- package/dist/schema-qE_P09zJ.mjs +124 -0
- package/dist/{session-BKGXyh80.mjs → session-C6tSs86s.mjs} +9672 -7270
- package/dist/{session-CPt_U8_f.mjs → session-CstInGIA.mjs} +9674 -7273
- package/dist/startup-CarQxWwi.d.mts +213 -0
- package/dist/{startup-7BYWuvBU.mjs → startup-EG5UqIcd.mjs} +341 -26
- package/dist/startup.d.mts +2 -99
- package/dist/startup.mjs +2 -2
- package/dist/{terminal-progress-source-DrqQhtT8.mjs → terminal-progress-source-CpfpQO_h.mjs} +2038 -67
- package/dist/{pasted-path-range-CMnxuGPx.mjs → transcript-view-C1YtJ49Y.mjs} +11590 -6718
- package/dist/{pasted-path-range-r6qzV_tC.mjs → transcript-view-CuJYWkhp.mjs} +12296 -6923
- package/dist/version-B9yC7bBk.mjs +83 -0
- package/dist/visual-tools.d.mts +1 -1
- package/dist/visual-tools.mjs +1 -1
- package/dist/web-preferences.d.mts +1 -1
- package/dist/{web-roster-CjqnUXNk.mjs → web-roster-Dis7BhrA.mjs} +63 -3
- package/generated/dsh-presets/cordis.patch.yml +4 -2
- package/generated/dsh-presets/ptc.patch.yml +4 -0
- package/generated/dsh-presets/standard.patch.yml +7 -0
- package/generated/web-access/cordis.patch.yml +239 -0
- package/package.json +217 -170
- package/dist/entry-control-DnduyDiw.mjs +0 -92
- package/dist/local-discovery-C9VMjc0K.mjs +0 -759
- package/dist/local-discovery-CDaQHA_R.mjs +0 -2
- package/dist/pi-tui-remote-contribution-B0EQsP0N.mjs +0 -85
- package/dist/pi-tui-terminal-progress-contract-CdBH9j78.mjs +0 -70
- package/dist/pi-tui-terminal-progress-contract-MLXZ-i3t.mjs +0 -905
- package/dist/version-a-eF-QER.mjs +0 -80
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { d as readInstalledDshVersion } from "./local-scope-DamiMqPd.mjs";
|
|
2
|
+
import "./entry-control-DjNsE3I0.mjs";
|
|
3
|
+
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";
|
|
8
|
+
import { homedir } from "node:os";
|
|
9
|
+
import "node:child_process";
|
|
10
|
+
//#region src/runtime/process/diagnostics.ts
|
|
11
|
+
/**
|
|
12
|
+
* Structured process diagnostics for the TUI.
|
|
13
|
+
*
|
|
14
|
+
* The TUI cannot rely on `ctx.logger` for human-visible troubleshooting:
|
|
15
|
+
* no dsh server-side package registers a logger exporter, so those lines
|
|
16
|
+
* only fill cordis's in-memory buffer. This module owns a dedicated
|
|
17
|
+
* diagnostics channel instead — one line per event, written to stderr
|
|
18
|
+
* (warn/error by default, matching the legacy `[tui]` fd-2 lines) and to a
|
|
19
|
+
* log file (info by default) under `$DSH_HOME/logs/`.
|
|
20
|
+
*
|
|
21
|
+
* Configuration (env):
|
|
22
|
+
* - `DSH_PI_TUI_LOG` — log file path, or `off` to disable the file sink.
|
|
23
|
+
* - `DSH_PI_TUI_LOG_LEVEL` — one of debug/info/warn/error (default `info`).
|
|
24
|
+
*
|
|
25
|
+
* Writes are best-effort and never throw; a failed file sink is disabled
|
|
26
|
+
* silently so diagnostics can never take the TUI down.
|
|
27
|
+
* @module @xmoon76/dsh-pi-tui/runtime/process/diagnostics
|
|
28
|
+
*/
|
|
29
|
+
const LEVEL_RANK = {
|
|
30
|
+
debug: 0,
|
|
31
|
+
info: 1,
|
|
32
|
+
warn: 2,
|
|
33
|
+
error: 3
|
|
34
|
+
};
|
|
35
|
+
/** `2026-08-15T10:00:00.000+08:00` — local wall time with the zone offset. */
|
|
36
|
+
function formatDiagTime(date) {
|
|
37
|
+
const pad = (value, width = 2) => String(value).padStart(width, "0");
|
|
38
|
+
const offsetMinutes = -date.getTimezoneOffset();
|
|
39
|
+
const offset = `${offsetMinutes >= 0 ? "+" : "-"}${pad(Math.floor(Math.abs(offsetMinutes) / 60))}:${pad(Math.abs(offsetMinutes) % 60)}`;
|
|
40
|
+
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}`;
|
|
41
|
+
}
|
|
42
|
+
/** Render a single field value for the `k=v` line format. */
|
|
43
|
+
function formatField(value) {
|
|
44
|
+
if (typeof value === "string") return value;
|
|
45
|
+
if (typeof value === "number" || typeof value === "boolean" || value === null || value === void 0) return String(value);
|
|
46
|
+
try {
|
|
47
|
+
return JSON.stringify(value) ?? String(value);
|
|
48
|
+
} catch {
|
|
49
|
+
return safeErrorMessage(value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** The dsh home directory (`$DSH_HOME`, defaulting to `~/.dsh`). */
|
|
53
|
+
function dshHome(env) {
|
|
54
|
+
const explicit = env.DSH_HOME;
|
|
55
|
+
if (explicit !== void 0 && explicit !== "") return explicit;
|
|
56
|
+
return join(homedir(), ".dsh");
|
|
57
|
+
}
|
|
58
|
+
/** Build the default diagnostics log path: `$DSH_HOME/logs/pi-tui-<pid>.log`. */
|
|
59
|
+
function defaultDiagLogPath(env) {
|
|
60
|
+
const configured = env.DSH_PI_TUI_LOG;
|
|
61
|
+
if (configured === "off" || configured === "") return void 0;
|
|
62
|
+
if (configured !== void 0) return configured;
|
|
63
|
+
return join(dshHome(env), "logs", `pi-tui-${process.pid}.log`);
|
|
64
|
+
}
|
|
65
|
+
/** Resolve the effective file level from `DSH_PI_TUI_LOG_LEVEL`. */
|
|
66
|
+
function diagLevelFromEnv(env) {
|
|
67
|
+
const configured = env.DSH_PI_TUI_LOG_LEVEL;
|
|
68
|
+
if (configured === "debug" || configured === "info" || configured === "warn" || configured === "error") return configured;
|
|
69
|
+
return "info";
|
|
70
|
+
}
|
|
71
|
+
/** Create the diagnostics channel from the process environment. */
|
|
72
|
+
function diagFromEnv(env) {
|
|
73
|
+
return createDiag({
|
|
74
|
+
fileLevel: diagLevelFromEnv(env),
|
|
75
|
+
filePath: defaultDiagLogPath(env)
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/** Create one diagnostics channel. Writes are best-effort, never throw. */
|
|
79
|
+
function createDiag(options = {}) {
|
|
80
|
+
const fileLevel = options.fileLevel ?? "info";
|
|
81
|
+
const stderrLevel = options.stderrLevel ?? "warn";
|
|
82
|
+
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
83
|
+
const sinks = [...options.sinks ?? []];
|
|
84
|
+
let fileHandle;
|
|
85
|
+
let fileDisabled = false;
|
|
86
|
+
if (options.filePath !== void 0) try {
|
|
87
|
+
const dir = options.filePath.slice(0, Math.max(options.filePath.lastIndexOf("/"), 0));
|
|
88
|
+
if (dir !== "") mkdirSync(dir, { recursive: true });
|
|
89
|
+
fileHandle = openSync(options.filePath, "a");
|
|
90
|
+
} catch {
|
|
91
|
+
fileDisabled = true;
|
|
92
|
+
}
|
|
93
|
+
const emit = (level, message, fields) => {
|
|
94
|
+
const stamp = formatDiagTime(now());
|
|
95
|
+
const suffix = fields === void 0 ? "" : ` ${Object.entries(fields).map(([key, value]) => `${key}=${formatField(value)}`).join(" ")}`;
|
|
96
|
+
const line = `[tui] ${stamp} ${level.toUpperCase()} ${message}${suffix}\n`;
|
|
97
|
+
for (const sink of sinks) try {
|
|
98
|
+
sink.write(line);
|
|
99
|
+
} catch {}
|
|
100
|
+
if (stderrLevel !== "off" && LEVEL_RANK[level] >= LEVEL_RANK[stderrLevel]) try {
|
|
101
|
+
writeSync(2, line);
|
|
102
|
+
} catch {}
|
|
103
|
+
if (fileHandle !== void 0 && !fileDisabled && LEVEL_RANK[level] >= LEVEL_RANK[fileLevel]) try {
|
|
104
|
+
writeSync(fileHandle, line);
|
|
105
|
+
} catch {
|
|
106
|
+
fileDisabled = true;
|
|
107
|
+
try {
|
|
108
|
+
writeSync(2, `[tui] ${formatDiagTime(now())} WARN diag file sink disabled\n`);
|
|
109
|
+
} catch {}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return {
|
|
113
|
+
debug: (message, fields) => emit("debug", message, fields),
|
|
114
|
+
info: (message, fields) => emit("info", message, fields),
|
|
115
|
+
warn: (message, fields) => emit("warn", message, fields),
|
|
116
|
+
error: (message, fields) => emit("error", message, fields),
|
|
117
|
+
dispose: () => {
|
|
118
|
+
if (fileHandle !== void 0) {
|
|
119
|
+
try {
|
|
120
|
+
closeSync(fileHandle);
|
|
121
|
+
} catch {}
|
|
122
|
+
fileHandle = void 0;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//#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 };
|