dsh-bash-terminal-ts 0.9.1 → 0.9.2
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/CHANGELOG.md +205 -205
- package/CHANGELOG.pt.md +151 -151
- package/README.de.md +206 -206
- package/README.en.md +212 -212
- package/README.es.md +206 -206
- package/README.fr.md +206 -206
- package/README.it.md +206 -206
- package/README.md +423 -423
- package/README.pt.md +212 -212
- package/README.ru.md +206 -206
- package/agent-presets/README.md +171 -171
- package/agent-presets/install-presets.mjs +180 -180
- package/agent-presets/standard-win/agent.cordis.yml +271 -271
- package/agent-presets/standard-win/preset.yml +2 -2
- package/agent-presets/standard-win-gitbash/agent.cordis.yml +271 -271
- package/agent-presets/standard-win-gitbash/preset.yml +2 -2
- package/agent-presets/standard-win-msys2/agent.cordis.yml +272 -272
- package/agent-presets/standard-win-msys2/preset.yml +2 -2
- package/agent-presets/standard-win-niu/agent.cordis.yml +270 -270
- package/agent-presets/standard-win-niu/preset.yml +2 -2
- package/agent-presets/standard-win-payload/agent.cordis.yml +271 -271
- package/agent-presets/standard-win-payload/preset.yml +2 -2
- package/agent-presets/standard-win-wsl2/agent.cordis.yml +271 -271
- package/agent-presets/standard-win-wsl2/preset.yml +2 -2
- package/cordis.patch.yml +72 -84
- package/dist/client.core.js +6 -16
- package/dist/client.js +6 -16
- package/docs/niu-backend.md +197 -197
- package/dsh.plugin.json +23 -23
- package/lib/client.js +6 -16
- package/lib/dsh-types.d.ts +0 -2
- package/lib/index.d.ts +2 -23
- package/lib/index.js +4 -34
- package/lib/locales.js +0 -10
- package/lib/payload.d.ts +72 -72
- package/lib/payload.js +279 -279
- package/lib/shell-id.d.ts +2 -2
- package/lib/shells.d.ts +2 -11
- package/lib/shells.js +4 -14
- package/lib/terminal.js +0 -1
- package/lib/webterminals/catalog.d.ts +0 -2
- package/lib/webterminals/catalog.js +0 -1
- package/lib/webterminals/mount.d.ts +0 -5
- package/lib/webterminals/mount.js +0 -4
- package/locale/de.json +5 -5
- package/locale/en.json +5 -5
- package/locale/es.json +5 -5
- package/locale/fr.json +5 -5
- package/locale/it.json +5 -5
- package/locale/ja.json +5 -5
- package/locale/ko.json +5 -5
- package/locale/pt.json +6 -6
- package/locale/ru.json +5 -5
- package/locale/zh.json +5 -5
- package/package.json +1 -5
- package/scripts/check-artifacts.mjs +96 -96
- package/scripts/link-shells.mjs +0 -21
- package/src/client.tsx +685 -685
- package/src/dsh-types.ts +330 -332
- package/src/index.ts +1267 -1316
- package/src/locales.ts +499 -509
- package/src/shell-id.ts +11 -11
- package/src/shells.ts +263 -279
- package/src/terminal.ts +615 -616
- package/src/webterminals/catalog.ts +0 -3
- package/src/webterminals/host.ts +361 -361
- package/src/webterminals/mount.ts +228 -237
- package/scripts/payload-alias.mjs +0 -97
- package/scripts/provision-payload.mjs +0 -233
- package/src/payload.ts +0 -322
package/lib/index.js
CHANGED
|
@@ -26,7 +26,6 @@ import { isAbsolute, join, resolve } from "node:path";
|
|
|
26
26
|
import { mountBrowserTerminals } from "./webterminals/mount.js";
|
|
27
27
|
import { ESCALATION_TARGETS, TOOL_ABORTED, approveEscalation, defineTool, escalationHintMarker, clampTimeout, deadline, parseExitStatus, timeoutOf, sandboxDenialMarker, validateEscalationArgs, z, HarnessError } from "./dsh.js";
|
|
28
28
|
import { createTerminalRegistry, terminalTool } from "./terminal.js";
|
|
29
|
-
import { resolvePayloadBash } from "./payload.js";
|
|
30
29
|
/** Stable Cordis plugin name. */
|
|
31
30
|
export const name = "bash-terminal";
|
|
32
31
|
/** Composition entry id (the `tool-bash-terminal` row the bundle patch declares). */
|
|
@@ -34,7 +33,7 @@ const ENTRY_ID = "tool-bash-terminal";
|
|
|
34
33
|
/** Services required before the tool can register. */
|
|
35
34
|
export const inject = ["tools", "systemPrompt", "shellEnv", "subprocess", "settings", "sandbox", "sandboxPolicy"];
|
|
36
35
|
/** The terminal backends this tool exposes, in catalog order. */
|
|
37
|
-
export const SHELLS = ["powershell", "gitbash", "msys2", "wsl", "
|
|
36
|
+
export const SHELLS = ["powershell", "gitbash", "msys2", "wsl", "niu"];
|
|
38
37
|
/** The backend used when the caller does not name one. */
|
|
39
38
|
export const DEFAULT_SHELL = "powershell";
|
|
40
39
|
/** Default per-command timeout (ms). */
|
|
@@ -73,12 +72,7 @@ export const Config = z.object({
|
|
|
73
72
|
shellGitBash: z.boolean().default(true).volatile(),
|
|
74
73
|
shellMsys2: z.boolean().default(true).volatile(),
|
|
75
74
|
shellWsl: z.boolean().default(true).volatile(),
|
|
76
|
-
shellPayload: z.boolean().default(false).volatile(),
|
|
77
75
|
wslDistro: z.string().default("").volatile(),
|
|
78
|
-
// Payload gate state is read once per process (paths resolve at startup), so
|
|
79
|
-
// these are deliberately NOT volatile: a flip needs the restart it implies.
|
|
80
|
-
enablePosixPayload: z.boolean().default(false),
|
|
81
|
-
payloadPosixPath: z.string().default(""),
|
|
82
76
|
niuPath: z.string().default(""),
|
|
83
77
|
shellNiu: z.boolean().default(true).volatile()
|
|
84
78
|
});
|
|
@@ -198,7 +192,7 @@ export function defaultWslPath(env = process.env) {
|
|
|
198
192
|
const systemRoot = env.SystemRoot ?? "C:\\Windows";
|
|
199
193
|
return join(systemRoot, "System32", "wsl.exe");
|
|
200
194
|
}
|
|
201
|
-
export function resolveAllPaths(config = {}, env = process.env
|
|
195
|
+
export function resolveAllPaths(config = {}, env = process.env) {
|
|
202
196
|
const pwsh = config.pwshPath && config.pwshPath.trim().length > 0
|
|
203
197
|
? config.pwshPath
|
|
204
198
|
: resolveFromCandidates(candidatePwshPaths(env));
|
|
@@ -214,10 +208,7 @@ export function resolveAllPaths(config = {}, env = process.env, payloadBash) {
|
|
|
214
208
|
const niu = config.niuPath && config.niuPath.trim().length > 0
|
|
215
209
|
? config.niuPath
|
|
216
210
|
: resolveFromCandidates(candidateNiuPaths(env));
|
|
217
|
-
|
|
218
|
-
// silently substitutes for the gitbash slot, so a row labelled "Git Bash"
|
|
219
|
-
// always names a shell the machine actually has.
|
|
220
|
-
return { pwsh, gitbash, msys2, wsl, niu, ...(payloadBash !== undefined ? { payload: payloadBash } : {}) };
|
|
211
|
+
return { pwsh, gitbash, msys2, wsl, niu };
|
|
221
212
|
}
|
|
222
213
|
// ---- argv / env construction ------------------------------------------------
|
|
223
214
|
export function buildArgv(shell, command, paths, distro) {
|
|
@@ -231,10 +222,6 @@ export function buildArgv(shell, command, paths, distro) {
|
|
|
231
222
|
// /usr/bin and /mingw64/bin on PATH. With a bare -c, `tr`, `sed`, `gcc`
|
|
232
223
|
// and friends are all "command not found".
|
|
233
224
|
return [paths.msys2, "-lc", command];
|
|
234
|
-
case "payload":
|
|
235
|
-
// Same login-shell rule as msys2/gitbash: the payload is a
|
|
236
|
-
// Git-for-Windows tree and `-lc` is what gives it a usable PATH.
|
|
237
|
-
return [paths.payload, "-lc", command];
|
|
238
225
|
case "niu":
|
|
239
226
|
// Same login-shell rule: -lc sources the profile chain so winuxcmd's
|
|
240
227
|
// bin directory joins PATH. (niu has no MSYS runtime; see findings F2
|
|
@@ -458,7 +445,6 @@ export const SHELL_DESCRIPTIONS = {
|
|
|
458
445
|
gitbash: "Execute a bash command (Git for Windows bash -lc <command>) and return its stdout/stderr. POSIX syntax; paths like /d/WorkSpace; PATH includes /usr/bin and /mingw64/bin so git, npm, ssh etc. work; environment variables via $NAME.",
|
|
459
446
|
msys2: "Execute a bash command (MSYS2 bash -lc <command>) and return its stdout/stderr. POSIX syntax; paths like /c/...; PATH includes /usr/bin and /mingw64/bin so git, npm, gcc, make etc. work; environment variables via $NAME. MSYS2 provides a full GCC/mingw64 toolchain.",
|
|
460
447
|
wsl: "Execute a Linux bash command (wsl [-d <distro>] -e bash -lc <command>) and return its stdout/stderr. Linux syntax; Windows files under /mnt/d/...; environment variables via $NAME.",
|
|
461
|
-
payload: "Execute a bash command in the plugin's pinned POSIX runtime payload (a digest-verified Git-for-Windows bash -lc <command>) and return its stdout/stderr. POSIX syntax; paths like /c/...; PATH includes /usr/bin so git, npm, ssh etc. work; environment variables via $NAME. Use it only when the user has deliberately enabled the payload backend.",
|
|
462
448
|
niu: "Execute a bash command (Niubash niu -lc <command>) and return its stdout/stderr. GNU bash 5.3 semantics; WinuxCmd applets (ls, cp, rm, grep, find, cat, sed, awk, ...) are on PATH; native Windows paths such as C:\\... are kept as-is while /c/... style arguments are translated; environment variables via $NAME. Niubash is a native binary with no MSYS emulation layer, so /dev/* redirects other than /dev/null do not exist; its startup file is ~/.niubashrc."
|
|
463
449
|
};
|
|
464
450
|
/**
|
|
@@ -593,20 +579,7 @@ export async function persistConfigValue(svc, path, value) {
|
|
|
593
579
|
}
|
|
594
580
|
// ---- plugin -------------------------------------------------------------------
|
|
595
581
|
export function apply(ctx, config = {}) {
|
|
596
|
-
|
|
597
|
-
// detected WSL distro is an advisory note only (the official menu lists both
|
|
598
|
-
// side by side, so our picker must not be stricter); the digest gate is the
|
|
599
|
-
// only hard no: an unverified payload simply does not run.
|
|
600
|
-
let payloadBash;
|
|
601
|
-
const payloadSuppressed = false;
|
|
602
|
-
if (config.enablePosixPayload === true && process.platform === "win32") {
|
|
603
|
-
const outcome = resolvePayloadBash({ payloadBashPath: config.payloadPosixPath ?? "" });
|
|
604
|
-
if (outcome.engaged)
|
|
605
|
-
payloadBash = outcome.bashPath;
|
|
606
|
-
for (const note of outcome.notes)
|
|
607
|
-
ctx.logger?.warn?.(`dsh-bash-terminal-ts: ${note}`);
|
|
608
|
-
}
|
|
609
|
-
const paths = resolveAllPaths(config, process.env, payloadBash);
|
|
582
|
+
const paths = resolveAllPaths(config, process.env);
|
|
610
583
|
// 0.1.7: `defaultShell` is a `.volatile()` config field — the loader hands
|
|
611
584
|
// `apply` a live ref and the latest value is resolved on every read; there
|
|
612
585
|
// is no settings registration call anymore (removed with the 0.1.7 host).
|
|
@@ -650,8 +623,6 @@ export function apply(ctx, config = {}) {
|
|
|
650
623
|
return read(config.shellMsys2, true);
|
|
651
624
|
if (shell === "wsl")
|
|
652
625
|
return read(config.shellWsl, true);
|
|
653
|
-
if (shell === "payload")
|
|
654
|
-
return read(config.shellPayload, false);
|
|
655
626
|
if (shell === "niu")
|
|
656
627
|
return read(config.shellNiu, true);
|
|
657
628
|
return false;
|
|
@@ -681,7 +652,6 @@ export function apply(ctx, config = {}) {
|
|
|
681
652
|
config: config,
|
|
682
653
|
paths,
|
|
683
654
|
configuredShell: storedShell,
|
|
684
|
-
payloadSuppressed: () => payloadSuppressed,
|
|
685
655
|
persist: async (svc, path, value) => {
|
|
686
656
|
await persistConfigValue(svc, path, value);
|
|
687
657
|
// ≤0.1.6 hosts have no config hot-reload, so mirror a defaultShell write into
|
package/lib/locales.js
CHANGED
|
@@ -24,7 +24,6 @@ const zh = {
|
|
|
24
24
|
"dock.state.available": "可用",
|
|
25
25
|
"dock.state.notInstalled": "未探测到",
|
|
26
26
|
"dock.state.wslPreferred": "已检测到 WSL 发行版(优先用 WSL bash)",
|
|
27
|
-
"shell.payload": "POSIX payload",
|
|
28
27
|
"shell.niu": "Niubash",
|
|
29
28
|
"dock.state.noDistro": "无已安装发行版",
|
|
30
29
|
"dock.state.launcherOnly": "只找到启动器,无法内嵌",
|
|
@@ -72,7 +71,6 @@ const en = {
|
|
|
72
71
|
"dock.state.available": "Available",
|
|
73
72
|
"dock.state.notInstalled": "Not found",
|
|
74
73
|
"dock.state.wslPreferred": "WSL distro detected (WSL bash preferred)",
|
|
75
|
-
"shell.payload": "POSIX payload",
|
|
76
74
|
"shell.niu": "Niubash",
|
|
77
75
|
"dock.state.noDistro": "No distro installed",
|
|
78
76
|
"dock.state.launcherOnly": "Only a launcher was found; it cannot be embedded",
|
|
@@ -120,7 +118,6 @@ const ja = {
|
|
|
120
118
|
"dock.state.available": "利用可",
|
|
121
119
|
"dock.state.notInstalled": "見つかりません",
|
|
122
120
|
"dock.state.wslPreferred": "WSL ディストリ検出済み(WSL bash 優先)",
|
|
123
|
-
"shell.payload": "POSIX payload",
|
|
124
121
|
"shell.niu": "Niubash",
|
|
125
122
|
"dock.state.noDistro": "インストール済みディストリビューションなし",
|
|
126
123
|
"dock.state.launcherOnly": "ランチャーのみ検出、埋め込み不可",
|
|
@@ -168,7 +165,6 @@ const ko = {
|
|
|
168
165
|
"dock.state.available": "사용 가능",
|
|
169
166
|
"dock.state.notInstalled": "탐지되지 않음",
|
|
170
167
|
"dock.state.wslPreferred": "WSL 배포판 감지됨 (WSL bash 우선)",
|
|
171
|
-
"shell.payload": "POSIX payload",
|
|
172
168
|
"shell.niu": "Niubash",
|
|
173
169
|
"dock.state.noDistro": "설치된 배포판 없음",
|
|
174
170
|
"dock.state.launcherOnly": "런처만 발견되어 내장할 수 없음",
|
|
@@ -216,7 +212,6 @@ const fr = {
|
|
|
216
212
|
"dock.state.available": "Disponible",
|
|
217
213
|
"dock.state.notInstalled": "Non détecté",
|
|
218
214
|
"dock.state.wslPreferred": "Distro WSL détectée (bash WSL préféré)",
|
|
219
|
-
"shell.payload": "POSIX payload",
|
|
220
215
|
"shell.niu": "Niubash",
|
|
221
216
|
"dock.state.noDistro": "Aucune distribution installée",
|
|
222
217
|
"dock.state.launcherOnly": "Seuls des lanceurs ont été trouvés; intégration impossible",
|
|
@@ -264,7 +259,6 @@ const de = {
|
|
|
264
259
|
"dock.state.available": "Verfügbar",
|
|
265
260
|
"dock.state.notInstalled": "Nicht gefunden",
|
|
266
261
|
"dock.state.wslPreferred": "WSL-Distro erkannt (WSL bash bevorzugt)",
|
|
267
|
-
"shell.payload": "POSIX payload",
|
|
268
262
|
"shell.niu": "Niubash",
|
|
269
263
|
"dock.state.noDistro": "Keine Distribution installiert",
|
|
270
264
|
"dock.state.launcherOnly": "Nur Launcher gefunden; Einbettung nicht möglich",
|
|
@@ -312,7 +306,6 @@ const it = {
|
|
|
312
306
|
"dock.state.available": "Disponibile",
|
|
313
307
|
"dock.state.notInstalled": "Non trovato",
|
|
314
308
|
"dock.state.wslPreferred": "Distro WSL rilevata (bash WSL preferito)",
|
|
315
|
-
"shell.payload": "POSIX payload",
|
|
316
309
|
"shell.niu": "Niubash",
|
|
317
310
|
"dock.state.noDistro": "Nessuna distribuzione installata",
|
|
318
311
|
"dock.state.launcherOnly": "Trovato solo un launcher; incorporamento non possibile",
|
|
@@ -360,7 +353,6 @@ const ru = {
|
|
|
360
353
|
"dock.state.available": "Доступен",
|
|
361
354
|
"dock.state.notInstalled": "Не найден",
|
|
362
355
|
"dock.state.wslPreferred": "Обнаружен дистрибутив WSL (предпочтительнее WSL bash)",
|
|
363
|
-
"shell.payload": "POSIX payload",
|
|
364
356
|
"shell.niu": "Niubash",
|
|
365
357
|
"dock.state.noDistro": "Нет установленных дистрибутивов",
|
|
366
358
|
"dock.state.launcherOnly": "Найден только лаунчер, встраивание невозможно",
|
|
@@ -408,7 +400,6 @@ const es = {
|
|
|
408
400
|
"dock.state.available": "Disponible",
|
|
409
401
|
"dock.state.notInstalled": "No detectado",
|
|
410
402
|
"dock.state.wslPreferred": "Distro de WSL detectada (se prefiere bash de WSL)",
|
|
411
|
-
"shell.payload": "POSIX payload",
|
|
412
403
|
"shell.niu": "Niubash",
|
|
413
404
|
"dock.state.noDistro": "Sin distribución instalada",
|
|
414
405
|
"dock.state.launcherOnly": "Solo se encontró un lanzador; no se puede incrustar",
|
|
@@ -456,7 +447,6 @@ const pt = {
|
|
|
456
447
|
"dock.state.available": "Disponível",
|
|
457
448
|
"dock.state.notInstalled": "Não detectado",
|
|
458
449
|
"dock.state.wslPreferred": "Distro WSL detectada (bash do WSL preferido)",
|
|
459
|
-
"shell.payload": "POSIX payload",
|
|
460
450
|
"shell.niu": "Niubash",
|
|
461
451
|
"dock.state.noDistro": "Nenhuma distribuição instalada",
|
|
462
452
|
"dock.state.launcherOnly": "Apenas um lançador foi encontrado; não é possível incorporá-lo",
|
package/lib/payload.d.ts
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
/** npm package name of OUR POSIX runtime repack (optionalDependency-style; absent = simply no payload). */
|
|
2
|
-
export declare const PAYLOAD_PACKAGE = "@drscrewdriver/posix-runtime-win32-x64";
|
|
3
|
-
/** Trust record written next to a provisioned payload root by scripts/provision-payload.mjs. */
|
|
4
|
-
export declare const TRUST_FILE_NAME = "payload.trust.json";
|
|
5
|
-
/** Files every payload root must expose for verification, normalized to forward slashes, lowercase. */
|
|
6
|
-
export declare const REQUIRED_FILES: readonly string[];
|
|
7
|
-
/** One pinned payload build = one digest map. Keyed by the `posix-*` label. */
|
|
8
|
-
export type DigestMap = Record<string, string>;
|
|
9
|
-
/**
|
|
10
|
-
* Built-in ledger, keyed by payload build label. Populated by
|
|
11
|
-
* `provision-payload.mjs --emit-ledger` at release time (V-flow). EMPTY on a
|
|
12
|
-
* fresh checkout by design: with no ledger entry, a root is only usable if the
|
|
13
|
-
* operator's local trust file pins it - which is an explicit human act, the
|
|
14
|
-
* same posture as `dsh-ops provision-shells` but self-managed.
|
|
15
|
-
*/
|
|
16
|
-
export declare const PAYLOAD_LEDGER: Readonly<Record<string, DigestMap>>;
|
|
17
|
-
export type PayloadVerdict = {
|
|
18
|
-
readonly ok: true;
|
|
19
|
-
readonly bashPath: string;
|
|
20
|
-
readonly source: "ledger" | "trust";
|
|
21
|
-
} | {
|
|
22
|
-
readonly ok: false;
|
|
23
|
-
readonly reason: string;
|
|
24
|
-
};
|
|
25
|
-
/** The OS face this module needs; tests substitute a table-driven fake. */
|
|
26
|
-
export interface PayloadProbe {
|
|
27
|
-
exists(path: string): boolean;
|
|
28
|
-
read(path: string): Buffer | undefined;
|
|
29
|
-
/** `size|mtimeMs` fingerprint for the hash cache, or undefined when unstatable. */
|
|
30
|
-
stamp(path: string): string | undefined;
|
|
31
|
-
readdir(dir: string): string[];
|
|
32
|
-
/** Directory holding `package.json` of PAYLOAD_PACKAGE, if installed. */
|
|
33
|
-
resolvePackageRoot(): string | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* WSL distro probe: names of installed distros, or undefined when the probe
|
|
36
|
-
* cannot answer (undefined is NOT "no distro" - absence needs a positive
|
|
37
|
-
* empty list, same three-valued rule as the browser catalog's distros fact).
|
|
38
|
-
*/
|
|
39
|
-
wslDistros(): readonly string[] | undefined;
|
|
40
|
-
}
|
|
41
|
-
/** Environment directory carrying auto-discovered payload roots. */
|
|
42
|
-
export declare function payloadStoreDir(env?: NodeJS.ProcessEnv): string | undefined;
|
|
43
|
-
/** sha256 hex of one file, memoized on (size, mtimeMs); undefined when unreadable. */
|
|
44
|
-
export declare function hashFile(path: string, probe?: PayloadProbe): string | undefined;
|
|
45
|
-
/** Test/backdoor: drop the memo (a payload replaced in place must re-verify). */
|
|
46
|
-
export declare function clearHashCache(): void;
|
|
47
|
-
/**
|
|
48
|
-
* Verify one payload root: both REQUIRED_FILES exist, their digests match the
|
|
49
|
-
* built-in ledger OR the root-local trust file. Everything else fails closed.
|
|
50
|
-
*/
|
|
51
|
-
export declare function verifyPayloadRoot(root: string, probe?: PayloadProbe): PayloadVerdict;
|
|
52
|
-
/** Candidate payload roots in preference order: explicit path, npm package, store dir. */
|
|
53
|
-
export declare function findPayloadRoots(config: {
|
|
54
|
-
payloadBashPath?: string;
|
|
55
|
-
}, probe?: PayloadProbe, env?: NodeJS.ProcessEnv): string[];
|
|
56
|
-
export interface PayloadOutcome {
|
|
57
|
-
/** True only when a verified payload bash was selected. */
|
|
58
|
-
readonly engaged: boolean;
|
|
59
|
-
readonly bashPath?: string;
|
|
60
|
-
/** True when a WSL distro was positively detected - advisory, not a veto. */
|
|
61
|
-
readonly wslPreferred?: boolean;
|
|
62
|
-
/** One-shot human-readable notes for the plugin log. */
|
|
63
|
-
readonly notes: readonly string[];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* The whole decision table for one startup. Call ONLY when the payload feature
|
|
67
|
-
* is enabled; the caller wires the resulting `bashPath` into the gitbash slot
|
|
68
|
-
* of `resolveAllPaths` as the last-resort source.
|
|
69
|
-
*/
|
|
70
|
-
export declare function resolvePayloadBash(config: {
|
|
71
|
-
payloadBashPath?: string;
|
|
72
|
-
}, probe?: PayloadProbe, env?: NodeJS.ProcessEnv): PayloadOutcome;
|
|
1
|
+
/** npm package name of OUR POSIX runtime repack (optionalDependency-style; absent = simply no payload). */
|
|
2
|
+
export declare const PAYLOAD_PACKAGE = "@drscrewdriver/posix-runtime-win32-x64";
|
|
3
|
+
/** Trust record written next to a provisioned payload root by scripts/provision-payload.mjs. */
|
|
4
|
+
export declare const TRUST_FILE_NAME = "payload.trust.json";
|
|
5
|
+
/** Files every payload root must expose for verification, normalized to forward slashes, lowercase. */
|
|
6
|
+
export declare const REQUIRED_FILES: readonly string[];
|
|
7
|
+
/** One pinned payload build = one digest map. Keyed by the `posix-*` label. */
|
|
8
|
+
export type DigestMap = Record<string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* Built-in ledger, keyed by payload build label. Populated by
|
|
11
|
+
* `provision-payload.mjs --emit-ledger` at release time (V-flow). EMPTY on a
|
|
12
|
+
* fresh checkout by design: with no ledger entry, a root is only usable if the
|
|
13
|
+
* operator's local trust file pins it - which is an explicit human act, the
|
|
14
|
+
* same posture as `dsh-ops provision-shells` but self-managed.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PAYLOAD_LEDGER: Readonly<Record<string, DigestMap>>;
|
|
17
|
+
export type PayloadVerdict = {
|
|
18
|
+
readonly ok: true;
|
|
19
|
+
readonly bashPath: string;
|
|
20
|
+
readonly source: "ledger" | "trust";
|
|
21
|
+
} | {
|
|
22
|
+
readonly ok: false;
|
|
23
|
+
readonly reason: string;
|
|
24
|
+
};
|
|
25
|
+
/** The OS face this module needs; tests substitute a table-driven fake. */
|
|
26
|
+
export interface PayloadProbe {
|
|
27
|
+
exists(path: string): boolean;
|
|
28
|
+
read(path: string): Buffer | undefined;
|
|
29
|
+
/** `size|mtimeMs` fingerprint for the hash cache, or undefined when unstatable. */
|
|
30
|
+
stamp(path: string): string | undefined;
|
|
31
|
+
readdir(dir: string): string[];
|
|
32
|
+
/** Directory holding `package.json` of PAYLOAD_PACKAGE, if installed. */
|
|
33
|
+
resolvePackageRoot(): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* WSL distro probe: names of installed distros, or undefined when the probe
|
|
36
|
+
* cannot answer (undefined is NOT "no distro" - absence needs a positive
|
|
37
|
+
* empty list, same three-valued rule as the browser catalog's distros fact).
|
|
38
|
+
*/
|
|
39
|
+
wslDistros(): readonly string[] | undefined;
|
|
40
|
+
}
|
|
41
|
+
/** Environment directory carrying auto-discovered payload roots. */
|
|
42
|
+
export declare function payloadStoreDir(env?: NodeJS.ProcessEnv): string | undefined;
|
|
43
|
+
/** sha256 hex of one file, memoized on (size, mtimeMs); undefined when unreadable. */
|
|
44
|
+
export declare function hashFile(path: string, probe?: PayloadProbe): string | undefined;
|
|
45
|
+
/** Test/backdoor: drop the memo (a payload replaced in place must re-verify). */
|
|
46
|
+
export declare function clearHashCache(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Verify one payload root: both REQUIRED_FILES exist, their digests match the
|
|
49
|
+
* built-in ledger OR the root-local trust file. Everything else fails closed.
|
|
50
|
+
*/
|
|
51
|
+
export declare function verifyPayloadRoot(root: string, probe?: PayloadProbe): PayloadVerdict;
|
|
52
|
+
/** Candidate payload roots in preference order: explicit path, npm package, store dir. */
|
|
53
|
+
export declare function findPayloadRoots(config: {
|
|
54
|
+
payloadBashPath?: string;
|
|
55
|
+
}, probe?: PayloadProbe, env?: NodeJS.ProcessEnv): string[];
|
|
56
|
+
export interface PayloadOutcome {
|
|
57
|
+
/** True only when a verified payload bash was selected. */
|
|
58
|
+
readonly engaged: boolean;
|
|
59
|
+
readonly bashPath?: string;
|
|
60
|
+
/** True when a WSL distro was positively detected - advisory, not a veto. */
|
|
61
|
+
readonly wslPreferred?: boolean;
|
|
62
|
+
/** One-shot human-readable notes for the plugin log. */
|
|
63
|
+
readonly notes: readonly string[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The whole decision table for one startup. Call ONLY when the payload feature
|
|
67
|
+
* is enabled; the caller wires the resulting `bashPath` into the gitbash slot
|
|
68
|
+
* of `resolveAllPaths` as the last-resort source.
|
|
69
|
+
*/
|
|
70
|
+
export declare function resolvePayloadBash(config: {
|
|
71
|
+
payloadBashPath?: string;
|
|
72
|
+
}, probe?: PayloadProbe, env?: NodeJS.ProcessEnv): PayloadOutcome;
|