dsh-bash-terminal-ts 0.8.2 → 0.8.4
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.de.md +1 -1
- package/README.en.md +6 -2
- package/README.es.md +1 -1
- package/README.fr.md +1 -1
- package/README.it.md +1 -1
- package/README.md +5 -1
- package/README.ru.md +1 -1
- package/agent-presets/README.md +170 -0
- package/agent-presets/install-presets.mjs +179 -0
- package/agent-presets/standard-win/agent.cordis.yml +271 -0
- package/agent-presets/standard-win/preset.yml +2 -0
- package/agent-presets/standard-win-gitbash/agent.cordis.yml +271 -0
- package/agent-presets/standard-win-gitbash/preset.yml +2 -0
- package/agent-presets/standard-win-msys2/agent.cordis.yml +272 -0
- package/agent-presets/standard-win-msys2/preset.yml +2 -0
- package/agent-presets/standard-win-payload/agent.cordis.yml +271 -0
- package/agent-presets/standard-win-payload/preset.yml +2 -0
- package/agent-presets/standard-win-wsl2/agent.cordis.yml +271 -0
- package/agent-presets/standard-win-wsl2/preset.yml +2 -0
- package/cordis.patch.yml +12 -0
- package/dist/client.core.js +43 -12
- package/dist/client.js +43 -12
- package/dsh.plugin.json +2 -2
- package/lib/client.js +43 -12
- package/lib/dsh-types.d.ts +3 -1
- package/lib/index.d.ts +23 -2
- package/lib/index.js +79 -18
- package/lib/locales.js +27 -9
- package/lib/payload.d.ts +72 -0
- package/lib/payload.js +279 -0
- package/lib/shell-id.d.ts +2 -2
- package/lib/shells.d.ts +11 -2
- package/lib/shells.js +18 -4
- package/lib/terminal.js +1 -0
- package/lib/webterminals/catalog.d.ts +2 -0
- package/lib/webterminals/catalog.js +1 -0
- package/lib/webterminals/host.js +2 -2
- package/lib/webterminals/mount.d.ts +5 -0
- package/lib/webterminals/mount.js +4 -0
- package/package.json +17 -11
- package/scripts/check-artifacts.mjs +1 -1
- package/scripts/link-shells.mjs +22 -0
- package/scripts/payload-alias.mjs +97 -0
- package/scripts/provision-payload.mjs +233 -0
- package/src/client.tsx +29 -4
- package/src/dsh-types.ts +3 -1
- package/src/index.ts +117 -16
- package/src/locales.ts +27 -9
- package/src/payload.ts +322 -0
- package/src/shell-id.ts +2 -2
- package/src/shells.ts +27 -5
- package/src/terminal.ts +1 -0
- package/src/webterminals/browser/api.ts +1 -1
- package/src/webterminals/catalog.ts +3 -0
- package/src/webterminals/host.ts +2 -2
- package/src/webterminals/mount.ts +9 -0
package/src/index.ts
CHANGED
|
@@ -52,6 +52,7 @@ import type {
|
|
|
52
52
|
ToolRunContext
|
|
53
53
|
} from "./dsh-types.js";
|
|
54
54
|
import { createTerminalRegistry, terminalTool } from "./terminal.js";
|
|
55
|
+
import { resolvePayloadBash } from "./payload.js";
|
|
55
56
|
|
|
56
57
|
/** Stable Cordis plugin name. */
|
|
57
58
|
export const name = "bash-terminal";
|
|
@@ -61,7 +62,7 @@ const ENTRY_ID = "tool-bash-terminal";
|
|
|
61
62
|
export const inject = ["tools", "systemPrompt", "shellEnv", "subprocess", "settings", "sandbox", "sandboxPolicy"];
|
|
62
63
|
|
|
63
64
|
/** The terminal backends this tool exposes, in catalog order. */
|
|
64
|
-
export const SHELLS = ["powershell", "gitbash", "msys2", "wsl"] as const;
|
|
65
|
+
export const SHELLS = ["powershell", "gitbash", "msys2", "wsl", "payload"] as const;
|
|
65
66
|
/** The backend used when the caller does not name one. */
|
|
66
67
|
export const DEFAULT_SHELL: ShellId = "powershell";
|
|
67
68
|
/** Default per-command timeout (ms). */
|
|
@@ -124,8 +125,29 @@ export interface ConfigValues {
|
|
|
124
125
|
shellGitBash: boolean;
|
|
125
126
|
shellMsys2: boolean;
|
|
126
127
|
shellWsl: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Activation switch for the payload row in the bottom-terminal UI. Separate
|
|
130
|
+
* from `enablePosixPayload` (the operator gate that RUNS the digest check at
|
|
131
|
+
* startup): this one only decides whether a resolved payload may appear in
|
|
132
|
+
* pickers. Default false - the payload is opt-in twice, provisioning and
|
|
133
|
+
* activation.
|
|
134
|
+
*/
|
|
135
|
+
shellPayload: boolean;
|
|
127
136
|
/** WSL distribution for the browser terminal; '' means the WSL default. */
|
|
128
137
|
wslDistro: string;
|
|
138
|
+
/**
|
|
139
|
+
* Pinned backup POSIX runtime payload (see src/payload.ts - the artifact is
|
|
140
|
+
* a Git-for-Windows tree; OUR name avoids the bash/msys tokens by policy).
|
|
141
|
+
* Default off; enabling it lets a digest-verified payload fill the Git Bash
|
|
142
|
+
* slot as a LAST-RESORT source when the machine has no system Git Bash. A
|
|
143
|
+
* detected WSL distro outranks the payload entirely (a real WSL bash is the
|
|
144
|
+
* better POSIX shell), and an unverifiable payload fails closed - it is
|
|
145
|
+
* never run, never silently replaced. Resolved at startup, so toggling
|
|
146
|
+
* takes effect on the next restart.
|
|
147
|
+
*/
|
|
148
|
+
enablePosixPayload: boolean;
|
|
149
|
+
/** Explicit payload root or bin/bash.exe path; '' = auto-discovery only. */
|
|
150
|
+
payloadPosixPath: string;
|
|
129
151
|
}
|
|
130
152
|
|
|
131
153
|
/** Runtime configuration schema. */
|
|
@@ -145,7 +167,12 @@ export const Config = z.object({
|
|
|
145
167
|
shellGitBash: z.boolean().default(true).volatile(),
|
|
146
168
|
shellMsys2: z.boolean().default(true).volatile(),
|
|
147
169
|
shellWsl: z.boolean().default(true).volatile(),
|
|
148
|
-
|
|
170
|
+
shellPayload: z.boolean().default(false).volatile(),
|
|
171
|
+
wslDistro: z.string().default("").volatile(),
|
|
172
|
+
// Payload gate state is read once per process (paths resolve at startup), so
|
|
173
|
+
// these are deliberately NOT volatile: a flip needs the restart it implies.
|
|
174
|
+
enablePosixPayload: z.boolean().default(false),
|
|
175
|
+
payloadPosixPath: z.string().default("")
|
|
149
176
|
});
|
|
150
177
|
|
|
151
178
|
// ---- executable resolution ------------------------------------------------
|
|
@@ -244,7 +271,11 @@ export type { ResolvedPaths };
|
|
|
244
271
|
|
|
245
272
|
type PathConfig = Partial<Pick<ConfigValues, "pwshPath" | "gitBashPath" | "msys2Path" | "wslPath">>;
|
|
246
273
|
|
|
247
|
-
export function resolveAllPaths(
|
|
274
|
+
export function resolveAllPaths(
|
|
275
|
+
config: PathConfig = {},
|
|
276
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
277
|
+
payloadBash?: string
|
|
278
|
+
): ResolvedPaths {
|
|
248
279
|
const pwsh = config.pwshPath && config.pwshPath.trim().length > 0
|
|
249
280
|
? config.pwshPath
|
|
250
281
|
: resolveFromCandidates(candidatePwshPaths(env));
|
|
@@ -257,7 +288,10 @@ export function resolveAllPaths(config: PathConfig = {}, env: NodeJS.ProcessEnv
|
|
|
257
288
|
const wsl = config.wslPath && config.wslPath.trim().length > 0
|
|
258
289
|
? config.wslPath
|
|
259
290
|
: defaultWslPath(env);
|
|
260
|
-
|
|
291
|
+
// The payload is its OWN backend (first-class catalog row) - it never
|
|
292
|
+
// silently substitutes for the gitbash slot, so a row labelled "Git Bash"
|
|
293
|
+
// always names a shell the machine actually has.
|
|
294
|
+
return { pwsh, gitbash, msys2, wsl, ...(payloadBash !== undefined ? { payload: payloadBash } : {}) };
|
|
261
295
|
}
|
|
262
296
|
|
|
263
297
|
// ---- argv / env construction ------------------------------------------------
|
|
@@ -278,6 +312,10 @@ export function buildArgv(
|
|
|
278
312
|
// /usr/bin and /mingw64/bin on PATH. With a bare -c, `tr`, `sed`, `gcc`
|
|
279
313
|
// and friends are all "command not found".
|
|
280
314
|
return [paths.msys2, "-lc", command];
|
|
315
|
+
case "payload":
|
|
316
|
+
// Same login-shell rule as msys2/gitbash: the payload is a
|
|
317
|
+
// Git-for-Windows tree and `-lc` is what gives it a usable PATH.
|
|
318
|
+
return [paths.payload, "-lc", command];
|
|
281
319
|
case "wsl": {
|
|
282
320
|
const distroArg = distro !== undefined && distro.trim().length > 0 ? ["-d", distro.trim()] : [];
|
|
283
321
|
return [paths.wsl, ...distroArg, "-e", "bash", "-lc", command];
|
|
@@ -570,7 +608,8 @@ export const SHELL_DESCRIPTIONS: Record<ShellId, string> = {
|
|
|
570
608
|
powershell: "Execute a PowerShell command (pwsh -NoLogo -NoProfile -NonInteractive -Command <command>) and return its stdout/stderr. PowerShell syntax; native Windows paths (C:\\...); environment variables via $env:NAME.",
|
|
571
609
|
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.",
|
|
572
610
|
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.",
|
|
573
|
-
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."
|
|
611
|
+
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.",
|
|
612
|
+
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."
|
|
574
613
|
};
|
|
575
614
|
|
|
576
615
|
/**
|
|
@@ -586,7 +625,7 @@ export function toolDescription(backgroundEnabled: boolean, shell: string = DEFA
|
|
|
586
625
|
const base = [
|
|
587
626
|
`The user's chosen default terminal (Settings -> General -> Default terminal) is ${active}; commands run there.`,
|
|
588
627
|
lead,
|
|
589
|
-
"Each call spawns a fresh shell: no state (cwd, variables, aliases) persists between calls - pass workdir instead of using cd. Non-zero exits are reported as [exit code: N] markers; investigate failures before moving on. Long output is truncated to its tail; the full output is saved to a file whose path is reported when available. Commands run under the DSH sandbox: confined modes (read-only / workspace-write) are enforced through ctx.sandbox and deny fail-closed for PowerShell; danger-full-access, Git Bash, MSYS2, and WSL run unconfined."
|
|
628
|
+
"Each call spawns a fresh shell: no state (cwd, variables, aliases) persists between calls - pass workdir instead of using cd. Non-zero exits are reported as [exit code: N] markers; investigate failures before moving on. Long output is truncated to its tail; the full output is saved to a file whose path is reported when available. Commands run under the DSH sandbox: confined modes (read-only / workspace-write) are enforced through ctx.sandbox and deny fail-closed for PowerShell; danger-full-access, Git Bash, MSYS2, the pinned POSIX payload, and WSL run unconfined."
|
|
590
629
|
].join(" ");
|
|
591
630
|
if (!backgroundEnabled) return base;
|
|
592
631
|
return base + " Set run_in_background: true for long-running commands: the call returns a job id immediately; read its output with job_output and stop it with job_kill. No timeout applies to background runs.";
|
|
@@ -637,14 +676,18 @@ function confineSpawn(
|
|
|
637
676
|
policy: SandboxPolicy,
|
|
638
677
|
shell: string
|
|
639
678
|
): { argv: string[]; sandbox?: SandboxFacts } {
|
|
640
|
-
if (policy.mode === "danger-full-access" || shell === "wsl" || shell === "gitbash" || shell === "msys2") {
|
|
679
|
+
if (policy.mode === "danger-full-access" || shell === "wsl" || shell === "gitbash" || shell === "msys2" || shell === "payload") {
|
|
641
680
|
const sandbox = shell === "wsl"
|
|
642
681
|
? { mode: policy.mode, enforcement: "wsl-isolation" }
|
|
643
682
|
: shell === "gitbash"
|
|
644
683
|
? { mode: policy.mode, enforcement: "gitbash-unconfined" }
|
|
645
684
|
: shell === "msys2"
|
|
646
685
|
? { mode: policy.mode, enforcement: "msys2-unconfined" }
|
|
647
|
-
:
|
|
686
|
+
: shell === "payload"
|
|
687
|
+
// The payload cannot be confined either (same Cygwin/MSYS runtime
|
|
688
|
+
// constraint as Git Bash) - its safety layer is the digest gate.
|
|
689
|
+
? { mode: policy.mode, enforcement: "payload-unconfined" }
|
|
690
|
+
: undefined;
|
|
648
691
|
return { argv, sandbox };
|
|
649
692
|
}
|
|
650
693
|
const confined = ctx.sandbox.confine(argv, policy);
|
|
@@ -747,7 +790,18 @@ export async function persistConfigValue(svc: unknown, path: readonly string[],
|
|
|
747
790
|
// ---- plugin -------------------------------------------------------------------
|
|
748
791
|
|
|
749
792
|
export function apply(ctx: BashTerminalContext, config: Partial<ConfigValues> = {}): void {
|
|
750
|
-
|
|
793
|
+
// Pinned backup POSIX runtime payload: opt-in, its OWN backend slot. A
|
|
794
|
+
// detected WSL distro is an advisory note only (the official menu lists both
|
|
795
|
+
// side by side, so our picker must not be stricter); the digest gate is the
|
|
796
|
+
// only hard no: an unverified payload simply does not run.
|
|
797
|
+
let payloadBash: string | undefined;
|
|
798
|
+
const payloadSuppressed = false;
|
|
799
|
+
if (config.enablePosixPayload === true && process.platform === "win32") {
|
|
800
|
+
const outcome = resolvePayloadBash({ payloadBashPath: config.payloadPosixPath ?? "" });
|
|
801
|
+
if (outcome.engaged) payloadBash = outcome.bashPath;
|
|
802
|
+
for (const note of outcome.notes) ctx.logger?.warn?.(`dsh-bash-terminal-ts: ${note}`);
|
|
803
|
+
}
|
|
804
|
+
const paths = resolveAllPaths(config, process.env, payloadBash);
|
|
751
805
|
// 0.1.7: `defaultShell` is a `.volatile()` config field — the loader hands
|
|
752
806
|
// `apply` a live ref and the latest value is resolved on every read; there
|
|
753
807
|
// is no settings registration call anymore (removed with the 0.1.7 host).
|
|
@@ -772,6 +826,24 @@ export function apply(ctx: BashTerminalContext, config: Partial<ConfigValues> =
|
|
|
772
826
|
* command in a different shell than the model was told about.
|
|
773
827
|
*/
|
|
774
828
|
const currentShell = storedShell;
|
|
829
|
+
/**
|
|
830
|
+
* The activation switches are ONE truth: a switch off hides the backend from
|
|
831
|
+
* the dock AND makes it an invalid shell-tool target (powershell is the
|
|
832
|
+
* floor and always on). A stored defaultShell pointing at a switched-off
|
|
833
|
+
* backend is therefore stale, not executable.
|
|
834
|
+
*/
|
|
835
|
+
const switchOn = (shell: string): boolean => {
|
|
836
|
+
const read = <T>(v: T | VolatileRef<T> | undefined, fallback: T): T =>
|
|
837
|
+
typeof v === "object" && v !== null && typeof (v as VolatileRef<T>).get === "function"
|
|
838
|
+
? ((v as VolatileRef<T>).get() ?? fallback)
|
|
839
|
+
: ((v as T | undefined) ?? fallback);
|
|
840
|
+
if (shell === "powershell") return true;
|
|
841
|
+
if (shell === "gitbash") return read(config.shellGitBash as boolean | undefined, true);
|
|
842
|
+
if (shell === "msys2") return read(config.shellMsys2 as boolean | undefined, true);
|
|
843
|
+
if (shell === "wsl") return read(config.shellWsl as boolean | undefined, true);
|
|
844
|
+
if (shell === "payload") return read(config.shellPayload as boolean | undefined, false);
|
|
845
|
+
return false;
|
|
846
|
+
};
|
|
775
847
|
/**
|
|
776
848
|
* What the model is TOLD. Sanitised, because this one runs on every prompt
|
|
777
849
|
* assembly: an invalid stored value must not break the whole prompt, and naming
|
|
@@ -779,10 +851,10 @@ export function apply(ctx: BashTerminalContext, config: Partial<ConfigValues> =
|
|
|
779
851
|
*/
|
|
780
852
|
const describedShell = (): string => {
|
|
781
853
|
const stored = storedShell();
|
|
782
|
-
if ((SHELLS as readonly string[]).includes(stored)) return stored;
|
|
854
|
+
if ((SHELLS as readonly string[]).includes(stored) && switchOn(stored)) return stored;
|
|
783
855
|
if (!warnedStale) {
|
|
784
856
|
warnedStale = true;
|
|
785
|
-
ctx.logger?.warn?.(`dsh-bash-terminal-ts: defaultShell ${JSON.stringify(stored)} is not a selectable backend; shell calls will fail closed and the bottom terminal falls back to ${DEFAULT_SHELL}`);
|
|
857
|
+
ctx.logger?.warn?.(`dsh-bash-terminal-ts: defaultShell ${JSON.stringify(stored)} is not a selectable/activated backend; shell calls will fail closed and the bottom terminal falls back to ${DEFAULT_SHELL}`);
|
|
786
858
|
}
|
|
787
859
|
return DEFAULT_SHELL;
|
|
788
860
|
};
|
|
@@ -797,6 +869,7 @@ export function apply(ctx: BashTerminalContext, config: Partial<ConfigValues> =
|
|
|
797
869
|
config: config as Record<string, unknown>,
|
|
798
870
|
paths,
|
|
799
871
|
configuredShell: storedShell,
|
|
872
|
+
payloadSuppressed: () => payloadSuppressed,
|
|
800
873
|
persist: async (svc, path, value) => {
|
|
801
874
|
await persistConfigValue(svc, path, value);
|
|
802
875
|
// ≤0.1.6 hosts have no config hot-reload, so mirror a defaultShell write into
|
|
@@ -853,13 +926,29 @@ export function apply(ctx: BashTerminalContext, config: Partial<ConfigValues> =
|
|
|
853
926
|
// 注册命名空间,复用 perm-gate 自门控(not registered → register → 重试);
|
|
854
927
|
// rc.1+ 命名空间由 loader 占用,该分支自然不命中。GET 带回当前值与可选集。
|
|
855
928
|
// 宿主 context 类型未收录 inject/局部服务形状,compat 桥按宽化面调用。
|
|
856
|
-
|
|
929
|
+
// 窄面型只覆盖本桥用到的三个字段,避免 any 外泄。
|
|
930
|
+
interface BridgeReq {
|
|
931
|
+
socket?: { remoteAddress?: string };
|
|
932
|
+
method?: string;
|
|
933
|
+
on(event: "data", cb: (chunk: Buffer) => void): void;
|
|
934
|
+
on(event: "end", cb: () => void): void;
|
|
935
|
+
}
|
|
936
|
+
interface BridgeRes {
|
|
937
|
+
writeHead(status: number, headers: Record<string, string>): void;
|
|
938
|
+
end(body: string): void;
|
|
939
|
+
}
|
|
940
|
+
type BridgeSvcCtx = {
|
|
941
|
+
settings: unknown;
|
|
942
|
+
webServer: { register: (route: { kind: string; path: string; handler: (req: BridgeReq, res: BridgeRes) => void }) => () => void };
|
|
943
|
+
effect: (fn: () => (() => void) | void, label?: string) => void;
|
|
944
|
+
};
|
|
945
|
+
const compatCtx = ctx as unknown as { inject?: (deps: string[], fn: (svcCtx: BridgeSvcCtx) => void) => void };
|
|
857
946
|
if (typeof compatCtx.inject !== "function") {
|
|
858
947
|
// A context without `inject` (a bare mock, or a host that resolves services
|
|
859
948
|
// only synchronously) cannot receive the bridge at all. Skipping it must not
|
|
860
949
|
// take the tool down with it - the tool is what the model calls.
|
|
861
950
|
ctx.logger?.warn?.("dsh-bash-terminal-ts: ctx.inject unavailable - the settings bridge is not mounted (defaultShell reads still work, writes will not)");
|
|
862
|
-
} else compatCtx.inject(["webServer", "settings"], (svcCtx:
|
|
951
|
+
} else compatCtx.inject(["webServer", "settings"], (svcCtx: BridgeSvcCtx) => {
|
|
863
952
|
const svc = svcCtx.settings;
|
|
864
953
|
const writeShell = async (value: string): Promise<void> => {
|
|
865
954
|
// One implementation for every config write (the browser terminal's switches
|
|
@@ -874,7 +963,7 @@ export function apply(ctx: BashTerminalContext, config: Partial<ConfigValues> =
|
|
|
874
963
|
(res as { writeHead: (s: number, h: Record<string, string>) => void; end: (b: string) => void }).writeHead(status, { "content-type": "application/json; charset=utf-8" });
|
|
875
964
|
(res as { end: (b: string) => void }).end(JSON.stringify(body));
|
|
876
965
|
};
|
|
877
|
-
const handler = (req:
|
|
966
|
+
const handler = (req: BridgeReq, res: BridgeRes): void => {
|
|
878
967
|
const addr = req.socket?.remoteAddress ?? "";
|
|
879
968
|
if (addr !== "127.0.0.1" && addr !== "::1" && addr !== "::ffff:127.0.0.1") {
|
|
880
969
|
json(res, 403, { ok: false, code: "loopback-only" });
|
|
@@ -905,7 +994,7 @@ export function apply(ctx: BashTerminalContext, config: Partial<ConfigValues> =
|
|
|
905
994
|
if (size <= 65536) chunks.push(c);
|
|
906
995
|
});
|
|
907
996
|
req.on("end", () => {
|
|
908
|
-
let body: { defaultShell?: unknown }
|
|
997
|
+
let body: { defaultShell?: unknown };
|
|
909
998
|
try {
|
|
910
999
|
body = JSON.parse(Buffer.concat(chunks).toString("utf8") || "{}");
|
|
911
1000
|
} catch {
|
|
@@ -933,7 +1022,16 @@ export function apply(ctx: BashTerminalContext, config: Partial<ConfigValues> =
|
|
|
933
1022
|
|
|
934
1023
|
const toolName = "shell";
|
|
935
1024
|
const terminalRegistry = createTerminalRegistry(ctx);
|
|
936
|
-
|
|
1025
|
+
// The interactive terminal obeys the SAME activation gate as the shell tool:
|
|
1026
|
+
// the getter throws for a switched-off backend, so a session cannot open on
|
|
1027
|
+
// a shell the user just disabled.
|
|
1028
|
+
ctx.tools.register(terminalTool(ctx, terminalRegistry, paths, () => {
|
|
1029
|
+
const shell = currentShell();
|
|
1030
|
+
if ((SHELLS as readonly string[]).includes(shell) && !switchOn(shell)) {
|
|
1031
|
+
throw new Error(`dsh-bash-terminal-ts: ${shell} backend is not activated - enable its switch in the plugin settings first.`);
|
|
1032
|
+
}
|
|
1033
|
+
return shell;
|
|
1034
|
+
}));
|
|
937
1035
|
|
|
938
1036
|
// The model-facing description must track the user's chosen default
|
|
939
1037
|
// terminal: a static description listing every backend leaves the model
|
|
@@ -1049,6 +1147,9 @@ export function apply(ctx: BashTerminalContext, config: Partial<ConfigValues> =
|
|
|
1049
1147
|
async execute(args, exec) {
|
|
1050
1148
|
const v = validateArgs(args);
|
|
1051
1149
|
const shell = currentShell();
|
|
1150
|
+
if ((SHELLS as readonly string[]).includes(shell) && !switchOn(shell)) {
|
|
1151
|
+
throw new Error(`dsh-bash-terminal-ts: ${shell} backend is not activated - ask the user to enable its switch in the plugin settings (bottom terminal), or choose another default terminal.`);
|
|
1152
|
+
}
|
|
1052
1153
|
const argv0 = buildArgv(shell, v.command, paths, v.distro);
|
|
1053
1154
|
if (argv0[0] === undefined) {
|
|
1054
1155
|
throw new Error(`dsh-bash-terminal-ts: ${shell} backend unavailable - executable not found. Install it or set the corresponding *Path config.`);
|
package/src/locales.ts
CHANGED
|
@@ -22,9 +22,11 @@ const zh = {
|
|
|
22
22
|
"shell.unavailable": "设置面不可用:宿主配置桥未响应(检查宿主是否为 compat 版)",
|
|
23
23
|
|
|
24
24
|
"dock.title": "底部终端",
|
|
25
|
-
"dock.hint": "
|
|
25
|
+
"dock.hint": "开关同时约束底部终端与 shell 工具的可选后端(PowerShell 为保底,恒可选);不改变官方右栏终端。",
|
|
26
26
|
"dock.state.available": "可用",
|
|
27
27
|
"dock.state.notInstalled": "未探测到",
|
|
28
|
+
"dock.state.wslPreferred": "已检测到 WSL 发行版(优先用 WSL bash)",
|
|
29
|
+
"shell.payload": "POSIX payload",
|
|
28
30
|
"dock.state.noDistro": "无已安装发行版",
|
|
29
31
|
"dock.state.launcherOnly": "只找到启动器,无法内嵌",
|
|
30
32
|
"dock.powershell.locked": "PowerShell 是保底后端,无法关闭。",
|
|
@@ -68,9 +70,11 @@ const en: Record<keyof typeof zh, string> = {
|
|
|
68
70
|
"shell.wsl": "WSL",
|
|
69
71
|
"shell.unavailable": "Settings unavailable: the host config bridge did not respond (is the host a compat build?)",
|
|
70
72
|
"dock.title": "Bottom terminal",
|
|
71
|
-
"dock.hint": "These switches
|
|
73
|
+
"dock.hint": "These switches gate both the bottom dock terminal and the shell tool's selectable backends (PowerShell is the floor and always available). The official right-hand terminal is untouched.",
|
|
72
74
|
"dock.state.available": "Available",
|
|
73
75
|
"dock.state.notInstalled": "Not found",
|
|
76
|
+
"dock.state.wslPreferred": "WSL distro detected (WSL bash preferred)",
|
|
77
|
+
"shell.payload": "POSIX payload",
|
|
74
78
|
"dock.state.noDistro": "No distro installed",
|
|
75
79
|
"dock.state.launcherOnly": "Only a launcher was found; it cannot be embedded",
|
|
76
80
|
"dock.powershell.locked": "PowerShell is the fallback backend and cannot be turned off.",
|
|
@@ -114,9 +118,11 @@ const ja: Record<keyof typeof zh, string> = {
|
|
|
114
118
|
"shell.wsl": "WSL",
|
|
115
119
|
"shell.unavailable": "設定面を利用できません:ホストの設定ブリッジが応答しません(compat ビルドですか?)",
|
|
116
120
|
"dock.title": "下部ターミナル",
|
|
117
|
-
"dock.hint": "
|
|
121
|
+
"dock.hint": "このスイッチは下部ドックのターミナルと shell ツールの選択可能バックエンドの両方に影響します(PowerShell は最終代替のため常に選択可)。公式の右側ターミナルは変更されません。",
|
|
118
122
|
"dock.state.available": "利用可",
|
|
119
123
|
"dock.state.notInstalled": "見つかりません",
|
|
124
|
+
"dock.state.wslPreferred": "WSL ディストリ検出済み(WSL bash 優先)",
|
|
125
|
+
"shell.payload": "POSIX payload",
|
|
120
126
|
"dock.state.noDistro": "インストール済みディストリビューションなし",
|
|
121
127
|
"dock.state.launcherOnly": "ランチャーのみ検出、埋め込み不可",
|
|
122
128
|
"dock.powershell.locked": "PowerShell は最後の代替のため無効化できません。",
|
|
@@ -160,9 +166,11 @@ const ko: Record<keyof typeof zh, string> = {
|
|
|
160
166
|
"shell.wsl": "WSL",
|
|
161
167
|
"shell.unavailable": "설정면을 사용할 수 없습니다: 호스트 설정 브리지가 응답하지 않습니다 (compat 빌드인가요?)",
|
|
162
168
|
"dock.title": "하단 터미널",
|
|
163
|
-
"dock.hint": "이 스위치는 하단
|
|
169
|
+
"dock.hint": "이 스위치는 하단 독 터미널과 shell 도구의 선택 가능 백엔드 모두에 영향을 줍니다(PowerShell은 항상 선택 가능). 공식 오른쪽 터미널은 변경되지 않습니다.",
|
|
164
170
|
"dock.state.available": "사용 가능",
|
|
165
171
|
"dock.state.notInstalled": "탐지되지 않음",
|
|
172
|
+
"dock.state.wslPreferred": "WSL 배포판 감지됨 (WSL bash 우선)",
|
|
173
|
+
"shell.payload": "POSIX payload",
|
|
166
174
|
"dock.state.noDistro": "설치된 배포판 없음",
|
|
167
175
|
"dock.state.launcherOnly": "런처만 발견되어 내장할 수 없음",
|
|
168
176
|
"dock.powershell.locked": "PowerShell은 최종 대체 항목이므로 끌 수 없습니다.",
|
|
@@ -206,9 +214,11 @@ const fr: Record<keyof typeof zh, string> = {
|
|
|
206
214
|
"shell.wsl": "WSL",
|
|
207
215
|
"shell.unavailable": "Paramètres indisponibles: le pont de configuration de l'hôte n'a pas répondu",
|
|
208
216
|
"dock.title": "Terminal inférieur",
|
|
209
|
-
"dock.hint": "Ces interrupteurs
|
|
217
|
+
"dock.hint": "Ces interrupteurs régissent à la fois le terminal du dock bas et les backends sélectionnables de l'outil shell (PowerShell reste toujours disponible). Le terminal officiel de droite reste inchangé.",
|
|
210
218
|
"dock.state.available": "Disponible",
|
|
211
219
|
"dock.state.notInstalled": "Non détecté",
|
|
220
|
+
"dock.state.wslPreferred": "Distro WSL détectée (bash WSL préféré)",
|
|
221
|
+
"shell.payload": "POSIX payload",
|
|
212
222
|
"dock.state.noDistro": "Aucune distribution installée",
|
|
213
223
|
"dock.state.launcherOnly": "Seuls des lanceurs ont été trouvés; intégration impossible",
|
|
214
224
|
"dock.powershell.locked": "PowerShell sert de repli final et ne peut pas être désactivé.",
|
|
@@ -252,9 +262,11 @@ const de: Record<keyof typeof zh, string> = {
|
|
|
252
262
|
"shell.wsl": "WSL",
|
|
253
263
|
"shell.unavailable": "Einstellungen nicht verfügbar: Die Konfigurationsbrücke des Hosts hat nicht geantwortet",
|
|
254
264
|
"dock.title": "Unteres Terminal",
|
|
255
|
-
"dock.hint": "Diese Schalter
|
|
265
|
+
"dock.hint": "Diese Schalter steuern sowohl das Terminal im unteren Dock als auch die wählbaren Backends des shell-Werkzeugs (PowerShell bleibt immer verfügbar). Das offizielle rechte Terminal bleibt unberührt.",
|
|
256
266
|
"dock.state.available": "Verfügbar",
|
|
257
267
|
"dock.state.notInstalled": "Nicht gefunden",
|
|
268
|
+
"dock.state.wslPreferred": "WSL-Distro erkannt (WSL bash bevorzugt)",
|
|
269
|
+
"shell.payload": "POSIX payload",
|
|
258
270
|
"dock.state.noDistro": "Keine Distribution installiert",
|
|
259
271
|
"dock.state.launcherOnly": "Nur Launcher gefunden; Einbettung nicht möglich",
|
|
260
272
|
"dock.powershell.locked": "PowerShell ist die letzte Rückfallmöglichkeit und kann nicht deaktiviert werden.",
|
|
@@ -298,9 +310,11 @@ const it: Record<keyof typeof zh, string> = {
|
|
|
298
310
|
"shell.wsl": "WSL",
|
|
299
311
|
"shell.unavailable": "Impostazioni non disponibili: il bridge di configurazione dell'host non ha risposto",
|
|
300
312
|
"dock.title": "Terminale inferiore",
|
|
301
|
-
"dock.hint": "Questi interruttori
|
|
313
|
+
"dock.hint": "Questi interruttori controllano sia il terminale nella barra inferiore sia i backend selezionabili dello strumento shell (PowerShell resta sempre disponibile). Il terminale ufficiale a destra non cambia.",
|
|
302
314
|
"dock.state.available": "Disponibile",
|
|
303
315
|
"dock.state.notInstalled": "Non trovato",
|
|
316
|
+
"dock.state.wslPreferred": "Distro WSL rilevata (bash WSL preferito)",
|
|
317
|
+
"shell.payload": "POSIX payload",
|
|
304
318
|
"dock.state.noDistro": "Nessuna distribuzione installata",
|
|
305
319
|
"dock.state.launcherOnly": "Trovato solo un launcher; incorporamento non possibile",
|
|
306
320
|
"dock.powershell.locked": "PowerShell è il ripiego finale e non può essere disattivato.",
|
|
@@ -344,9 +358,11 @@ const ru: Record<keyof typeof zh, string> = {
|
|
|
344
358
|
"shell.wsl": "WSL",
|
|
345
359
|
"shell.unavailable": "Настройки недоступны: мост конфигурации хоста не ответил",
|
|
346
360
|
"dock.title": "Нижний терминал",
|
|
347
|
-
"dock.hint": "Эти переключатели влияют
|
|
361
|
+
"dock.hint": "Эти переключатели влияют и на терминал в нижней панели, и на выбираемые бэкенды инструмента shell (PowerShell доступен всегда). Официальный правый терминал не меняется.",
|
|
348
362
|
"dock.state.available": "Доступен",
|
|
349
363
|
"dock.state.notInstalled": "Не найден",
|
|
364
|
+
"dock.state.wslPreferred": "Обнаружен дистрибутив WSL (предпочтительнее WSL bash)",
|
|
365
|
+
"shell.payload": "POSIX payload",
|
|
350
366
|
"dock.state.noDistro": "Нет установленных дистрибутивов",
|
|
351
367
|
"dock.state.launcherOnly": "Найден только лаунчер, встраивание невозможно",
|
|
352
368
|
"dock.powershell.locked": "PowerShell — резервный вариант, его нельзя отключить.",
|
|
@@ -390,9 +406,11 @@ const es: Record<keyof typeof zh, string> = {
|
|
|
390
406
|
"shell.wsl": "WSL",
|
|
391
407
|
"shell.unavailable": "Configuración no disponible: el puente de configuración del host no respondió",
|
|
392
408
|
"dock.title": "Terminal inferior",
|
|
393
|
-
"dock.hint": "Estos interruptores
|
|
409
|
+
"dock.hint": "Estos interruptores afectan tanto al terminal del panel inferior como a los backends seleccionables de la herramienta shell (PowerShell siempre está disponible). El terminal oficial derecho no cambia.",
|
|
394
410
|
"dock.state.available": "Disponible",
|
|
395
411
|
"dock.state.notInstalled": "No detectado",
|
|
412
|
+
"dock.state.wslPreferred": "Distro de WSL detectada (se prefiere bash de WSL)",
|
|
413
|
+
"shell.payload": "POSIX payload",
|
|
396
414
|
"dock.state.noDistro": "Sin distribución instalada",
|
|
397
415
|
"dock.state.launcherOnly": "Solo se encontró un lanzador; no se puede incrustar",
|
|
398
416
|
"dock.powershell.locked": "PowerShell es el respaldo final y no puede desactivarse.",
|