dsh-bash-terminal-ts 0.7.2-compat.2 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.de.md +3 -2
  2. package/README.en.md +102 -3
  3. package/README.es.md +3 -2
  4. package/README.fr.md +3 -2
  5. package/README.it.md +3 -2
  6. package/README.md +198 -4
  7. package/README.ru.md +3 -2
  8. package/cordis.patch.yml +66 -0
  9. package/dist/client.core.js +7888 -79
  10. package/dist/client.js +7888 -79
  11. package/dsh.plugin.json +22 -22
  12. package/lib/browser-i18n.d.ts +4 -0
  13. package/lib/browser-i18n.js +23 -0
  14. package/lib/client.js +7888 -79
  15. package/lib/dsh-types.d.ts +10 -0
  16. package/lib/dsh.d.ts +2 -0
  17. package/lib/index.d.ts +43 -0
  18. package/lib/index.js +176 -91
  19. package/lib/locales.d.ts +4 -0
  20. package/lib/locales.js +422 -0
  21. package/lib/settings-surface.d.ts +20 -0
  22. package/lib/settings-surface.js +49 -0
  23. package/lib/shell-id.d.ts +2 -0
  24. package/lib/shell-id.js +9 -0
  25. package/lib/shells.d.ts +114 -0
  26. package/lib/shells.js +187 -0
  27. package/lib/terminal.d.ts +30 -1
  28. package/lib/terminal.js +18 -5
  29. package/lib/webterminals/catalog.d.ts +36 -0
  30. package/lib/webterminals/catalog.js +93 -0
  31. package/lib/webterminals/host.d.ts +67 -0
  32. package/lib/webterminals/host.js +278 -0
  33. package/lib/webterminals/mount.d.ts +46 -0
  34. package/lib/webterminals/mount.js +171 -0
  35. package/lib/webterminals/protocol.d.ts +94 -0
  36. package/lib/webterminals/protocol.js +9 -0
  37. package/lib/webterminals/pty.d.ts +42 -0
  38. package/lib/webterminals/pty.js +64 -0
  39. package/lib/webterminals/registry.d.ts +139 -0
  40. package/lib/webterminals/registry.js +353 -0
  41. package/lib/webterminals/ws.d.ts +54 -0
  42. package/lib/webterminals/ws.js +140 -0
  43. package/locale/de.json +4 -0
  44. package/locale/en.json +4 -0
  45. package/locale/es.json +4 -0
  46. package/locale/fr.json +4 -0
  47. package/locale/it.json +4 -0
  48. package/locale/ja.json +4 -0
  49. package/locale/ko.json +4 -0
  50. package/locale/ru.json +4 -0
  51. package/locale/zh.json +4 -0
  52. package/package.json +131 -121
  53. package/scripts/build-browser-tests.mjs +36 -0
  54. package/scripts/build-client.mjs +10 -0
  55. package/scripts/check-artifacts.mjs +93 -0
  56. package/scripts/link-shells.mjs +75 -0
  57. package/src/browser-i18n.ts +27 -0
  58. package/src/client.tsx +539 -134
  59. package/src/dsh-types.ts +6 -0
  60. package/src/dsh.ts +2 -0
  61. package/src/index.ts +146 -35
  62. package/src/locales.ts +434 -0
  63. package/src/settings-surface.ts +59 -0
  64. package/src/shell-id.ts +11 -0
  65. package/src/shells.ts +250 -0
  66. package/src/terminal.ts +34 -5
  67. package/src/webterminals/browser/api.ts +212 -0
  68. package/src/webterminals/browser/bridge.ts +188 -0
  69. package/src/webterminals/browser/css.d.ts +16 -0
  70. package/src/webterminals/browser/face.ts +151 -0
  71. package/src/webterminals/browser/shell-picker.tsx +98 -0
  72. package/src/webterminals/browser/store.ts +40 -0
  73. package/src/webterminals/browser/tab.tsx +136 -0
  74. package/src/webterminals/browser/testkit.ts +21 -0
  75. package/src/webterminals/browser/url.ts +70 -0
  76. package/src/webterminals/browser/view.ts +381 -0
  77. package/src/webterminals/browser/xterm.ts +269 -0
  78. package/src/webterminals/catalog.ts +114 -0
  79. package/src/webterminals/host.ts +361 -0
  80. package/src/webterminals/mount.ts +227 -0
  81. package/src/webterminals/protocol.ts +78 -0
  82. package/src/webterminals/pty.ts +90 -0
  83. package/src/webterminals/registry.ts +447 -0
  84. package/src/webterminals/ws.ts +166 -0
  85. package/tsconfig.client.json +9 -1
  86. package/tsconfig.json +1 -1
