dsh-bash-terminal-ts 0.5.1 → 0.5.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.en.md +5 -5
- package/README.md +15 -15
- package/cordis.patch.yml +2 -2
- package/dist/client.core.js +1 -1
- package/dist/client.js +2 -2
- package/dsh.plugin.json +3 -3
- package/lib/client.js +2 -2
- package/lib/dsh-types.d.ts +1 -1
- package/lib/dsh-types.js +9 -9
- package/lib/dsh.js +29 -29
- package/lib/index.js +6 -6
- package/lib/terminal.d.ts +110 -110
- package/lib/terminal.js +438 -438
- package/package.json +1 -1
- package/screenshots.json +5 -5
- package/scripts/build-client.mjs +2 -2
- package/src/client.tsx +2 -2
- package/src/dsh-types.ts +1 -1
- package/src/index.ts +6 -6
- package/src/terminal.ts +1 -1
- package/template/README.md +0 -82
- package/template/terminal-adapter.ts +0 -343
package/README.en.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# dsh-bash-terminal
|
|
1
|
+
# dsh-bash-terminal-ts
|
|
2
2
|
|
|
3
3
|
> Community: [LINUX DO](https://linux.do) · [GitHub](https://github.com/drscrewdriver/dsh-bash-terminal-ts)
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ A DeepSeek Harness (DSH) plugin: one `shell` tool that runs commands through **P
|
|
|
10
10
|
>
|
|
11
11
|
> | Branch | DSH segment | Package name | Status |
|
|
12
12
|
> |--------|-------------|--------------|--------|
|
|
13
|
-
> | `ts/0.1.5` | 0.1.5-alpha.1 – 0.1.5-rc.x | `dsh-bash-terminal` | this branch; `build` / `unit` / `apply` / `client` / `terminal` green locally |
|
|
13
|
+
> | `ts/0.1.5` | 0.1.5-alpha.1 – 0.1.5-rc.x | `dsh-bash-terminal-ts` | this branch; `build` / `unit` / `apply` / `client` / `terminal` green locally |
|
|
14
14
|
> | `main` | 0.1.2-alpha.1 – 0.1.2-rc.x | `dsh-bash-terminal-ts` | the TypeScript rewrite's mainline |
|
|
15
15
|
>
|
|
16
16
|
> The two lines **deliberately use different package names**, so they install side by side without overwriting each other. Pick the branch that covers your DSH build.
|
|
@@ -37,11 +37,11 @@ The **Default terminal** row in Settings -> General: the user picks PowerShell /
|
|
|
37
37
|
|
|
38
38
|
## Install
|
|
39
39
|
|
|
40
|
-
The package ships the official `dsh.bundle` manifest (its own `cordis.patch.yml`): listing `dsh-bash-terminal` in a profile's `dsh.profile.bundles` auto-applies the mount — no manual profile edits.
|
|
40
|
+
The package ships the official `dsh.bundle` manifest (its own `cordis.patch.yml`): listing `dsh-bash-terminal-ts` in a profile's `dsh.profile.bundles` auto-applies the mount — no manual profile edits.
|
|
41
41
|
|
|
42
42
|
```powershell
|
|
43
|
-
npm install -g dsh-bash-terminal
|
|
44
|
-
dsh plugin --profile web add dsh-bash-terminal # adds to profile bundles + applies the patch
|
|
43
|
+
npm install -g dsh-bash-terminal-ts
|
|
44
|
+
dsh plugin --profile web add dsh-bash-terminal-ts # adds to profile bundles + applies the patch
|
|
45
45
|
powershell -ExecutionPolicy Bypass -File install.ps1 install # patches the DSH settings-UI allowlist (see below)
|
|
46
46
|
# restart dsh web
|
|
47
47
|
```
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# dsh-bash-terminal
|
|
1
|
+
# dsh-bash-terminal-ts
|
|
2
2
|
|
|
3
3
|
> 🌐 [English](README.en.md) · 社区交流:[LINUX DO](https://linux.do) · [GitHub](https://github.com/drscrewdriver/dsh-bash-terminal-ts)
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ DSH(DeepSeek Harness)插件:一个 `shell` 工具,在 Windows 上统一
|
|
|
10
10
|
>
|
|
11
11
|
> | 分支 | DSH 段 | 包名 | 状态 |
|
|
12
12
|
> |------|--------|------|------|
|
|
13
|
-
> | `ts/0.1.5` | 0.1.5-alpha.1 – 0.1.5-rc.x | `dsh-bash-terminal` | 本分支;`build` / `unit` / `apply` / `client` / `terminal` 本机全绿 |
|
|
13
|
+
> | `ts/0.1.5` | 0.1.5-alpha.1 – 0.1.5-rc.x | `dsh-bash-terminal-ts` | 本分支;`build` / `unit` / `apply` / `client` / `terminal` 本机全绿 |
|
|
14
14
|
> | `main` | 0.1.2-alpha.1 – 0.1.2-rc.x | `dsh-bash-terminal-ts` | TypeScript 重写主线 |
|
|
15
15
|
>
|
|
16
16
|
> **两条线刻意使用不同包名**,因此可以并存安装、互不覆盖。请按你的 DSH 版本选分支。
|
|
@@ -46,8 +46,8 @@ DSH(DeepSeek Harness)插件:一个 `shell` 工具,在 Windows 上统一
|
|
|
46
46
|
|
|
47
47
|
```powershell
|
|
48
48
|
# 1. 安装插件包
|
|
49
|
-
npm install -g dsh-bash-terminal
|
|
50
|
-
dsh plugin --profile web add dsh-bash-terminal # 自动加进 profile 的 bundles 并应用 patch
|
|
49
|
+
npm install -g dsh-bash-terminal-ts
|
|
50
|
+
dsh plugin --profile web add dsh-bash-terminal-ts # 自动加进 profile 的 bundles 并应用 patch
|
|
51
51
|
|
|
52
52
|
# 2. patch DSH 设置白名单(DSH 限制,见下方说明)
|
|
53
53
|
powershell -ExecutionPolicy Bypass -File install.ps1 install
|
|
@@ -55,21 +55,21 @@ powershell -ExecutionPolicy Bypass -File install.ps1 install
|
|
|
55
55
|
# 3. 重启 dsh web
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
> 已用临时 profile 实测:`bundles: [dsh-bash-terminal]` → dump-config 自动出现 `tool-bash-terminal` entry。
|
|
58
|
+
> 已用临时 profile 实测:`bundles: [dsh-bash-terminal-ts]` → dump-config 自动出现 `tool-bash-terminal` entry。
|
|
59
59
|
|
|
60
60
|
### 本地开发安装(junction 直连,改源码即时生效)
|
|
61
61
|
|
|
62
62
|
```powershell
|
|
63
63
|
# 1. 链接插件包到 profile 的 node_modules(junction,改源码即时生效)
|
|
64
64
|
$profile = "$env:USERPROFILE\.dsh\profiles\web"
|
|
65
|
-
New-Item -ItemType Junction -Path "$profile\node_modules\dsh-bash-terminal" -Target "D:\workspace\projects\dsh-bash-terminal" | Out-Null
|
|
65
|
+
New-Item -ItemType Junction -Path "$profile\node_modules\dsh-bash-terminal-ts" -Target "D:\workspace\projects\dsh-bash-terminal-ts" | Out-Null
|
|
66
66
|
|
|
67
67
|
# 2. 让插件能解析 @deepseek-ai/* 依赖(junction 到 profile 的依赖树,插件与宿主共用同一份模块实例)
|
|
68
|
-
New-Item -ItemType Junction -Path "D:\workspace\projects\dsh-bash-terminal\node_modules\@deepseek-ai" -Target "$profile\..\node_modules\@deepseek-ai" | Out-Null
|
|
68
|
+
New-Item -ItemType Junction -Path "D:\workspace\projects\dsh-bash-terminal-ts\node_modules\@deepseek-ai" -Target "$profile\..\node_modules\@deepseek-ai" | Out-Null
|
|
69
69
|
|
|
70
|
-
# 3. 让 profile 通过官方 bundle 挂载插件(install.ps1 install 会自动做;等价于在 dsh.profile.bundles 加 "dsh-bash-terminal")
|
|
70
|
+
# 3. 让 profile 通过官方 bundle 挂载插件(install.ps1 install 会自动做;等价于在 dsh.profile.bundles 加 "dsh-bash-terminal-ts")
|
|
71
71
|
# 4. (仅修改前端源码后)重新打包 client bundle:
|
|
72
|
-
# cd D:\workspace\projects\dsh-bash-terminal && node scripts/build-client.mjs
|
|
72
|
+
# cd D:\workspace\projects\dsh-bash-terminal-ts && node scripts/build-client.mjs
|
|
73
73
|
# 5. 重启 dsh web
|
|
74
74
|
```
|
|
75
75
|
|
|
@@ -84,12 +84,12 @@ New-Item -ItemType Junction -Path "D:\workspace\projects\dsh-bash-terminal\node_
|
|
|
84
84
|
> 另:0.1.5 的 Web 设置面改为 `settings.describe()` 动态枚举,**不再有 namespace 白名单**
|
|
85
85
|
> (`settings-not-exposed` 已不存在),`install.ps1` 里的白名单 patch 只是历史遗留、可忽略。
|
|
86
86
|
|
|
87
|
-
> 当前已不再需要手动改 profile 的 `cordis.patch.yml`:插件包内自带 `dsh.bundle.patch`(包内 `cordis.patch.yml`),只要 profile 的 `dsh.profile.bundles` 里有 `dsh-bash-terminal`,DSH 就会自动挂载。
|
|
87
|
+
> 当前已不再需要手动改 profile 的 `cordis.patch.yml`:插件包内自带 `dsh.bundle.patch`(包内 `cordis.patch.yml`),只要 profile 的 `dsh.profile.bundles` 里有 `dsh-bash-terminal-ts`,DSH 就会自动挂载。
|
|
88
88
|
|
|
89
89
|
验证组合树(无需重启):
|
|
90
90
|
|
|
91
91
|
```powershell
|
|
92
|
-
node "$env:APPDATA\nvm\<node-version>\node_modules\@deepseek-ai\dsh\lib\bin.js" --profile web --dump-config | Select-String dsh-bash-terminal
|
|
92
|
+
node "$env:APPDATA\nvm\<node-version>\node_modules\@deepseek-ai\dsh\lib\bin.js" --profile web --dump-config | Select-String dsh-bash-terminal-ts
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
## 使用
|
|
@@ -132,7 +132,7 @@ node "$env:APPDATA\nvm\<node-version>\node_modules\@deepseek-ai\dsh\lib\bin.js"
|
|
|
132
132
|
npm 账号已启用 2FA 发布验证,需一次性验证码:
|
|
133
133
|
|
|
134
134
|
```powershell
|
|
135
|
-
cd D:\workspace\projects\dsh-bash-terminal
|
|
135
|
+
cd D:\workspace\projects\dsh-bash-terminal-ts
|
|
136
136
|
npm publish --otp <验证码> # 验证码来自你的认证器
|
|
137
137
|
```
|
|
138
138
|
|
|
@@ -146,9 +146,9 @@ npm publish --otp <验证码> # 验证码来自你的认证器
|
|
|
146
146
|
powershell -ExecutionPolicy Bypass -File install.ps1 uninstall
|
|
147
147
|
```
|
|
148
148
|
|
|
149
|
-
它会删除 junction、恢复设置白名单、清理旧版遗留的 `cordis.patch.yml` 挂载块,并从 `dsh.profile.bundles` 移除 `dsh-bash-terminal`。之后重启 dsh web 即可。
|
|
149
|
+
它会删除 junction、恢复设置白名单、清理旧版遗留的 `cordis.patch.yml` 挂载块,并从 `dsh.profile.bundles` 移除 `dsh-bash-terminal-ts`。之后重启 dsh web 即可。
|
|
150
150
|
|
|
151
|
-
手动卸载时,除了删除 `node_modules\dsh-bash-terminal`,还要记得从 profile `package.json` 的 `dsh.profile.bundles` 中移除 `dsh-bash-terminal`。
|
|
151
|
+
手动卸载时,除了删除 `node_modules\dsh-bash-terminal-ts`,还要记得从 profile `package.json` 的 `dsh.profile.bundles` 中移除 `dsh-bash-terminal-ts`。
|
|
152
152
|
|
|
153
153
|
## 交互式终端(terminal 工具)
|
|
154
154
|
|
|
@@ -194,7 +194,7 @@ powershell -ExecutionPolicy Bypass -File install.ps1 uninstall
|
|
|
194
194
|
## 测试
|
|
195
195
|
|
|
196
196
|
```powershell
|
|
197
|
-
cd D:\workspace\projects\dsh-bash-terminal
|
|
197
|
+
cd D:\workspace\projects\dsh-bash-terminal-ts
|
|
198
198
|
npm install # 安装依赖(含 typescript)
|
|
199
199
|
npm run build # tsc 编译 src/*.ts → lib/*.js;client.tsx → lib/client.js + dist/client.js;test/*.ts → test-dist/
|
|
200
200
|
npm test # node test-dist/unit.js → apply.js → client.js → terminal.js
|
package/cordis.patch.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# dsh-bash-terminal bundle layer — applied automatically when a profile lists
|
|
1
|
+
# dsh-bash-terminal-ts bundle layer — applied automatically when a profile lists
|
|
2
2
|
# this package in dsh.profile.bundles (dsh.bundle.patch declaration).
|
|
3
3
|
- insert:
|
|
4
4
|
- id: tool-bash-terminal
|
|
5
|
-
name: 'dsh-bash-terminal'
|
|
5
|
+
name: 'dsh-bash-terminal-ts'
|
package/dist/client.core.js
CHANGED
|
@@ -33,7 +33,7 @@ var SHELLS = ["powershell", "gitbash", "msys2", "wsl"];
|
|
|
33
33
|
var ROW_CSS = ".btRow{border-bottom:1px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.btRowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.btTitle{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.btDesc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.btSelector{background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:18px;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.btSelector:hover{background:var(--dsw-alias-interactive-bg-hover)}.btChevron{flex:none}";
|
|
34
34
|
if (typeof document !== "undefined" && document.querySelector('style[data-plugin-css="bash-terminal-row"]') === null) {
|
|
35
35
|
const tag = document.createElement("style");
|
|
36
|
-
tag.dataset.plugin = "dsh-bash-terminal";
|
|
36
|
+
tag.dataset.plugin = "dsh-bash-terminal-ts";
|
|
37
37
|
tag.dataset.pluginCss = "bash-terminal-row";
|
|
38
38
|
tag.textContent = ROW_CSS;
|
|
39
39
|
document.head.appendChild(tag);
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
window.__ModuleLoader__.load({
|
|
2
|
-
id: "dsh-bash-terminal",
|
|
2
|
+
id: "dsh-bash-terminal-ts",
|
|
3
3
|
factory: (require) => {
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
@@ -38,7 +38,7 @@ var SHELLS = ["powershell", "gitbash", "msys2", "wsl"];
|
|
|
38
38
|
var ROW_CSS = ".btRow{border-bottom:1px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.btRowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.btTitle{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.btDesc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.btSelector{background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:18px;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.btSelector:hover{background:var(--dsw-alias-interactive-bg-hover)}.btChevron{flex:none}";
|
|
39
39
|
if (typeof document !== "undefined" && document.querySelector('style[data-plugin-css="bash-terminal-row"]') === null) {
|
|
40
40
|
const tag = document.createElement("style");
|
|
41
|
-
tag.dataset.plugin = "dsh-bash-terminal";
|
|
41
|
+
tag.dataset.plugin = "dsh-bash-terminal-ts";
|
|
42
42
|
tag.dataset.pluginCss = "bash-terminal-row";
|
|
43
43
|
tag.textContent = ROW_CSS;
|
|
44
44
|
document.head.appendChild(tag);
|
package/dsh.plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "dsh-bash-terminal",
|
|
3
|
-
"name": "dsh-bash-terminal",
|
|
4
|
-
"version": "0.5.
|
|
2
|
+
"id": "dsh-bash-terminal-ts",
|
|
3
|
+
"name": "dsh-bash-terminal-ts",
|
|
4
|
+
"version": "0.5.2",
|
|
5
5
|
"description": {
|
|
6
6
|
"en": "One shell tool that runs commands through PowerShell, Git Bash, MSYS2 or WSL on Windows, with a user-chosen default terminal in the Web UI settings.",
|
|
7
7
|
"zh": "一个 shell 工具,可在 Windows 上通过 PowerShell / Git Bash / MSYS2 / WSL 执行命令,默认终端在 Web UI 设置中选择。"
|
package/lib/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
window.__ModuleLoader__.load({
|
|
2
|
-
id: "dsh-bash-terminal",
|
|
2
|
+
id: "dsh-bash-terminal-ts",
|
|
3
3
|
factory: (require) => {
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
@@ -38,7 +38,7 @@ var SHELLS = ["powershell", "gitbash", "msys2", "wsl"];
|
|
|
38
38
|
var ROW_CSS = ".btRow{border-bottom:1px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.btRowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.btTitle{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.btDesc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.btSelector{background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:18px;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.btSelector:hover{background:var(--dsw-alias-interactive-bg-hover)}.btChevron{flex:none}";
|
|
39
39
|
if (typeof document !== "undefined" && document.querySelector('style[data-plugin-css="bash-terminal-row"]') === null) {
|
|
40
40
|
const tag = document.createElement("style");
|
|
41
|
-
tag.dataset.plugin = "dsh-bash-terminal";
|
|
41
|
+
tag.dataset.plugin = "dsh-bash-terminal-ts";
|
|
42
42
|
tag.dataset.pluginCss = "bash-terminal-row";
|
|
43
43
|
tag.textContent = ROW_CSS;
|
|
44
44
|
document.head.appendChild(tag);
|
package/lib/dsh-types.d.ts
CHANGED
|
@@ -241,7 +241,7 @@ export interface ApprovalSeam {
|
|
|
241
241
|
request(input: unknown): Promise<unknown>;
|
|
242
242
|
}
|
|
243
243
|
/**
|
|
244
|
-
* The structural context face dsh-bash-terminal programs against: the union
|
|
244
|
+
* The structural context face dsh-bash-terminal-ts programs against: the union
|
|
245
245
|
* of every `ctx.*` member touched by src/index.ts and src/terminal.ts.
|
|
246
246
|
*/
|
|
247
247
|
export interface BashTerminalContext {
|
package/lib/dsh-types.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// Hand-written boundary types for the DSH seams this plugin consumes.
|
|
2
|
-
//
|
|
3
|
-
// The @deepseek-ai/* packages ship their own .d.ts, but their full generic
|
|
4
|
-
// surface (cordis Context augmentation, agent/session graphs) is far wider
|
|
5
|
-
// than what a plugin touches. These structural types describe exactly the
|
|
6
|
-
// face this plugin programs against — call them the plugin's side of the
|
|
7
|
-
// contract. Value imports stay on the real packages (see ./dsh.ts); only
|
|
8
|
-
// the shapes live here, so peer version drift cannot ripple into this tree.
|
|
9
|
-
export {};
|
|
1
|
+
// Hand-written boundary types for the DSH seams this plugin consumes.
|
|
2
|
+
//
|
|
3
|
+
// The @deepseek-ai/* packages ship their own .d.ts, but their full generic
|
|
4
|
+
// surface (cordis Context augmentation, agent/session graphs) is far wider
|
|
5
|
+
// than what a plugin touches. These structural types describe exactly the
|
|
6
|
+
// face this plugin programs against — call them the plugin's side of the
|
|
7
|
+
// contract. Value imports stay on the real packages (see ./dsh.ts); only
|
|
8
|
+
// the shapes live here, so peer version drift cannot ripple into this tree.
|
|
9
|
+
export {};
|
package/lib/dsh.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
// Value bridge to the @deepseek-ai/* peer packages.
|
|
2
|
-
//
|
|
3
|
-
// Peer packages ship their own .d.ts, but this plugin's contract with them is
|
|
4
|
-
// a narrow, stable face (see ./dsh-types.ts). Every import passes through one
|
|
5
|
-
// narrow cast here, so the plugin compiles against any 0.1.x peer whose
|
|
6
|
-
// runtime behavior matches the face — no deep generic coupling, no version
|
|
7
|
-
// drift leaking into the rewrite.
|
|
8
|
-
import * as toolsNs from "@deepseek-ai/dsh-tools";
|
|
9
|
-
import * as sandboxNs from "@deepseek-ai/dsh-sandbox";
|
|
10
|
-
import { HarnessError } from "@deepseek-ai/dsh-llm";
|
|
11
|
-
import { parseExitStatus } from "@deepseek-ai/dsh-shell";
|
|
12
|
-
import { clampTimeout, deadline, timeoutOf } from "@deepseek-ai/dsh-timeout";
|
|
13
|
-
import zDefault from "@deepseek-ai/schemastery";
|
|
14
|
-
export { HarnessError, parseExitStatus, clampTimeout, deadline, timeoutOf };
|
|
15
|
-
/** Wrap a fully specified tool spec into a registrable tool definition. */
|
|
16
|
-
export const defineTool = toolsNs.defineTool;
|
|
17
|
-
/** Sentinel code stamped on aborted tool calls. */
|
|
18
|
-
export const TOOL_ABORTED = toolsNs.TOOL_ABORTED;
|
|
19
|
-
/** Escalation modes advertised by the official sandbox seam. */
|
|
20
|
-
export const ESCALATION_TARGETS = sandboxNs.ESCALATION_TARGETS;
|
|
21
|
-
/** Official sandbox escalation (mirrors dsh-tool-bash / dsh-tool-pwsh). */
|
|
22
|
-
export const approveEscalation = sandboxNs.approveEscalation;
|
|
23
|
-
/** Fail-closed validation of the sandbox_permissions / justification pair. */
|
|
24
|
-
export const validateEscalationArgs = sandboxNs.validateEscalationArgs;
|
|
25
|
-
/** Marker appended to denied results so the UI can offer escalation. */
|
|
26
|
-
export const sandboxDenialMarker = sandboxNs.sandboxDenialMarker;
|
|
27
|
-
/** Marker appended to denied results pointing at the escalation affordance. */
|
|
28
|
-
export const escalationHintMarker = sandboxNs.escalationHintMarker;
|
|
29
|
-
export const z = zDefault;
|
|
1
|
+
// Value bridge to the @deepseek-ai/* peer packages.
|
|
2
|
+
//
|
|
3
|
+
// Peer packages ship their own .d.ts, but this plugin's contract with them is
|
|
4
|
+
// a narrow, stable face (see ./dsh-types.ts). Every import passes through one
|
|
5
|
+
// narrow cast here, so the plugin compiles against any 0.1.x peer whose
|
|
6
|
+
// runtime behavior matches the face — no deep generic coupling, no version
|
|
7
|
+
// drift leaking into the rewrite.
|
|
8
|
+
import * as toolsNs from "@deepseek-ai/dsh-tools";
|
|
9
|
+
import * as sandboxNs from "@deepseek-ai/dsh-sandbox";
|
|
10
|
+
import { HarnessError } from "@deepseek-ai/dsh-llm";
|
|
11
|
+
import { parseExitStatus } from "@deepseek-ai/dsh-shell";
|
|
12
|
+
import { clampTimeout, deadline, timeoutOf } from "@deepseek-ai/dsh-timeout";
|
|
13
|
+
import zDefault from "@deepseek-ai/schemastery";
|
|
14
|
+
export { HarnessError, parseExitStatus, clampTimeout, deadline, timeoutOf };
|
|
15
|
+
/** Wrap a fully specified tool spec into a registrable tool definition. */
|
|
16
|
+
export const defineTool = toolsNs.defineTool;
|
|
17
|
+
/** Sentinel code stamped on aborted tool calls. */
|
|
18
|
+
export const TOOL_ABORTED = toolsNs.TOOL_ABORTED;
|
|
19
|
+
/** Escalation modes advertised by the official sandbox seam. */
|
|
20
|
+
export const ESCALATION_TARGETS = sandboxNs.ESCALATION_TARGETS;
|
|
21
|
+
/** Official sandbox escalation (mirrors dsh-tool-bash / dsh-tool-pwsh). */
|
|
22
|
+
export const approveEscalation = sandboxNs.approveEscalation;
|
|
23
|
+
/** Fail-closed validation of the sandbox_permissions / justification pair. */
|
|
24
|
+
export const validateEscalationArgs = sandboxNs.validateEscalationArgs;
|
|
25
|
+
/** Marker appended to denied results so the UI can offer escalation. */
|
|
26
|
+
export const sandboxDenialMarker = sandboxNs.sandboxDenialMarker;
|
|
27
|
+
/** Marker appended to denied results pointing at the escalation affordance. */
|
|
28
|
+
export const escalationHintMarker = sandboxNs.escalationHintMarker;
|
|
29
|
+
export const z = zDefault;
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// dsh-bash-terminal - one shell tool, four Windows terminals.
|
|
1
|
+
// dsh-bash-terminal-ts - one shell tool, four Windows terminals.
|
|
2
2
|
//
|
|
3
3
|
// Registers a model-facing shell tool. The terminal backend (powershell /
|
|
4
4
|
// gitbash / msys2 / wsl) is chosen by the USER in the Web UI settings (default
|
|
@@ -251,7 +251,7 @@ function spawnSpec(resolved, argv, env, signal) {
|
|
|
251
251
|
function collectedOutput(handle) {
|
|
252
252
|
const { stdout, stderr } = handle.collected;
|
|
253
253
|
if (!isCollectedStream(stdout) || !isCollectedStream(stderr)) {
|
|
254
|
-
throw new Error("dsh-bash-terminal: subprocess implementation dropped a requested collect stream");
|
|
254
|
+
throw new Error("dsh-bash-terminal-ts: subprocess implementation dropped a requested collect stream");
|
|
255
255
|
}
|
|
256
256
|
return { stdout, stderr };
|
|
257
257
|
}
|
|
@@ -292,7 +292,7 @@ async function runForeground(ctx, argv, resolved, env, signal, timeoutMs) {
|
|
|
292
292
|
function requireSubprocess(ctx) {
|
|
293
293
|
const subprocess = ctx.subprocess;
|
|
294
294
|
if (subprocess === null) {
|
|
295
|
-
throw new Error("dsh-bash-terminal: ctx.subprocess seam unavailable (missing inject service)");
|
|
295
|
+
throw new Error("dsh-bash-terminal-ts: ctx.subprocess seam unavailable (missing inject service)");
|
|
296
296
|
}
|
|
297
297
|
return subprocess;
|
|
298
298
|
}
|
|
@@ -495,14 +495,14 @@ const BACKGROUND_OUTPUT_PROPERTIES = {
|
|
|
495
495
|
// ---- plugin -------------------------------------------------------------------
|
|
496
496
|
export function apply(ctx, config = {}) {
|
|
497
497
|
if (process.platform !== "win32") {
|
|
498
|
-
ctx.logger?.info?.("dsh-bash-terminal: only meaningful on win32; skipping tool registration");
|
|
498
|
+
ctx.logger?.info?.("dsh-bash-terminal-ts: only meaningful on win32; skipping tool registration");
|
|
499
499
|
return;
|
|
500
500
|
}
|
|
501
501
|
const backgroundEnabled = true;
|
|
502
502
|
const paths = resolveAllPaths(config);
|
|
503
503
|
const defaultShell = config.defaultShell ?? DEFAULT_SHELL;
|
|
504
504
|
if (!SHELLS.includes(defaultShell)) {
|
|
505
|
-
throw new Error(`dsh-bash-terminal: invalid defaultShell ${JSON.stringify(defaultShell)}`);
|
|
505
|
+
throw new Error(`dsh-bash-terminal-ts: invalid defaultShell ${JSON.stringify(defaultShell)}`);
|
|
506
506
|
}
|
|
507
507
|
const settingsScope = ctx.settings.register(SETTINGS_NAMESPACE, z.object({ defaultShell: z.union(SHELLS.map((s) => z.const(s))).default(defaultShell) }), { base: { defaultShell } });
|
|
508
508
|
/** Official sandbox-escalation surface (mirrors tool-bash): advertise the
|
|
@@ -647,7 +647,7 @@ export function apply(ctx, config = {}) {
|
|
|
647
647
|
const shell = settingsScope.get().defaultShell;
|
|
648
648
|
const argv0 = buildArgv(shell, v.command, paths, v.distro);
|
|
649
649
|
if (argv0[0] === undefined) {
|
|
650
|
-
throw new Error(`dsh-bash-terminal: ${shell} backend unavailable - executable not found. Install it or set the corresponding *Path config.`);
|
|
650
|
+
throw new Error(`dsh-bash-terminal-ts: ${shell} backend unavailable - executable not found. Install it or set the corresponding *Path config.`);
|
|
651
651
|
}
|
|
652
652
|
// Only element 0 (the resolved executable) can be undefined; guarded above.
|
|
653
653
|
const argv = argv0;
|
package/lib/terminal.d.ts
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
import type { BashTerminalContext, ResolvedPaths, TerminalHandle } from "./dsh-types.js";
|
|
2
|
-
declare const TERMINAL_SIGNALS: readonly ["SIGINT", "SIGTERM", "SIGKILL", "SIGTSTP", "SIGHUP"];
|
|
3
|
-
export type TerminalSignal = (typeof TERMINAL_SIGNALS)[number];
|
|
4
|
-
interface TerminalBufferRead {
|
|
5
|
-
delta: string;
|
|
6
|
-
nextOffset: number;
|
|
7
|
-
truncated: boolean;
|
|
8
|
-
}
|
|
9
|
-
interface TerminalBuffer {
|
|
10
|
-
append(chunk: string): void;
|
|
11
|
-
readFrom(offset: number): TerminalBufferRead;
|
|
12
|
-
snapshot(): string;
|
|
13
|
-
wasTruncated(): boolean;
|
|
14
|
-
lastAppendAt(): number;
|
|
15
|
-
}
|
|
16
|
-
/** Interactive-shell argv (no -c: the terminal itself is the session). */
|
|
17
|
-
export declare function terminalArgv(shell: string, paths: ResolvedPaths, distro?: string): Array<string | undefined>;
|
|
18
|
-
export interface TerminalSessionInfo {
|
|
19
|
-
sessionId: string;
|
|
20
|
-
shell: string;
|
|
21
|
-
pid: number;
|
|
22
|
-
closed: boolean;
|
|
23
|
-
}
|
|
24
|
-
interface TerminalSession {
|
|
25
|
-
id: string;
|
|
26
|
-
handle: TerminalHandle;
|
|
27
|
-
buffer: TerminalBuffer;
|
|
28
|
-
shell: string;
|
|
29
|
-
distro?: string;
|
|
30
|
-
closed: boolean;
|
|
31
|
-
idleMs: number;
|
|
32
|
-
idleTimer?: NodeJS.Timeout;
|
|
33
|
-
touch: () => void;
|
|
34
|
-
}
|
|
35
|
-
export interface TerminalOpenOptions {
|
|
36
|
-
argv: string[];
|
|
37
|
-
shell: string;
|
|
38
|
-
cwd: string;
|
|
39
|
-
env: Record<string, string | undefined>;
|
|
40
|
-
rows: number;
|
|
41
|
-
cols: number;
|
|
42
|
-
distro?: string;
|
|
43
|
-
initial?: string;
|
|
44
|
-
idleMs?: number;
|
|
45
|
-
}
|
|
46
|
-
export interface TerminalRegistry {
|
|
47
|
-
open(options: TerminalOpenOptions): Promise<TerminalSession>;
|
|
48
|
-
get(id: string): TerminalSession;
|
|
49
|
-
send(id: string, input: string): Promise<TerminalBufferRead>;
|
|
50
|
-
read(id: string): TerminalBufferRead;
|
|
51
|
-
signal(id: string, sig: string): Promise<TerminalBufferRead>;
|
|
52
|
-
close(id: string): Promise<boolean>;
|
|
53
|
-
list(): TerminalSessionInfo[];
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Terminal-session registry owned by the plugin fiber: opens PTYs through
|
|
57
|
-
* the official seam, forwards output into a capped buffer, and tears every
|
|
58
|
-
* session down on plugin disposal.
|
|
59
|
-
*/
|
|
60
|
-
export declare function createTerminalRegistry(ctx: BashTerminalContext): TerminalRegistry;
|
|
61
|
-
/** The terminal tool's arguments after runtime validation (discriminated by action). */
|
|
62
|
-
export type ValidatedTerminalArgs = {
|
|
63
|
-
action: "open";
|
|
64
|
-
sessionId?: string;
|
|
65
|
-
command?: string;
|
|
66
|
-
distro?: string;
|
|
67
|
-
workdir?: string;
|
|
68
|
-
idleMs?: number;
|
|
69
|
-
} | {
|
|
70
|
-
action: "send";
|
|
71
|
-
sessionId: string;
|
|
72
|
-
input: string;
|
|
73
|
-
} | {
|
|
74
|
-
action: "read";
|
|
75
|
-
sessionId: string;
|
|
76
|
-
} | {
|
|
77
|
-
action: "signal";
|
|
78
|
-
sessionId: string;
|
|
79
|
-
signal: TerminalSignal;
|
|
80
|
-
} | {
|
|
81
|
-
action: "close";
|
|
82
|
-
sessionId: string;
|
|
83
|
-
} | {
|
|
84
|
-
action: "list";
|
|
85
|
-
};
|
|
86
|
-
export declare function validateArgs(args: Record<string, unknown>): asserts args is ValidatedTerminalArgs;
|
|
87
|
-
export interface TerminalOpenResult {
|
|
88
|
-
kind: "open";
|
|
89
|
-
sessionId: string;
|
|
90
|
-
jobId?: string;
|
|
91
|
-
pid: number;
|
|
92
|
-
shell: string;
|
|
93
|
-
output: string;
|
|
94
|
-
}
|
|
95
|
-
export interface TerminalSessionResult {
|
|
96
|
-
kind: "session";
|
|
97
|
-
output: string;
|
|
98
|
-
truncated?: boolean;
|
|
99
|
-
}
|
|
100
|
-
export interface TerminalClosedResult {
|
|
101
|
-
kind: "closed";
|
|
102
|
-
sessionId: string;
|
|
103
|
-
}
|
|
104
|
-
export interface TerminalListResult {
|
|
105
|
-
kind: "list";
|
|
106
|
-
sessions: TerminalSessionInfo[];
|
|
107
|
-
}
|
|
108
|
-
export type TerminalToolResult = TerminalOpenResult | TerminalSessionResult | TerminalClosedResult | TerminalListResult;
|
|
109
|
-
export declare function terminalTool(ctx: BashTerminalContext, registry: TerminalRegistry, paths: ResolvedPaths, defaultShell: () => string): import("./dsh-types.js").ToolDefinition;
|
|
110
|
-
export {};
|
|
1
|
+
import type { BashTerminalContext, ResolvedPaths, TerminalHandle } from "./dsh-types.js";
|
|
2
|
+
declare const TERMINAL_SIGNALS: readonly ["SIGINT", "SIGTERM", "SIGKILL", "SIGTSTP", "SIGHUP"];
|
|
3
|
+
export type TerminalSignal = (typeof TERMINAL_SIGNALS)[number];
|
|
4
|
+
interface TerminalBufferRead {
|
|
5
|
+
delta: string;
|
|
6
|
+
nextOffset: number;
|
|
7
|
+
truncated: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface TerminalBuffer {
|
|
10
|
+
append(chunk: string): void;
|
|
11
|
+
readFrom(offset: number): TerminalBufferRead;
|
|
12
|
+
snapshot(): string;
|
|
13
|
+
wasTruncated(): boolean;
|
|
14
|
+
lastAppendAt(): number;
|
|
15
|
+
}
|
|
16
|
+
/** Interactive-shell argv (no -c: the terminal itself is the session). */
|
|
17
|
+
export declare function terminalArgv(shell: string, paths: ResolvedPaths, distro?: string): Array<string | undefined>;
|
|
18
|
+
export interface TerminalSessionInfo {
|
|
19
|
+
sessionId: string;
|
|
20
|
+
shell: string;
|
|
21
|
+
pid: number;
|
|
22
|
+
closed: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface TerminalSession {
|
|
25
|
+
id: string;
|
|
26
|
+
handle: TerminalHandle;
|
|
27
|
+
buffer: TerminalBuffer;
|
|
28
|
+
shell: string;
|
|
29
|
+
distro?: string;
|
|
30
|
+
closed: boolean;
|
|
31
|
+
idleMs: number;
|
|
32
|
+
idleTimer?: NodeJS.Timeout;
|
|
33
|
+
touch: () => void;
|
|
34
|
+
}
|
|
35
|
+
export interface TerminalOpenOptions {
|
|
36
|
+
argv: string[];
|
|
37
|
+
shell: string;
|
|
38
|
+
cwd: string;
|
|
39
|
+
env: Record<string, string | undefined>;
|
|
40
|
+
rows: number;
|
|
41
|
+
cols: number;
|
|
42
|
+
distro?: string;
|
|
43
|
+
initial?: string;
|
|
44
|
+
idleMs?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface TerminalRegistry {
|
|
47
|
+
open(options: TerminalOpenOptions): Promise<TerminalSession>;
|
|
48
|
+
get(id: string): TerminalSession;
|
|
49
|
+
send(id: string, input: string): Promise<TerminalBufferRead>;
|
|
50
|
+
read(id: string): TerminalBufferRead;
|
|
51
|
+
signal(id: string, sig: string): Promise<TerminalBufferRead>;
|
|
52
|
+
close(id: string): Promise<boolean>;
|
|
53
|
+
list(): TerminalSessionInfo[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Terminal-session registry owned by the plugin fiber: opens PTYs through
|
|
57
|
+
* the official seam, forwards output into a capped buffer, and tears every
|
|
58
|
+
* session down on plugin disposal.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createTerminalRegistry(ctx: BashTerminalContext): TerminalRegistry;
|
|
61
|
+
/** The terminal tool's arguments after runtime validation (discriminated by action). */
|
|
62
|
+
export type ValidatedTerminalArgs = {
|
|
63
|
+
action: "open";
|
|
64
|
+
sessionId?: string;
|
|
65
|
+
command?: string;
|
|
66
|
+
distro?: string;
|
|
67
|
+
workdir?: string;
|
|
68
|
+
idleMs?: number;
|
|
69
|
+
} | {
|
|
70
|
+
action: "send";
|
|
71
|
+
sessionId: string;
|
|
72
|
+
input: string;
|
|
73
|
+
} | {
|
|
74
|
+
action: "read";
|
|
75
|
+
sessionId: string;
|
|
76
|
+
} | {
|
|
77
|
+
action: "signal";
|
|
78
|
+
sessionId: string;
|
|
79
|
+
signal: TerminalSignal;
|
|
80
|
+
} | {
|
|
81
|
+
action: "close";
|
|
82
|
+
sessionId: string;
|
|
83
|
+
} | {
|
|
84
|
+
action: "list";
|
|
85
|
+
};
|
|
86
|
+
export declare function validateArgs(args: Record<string, unknown>): asserts args is ValidatedTerminalArgs;
|
|
87
|
+
export interface TerminalOpenResult {
|
|
88
|
+
kind: "open";
|
|
89
|
+
sessionId: string;
|
|
90
|
+
jobId?: string;
|
|
91
|
+
pid: number;
|
|
92
|
+
shell: string;
|
|
93
|
+
output: string;
|
|
94
|
+
}
|
|
95
|
+
export interface TerminalSessionResult {
|
|
96
|
+
kind: "session";
|
|
97
|
+
output: string;
|
|
98
|
+
truncated?: boolean;
|
|
99
|
+
}
|
|
100
|
+
export interface TerminalClosedResult {
|
|
101
|
+
kind: "closed";
|
|
102
|
+
sessionId: string;
|
|
103
|
+
}
|
|
104
|
+
export interface TerminalListResult {
|
|
105
|
+
kind: "list";
|
|
106
|
+
sessions: TerminalSessionInfo[];
|
|
107
|
+
}
|
|
108
|
+
export type TerminalToolResult = TerminalOpenResult | TerminalSessionResult | TerminalClosedResult | TerminalListResult;
|
|
109
|
+
export declare function terminalTool(ctx: BashTerminalContext, registry: TerminalRegistry, paths: ResolvedPaths, defaultShell: () => string): import("./dsh-types.js").ToolDefinition;
|
|
110
|
+
export {};
|