@hyzyn/dsh-tty 0.26.0 → 0.27.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.
- package/README.en.md +37 -1
- package/README.md +31 -1
- package/client.js +26 -11
- package/lib/index.d.ts +4 -0
- package/lib/index.js +44 -5
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
package/lib/index.d.ts
CHANGED
|
@@ -74,6 +74,7 @@ import WebSocket from 'ws';
|
|
|
74
74
|
import xtermHeadless from '@xterm/headless';
|
|
75
75
|
declare const HeadlessTerminal: typeof xtermHeadless.Terminal;
|
|
76
76
|
type HeadlessTerminal = InstanceType<typeof HeadlessTerminal>;
|
|
77
|
+
import type { TierClass } from '@hyzyn/dsh-kit';
|
|
77
78
|
import type { HostKeyRecord, SshHostEntry, TermHandle } from './ssh.js';
|
|
78
79
|
import type { TunnelSpec } from './tunnels.js';
|
|
79
80
|
import type { StatsFrame } from './stats.js';
|
|
@@ -179,6 +180,9 @@ export declare const Config: z;
|
|
|
179
180
|
* 条数上限的行为护栏。
|
|
180
181
|
*/
|
|
181
182
|
export declare const EXITED_RETAIN_MS: number;
|
|
183
|
+
export declare const TTY_TIER_CLASS: Record<string, TierClass>;
|
|
184
|
+
/** 本插件 agent 工具的名单前缀(档位闸只听这些名字,bash / 其它插件工具零介入)。 */
|
|
185
|
+
export declare const TTY_TIER_PREFIXES: readonly ["tty_", "sftp_", "tunnel_"];
|
|
182
186
|
/**
|
|
183
187
|
* 只读保留的会话数上限(超出按最旧淘汰,见 SessionManager.capExited)。
|
|
184
188
|
*
|
package/lib/index.js
CHANGED
|
@@ -15,7 +15,7 @@ const HeadlessTerminal = xtermHeadless.Terminal;
|
|
|
15
15
|
import { definePlugin, dshHome as resolveDshHome, getService, hasSameOriginProof, isLoopbackRequestStrict, plainConfig, settingsEntryScope, suppressAutoSettingsPage } from '@hyzyn/dsh-kit';
|
|
16
16
|
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
17
17
|
import { sanitizeJumpSpec, sanitizeProxyCommand, spawnSsh, sshTarget, expandHome, setCredentialResolver, setProxyCommandPolicy, validateJumpSpec, validateProxyCommand } from './ssh.js';
|
|
18
|
-
import { sharedGrantStore, auditLoadedGrants, bindCapabilitySources, capabilityDeniedMessage, capabilityGrantAt, capabilityGrantVia, capabilityGranted, capabilityPaths, createElevationManager, } from '@hyzyn/dsh-kit';
|
|
18
|
+
import { sharedGrantStore, auditLoadedGrants, attachTierGate, bindCapabilitySources, capabilityDeniedMessage, capabilityGrantAt, capabilityGrantVia, capabilityGranted, capabilityPaths, createElevationManager, } from '@hyzyn/dsh-kit';
|
|
19
19
|
import { probeSsh } from './probe.js';
|
|
20
20
|
import { buildCommandSpawn, buildShellSpawn, commandShellHint, defaultShellPath } from './shell-integration.js';
|
|
21
21
|
import { KEY_VOCABULARY, resolveKeys } from './keys.js';
|
|
@@ -169,6 +169,37 @@ const DEFAULT_RECONNECT_GRACE_SEC = 120;
|
|
|
169
169
|
* 条数上限的行为护栏。
|
|
170
170
|
*/
|
|
171
171
|
export const EXITED_RETAIN_MS = Number.POSITIVE_INFINITY;
|
|
172
|
+
/*
|
|
173
|
+
* 档位闸的分类表(docs/permission-tier-plan.md §2.1):`read` 纯读;`write` 有界变更(远程
|
|
174
|
+
* ≤1MB 文本 / 目录 / 停隧道转发);`exec` 无界命令面——tty_open / tty_run / tty_send 能在本机
|
|
175
|
+
* 或远程 shell 里跑任意命令(tty_send 是往**活 shell** 里敲命令,同样是执行面),tunnel_start
|
|
176
|
+
* 在本机开监听端口。名单必须与 registerAll 注册的工集一一对应:对账由 test/tier-gate.test.ts
|
|
177
|
+
* 从注册处的启动日志行现算(漏分类 → 红)。悬而未决的格子(R2 tty_close / R3 tunnel_start)
|
|
178
|
+
* 按方案推荐值落,改格子就是改这张表。
|
|
179
|
+
*/
|
|
180
|
+
export const TTY_TIER_CLASS = {
|
|
181
|
+
tty_list: 'read',
|
|
182
|
+
tty_capture: 'read',
|
|
183
|
+
tty_screen: 'read',
|
|
184
|
+
tty_expect: 'read',
|
|
185
|
+
tty_stats: 'read',
|
|
186
|
+
tunnel_list: 'read',
|
|
187
|
+
sftp_list: 'read',
|
|
188
|
+
sftp_read: 'read',
|
|
189
|
+
sftp_tree: 'read',
|
|
190
|
+
tty_close: 'read',
|
|
191
|
+
sftp_write: 'write',
|
|
192
|
+
sftp_mkdir: 'write',
|
|
193
|
+
sftp_rename: 'write',
|
|
194
|
+
sftp_remove: 'write',
|
|
195
|
+
tunnel_stop: 'write',
|
|
196
|
+
tty_open: 'exec',
|
|
197
|
+
tty_run: 'exec',
|
|
198
|
+
tty_send: 'exec',
|
|
199
|
+
tunnel_start: 'exec',
|
|
200
|
+
};
|
|
201
|
+
/** 本插件 agent 工具的名单前缀(档位闸只听这些名字,bash / 其它插件工具零介入)。 */
|
|
202
|
+
export const TTY_TIER_PREFIXES = ['tty_', 'sftp_', 'tunnel_'];
|
|
172
203
|
/**
|
|
173
204
|
* 只读保留的会话数上限(超出按最旧淘汰,见 SessionManager.capExited)。
|
|
174
205
|
*
|
|
@@ -3525,7 +3556,7 @@ const plugin = definePlugin({
|
|
|
3525
3556
|
* 「静默继承」必须在日志里留下痕迹(kit D09)。刻意放在 `enabled` 判定**之前**:授权是宿主级的,
|
|
3526
3557
|
* 与插件这次是否启用无关。
|
|
3527
3558
|
*/
|
|
3528
|
-
auditLoadedGrants(grantStore, [CAP_PROXY_COMMAND.env],
|
|
3559
|
+
auditLoadedGrants(grantStore, [CAP_PROXY_COMMAND.env], '[dsh-tty]');
|
|
3529
3560
|
// volatile 字段解析后是 `{ get() }` 引用,先还原成纯数据(见 @hyzyn/dsh-kit 的 plainConfig)。
|
|
3530
3561
|
const config = plainConfig((rawConfig ?? {}));
|
|
3531
3562
|
if (config?.enabled === false)
|
|
@@ -4747,9 +4778,11 @@ const plugin = definePlugin({
|
|
|
4747
4778
|
}, 'dsh-tty: settings');
|
|
4748
4779
|
});
|
|
4749
4780
|
// agent 工具集(P1):tty_list / tty_open / tty_close / tty_stats / tty_capture / tty_send …
|
|
4750
|
-
//
|
|
4751
|
-
//
|
|
4752
|
-
//
|
|
4781
|
+
// 信任模型(2026-10-07 起,档位闸落地):注册仍只受 enabled 门控,但**每次调用**受会话权限
|
|
4782
|
+
// 档位约束——受限档(仅可查看 / 工作区内修改)下 write/exec 类要经宿主 approval 服务逐次
|
|
4783
|
+
// 确认,完全权限档零询问(机制见 kit 的 tier-gate.ts,方案见 docs/permission-tier-plan.md)。
|
|
4784
|
+
// 「agent 对终端的操作实时出现在面板里」的可见性仍然成立,但不再是唯一的监督手段——
|
|
4785
|
+
// 旧注释「与 bash 工具同权、不额外加确认层」描述的是档位闸落地前的模型,已作废。
|
|
4753
4786
|
const toolsHost = ctx.get('tools');
|
|
4754
4787
|
if (toolsHost !== undefined) {
|
|
4755
4788
|
ctx.effect(() => {
|
|
@@ -5901,6 +5934,12 @@ const plugin = definePlugin({
|
|
|
5901
5934
|
return result;
|
|
5902
5935
|
},
|
|
5903
5936
|
})));
|
|
5937
|
+
// 档位闸与工具同生命周期:enabled 热切换撤工具时一并撤下(activeDisposers 统一管理)。
|
|
5938
|
+
activeDisposers.push(attachTierGate(ctx, {
|
|
5939
|
+
pkg: 'tty',
|
|
5940
|
+
prefixes: TTY_TIER_PREFIXES,
|
|
5941
|
+
classify: (tool) => TTY_TIER_CLASS[tool],
|
|
5942
|
+
}));
|
|
5904
5943
|
stateRef.toolsRegistered = true;
|
|
5905
5944
|
console.log('[dsh-tty] agent tools registered (tty_list, tty_open, tty_close, tty_run, tty_stats, tty_capture, tty_screen, tty_expect, tty_send, tunnel_list, tunnel_start, tunnel_stop, sftp_list, sftp_read, sftp_write, sftp_mkdir, sftp_rename, sftp_remove, sftp_tree)');
|
|
5906
5945
|
};
|