@@ -254,6 +254,16 @@ export interface BashTerminalContext {
254
254
  sandbox: SandboxSeam;
255
255
  get(key: string): unknown;
256
256
  effect(fn: () => void | (() => void), name?: string): unknown;
257
+ /**
258
+ * Service-arrival callback (cordis core). Both host channels mount through it:
259
+ * the six-line settings bridge and the browser terminal's routes. Typed to the
260
+ * services they actually read; the derived context carries more.
261
+ */
262
+ inject?(deps: string[], callback: (svcCtx: {
263
+ webServer?: unknown;
264
+ settings?: unknown;
265
+ effect(fn: () => void | (() => void), name?: string): unknown;
266
+ }) => void): void;
257
267
  /** Injected via `inject: ["subprocess"]`; tests may defer assignment. */
258
268
  subprocess: SubprocessSeam | null;
259
269
  }
package/lib/dsh.d.ts CHANGED
@@ -27,6 +27,8 @@ export interface Schemastery {
27
27
  object(fields: Record<string, SchemasterySchema>): SchemasterySchema;
28
28
  string(): SchemasterySchema;
29
29
  number(): SchemasterySchema;
30
+ /** Accept booleans (the fork's `Static.boolean`; renders as a switch). */
31
+ boolean(): SchemasterySchema;
30
32
  const(value: string): SchemasterySchema;
31
33
  union(schemas: SchemasterySchema[]): SchemasterySchema;
32
34
  }
package/lib/index.d.ts CHANGED
@@ -16,6 +16,33 @@ export interface ConfigValues {
16
16
  gitBashPath: string;
17
17
  msys2Path: string;
18
18
  wslPath: string;
19
+ /**
20
+ * The bottom terminal's MASTER switch. Off outranks every child choice: the
21
+ * settings row hides the per-shell switches (a switch for something that cannot
22
+ * run is a lie) and the routes refuse allocations.
23
+ */
24
+ bottomTerminal: boolean;
25
+ /**
26
+ * Opt in to publishing the client-side `webTerminals` service, which is what powers
27
+ * dsh-better-sidebar's OFFICIAL bottom "Terminal" row on a deployment that has no
28
+ * terminal controller. Default false: the name is also provided by the host's own
29
+ * controller client, cordis refuses the second provider, and the controller's provide
30
+ * is unguarded - so claiming it by default breaks the first-party terminal and the
31
+ * whole web boot on DSH 0.2.0+ (measured). Turn it on only where the official row is
32
+ * dead because no controller exists.
33
+ */
34
+ shimOfficialTerminal: boolean;
35
+ /**
36
+ * Browser-terminal activation (R1/R2). The default is `true` for all three:
37
+ * a switch means "allowed", and availability is ANDed with it by the catalog -
38
+ * so "detected means on" needs no probe at schema level, while an explicit
39
+ * `false` is a real opt-out even on a machine that has the shell.
40
+ */
41
+ shellGitBash: boolean;
42
+ shellMsys2: boolean;
43
+ shellWsl: boolean;
44
+ /** WSL distribution for the browser terminal; '' means the WSL default. */
45
+ wslDistro: string;
19
46
  }
20
47
  /** Runtime configuration schema. */
21
48
  export declare const Config: import("./dsh.js").SchemasterySchema;
@@ -178,6 +205,22 @@ export interface BackgroundResult {
178
205
  jobId: string;
179
206
  }
180
207
  export type ShellToolResult = ForegroundResult | BackgroundResult;
208
+ /**
209
+ * Persist one config path through the host settings service.
210
+ *
211
+ * Shared by the model tool's `defaultShell` write and the browser terminal's
212
+ * activation switches, because the line-dependent part is the whole difficulty:
213
+ * ≤0.1.6 loaders do not register a plugin's settings namespace automatically, so
214
+ * the first `mutate` fails with "not registered" and the caller has to register it
215
+ * (with the written value as the base, so the retry sees it) and retry. On rc.1+
216
+ * the namespace is already owned by the loader, that branch never fires, and the
217
+ * plain `mutate` is the whole story.
218
+ * @param svc - the host `settings` service (untyped: shapes differ per line).
219
+ * @param path - the config path inside this plugin's entry (one level today).
220
+ * @throws when the line has no `mutate` at all - the caller reports it, and the
221
+ * value then applies for this process only.
222
+ */
223
+ export declare function persistConfigValue(svc: unknown, path: readonly string[], value: unknown): Promise<void>;
181
224
  export declare function apply(ctx: BashTerminalContext, config?: Partial<ConfigValues>): void;
