dsh-bash-terminal-ts 0.7.0 → 0.7.2-compat.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/README.de.md +205 -0
- package/README.en.md +19 -1
- package/README.es.md +205 -0
- package/README.fr.md +205 -0
- package/README.it.md +205 -0
- package/README.md +19 -1
- package/README.ru.md +205 -0
- package/dist/client.core.js +228 -151
- package/dist/client.js +237 -160
- package/dsh.plugin.json +2 -2
- package/lib/client.js +237 -160
- package/lib/dsh-types.d.ts +259 -259
- package/lib/dsh-types.js +9 -9
- package/lib/dsh.d.ts +35 -35
- package/lib/dsh.js +29 -29
- package/lib/index.d.ts +200 -200
- package/lib/index.js +866 -765
- package/lib/terminal.d.ts +110 -110
- package/lib/terminal.js +456 -438
- package/package.json +14 -18
- package/src/client.tsx +187 -133
- package/src/index.ts +105 -0
- package/src/terminal.ts +15 -0
package/README.de.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# dsh-bash-terminal-ts
|
|
2
|
+
|
|
3
|
+
> 🌐 [简体中文](README.md) | [English](README.en.md) | [Français](README.fr.md) | [Deutsch](README.de.md) | [Italiano](README.it.md) | [Русский](README.ru.md) | [Español](README.es.md) · Community: [LINUX DO](https://linux.do) · [GitHub](https://github.com/drscrewdriver/dsh-bash-terminal-ts)
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
DSH-Plugin (DeepSeek Harness): ein `shell`-Werkzeug, das unter Windows die Befehle **vierer** Terminals – **PowerShell / Git Bash / MSYS2 / WSL** – einheitlich ausführt.
|
|
8
|
+
|
|
9
|
+
> **Dieses Repository ist die TypeScript-Neuschreibung von `MAXeaglet/dsh-bash-terminal`** mit funktionsfähiger MSYS2/MINGW64-Unterstützung. Die Kompatibilitätslinien werden pro DSH-Host-Segment geschnitten; alle Linien teilen sich den Paketnamen `dsh-bash-terminal-ts` und werden über npm-dist-tags unterschieden:
|
|
10
|
+
>
|
|
11
|
+
> | DSH-Segment | Branch | Plugin-Version | npm-dist-tag |
|
|
12
|
+
> |--------|------|----------|--------------|
|
|
13
|
+
> | `>=0.2.0-rc.1 <0.2.1-0` | `compat/0.2.0` (dieser Branch) | 0.7.x | `dsh-0.2.0` |
|
|
14
|
+
> | 0.1.7-rc.1 – 0.1.7.x | `compat/0.1.7` | 0.6.x | `dsh-0.1.7` |
|
|
15
|
+
> | 0.1.5-alpha.1 – 0.1.5-rc.x | `ts/0.1.5` (historisch, eingefroren) | ≤ 0.5.2 | `dsh-0.1.5` |
|
|
16
|
+
> | 0.1.2-alpha.1 – 0.1.2-rc.x | `main` (historisch, eingefroren) | ≤ 0.4.2 | `dsh-0.1.2` |
|
|
17
|
+
>
|
|
18
|
+
> Wählen Sie die Linie passend zu Ihrer DSH-Version; die Versionsserien überlappen nicht, daher kann eine `^`-Installation nie über Linien hinweg auflösen.
|
|
19
|
+
|
|
20
|
+
| Backend | Tatsächliche Ausführung | Syntax / Pfade | Umgebungsvariablen |
|
|
21
|
+
|------|----------|-------------|----------|
|
|
22
|
+
| `powershell` (Standard) | `pwsh -NoLogo -NoProfile -NonInteractive -Command <cmd>` | PowerShell; `C:\...` | `$env:NAME` |
|
|
23
|
+
| `gitbash` | `bash -lc <cmd>` aus Git for Windows | POSIX; `/d/workspace`; PATH enthält `/usr/bin` und `/mingw64/bin` | `$NAME` |
|
|
24
|
+
| `msys2` | MSYS2 `bash -lc <cmd>` (`C:\msys64\usr\bin\bash.exe`) | POSIX; `/c/...`; PATH enthält `/usr/bin` und `/mingw64/bin` (gcc / make) | `$NAME` (`MSYSTEM=MINGW64` wird automatisch injiziert) |
|
|
25
|
+
| `wsl` | `wsl [-d <distro>] -e bash -lc <cmd>` | Linux; `/mnt/d/...` | `$NAME` (über WSLENV) |
|
|
26
|
+
|
|
27
|
+
Jeder Aufruf startet eine komplett neue Shell: **Es wird kein Zustand bewahrt** (cwd / Variablen / Aliasse) – übergeben Sie `workdir`, statt `cd` zu verwenden.
|
|
28
|
+
|
|
29
|
+
## Vorschau der Oberfläche
|
|
30
|
+
|
|
31
|
+
Die Zeile „Standardterminal" in Einstellungen → Allgemein: Der Nutzer wählt zwischen PowerShell / Git Bash / MSYS2 / WSL, und das `shell`-Werkzeug führt ausschließlich gemäß dieser Einstellung aus – das Modell kann sie nicht überschreiben:
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
## Entwurfsprinzipien
|
|
36
|
+
|
|
37
|
+
- **Das Terminal bestimmt der Nutzer, die KI kann es nicht ändern**: Die Einstellungsseite der Web-UI (Einstellungen → Allgemein) bietet ein Dropdown „Standardterminal" (PowerShell / Git Bash / MSYS2 / WSL); das `shell`-Werkzeug folgt stets ausschließlich dieser Einstellung und legt dem Modell keine Terminal-Parameter offen. Die Einstellung wird über das DSH-Settings-System persistiert (settings.yaml).
|
|
38
|
+
- **Belegt die Fähigkeitsschnittstelle `ctx.shell` nicht**: Das sandboxierte `pwsh`-Werkzeug von DSH bleibt unverändert nutzbar; das `shell`-Werkzeug dieses Plugins ist ein **zusätzlicher** Multi-Terminal-Einstiegspunkt.
|
|
39
|
+
- Prozesse werden über die gemeinsame `ctx.subprocess`-Naht erzeugt: Beendigung des Prozessbaums (unter Windows `taskkill /T`), SIGTERM → Gnistenfrist → SIGKILL, Ausgabe-Spill-Dateien – Verhalten identisch zu den offiziellen Werkzeugen `dsh-tool-bash` / `dsh-tool-pwsh`.
|
|
40
|
+
- Hintergrundaufgaben werden im generischen `jobs`-Registry registriert, mit Unterstützung für `run_in_background` / `job_output` / `job_kill`.
|
|
41
|
+
- Die Zeile „Standardterminal" der Frontend-Einstellungsseite ist eine Enumeration (von der UI automatisch als Dropdown gerendert); das Modell führt bei jedem Aufruf gemäß dieser Einstellung aus und kann das Terminal nicht eigenmächtig wechseln.
|
|
42
|
+
|
|
43
|
+
## Installation (Web-Profil)
|
|
44
|
+
|
|
45
|
+
### Standardinstallation (nach der npm-Veröffentlichung, offizieller Bundle-Mechanismus)
|
|
46
|
+
|
|
47
|
+
Das Plugin bringt das offizielle `dsh.bundle`-Manifest mit (eigene `cordis.patch.yml` im Paket); sobald ein Profil dieses Paket aufführt, **wendet DSH den Mount automatisch an** – eine manuelle Anpassung der Profil-Konfiguration ist nicht nötig:
|
|
48
|
+
|
|
49
|
+
```powershell
|
|
50
|
+
# 1. Plugin-Paket installieren
|
|
51
|
+
npm install -g dsh-bash-terminal-ts
|
|
52
|
+
dsh plugin --profile web add dsh-bash-terminal-ts # automatisch in die Profile-Bundles aufnehmen und Patch anwenden
|
|
53
|
+
|
|
54
|
+
# 2. Settings-Allowlist von DSH patchen (DSH-Einschränkung, siehe Erläuterung unten)
|
|
55
|
+
powershell -ExecutionPolicy Bypass -File install.ps1 install
|
|
56
|
+
|
|
57
|
+
# 3. dsh web neu starten
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> Mit einem temporären Profil praktisch erprobt: `bundles: [dsh-bash-terminal-ts]` → der Eintrag `tool-bash-terminal` erscheint automatisch im dump-config.
|
|
61
|
+
|
|
62
|
+
### Installation für die lokale Entwicklung (Junction, Quellcode-Änderungen wirken sofort)
|
|
63
|
+
|
|
64
|
+
```powershell
|
|
65
|
+
# 1. Plugin-Paket in die node_modules des Profils linken (Junction, Quellcode-Änderungen wirken sofort)
|
|
66
|
+
$profile = "$env:USERPROFILE\.dsh\profiles\web"
|
|
67
|
+
New-Item -ItemType Junction -Path "$profile\node_modules\dsh-bash-terminal-ts" -Target "D:\workspace\projects\dsh-bash-terminal-ts" | Out-Null
|
|
68
|
+
|
|
69
|
+
# 2. Dem Plugin die Auflösung der @deepseek-ai/*-Abhängigkeiten ermöglichen (Junction in den Abhängigkeitsbaum des Profils; Plugin und Host teilen sich dieselben Modulinstanzen)
|
|
70
|
+
New-Item -ItemType Junction -Path "D:\workspace\projects\dsh-bash-terminal-ts\node_modules\@deepseek-ai" -Target "$profile\..\node_modules\@deepseek-ai" | Out-Null
|
|
71
|
+
|
|
72
|
+
# 3. Das Profil das Plugin über das offizielle Bundle mounten lassen (install.ps1 install erledigt das automatisch; entspricht dem Eintrag "dsh-bash-terminal-ts" in dsh.profile.bundles)
|
|
73
|
+
# 4. (nur nach Änderungen am Frontend-Quellcode) Client-Bundle neu bauen:
|
|
74
|
+
# cd D:\workspace\projects\dsh-bash-terminal-ts && node scripts/build-client.mjs
|
|
75
|
+
# 5. dsh web neu starten
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
> ⚠️ **Führen Sie in diesem Projekt kein `npm install` aus**: Es würde die Junction aus Schritt 2 oben löschen und stattdessen eine **eigenständige** Kopie von
|
|
79
|
+
> `@deepseek-ai/*` für das Plugin installieren – Plugin und Host teilten sich dann keine Modulinstanzen mehr, und nach einem Host-Upgrade bliebe das Plugin auf der alten API hängen
|
|
80
|
+
> (dieses Projekt hing dadurch einmal auf 0.1.0-rc.6 fest). Nur zum Aktualisieren des Locks `npm install --package-lock-only` verwenden.
|
|
81
|
+
|
|
82
|
+
> **Kompatibilität**: Erfordert DSH ≥ **0.1.7-rc.1** (Linie `compat/0.1.7`) oder ≥ **0.2.0-rc.1** (Linie `compat/0.2.0`, dieser Branch).
|
|
83
|
+
> Historischer Hintergrund: In 0.1.5 wurde `@deepseek-ai/dsh-client-runtime` in der Client-Modultabelle in `@deepseek-ai/dsh-client-store` umbenannt und wird nur über exakte Treffer des nackten Namens aufgelöst; alte Bundles schlagen auf dem neuen Host fehl mit
|
|
84
|
+
> `Failed to load plugins` / `require(...) missed the module table`.
|
|
85
|
+
>
|
|
86
|
+
> Hinweis: Seit 0.1.5 nutzt die Web-Settings-Oberfläche die dynamische Enumeration `settings.describe()` und hat **keine Namespace-Allowlist mehr**
|
|
87
|
+
> (`settings-not-exposed` existiert nicht mehr); der Allowlist-Patch in `install.ps1` ist nur noch ein historisches Überbleibsel und kann ignoriert werden.
|
|
88
|
+
|
|
89
|
+
> Eine manuelle Anpassung der `cordis.patch.yml` des Profils ist nicht mehr erforderlich: Das Plugin-Paket bringt sein eigenes `dsh.bundle.patch` mit (`cordis.patch.yml` im Paket); sobald `dsh-bash-terminal-ts` im `dsh.profile.bundles` des Profils steht, mountet DSH das Plugin automatisch.
|
|
90
|
+
|
|
91
|
+
Kombinierten Baum verifizieren (ohne Neustart):
|
|
92
|
+
|
|
93
|
+
```powershell
|
|
94
|
+
node "$env:APPDATA\nvm\<node-version>\node_modules\@deepseek-ai\dsh\lib\bin.js" --profile web --dump-config | Select-String dsh-bash-terminal-ts
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Verwendung
|
|
98
|
+
|
|
99
|
+
**Der Nutzer wählt das Standardterminal in der Web-UI**: Einstellungen (Zahnrad) öffnen → Allgemein → Dropdown „Standardterminal" und eines der Terminals PowerShell / Git Bash / MSYS2 / WSL wählen. Änderungen wirken sofort und werden persistiert.
|
|
100
|
+
|
|
101
|
+
Sobald das Modell das `shell`-Werkzeug sieht, verwendet es automatisch das von Ihnen gewählte Terminal (das Werkzeug legt keinen Terminal-Parameter offen; das Modell kann Ihre Wahl nicht ändern):
|
|
102
|
+
|
|
103
|
+
- Standardterminal = Git Bash: `shell(command: "git status")` läuft über Git Bash
|
|
104
|
+
- Standardterminal = MSYS2: `shell(command: "gcc --version")` läuft über MSYS2 (MINGW64-Umgebung, gcc und make aus `/mingw64/bin` verfügbar)
|
|
105
|
+
- Standardterminal = WSL: `shell(command: "ls -la /mnt/d/workspace")` läuft über WSL; mit `distro: "Ubuntu"` lässt sich die Distribution angeben
|
|
106
|
+
- Standardterminal = PowerShell: `shell(command: "Get-Process node")` läuft über PowerShell
|
|
107
|
+
|
|
108
|
+
## Beispiele zur Modellnutzung
|
|
109
|
+
|
|
110
|
+
- Einmalbefehl (Standardterminal): `shell(command: "git status", description: "Git-Status prüfen")`
|
|
111
|
+
- Zustand über Runden hinweg bewahren (interaktiv): `terminal(action: "open")` → `sessionId` notieren → `terminal(action: "send", sessionId, input: "cd /d/project\n")` → `terminal(action: "send", sessionId, input: "npm run dev\n")` → `terminal(action: "close", sessionId)`
|
|
112
|
+
- Laufendes Programm unterbrechen: `terminal(action: "signal", sessionId, signal: "SIGINT")`
|
|
113
|
+
- Aktive Sitzungen einsehen: `terminal(action: "list")`
|
|
114
|
+
- Eskalation nach Sandbox-Ablehnung: `shell(command: ..., sandbox_permissions: "workspace-write", justification: "...")`
|
|
115
|
+
|
|
116
|
+
## Konfiguration
|
|
117
|
+
|
|
118
|
+
**Web-UI-Einstellungen** (empfohlen): Einstellungen → Allgemein → „Standardterminal".
|
|
119
|
+
|
|
120
|
+
`config` der Plugin-Zeile (überschreibt die Standardwerte und dient als Kompositionsgrundlage der Einstellungen):
|
|
121
|
+
|
|
122
|
+
| Schlüssel | Standard | Beschreibung |
|
|
123
|
+
|----|------|------|
|
|
124
|
+
| `defaultShell` | `powershell` | Backend, sofern die Einstellungen nichts anderes festlegen |
|
|
125
|
+
| `timeoutMs` | 120000 | Standard-Timeout |
|
|
126
|
+
| `maxTimeoutMs` | 600000 | Obergrenze für das timeoutMs des Aufrufers |
|
|
127
|
+
| `pwshPath` | automatische Erkennung | Fester Pfad zu pwsh.exe |
|
|
128
|
+
| `gitBashPath` | automatische Erkennung | Fester Pfad zu git bash.exe |
|
|
129
|
+
| `msys2Path` | automatische Erkennung (`C:\msys64\usr\bin\bash.exe` bevorzugt, Fallback `msys2.exe`) | Fester Pfad zu MSYS2 bash.exe |
|
|
130
|
+
| `wslPath` | automatische Erkennung | Fester Pfad zu wsl.exe |
|
|
131
|
+
|
|
132
|
+
## Veröffentlichung (npm)
|
|
133
|
+
|
|
134
|
+
Das npm-Konto hat die 2FA-Verifizierung für Veröffentlichungen aktiviert; ein Einmalcode ist erforderlich:
|
|
135
|
+
|
|
136
|
+
```powershell
|
|
137
|
+
cd D:\workspace\projects\dsh-bash-terminal-ts
|
|
138
|
+
npm publish --otp <Code> # der Code stammt von Ihrem Authentifikator
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Vor der Veröffentlichung mit `npm pack --dry-run` den Inhalt prüfen und `npm run build` ausführen, um alles neu zu bauen (tsc-Serverkompilierung + Client-Bundle + Testkompilierung).
|
|
142
|
+
|
|
143
|
+
## Deinstallation
|
|
144
|
+
|
|
145
|
+
Einfach ausführen:
|
|
146
|
+
|
|
147
|
+
```powershell
|
|
148
|
+
powershell -ExecutionPolicy Bypass -File install.ps1 uninstall
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Der Befehl entfernt die Junctions, stellt die Settings-Allowlist wieder her, räumt die veralteten `cordis.patch.yml`-Mount-Blöcke früherer Versionen auf und entfernt `dsh-bash-terminal-ts` aus dem `dsh.profile.bundles`. Anschließend dsh web neu starten.
|
|
152
|
+
|
|
153
|
+
Bei manueller Deinstallation ist – neben dem Entfernen von `node_modules\dsh-bash-terminal-ts` – auch daran zu denken, `dsh-bash-terminal-ts` aus dem `dsh.profile.bundles` der Profil-`package.json` zu entfernen.
|
|
154
|
+
|
|
155
|
+
## Interaktives Terminal (Werkzeug `terminal`)
|
|
156
|
+
|
|
157
|
+
Das Werkzeug `terminal` stellt **persistente interaktive Sitzungen** über die PTY-Naht bereit (node-pty; unter Windows direkt über node-pty, weil der Process Inspector des upstream `spawnTerminal` nur POSIX unterstützt – `lib/terminal.js` verbindet sich daher direkt mit node-pty; unter Nicht-Windows wird weiterhin das offizielle `ctx.subprocess.spawnTerminal` verwendet):
|
|
158
|
+
|
|
159
|
+
- `action: open` startet eine echte Terminal-Sitzung (gemäß Ihrer Standardterminal-Einstellung; bei wsl kann `distro` angegeben werden) und liefert eine `sessionId`
|
|
160
|
+
- `action: send` schreibt die Eingabe und liest die neue Ausgabe; `action: read` liest nur, ohne zu schreiben; `action: signal` sendet ein Signal an die Vordergrund-Prozessgruppe (SIGINT = Ctrl+C)
|
|
161
|
+
- `action: close` beendet die Sitzung
|
|
162
|
+
- **Der Sitzungszustand bleibt über Aufrufe hinweg erhalten** (cwd / Variablen / Aliasse), geeignet für REPL, ssh und interaktive CLIs
|
|
163
|
+
- `send` wartet, bis sich die Ausgabe stabilisiert hat (300 ms Stille, Obergrenze 5 s), und liefert die **vollständige Antwort**; bei mehr als 1 MB Ausgabe folgt der Hinweis `truncated`
|
|
164
|
+
- Die Eingabe endet mit `\\n` (oder \\r), um die Eingabetaste zu signalisieren
|
|
165
|
+
|
|
166
|
+
## Sandbox (Anbindung an den offiziellen Mechanismus)
|
|
167
|
+
|
|
168
|
+
Das `shell`-Werkzeug nutzt die offizielle Sandbox-Naht von DSH (`ctx.sandboxPolicy` + `ctx.sandbox`):
|
|
169
|
+
|
|
170
|
+
- Bei jedem Aufruf wird die aktuelle Sandbox-Richtlinie aufgelöst; `danger-full-access`-Sitzungen werden direkt ausgeführt (ohne Ummantelung).
|
|
171
|
+
- Das PowerShell-Backend umhüllt argv über `ctx.sandbox.confine` – dieselbe **Fail-closed**-Semantik wie bei den offiziellen Executoren: Wird der eingeschränkte Modus angefordert, aber kein Backend gefunden, fliegt eine `SandboxUnavailableError`; ein ungeschützter Lauf wird verweigert.
|
|
172
|
+
- Das Git-Bash-Backend wird nicht umhüllt: Der Windows-ACL-Restricted-Token-Runner von DSH ist inkompatibel mit Cygwin/MSYS2 (bash bricht beim Start mit `CreateFileMapping` Win32-Fehler 5 ab); daher läuft Git Bash auch im eingeschränkten Modus ohne Sandbox-Ummantelung; das Ergebnis meldet `enforcement: gitbash-unconfined`.
|
|
173
|
+
- Das MSYS2-Backend wird ebenfalls nicht umhüllt (dieselbe Cygwin/MSYS2-Laufzeitinkompatibilität); das Ergebnis meldet `enforcement: msys2-unconfined`.
|
|
174
|
+
- Das WSL-Backend wird nicht umhüllt: Die eigenständige Linux-VM von WSL ist selbst die Isolation (das Ergebnis meldet `enforcement: wsl-isolation`).
|
|
175
|
+
- Wird ein Aufruf im eingeschränkten Modus von der Sandbox abgelehnt, trägt das Ergebnis das offizielle Kennzeichen `[sandbox: file access denied under <mode> mode]` samt Eskalationshinweis für dieselbe Runde; das Modell kann mit `sandbox_permissions` + `justification` eine Eskalation anstoßen (Nutzerfreigabe über `ctx.approval`) – exakt wie bei den offiziellen bash/pwsh-Werkzeugen.
|
|
176
|
+
- Hinweis: Wenn der Windows-ACL-Runner von DSH verfügbar ist, wird der eingeschränkte Modus von PowerShell über ihn umhüllt; Git Bash und MSYS2 bleiben wegen der Cygwin/MSYS2-Inkompatibilität unumhüllt.
|
|
177
|
+
|
|
178
|
+
## ⚠️ Sicherheitshinweis
|
|
179
|
+
|
|
180
|
+
Das `shell`-Werkzeug im eingeschränkten Modus: PowerShell wird über `ctx.sandbox.confine` umhüllt (fail-closed); Git Bash und MSYS2 bleiben wegen der Inkompatibilität von Cygwin/MSYS2 mit dem Windows-ACL-Restricted-Token **unumhüllt** (gleiche Berechtigungen wie der dsh-Prozess); WSL bleibt dank seiner eigenständigen Linux-VM unumhüllt. Es ist ein **zusätzlicher Multi-Terminal-Einstiegspunkt** und genießt nicht die ConstrainedLanguage-Einschränkungen des offiziellen `pwsh`-Werkzeugs. Die Datei-Werkzeuge von DSH (read/write/edit) unterliegen weiterhin der Datei-Sandbox. Nur in Sitzungen verwenden, denen Sie vertrauen; für sandboxgeschütztes PowerShell weiterhin das offizielle `pwsh`-Werkzeug nutzen.
|
|
181
|
+
|
|
182
|
+
## Bekannte Einschränkungen des interaktiven Terminals (ConPTY)
|
|
183
|
+
|
|
184
|
+
- **PowerShell 5.1 kann in einem ConPTY nicht starten** (0x8009001d) – für interaktives PowerShell [PowerShell 7](https://github.com/PowerShell/PowerShell/releases) installieren (Einmalbefehle sind nicht betroffen).
|
|
185
|
+
- **Der interaktive Modus von wsl.exe kann unter ConPTY einen RPC-Fehler des WSL-Dienstes auslösen** (0x8007072c, sporadisch) – Einmalbefehle `wsl -e bash -lc ...` funktionieren normal; für interaktive Sitzungen besser Windows Terminal / ein WSL-Terminal verwenden oder es erneut versuchen.
|
|
186
|
+
- **node-pty akzeptiert unter Windows keine benannten Signale**: `SIGINT` von `signal` wird auf Ctrl+C (`\x03`) abgebildet; andere Signale (`SIGTERM` / `SIGKILL` / `SIGTSTP` / `SIGHUP`) degradieren zur Beendigung der Sitzung.
|
|
187
|
+
- Interaktive Git-Bash-Sitzungen funktionieren vollumfänglich.
|
|
188
|
+
|
|
189
|
+
## Bekannte Einschränkungen
|
|
190
|
+
|
|
191
|
+
- WSL-Hintergrundprozesse können nach Timeout/Abbruch noch kurz in der Distribution weiterlaufen (die WSL-Instanz schaltet sich nach dem Ende des letzten Prozesses automatisch ab).
|
|
192
|
+
- Git Bash ist eine msys2-Umgebung und weicht vom Linux-Verhalten von WSL ab (Pfad-Mapping, Paketverfügbarkeit).
|
|
193
|
+
- Das MSYS2-Backend erfordert eine lokal installierte MSYS2 (Standard `C:\msys64`); ohne Installation meldet `shell` den Fehler `backend unavailable`, mit `msys2Path` lässt sich ein benutzerdefinierter Ort angeben. Die Kandidatenreihenfolge bleibt immer: `bash.exe` zuerst, `msys2.exe` als Fallback – bei weitergeleitetem stdio liefert `msys2.exe` stumm null Byte und dient nur als letzte Rettung.
|
|
194
|
+
- Dieses Plugin registriert seine Werkzeuge nur auf der Plattform `win32`.
|
|
195
|
+
|
|
196
|
+
## Tests
|
|
197
|
+
|
|
198
|
+
```powershell
|
|
199
|
+
cd D:\workspace\projects\dsh-bash-terminal-ts
|
|
200
|
+
npm install # Abhängigkeiten installieren (typescript inklusive)
|
|
201
|
+
npm run build # tsc-Kompilierung src/*.ts → lib/*.js; client.tsx → lib/client.js + dist/client.js; test/*.ts → test-dist/
|
|
202
|
+
npm test # node test-dist/unit.js → apply.js → client.js → terminal.js
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Der Quellcode ist TypeScript (`strict` + `noUncheckedIndexedAccess`); die Build-Artefakte `lib/` und `dist/` werden mit dem Repository eingecheckt, DSH lädt direkt `lib/index.js` – ohne Installation einsatzbereit.
|
package/README.en.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-bash-terminal-ts
|
|
2
2
|
|
|
3
|
-
> Community: [LINUX DO](https://linux.do) · [GitHub](https://github.com/drscrewdriver/dsh-bash-terminal-ts)
|
|
3
|
+
> 🌐 [简体中文](README.md) | [English](README.en.md) | [Français](README.fr.md) | [Deutsch](README.de.md) | [Italiano](README.it.md) | [Русский](README.ru.md) | [Español](README.es.md) · Community: [LINUX DO](https://linux.do) · [GitHub](https://github.com/drscrewdriver/dsh-bash-terminal-ts)
|
|
4
4
|
|
|
5
5
|
A DeepSeek Harness (DSH) plugin: one `shell` tool that runs commands through **PowerShell / Git Bash / MSYS2 / WSL** on Windows, plus an **interactive terminal** tool — all following the terminal **you** choose in the Web UI settings.
|
|
6
6
|
|
|
@@ -50,6 +50,24 @@ powershell -ExecutionPolicy Bypass -File install.ps1 install # patches the DSH
|
|
|
50
50
|
|
|
51
51
|
> **DSH limitation**: the Web settings client only exposes a hard-coded allowlist of settings namespaces (`dsh-host-apiproxy`); third-party settings writes are refused with `settings-not-exposed` otherwise. `install.ps1` patches the allowlist (with a backup) — re-run it after upgrading DSH; `install` / `uninstall` restores it.
|
|
52
52
|
|
|
53
|
+
### pnpm users: the node-pty build-script notice
|
|
54
|
+
|
|
55
|
+
This plugin depends on the native PTY library [`node-pty`](https://www.npmjs.com/package/node-pty) (Microsoft-maintained, the same library VS Code uses) for the interactive `terminal` tool. **As of 0.7.1 it is pinned to `1.2.0-beta.15`** (the same version both DSH host lines use): the tarball ships prebuilt binaries for every platform, so even when pnpm 10+ skips the install script, the runtime loader falls back to `prebuilds/<platform>-<arch>/` and **runs without compiling**. The notice at the end of `pnpm add` only reports the skipped script; approve once to silence it:
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
Error: ERR_PNPM_IGNORED_BUILDS
|
|
59
|
+
Ignored build scripts: node-pty@1.2.0-beta.15
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```powershell
|
|
63
|
+
pnpm approve-builds # pick node-pty interactively
|
|
64
|
+
# or declare it in the profile's package.json, then rebuild:
|
|
65
|
+
# "pnpm": { "onlyBuiltDependencies": ["node-pty"] }
|
|
66
|
+
pnpm rebuild node-pty
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> This is the **only** own dsh plugin with a native dependency; the other 0.2.0-line plugins (search-index, session-steward, patch-edit-plus, browser-cdp, date-wrapper) and live-token-stats are pure-JS and install on pnpm without any approval.
|
|
70
|
+
|
|
53
71
|
For local development (junction install, source changes apply instantly) see the Chinese README's development section.
|
|
54
72
|
|
|
55
73
|
## Sandbox
|
package/README.es.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# dsh-bash-terminal-ts
|
|
2
|
+
|
|
3
|
+
> 🌐 [简体中文](README.md) | [English](README.en.md) | [Français](README.fr.md) | [Deutsch](README.de.md) | [Italiano](README.it.md) | [Русский](README.ru.md) | [Español](README.es.md) · Comunidad: [LINUX DO](https://linux.do) · [GitHub](https://github.com/drscrewdriver/dsh-bash-terminal-ts)
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
Plugin de DSH (DeepSeek Harness): una herramienta `shell` que ejecuta de forma unificada en Windows los comandos de **cuatro** terminales — **PowerShell / Git Bash / MSYS2 / WSL**.
|
|
8
|
+
|
|
9
|
+
> **Este repositorio es la reescritura en TypeScript de `MAXeaglet/dsh-bash-terminal`**, con soporte MSYS2/MINGW64 funcional. Las líneas de compatibilidad se cortan por segmento de versión del host DSH; todas las líneas comparten el nombre de paquete `dsh-bash-terminal-ts` y se distinguen mediante dist-tags de npm:
|
|
10
|
+
>
|
|
11
|
+
> | Segmento DSH | Rama | Versión del plugin | dist-tag npm |
|
|
12
|
+
> |--------|------|----------|--------------|
|
|
13
|
+
> | `>=0.2.0-rc.1 <0.2.1-0` | `compat/0.2.0` (esta rama) | 0.7.x | `dsh-0.2.0` |
|
|
14
|
+
> | 0.1.7-rc.1 – 0.1.7.x | `compat/0.1.7` | 0.6.x | `dsh-0.1.7` |
|
|
15
|
+
> | 0.1.5-alpha.1 – 0.1.5-rc.x | `ts/0.1.5` (histórica, congelada) | ≤ 0.5.2 | `dsh-0.1.5` |
|
|
16
|
+
> | 0.1.2-alpha.1 – 0.1.2-rc.x | `main` (histórica, congelada) | ≤ 0.4.2 | `dsh-0.1.2` |
|
|
17
|
+
>
|
|
18
|
+
> Elige la línea que cubra tu versión de DSH; las series de versiones nunca se solapan, por lo que una instalación con `^` no puede resolverse entre líneas.
|
|
19
|
+
|
|
20
|
+
| Backend | Ejecución real | Sintaxis / rutas | Variables de entorno |
|
|
21
|
+
|------|----------|-------------|----------|
|
|
22
|
+
| `powershell` (predeterminado) | `pwsh -NoLogo -NoProfile -NonInteractive -Command <cmd>` | PowerShell; `C:\...` | `$env:NAME` |
|
|
23
|
+
| `gitbash` | `bash -lc <cmd>` de Git for Windows | POSIX; `/d/workspace`; PATH con `/usr/bin` y `/mingw64/bin` | `$NAME` |
|
|
24
|
+
| `msys2` | `bash -lc <cmd>` de MSYS2 (`C:\msys64\usr\bin\bash.exe`) | POSIX; `/c/...`; PATH con `/usr/bin` y `/mingw64/bin` (gcc / make) | `$NAME` (inyección automática de `MSYSTEM=MINGW64`) |
|
|
25
|
+
| `wsl` | `wsl [-d <distro>] -e bash -lc <cmd>` | Linux; `/mnt/d/...` | `$NAME` (vía WSLENV) |
|
|
26
|
+
|
|
27
|
+
Cada llamada arranca una shell totalmente nueva: **no se conserva estado alguno** (cwd / variables / alias) — pasa `workdir` en lugar de usar `cd`.
|
|
28
|
+
|
|
29
|
+
## Vista previa de la interfaz
|
|
30
|
+
|
|
31
|
+
La fila «Terminal predeterminado» en Ajustes → General: el usuario elige entre PowerShell / Git Bash / MSYS2 / WSL, y la herramienta `shell` ejecuta solo conforme a ese ajuste, sin que el modelo pueda saltárselo:
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
## Puntos de diseño
|
|
36
|
+
|
|
37
|
+
- **El terminal lo decide el usuario, la IA no puede cambiarlo**: la página de ajustes de la UI web (Ajustes → General) muestra un desplegable de «Terminal predeterminado» (PowerShell / Git Bash / MSYS2 / WSL); la herramienta `shell` usa siempre únicamente ese ajuste y no expone ningún parámetro de terminal al modelo. El ajuste se persiste mediante el sistema de settings de DSH (settings.yaml).
|
|
38
|
+
- **No ocupa la costura de capacidades `ctx.shell`**: la herramienta `pwsh` sandboxizada que trae DSH sigue disponible tal cual; la herramienta `shell` de este plugin es una **entrada adicional** multi-terminal.
|
|
39
|
+
- Los procesos se derivan mediante la costura compartida `ctx.subprocess`: terminación del árbol de procesos (`taskkill /T` en Windows), SIGTERM → gracia → SIGKILL, archivos de spill de salida — comportamiento idéntico al de las herramientas oficiales `dsh-tool-bash` / `dsh-tool-pwsh`.
|
|
40
|
+
- Las tareas en segundo plano se registran en el registro genérico de `jobs`, con soporte de `run_in_background` / `job_output` / `job_kill`.
|
|
41
|
+
- La fila «Terminal predeterminado» de la página de ajustes del frontend es una enumeración (la UI la renderiza automáticamente como desplegable); en cada llamada el modelo ejecuta solo conforme a ese ajuste y no puede cambiar de terminal por su cuenta.
|
|
42
|
+
|
|
43
|
+
## Instalación (perfil web)
|
|
44
|
+
|
|
45
|
+
### Instalación estándar (tras la publicación en npm, mecanismo oficial de bundle)
|
|
46
|
+
|
|
47
|
+
El plugin trae el manifiesto oficial `dsh.bundle` (`cordis.patch.yml` dentro del paquete); en cuanto un perfil lista este paquete, DSH **aplica el montaje automáticamente**, sin necesidad de editar a mano la configuración del perfil:
|
|
48
|
+
|
|
49
|
+
```powershell
|
|
50
|
+
# 1. Instalar el paquete del plugin
|
|
51
|
+
npm install -g dsh-bash-terminal-ts
|
|
52
|
+
dsh plugin --profile web add dsh-bash-terminal-ts # se añade automáticamente a los bundles del perfil y aplica el parche
|
|
53
|
+
|
|
54
|
+
# 2. Parchear la allowlist de ajustes de DSH (limitación de DSH, ver explicación abajo)
|
|
55
|
+
powershell -ExecutionPolicy Bypass -File install.ps1 install
|
|
56
|
+
|
|
57
|
+
# 3. Reiniciar dsh web
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> Probado en la práctica con un perfil temporal: `bundles: [dsh-bash-terminal-ts]` → la entrada `tool-bash-terminal` aparece automáticamente en el dump-config.
|
|
61
|
+
|
|
62
|
+
### Instalación para desarrollo local (junction, los cambios de código fuente surten efecto al instante)
|
|
63
|
+
|
|
64
|
+
```powershell
|
|
65
|
+
# 1. Enlazar el paquete del plugin a los node_modules del perfil (junction, los cambios de fuente surten efecto al instante)
|
|
66
|
+
$profile = "$env:USERPROFILE\.dsh\profiles\web"
|
|
67
|
+
New-Item -ItemType Junction -Path "$profile\node_modules\dsh-bash-terminal-ts" -Target "D:\workspace\projects\dsh-bash-terminal-ts" | Out-Null
|
|
68
|
+
|
|
69
|
+
# 2. Permitir que el plugin resuelva las dependencias @deepseek-ai/* (junction hacia el árbol de dependencias del perfil; plugin y host comparten las mismas instancias de módulos)
|
|
70
|
+
New-Item -ItemType Junction -Path "D:\workspace\projects\dsh-bash-terminal-ts\node_modules\@deepseek-ai" -Target "$profile\..\node_modules\@deepseek-ai" | Out-Null
|
|
71
|
+
|
|
72
|
+
# 3. Dejar que el perfil monte el plugin mediante el bundle oficial (install.ps1 install lo hace automáticamente; equivale a añadir "dsh-bash-terminal-ts" a dsh.profile.bundles)
|
|
73
|
+
# 4. (solo tras modificar el código del frontend) recompilar el bundle del cliente:
|
|
74
|
+
# cd D:\workspace\projects\dsh-bash-terminal-ts && node scripts/build-client.mjs
|
|
75
|
+
# 5. Reiniciar dsh web
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
> ⚠️ **No ejecutes `npm install` en este proyecto**: borraría la junction del paso 2 de arriba e instalaría para el plugin una copia **independiente** de
|
|
79
|
+
> `@deepseek-ai/*` — plugin y host dejarían de compartir instancias de módulos y, tras una actualización del host, el plugin se quedaría en la API antigua
|
|
80
|
+
> (este proyecto llegó a quedarse atascado en 0.1.0-rc.6 por esa razón). Para refrescar solo el lock, usa `npm install --package-lock-only`.
|
|
81
|
+
|
|
82
|
+
> **Compatibilidad**: requiere DSH ≥ **0.1.7-rc.1** (línea `compat/0.1.7`) o ≥ **0.2.0-rc.1** (línea `compat/0.2.0`, esta rama).
|
|
83
|
+
> Contexto histórico: en 0.1.5, `@deepseek-ai/dsh-client-runtime` en la tabla de módulos del cliente pasó a llamarse `@deepseek-ai/dsh-client-store` y solo se resuelve por coincidencia exacta del nombre desnudo; los bundles antiguos fallan en el host nuevo con
|
|
84
|
+
> `Failed to load plugins` / `require(...) missed the module table`.
|
|
85
|
+
>
|
|
86
|
+
> Además: desde 0.1.5 la superficie de ajustes web usa la enumeración dinámica `settings.describe()` y **ya no tiene una allowlist de namespaces**
|
|
87
|
+
> (`settings-not-exposed` ya no existe); el parche de allowlist presente en `install.ps1` es solo un residuo histórico y puede ignorarse.
|
|
88
|
+
|
|
89
|
+
> Ya no hace falta editar manualmente el `cordis.patch.yml` del perfil: el paquete del plugin trae su propio `dsh.bundle.patch` (`cordis.patch.yml` dentro del paquete); basta con que `dsh-bash-terminal-ts` figure en el `dsh.profile.bundles` del perfil para que DSH monte el plugin automáticamente.
|
|
90
|
+
|
|
91
|
+
Verificar el árbol combinado (sin reiniciar):
|
|
92
|
+
|
|
93
|
+
```powershell
|
|
94
|
+
node "$env:APPDATA\nvm\<node-version>\node_modules\@deepseek-ai\dsh\lib\bin.js" --profile web --dump-config | Select-String dsh-bash-terminal-ts
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Uso
|
|
98
|
+
|
|
99
|
+
**El usuario establece el terminal predeterminado en la UI web**: abre los ajustes (engranaje) → General → desplegable «Terminal predeterminado» y elige uno entre PowerShell / Git Bash / MSYS2 / WSL. El cambio surte efecto de inmediato y se persiste.
|
|
100
|
+
|
|
101
|
+
Cuando el modelo ve la herramienta `shell`, ejecuta automáticamente con el terminal que elegiste (la herramienta no expone parámetros de terminal; el modelo no puede cambiar tu elección):
|
|
102
|
+
|
|
103
|
+
- Terminal predeterminado = Git Bash: `shell(command: "git status")` va por Git Bash
|
|
104
|
+
- Terminal predeterminado = MSYS2: `shell(command: "gcc --version")` va por MSYS2 (entorno MINGW64, disponibles gcc y make de `/mingw64/bin`)
|
|
105
|
+
- Terminal predeterminado = WSL: `shell(command: "ls -la /mnt/d/workspace")` va por WSL; `distro: "Ubuntu"` permite indicar la distribución
|
|
106
|
+
- Terminal predeterminado = PowerShell: `shell(command: "Get-Process node")` va por PowerShell
|
|
107
|
+
|
|
108
|
+
## Ejemplos de uso para el modelo
|
|
109
|
+
|
|
110
|
+
- Comando puntual (terminal predeterminado): `shell(command: "git status", description: "ver el estado de git")`
|
|
111
|
+
- Estado preservado entre turnos (interactivo): `terminal(action: "open")` → anota el `sessionId` → `terminal(action: "send", sessionId, input: "cd /d/project\n")` → `terminal(action: "send", sessionId, input: "npm run dev\n")` → `terminal(action: "close", sessionId)`
|
|
112
|
+
- Interrumpir un programa en ejecución: `terminal(action: "signal", sessionId, signal: "SIGINT")`
|
|
113
|
+
- Consultar las sesiones activas: `terminal(action: "list")`
|
|
114
|
+
- Escalada tras un rechazo de la sandbox: `shell(command: ..., sandbox_permissions: "workspace-write", justification: "...")`
|
|
115
|
+
|
|
116
|
+
## Configuración
|
|
117
|
+
|
|
118
|
+
**Ajustes de la UI web** (recomendado): Ajustes → General → «Terminal predeterminado».
|
|
119
|
+
|
|
120
|
+
El `config` de la fila del plugin (sobrescribe los predeterminados y sirve de base de composición para los ajustes):
|
|
121
|
+
|
|
122
|
+
| Clave | Predeterminado | Descripción |
|
|
123
|
+
|----|------|------|
|
|
124
|
+
| `defaultShell` | `powershell` | Backend usado cuando los ajustes no sobrescriben |
|
|
125
|
+
| `timeoutMs` | 120000 | Tiempo de espera predeterminado |
|
|
126
|
+
| `maxTimeoutMs` | 600000 | Límite superior del timeoutMs del llamante |
|
|
127
|
+
| `pwshPath` | detección automática | Ruta fija de pwsh.exe |
|
|
128
|
+
| `gitBashPath` | detección automática | Ruta fija de git bash.exe |
|
|
129
|
+
| `msys2Path` | detección automática (primero `C:\msys64\usr\bin\bash.exe`, reserva en `msys2.exe`) | Ruta fija de MSYS2 bash.exe |
|
|
130
|
+
| `wslPath` | detección automática | Ruta fija de wsl.exe |
|
|
131
|
+
|
|
132
|
+
## Publicación (npm)
|
|
133
|
+
|
|
134
|
+
La cuenta de npm tiene activada la verificación 2FA para publicar; hace falta un código de un solo uso:
|
|
135
|
+
|
|
136
|
+
```powershell
|
|
137
|
+
cd D:\workspace\projects\dsh-bash-terminal-ts
|
|
138
|
+
npm publish --otp <código> # el código lo da tu autenticador
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Antes de publicar, haz un `npm pack --dry-run` para revisar el contenido y ejecuta `npm run build` para recompilar todo (compilación de servidor con tsc + bundle del cliente + compilación de los tests).
|
|
142
|
+
|
|
143
|
+
## Desinstalación
|
|
144
|
+
|
|
145
|
+
Basta con ejecutar:
|
|
146
|
+
|
|
147
|
+
```powershell
|
|
148
|
+
powershell -ExecutionPolicy Bypass -File install.ps1 uninstall
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Elimina las junction, restaura la allowlist de ajustes, limpia los bloques de montaje `cordis.patch.yml` heredados de versiones antiguas y retira `dsh-bash-terminal-ts` del `dsh.profile.bundles`. Después reinicia dsh web.
|
|
152
|
+
|
|
153
|
+
En una desinstalación manual, además de borrar `node_modules\dsh-bash-terminal-ts`, recuerda también retirar `dsh-bash-terminal-ts` del `dsh.profile.bundles` del `package.json` del perfil.
|
|
154
|
+
|
|
155
|
+
## Terminal interactivo (herramienta `terminal`)
|
|
156
|
+
|
|
157
|
+
La herramienta `terminal` ofrece **sesiones interactivas persistentes** sobre la costura PTY (node-pty; en Windows, como el process inspector del `spawnTerminal` upstream solo admite POSIX, `lib/terminal.js` se conecta directamente a node-pty; fuera de Windows se sigue usando el `ctx.subprocess.spawnTerminal` oficial):
|
|
158
|
+
|
|
159
|
+
- `action: open` inicia una sesión de terminal real (según tu terminal predeterminado configurado; en wsl se puede pasar `distro`) y devuelve un `sessionId`
|
|
160
|
+
- `action: send` escribe la entrada y lee la nueva salida; `action: read` solo lee, sin escribir; `action: signal` envía una señal al grupo de procesos en primer plano (SIGINT = Ctrl+C)
|
|
161
|
+
- `action: close` termina la sesión
|
|
162
|
+
- **El estado de la sesión se conserva entre llamadas** (cwd / variables / alias), ideal para REPL, ssh y CLIs interactivos
|
|
163
|
+
- `send` espera a que la salida se estabilice (300 ms de silencio, tope de 5 s) y devuelve la **respuesta completa**; con más de 1 MB de salida emite el aviso `truncated`
|
|
164
|
+
- La entrada termina en `\\n` (o \\r) para representar la tecla Enter
|
|
165
|
+
|
|
166
|
+
## Sandbox (conexión con el mecanismo oficial)
|
|
167
|
+
|
|
168
|
+
La herramienta `shell` pasa por la costura oficial de sandbox de DSH (`ctx.sandboxPolicy` + `ctx.sandbox`):
|
|
169
|
+
|
|
170
|
+
- En cada llamada se resuelve la política de sandbox vigente; las sesiones `danger-full-access` se ejecutan directamente (sin envoltura).
|
|
171
|
+
- El backend PowerShell envuelve el argv mediante `ctx.sandbox.confine` — la misma semántica **fail-closed** que los ejecutores oficiales: si se pide el modo restringido y no hay backend disponible, se lanza `SandboxUnavailableError`, rechazando la ejecución desnuda.
|
|
172
|
+
- El backend Git Bash no se envuelve: el runner de token restringido con ACL de Windows de DSH es incompatible con Cygwin/MSYS2 (bash aborta al arrancar con el error Win32 5 de `CreateFileMapping`); por eso Git Bash tampoco pasa por envoltura de sandbox en modo restringido; el resultado informa `enforcement: gitbash-unconfined`.
|
|
173
|
+
- El backend MSYS2 tampoco se envuelve (la misma incompatibilidad de runtime Cygwin/MSYS2); el resultado informa `enforcement: msys2-unconfined`.
|
|
174
|
+
- El backend WSL no se envuelve: la máquina virtual Linux independiente de WSL es por sí misma el aislamiento (el resultado informa `enforcement: wsl-isolation`).
|
|
175
|
+
- Cuando la sandbox rechaza en modo restringido, el resultado lleva el marcador oficial `[sandbox: file access denied under <mode> mode]` y la pista de escalada del mismo turno; el modelo puede iniciar una escalada con `sandbox_permissions` + `justification` (aprobación del usuario vía `ctx.approval`), exactamente igual que las herramientas oficiales bash/pwsh.
|
|
176
|
+
- Nota: cuando el runner de ACL de Windows de DSH está disponible, el modo restringido de PowerShell se envuelve a través de él; Git Bash y MSYS2 siguen sin envolver por la incompatibilidad Cygwin/MSYS2.
|
|
177
|
+
|
|
178
|
+
## ⚠️ Notas de seguridad
|
|
179
|
+
|
|
180
|
+
La herramienta `shell` en modo restringido: PowerShell se envuelve vía `ctx.sandbox.confine` (fail-closed); Git Bash y MSYS2 **no se envuelven** por la incompatibilidad entre Cygwin/MSYS2 y los tokens restringidos de ACL de Windows (mismos permisos que el proceso dsh); WSL no se envuelve gracias a su VM Linux independiente. Es una **entrada adicional multi-terminal** y no disfruta de las restricciones ConstrainedLanguage de la herramienta oficial `pwsh`. Las herramientas de manejo de archivos de DSH (read/write/edit) siguen sujetas a la sandbox de archivos. Úsala solo en sesiones de confianza; para un PowerShell protegido por la sandbox sigue usando la herramienta oficial `pwsh`.
|
|
181
|
+
|
|
182
|
+
## Limitaciones conocidas del terminal interactivo (ConPTY)
|
|
183
|
+
|
|
184
|
+
- **PowerShell 5.1 no puede arrancar en un ConPTY** (0x8009001d) — para PowerShell interactivo instala [PowerShell 7](https://github.com/PowerShell/PowerShell/releases) (los comandos puntuales no se ven afectados).
|
|
185
|
+
- **El modo interactivo de wsl.exe puede desencadenar un error RPC del servicio WSL bajo ConPTY** (0x8007072c, intermitente) — los comandos puntuales `wsl -e bash -lc ...` funcionan con normalidad; para sesiones interactivas conviene usar directamente Windows Terminal / un terminal de WSL, o reintentar.
|
|
186
|
+
- **node-pty no acepta señales con nombre en Windows**: el `SIGINT` de `signal` se mapea a Ctrl+C (`\x03`); las demás señales (`SIGTERM` / `SIGKILL` / `SIGTSTP` / `SIGHUP`) degradan a terminar la sesión.
|
|
187
|
+
- Las sesiones interactivas de Git Bash funcionan por completo.
|
|
188
|
+
|
|
189
|
+
## Limitaciones conocidas
|
|
190
|
+
|
|
191
|
+
- Los procesos en segundo plano de WSL pueden sobrevivir brevemente dentro de la distribución tras un timeout/interrupción (la instancia de WSL se apaga sola tras la salida del último proceso).
|
|
192
|
+
- Git Bash es un entorno msys2, con diferencias respecto al comportamiento Linux de WSL (mapeo de rutas, disponibilidad de paquetes).
|
|
193
|
+
- El backend MSYS2 requiere MSYS2 instalado localmente (por defecto `C:\msys64`); sin instalación `shell` informa `backend unavailable`, y con `msys2Path` se puede indicar una ubicación personalizada. El orden de candidatos siempre es `bash.exe` primero y `msys2.exe` de reserva — con stdio por tubería `msys2.exe` devuelve silenciosamente cero bytes y solo sirve como último recurso.
|
|
194
|
+
- Este plugin registra sus herramientas únicamente en la plataforma `win32`.
|
|
195
|
+
|
|
196
|
+
## Pruebas
|
|
197
|
+
|
|
198
|
+
```powershell
|
|
199
|
+
cd D:\workspace\projects\dsh-bash-terminal-ts
|
|
200
|
+
npm install # instalar las dependencias (typescript incluido)
|
|
201
|
+
npm run build # compilación tsc de src/*.ts → lib/*.js; client.tsx → lib/client.js + dist/client.js; test/*.ts → test-dist/
|
|
202
|
+
npm test # node test-dist/unit.js → apply.js → client.js → terminal.js
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
El código fuente está en TypeScript (`strict` + `noUncheckedIndexedAccess`); los artefactos de compilación `lib/` y `dist/` se suben al repositorio y DSH carga directamente `lib/index.js`, listo para usar sin instalación.
|