@hyzyn/dsh-tty 0.1.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.md +123 -0
- package/client.js +285 -0
- package/cordis.patch.yml +8 -0
- package/lib/index.d.ts +47 -0
- package/lib/index.js +768 -0
- package/lib/index.js.map +1 -0
- package/package.json +65 -0
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# dsh-plugin-kit/tty bundle patch:把本插件行插入 profile 阵容。
|
|
2
|
+
# 作为 profile bundle 层(package.json 的 dsh.bundle.patch 字段)叠加到
|
|
3
|
+
# dsh-base 之上;启用方式:
|
|
4
|
+
# dsh plugin --profile web add link:$(pwd)/packages/tty
|
|
5
|
+
# 行内容为按包名注册的裸插件行:exports "." 的 node 半体运行在宿主进程。
|
|
6
|
+
- insert:
|
|
7
|
+
- id: tty
|
|
8
|
+
name: '@hyzyn/dsh-tty'
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hyzyn/dsh-tty — DSH Web GUI 的终端面板插件(宿主半体)。
|
|
3
|
+
*
|
|
4
|
+
* 机制:浏览器半体打开「终端」大弹窗后,经 WebSocket 连接
|
|
5
|
+
* /api/dsh-tty/ws(webServer.registerUpgrade 注册的 upgrade 路由),
|
|
6
|
+
* spawn 帧创建真实 PTY 会话(ctx.subprocess.spawnTerminal,node-pty),
|
|
7
|
+
* 之后双向透传:input/resize/kill 上行,data/exit/error 下行。
|
|
8
|
+
*
|
|
9
|
+
* 帧协议 v2(JSON 文本帧;sid 维度支持单连接多会话/标签页):
|
|
10
|
+
* C→S {t:'spawn', sid?, cols?, rows?, cwd?} 创建会话;sid 缺省时宿主生成
|
|
11
|
+
* C→S {t:'input', sid?, d} 按键/粘贴数据
|
|
12
|
+
* C→S {t:'resize', sid?, cols, rows} xterm fit 触发
|
|
13
|
+
* C→S {t:'kill', sid?} 关闭会话
|
|
14
|
+
* S→C {t:'ready', sid, pid} 会话就绪
|
|
15
|
+
* S→C {t:'data', sid, d} 终端输出(utf8 文本)
|
|
16
|
+
* S→C {t:'exit', sid, code, signal} PTY 退出事实(恰好一次)
|
|
17
|
+
* S→C {t:'error', sid?, m} 错误
|
|
18
|
+
* 省略 sid 时按「该连接唯一会话」路由;连接上存在 0 或多个会话时省略 sid 报错。
|
|
19
|
+
* 旧脚本(spawn 不带 sid)自动兼容:宿主生成 sid,响应帧多带 sid 字段。
|
|
20
|
+
*
|
|
21
|
+
* M0 探针(scripts/probe.mjs)验证过的三个关键结论:
|
|
22
|
+
* 1. TERM 必须用 `shell -c 'export TERM=...; exec "$shell"'` 包装层注入——
|
|
23
|
+
* DSH 的 spawnTerminal 硬编码 node-pty name:"dumb",且 node-pty 里
|
|
24
|
+
* name 优先于 env.TERM,直接传 env 覆盖无效;
|
|
25
|
+
* 2. resize 通过 (handle).terminal.resize(cols, rows) 透传 node-pty 原生
|
|
26
|
+
* API(DSH 的 terminal handle 未暴露 resize,属内部耦合,见 README);
|
|
27
|
+
* 3. terminate() 偶发「幸存者」竞态(SIGTERM→SIGKILL 升级后仍扫描到存活
|
|
28
|
+
* 子进程),必须 best-effort:失败降级为对顶层 shell 直接 SIGKILL。
|
|
29
|
+
*/
|
|
30
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
31
|
+
export interface Config {
|
|
32
|
+
/** 关闭整个插件。默认开。 */
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
/** 是否向 agent 注入插件能力公告。默认开。 */
|
|
35
|
+
announceToAgent?: boolean;
|
|
36
|
+
/** 并发 PTY 会话上限(1~16)。默认 4。 */
|
|
37
|
+
maxSessions?: number;
|
|
38
|
+
/** shell 路径;缺省 $SHELL(macOS 上通常 /bin/zsh)。 */
|
|
39
|
+
shell?: string;
|
|
40
|
+
/** TERM 值(经 -c 包装层注入)。默认 xterm-256color。 */
|
|
41
|
+
term?: string;
|
|
42
|
+
/** COLORTERM 值。默认 truecolor。 */
|
|
43
|
+
colorTerm?: string;
|
|
44
|
+
/** 会话工作目录(客户端 spawn 带 cwd 时优先);缺省为宿主进程启动目录。 */
|
|
45
|
+
cwd?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const name: string, inject: string[] | undefined, apply: (ctx: Context, config?: Config | undefined) => void;
|