182
225
  export declare const internals: {
183
226
  candidateExists: typeof candidateExists;
package/lib/index.js CHANGED
@@ -23,6 +23,7 @@
23
23
  // "CreateFileMapping ... Win32 error 5" during startup.
24
24
  import { lstatSync } from "node:fs";
25
25
  import { isAbsolute, join, resolve } from "node:path";
26
+ import { mountBrowserTerminals } from "./webterminals/mount.js";
26
27
  import { ESCALATION_TARGETS, TOOL_ABORTED, approveEscalation, defineTool, escalationHintMarker, clampTimeout, deadline, parseExitStatus, timeoutOf, sandboxDenialMarker, validateEscalationArgs, z, HarnessError } from "./dsh.js";
27
28
  import { createTerminalRegistry, terminalTool } from "./terminal.js";
28
29
  /** Stable Cordis plugin name. */
@@ -62,7 +63,16 @@ export const Config = z.object({
62
63
  pwshPath: z.string().default(""),
63
64
  gitBashPath: z.string().default(""),
64
65
  msys2Path: z.string().default(""),
65
- wslPath: z.string().default("")
66
+ wslPath: z.string().default(""),
67
+ // `.volatile()` on the new fields: the browser terminal reads them on every
68
+ // allocation, and a flip in the settings page has to take effect without a
69
+ // restart (0.1.7+ hands apply a live ref; older lines re-read the same value).
70
+ bottomTerminal: z.boolean().default(true).volatile(),
71
+ shimOfficialTerminal: z.boolean().default(false).volatile(),
72
+ shellGitBash: z.boolean().default(true).volatile(),
73
+ shellMsys2: z.boolean().default(true).volatile(),
74
+ shellWsl: z.boolean().default(true).volatile(),
75
+ wslDistro: z.string().default("").volatile()
66
76
  });
67
77
  // ---- executable resolution ------------------------------------------------
68
78
  function candidateExists(candidate) {
@@ -492,13 +502,43 @@ const BACKGROUND_OUTPUT_PROPERTIES = {
492
502
  kind: { type: "string", required: true, const: "background" },
493
503
  jobId: { type: "string", required: true }
494
504
  };
505
+ /**
506
+ * Persist one config path through the host settings service.
507
+ *
508
+ * Shared by the model tool's `defaultShell` write and the browser terminal's
509
+ * activation switches, because the line-dependent part is the whole difficulty:
510
+ * ≤0.1.6 loaders do not register a plugin's settings namespace automatically, so
511
+ * the first `mutate` fails with "not registered" and the caller has to register it
512
+ * (with the written value as the base, so the retry sees it) and retry. On rc.1+
513
+ * the namespace is already owned by the loader, that branch never fires, and the
514
+ * plain `mutate` is the whole story.
515
+ * @param svc - the host `settings` service (untyped: shapes differ per line).
516
+ * @param path - the config path inside this plugin's entry (one level today).
517
+ * @throws when the line has no `mutate` at all - the caller reports it, and the
518
+ * value then applies for this process only.
519
+ */
520
+ export async function persistConfigValue(svc, path, value) {
521
+ const service = svc;
522
+ if (typeof service?.mutate !== "function") {
523
+ throw new Error("settings service exposes no mutate on this host line - the value applies for this process only; persist via cordis.patch.yml");
524
+ }
525
+ const ops = [{ op: "set", path: [...path], value }];
526
+ try {
527
+ await service.mutate(ENTRY_ID, ops);
528
+ }
529
+ catch (e) {
530
+ const message = e instanceof Error ? e.message : String(e);
531
+ if (!/not registered/i.test(message) || typeof service.register !== "function") {
532
+ throw e;
533
+ }
534
+ console.warn(`[dsh-bash-terminal-ts] legacy line: registering settings namespace ${ENTRY_ID}`);
535
+ service.register(ENTRY_ID, Config, { base: { [path.join(".")]: value } });
536
+ await service.mutate(ENTRY_ID, ops);
537
+ console.warn("[dsh-bash-terminal-ts] legacy settings namespace registered");
538
+ }
539
+ }
495
540
  // ---- plugin -------------------------------------------------------------------
496
541
  export function apply(ctx, config = {}) {
497
- if (process.platform !== "win32") {
498
- ctx.logger?.info?.("dsh-bash-terminal-ts: only meaningful on win32; skipping tool registration");
499
- return;
500
- }
501
- const backgroundEnabled = true;
502
542
  const paths = resolveAllPaths(config);
503
543
  // 0.1.7: `defaultShell` is a `.volatile()` config field — the loader hands
504
544
  // `apply` a live ref and the latest value is resolved on every read; there
@@ -506,7 +546,8 @@ export function apply(ctx, config = {}) {
506
546
  // compat-legacy: ≤0.1.6 的宿主没有配置热重载,bridge 写入走这个覆盖值
507
547
  // (rc.1+ 上 volatile 与覆盖值同源同写,二者一致)。
508
548
  let shellOverride;
509
- const currentShell = () => {
549
+ /** The stored value, verbatim - including one that is no longer selectable. */
550
+ const storedShell = () => {
510
551
  if (typeof shellOverride === "string" && SHELLS.includes(shellOverride)) {
511
552
  return shellOverride;
512
553
  }
@@ -516,9 +557,60 @@ export function apply(ctx, config = {}) {
516
557
  const got = typeof v?.get === "function" ? v.get() : undefined;
517
558
  return typeof got === "string" ? got : DEFAULT_SHELL;
518
559
  };
519
- if (!SHELLS.includes(currentShell())) {
520
- throw new Error(`dsh-bash-terminal-ts: invalid defaultShell ${JSON.stringify(currentShell())}`);
560
+ let warnedStale = false;
561
+ /**
562
+ * The shell the TOOL will run. Deliberately the stored value, un-sanitised:
563
+ * `buildArgv`/`terminalArgv` throw for anything outside SHELLS, so an
564
+ * out-of-enum choice fails closed at call time rather than quietly running the
565
+ * command in a different shell than the model was told about.
566
+ */
567
+ const currentShell = storedShell;
568
+ /**
569
+ * What the model is TOLD. Sanitised, because this one runs on every prompt
570
+ * assembly: an invalid stored value must not break the whole prompt, and naming
571
+ * the floor is honest about what a successful call would use.
572
+ */
573
+ const describedShell = () => {
574
+ const stored = storedShell();
575
+ if (SHELLS.includes(stored))
576
+ return stored;
577
+ if (!warnedStale) {
578
+ warnedStale = true;
579
+ 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}`);
580
+ }
581
+ return DEFAULT_SHELL;
582
+ };
583
+ // The browser terminal (bottom dock / embedded shell). Mounted BEFORE the
584
+ // win32 return below: the model tool is Windows-only, the terminal is not
585
+ // (finding F1). Its routes report their own availability, so a host without
586
+ // `registerUpgrade` or without any PTY backend shows a reason instead of a
587
+ // dead panel.
588
+ const browserTerminals = mountBrowserTerminals({
589
+ ctx: ctx,
590
+ config: config,
591
+ paths,
592
+ configuredShell: storedShell,
593
+ persist: async (svc, path, value) => {
594
+ await persistConfigValue(svc, path, value);
595
+ // ≤0.1.6 hosts have no config hot-reload, so mirror a defaultShell write into
596
+ // the same in-process override the legacy bridge uses. Without it, choosing a
597
+ // shell in the bottom-terminal section would only reach the model tool after
598
+ // a restart - the exact divergence the bridge's `shellOverride` exists to kill.
599
+ if (path.length === 1 && path[0] === "defaultShell" && typeof value === "string") {
600
+ shellOverride = value;
601
+ }
602
+ },
603
+ });
604
+ ctx.effect(() => () => browserTerminals.dispose(), "bash-terminal: browser terminal teardown");
605
+ if (process.platform !== "win32") {
606
+ ctx.logger?.info?.("dsh-bash-terminal-ts: only meaningful on win32; skipping tool registration");
607
+ return;
521
608
  }
609
+ const backgroundEnabled = true;
610
+ // R5/R6 and finding F8: an invalid stored value used to throw here, which failed
611
+ // the whole entry - the tool, the settings row and the browser terminal all
612
+ // disappeared. The entry now stays mounted, the tool fails closed per call, and
613
+ // the browser terminal substitutes the floor and says so.
522
614
  /** Official sandbox-escalation surface (mirrors tool-bash): advertise the
523
615
  * escalation modes whenever the deployment confines. */
524
616
  const escalationModes = ESCALATION_TARGETS;
@@ -547,93 +639,86 @@ export function apply(ctx, config = {}) {
547
639
  // rc.1+ 命名空间由 loader 占用,该分支自然不命中。GET 带回当前值与可选集。
548
640
  // 宿主 context 类型未收录 inject/局部服务形状,compat 桥按宽化面调用。
549
641
  const compatCtx = ctx;
550
- compatCtx.inject(["webServer", "settings"], (svcCtx) => {
551
- const svc = svcCtx.settings;
552
- const writeShell = async (value) => {
553
- if (typeof svc.mutate !== "function") {
554
- // 显式降级:该线 settings 服务无 mutate(理论仅最老线),覆盖值仅本进程
555
- // 生效;持久化请改 cordis.patch.yml 的 defaultShell。
556
- throw new Error("settings service exposes no mutate on this host line - defaultShell applies for this process only; persist via cordis.patch.yml");
557
- }
558
- shellOverride = value;
559
- try {
560
- await svc.mutate(ENTRY_ID, [{ op: "set", path: ["defaultShell"], value }]);
561
- }
562
- catch (e) {
563
- const message = e instanceof Error ? e.message : String(e);
564
- if (!/not registered/i.test(message) || typeof svc.register !== "function") {
565
- throw e;
566
- }
567
- console.warn(`[dsh-bash-terminal-ts] legacy line: registering settings namespace ${ENTRY_ID}`);
568
- svc.register(ENTRY_ID, Config, { base: { defaultShell: value } });
569
- await svc.mutate(ENTRY_ID, [{ op: "set", path: ["defaultShell"], value }]);
570
- console.warn("[dsh-bash-terminal-ts] legacy settings namespace registered");
571
- }
572
- };
573
- svcCtx.effect(() => {
574
- const json = (res, status, body) => {
575
- res.writeHead(status, { "content-type": "application/json; charset=utf-8" });
576
- res.end(JSON.stringify(body));
642
+ if (typeof compatCtx.inject !== "function") {
643
+ // A context without `inject` (a bare mock, or a host that resolves services
644
+ // only synchronously) cannot receive the bridge at all. Skipping it must not
645
+ // take the tool down with it - the tool is what the model calls.
646
+ ctx.logger?.warn?.("dsh-bash-terminal-ts: ctx.inject unavailable - the settings bridge is not mounted (defaultShell reads still work, writes will not)");
647
+ }
648
+ else
649
+ compatCtx.inject(["webServer", "settings"], (svcCtx) => {
650
+ const svc = svcCtx.settings;
651
+ const writeShell = async (value) => {
652
+ // One implementation for every config write (the browser terminal's switches
653
+ // go through the same helper), so the legacy self-registration dance exists
654
+ // in exactly one place.
655
+ await persistConfigValue(svc, ["defaultShell"], value);
656
+ shellOverride = value;
577
657
  };
578
- const handler = (req, res) => {
579
- const addr = req.socket?.remoteAddress ?? "";
580
- if (addr !== "127.0.0.1" && addr !== "::1" && addr !== "::ffff:127.0.0.1") {
581
- json(res, 403, { ok: false, code: "loopback-only" });
582
- return;
583
- }
584
- if (req.method === "GET") {
585
- // 缝内省:compat 验证用——当前线 ctx.subprocess 的真实能力面
586
- const seam = ctx;
587
- const sp = seam.subprocess;
588
- json(res, 200, {
589
- ok: true,
590
- value: {
591
- defaultShell: currentShell(),
592
- shells: SHELLS,
593
- seam: { spawn: typeof sp?.spawn, spawnTerminal: typeof sp?.spawnTerminal },
594
- },
595
- });
596
- return;
597
- }
598
- if (req.method !== "POST") {
599
- json(res, 405, { ok: false, code: "method-not-allowed" });
600
- return;
601
- }
602
- const chunks = [];
603
- let size = 0;
604
- req.on("data", (c) => {
605
- size += c.length;
606
- if (size <= 65536)
607
- chunks.push(c);
608
- });
609
- req.on("end", () => {
610
- let body = {};
611
- try {
612
- body = JSON.parse(Buffer.concat(chunks).toString("utf8") || "{}");
658
+ svcCtx.effect(() => {
659
+ const json = (res, status, body) => {
660
+ res.writeHead(status, { "content-type": "application/json; charset=utf-8" });
661
+ res.end(JSON.stringify(body));
662
+ };
663
+ const handler = (req, res) => {
664
+ const addr = req.socket?.remoteAddress ?? "";
665
+ if (addr !== "127.0.0.1" && addr !== "::1" && addr !== "::ffff:127.0.0.1") {
666
+ json(res, 403, { ok: false, code: "loopback-only" });
667
+ return;
613
668
  }
614
- catch {
615
- json(res, 400, { ok: false, code: "bad-json" });
669
+ if (req.method === "GET") {
670
+ // 缝内省:compat 验证用——当前线 ctx.subprocess 的真实能力面
671
+ const seam = ctx;
672
+ const sp = seam.subprocess;
673
+ json(res, 200, {
674
+ ok: true,
675
+ value: {
676
+ defaultShell: currentShell(),
677
+ shells: SHELLS,
678
+ seam: { spawn: typeof sp?.spawn, spawnTerminal: typeof sp?.spawnTerminal },
679
+ },
680
+ });
616
681
  return;
617
682
  }
618
- const value = typeof body.defaultShell === "string" ? body.defaultShell : "";
619
- if (!SHELLS.includes(value)) {
620
- json(res, 400, { ok: false, code: "invalid-shell" });
683
+ if (req.method !== "POST") {
684
+ json(res, 405, { ok: false, code: "method-not-allowed" });
621
685
  return;
622
686
  }
623
- void writeShell(value)
624
- .then(() => json(res, 200, { ok: true, value: { defaultShell: value } }))
625
- .catch((e) => json(res, 500, { ok: false, code: "write-failed", message: e instanceof Error ? e.message : String(e) }));
626
- });
627
- };
628
- const registered = [
629
- svcCtx.webServer.register({ kind: "exact", path: "/api/bash-terminal/config", handler }),
630
- ];
631
- return () => {
632
- for (const dispose of registered)
633
- dispose();
634
- };
635
- }, "bash-terminal: compat config bridge");
636
- });
687
+ const chunks = [];
688
+ let size = 0;
689
+ req.on("data", (c) => {
690
+ size += c.length;
691
+ if (size <= 65536)
692
+ chunks.push(c);
693
+ });
694
+ req.on("end", () => {
695
+ let body = {};
696
+ try {
697
+ body = JSON.parse(Buffer.concat(chunks).toString("utf8") || "{}");
698
+ }
699
+ catch {
700
+ json(res, 400, { ok: false, code: "bad-json" });
701
+ return;
702
+ }
703
+ const value = typeof body.defaultShell === "string" ? body.defaultShell : "";
704
+ if (!SHELLS.includes(value)) {
705
+ json(res, 400, { ok: false, code: "invalid-shell" });
706
+ return;
707
+ }
708
+ void writeShell(value)
709
+ .then(() => json(res, 200, { ok: true, value: { defaultShell: value } }))
710
+ .catch((e) => json(res, 500, { ok: false, code: "write-failed", message: e instanceof Error ? e.message : String(e) }));
711
+ });
712
+ };
713
+ const registered = [
714
+ svcCtx.webServer.register({ kind: "exact", path: "/api/bash-terminal/config", handler }),
715
+ ];
716
+ return () => {
717
+ for (const dispose of registered)
718
+ dispose();
719
+ };
720
+ }, "bash-terminal: compat config bridge");
721
+ });
637
722
  const toolName = "shell";
638
723
  const terminalRegistry = createTerminalRegistry(ctx);
639
724
  ctx.tools.register(terminalTool(ctx, terminalRegistry, paths, () => currentShell()));
@@ -644,7 +729,7 @@ export function apply(ctx, config = {}) {
644
729
  // without a restart.
645
730
  ctx.on("system-prompt/assemble", async (_assembly, _context, next) => {
646
731
  const assembled = await next();
647
- const description = toolDescription(backgroundEnabled, currentShell());
732
+ const description = toolDescription(backgroundEnabled, describedShell());
648
733
  const tools = Array.isArray(assembled.tools)
649
734
  ? assembled.tools.map((tool) => (tool.name === toolName ? { ...tool, description } : tool))
650
735
  : assembled.tools;
@@ -0,0 +1,4 @@
1
+ /** The registered dictionary, one row per host language. */
2
+ export declare const dictionaries: Record<string, Record<string, string>>;
3
+ /** The Chinese fallback used when the host exposes no `locale.bind` (0.1.0/0.1.1). */
4
+ export declare const fallbackDict: Record<string, string>;