@ohmynpm/dsh-baton 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +159 -2
- package/README.zh-CN.md +135 -0
- package/client.js +901 -0
- package/connection.js +397 -0
- package/cordis.patch.yml +8 -0
- package/icon.svg +5 -0
- package/index.js +498 -0
- package/locale/en.json +1 -0
- package/locale/zh.json +1 -0
- package/package.json +64 -4
- package/session.js +221 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Baton contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,160 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Baton DSH plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
English | [中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
The DSH side of Baton: receive a teammate's task, approve it, and start a Session
|
|
6
|
+
in a directory you configured. The relay server lives in a separate repository:
|
|
7
|
+
[dsh-team-baton](https://github.com/Of-qinhai/dsh-team-baton).
|
|
8
|
+
|
|
9
|
+
Public source does not connect to any server by default. You deploy the server
|
|
10
|
+
yourself, or get your team's endpoint and shared secret from its administrator.
|
|
11
|
+
|
|
12
|
+
## Requirements
|
|
13
|
+
|
|
14
|
+
- DSH Desktop. Verified on Electron 44 / Node 24; other versions may change the
|
|
15
|
+
`sessionController` / `workspaceRegistry` / `uiWorkspace` interfaces used here.
|
|
16
|
+
- A running `baton-server`, or your team's endpoint and secret.
|
|
17
|
+
- Node 22+ only for the development tests and preview; the installed plugin uses
|
|
18
|
+
DSH's own React and needs no build.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
The package ships a **safe placeholder** `cordis.patch.yml` (empty `serverUrl`),
|
|
23
|
+
so the bundle can be installed before it is configured. Configure it through your
|
|
24
|
+
DSH profile after installation.
|
|
25
|
+
|
|
26
|
+
### 1. Put the team secret in place
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
mkdir -p ~/.config/baton
|
|
30
|
+
printf '%s\n' '<team secret>' > ~/.config/baton/secret
|
|
31
|
+
chmod 700 ~/.config/baton
|
|
32
|
+
chmod 600 ~/.config/baton/secret
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`secretFile` defaults to this path; `BATON_SECRET` in the environment takes
|
|
36
|
+
precedence when non-empty.
|
|
37
|
+
|
|
38
|
+
### 2. Install the plugin
|
|
39
|
+
|
|
40
|
+
Paste the repository URL into the plugin manager's Git repository field (the
|
|
41
|
+
dialog that shows **Git 仓库**), or clone and install the local directory:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
git clone https://github.com/Of-qinhai/dsh-team-baton-client.git
|
|
45
|
+
# then, in DSH:
|
|
46
|
+
plugin_manager install_bundle target=/absolute/path/to/dsh-team-baton-client
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The install requires approval.
|
|
50
|
+
|
|
51
|
+
### 3. Configure in the profile patch
|
|
52
|
+
|
|
53
|
+
Open the profile's `cordis.patch.yml`:
|
|
54
|
+
|
|
55
|
+
- macOS/Linux: `~/.dsh/profiles/<profile>/cordis.patch.yml`
|
|
56
|
+
- Windows: `%USERPROFILE%\.dsh\profiles\<profile>\cordis.patch.yml`
|
|
57
|
+
|
|
58
|
+
Add a **complete override row** (the same id replaces the whole config, so keep
|
|
59
|
+
`serverUrl`):
|
|
60
|
+
|
|
61
|
+
```yaml
|
|
62
|
+
- id: baton
|
|
63
|
+
name: '@ohmynpm/dsh-baton'
|
|
64
|
+
config:
|
|
65
|
+
serverUrl: wss://baton.example.com/ws
|
|
66
|
+
# secretFile: /absolute/path/to/secret # defaults to ~/.config/baton/secret
|
|
67
|
+
displayName: Your name
|
|
68
|
+
environments:
|
|
69
|
+
- { key: frontend, label: Frontend, cwd: /absolute/path/to/web }
|
|
70
|
+
- { key: backend, label: Backend, cwd: /absolute/path/to/api }
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Do not edit the copy under `node_modules`; it is replaced on reinstall.
|
|
74
|
+
|
|
75
|
+
### 4. Restart and refresh
|
|
76
|
+
|
|
77
|
+
Restart DSH, then refresh the page. The sidebar entry sits below Automation Tasks.
|
|
78
|
+
|
|
79
|
+
A non-localhost `serverUrl` must use `wss://`; `secretFile` must be absolute and
|
|
80
|
+
mode 0600. Never commit your endpoint, secret, or local paths.
|
|
81
|
+
|
|
82
|
+
## Environments
|
|
83
|
+
|
|
84
|
+
Each install configures its own directories visually: the folder button in the
|
|
85
|
+
panel header opens **本机执行环境**. Add a key, a display label, and an absolute
|
|
86
|
+
local directory per environment. The list is saved to
|
|
87
|
+
`~/.dsh/baton/environments.json` (0600).
|
|
88
|
+
|
|
89
|
+
Only the key and label are advertised to room members; absolute paths never leave
|
|
90
|
+
the machine. A sender therefore picks an environment from the recipient's own
|
|
91
|
+
advertised list, and the recipient still resolves it to its own directory. The
|
|
92
|
+
`environments` block in the profile config is only the initial seed for a fresh
|
|
93
|
+
install; once the visual editor saves, the local file is authoritative.
|
|
94
|
+
|
|
95
|
+
## Panel
|
|
96
|
+
|
|
97
|
+
The sidebar entry sits below Automation Tasks. Clicking it opens the inbox in the
|
|
98
|
+
main area: rooms on the left, tasks in the middle, task detail on the right. Only
|
|
99
|
+
**Accept and start** creates a Session and submits the brief. Declining only
|
|
100
|
+
updates state. A `needs review` task can only be dismissed manually.
|
|
101
|
+
|
|
102
|
+
The sender chooses an environment key; this install maps it to its own absolute
|
|
103
|
+
`cwd`. Remote paths are never sent and there is no fallback directory.
|
|
104
|
+
|
|
105
|
+
## Task visibility and layout
|
|
106
|
+
|
|
107
|
+
Both inbox and sent items support **Delete** (move to the deleted-items tab),
|
|
108
|
+
restore, and a separately confirmed permanent deletion. One participant's action
|
|
109
|
+
does not remove the other participant's copy. After both permanently delete,
|
|
110
|
+
the relay removes the live task/brief and retains only its ID and original expiry
|
|
111
|
+
to prevent retry resurrection. The existing seven-day expiry remains in effect;
|
|
112
|
+
older backups expire on their normal retention schedule. DSH sessions and messages
|
|
113
|
+
are never deleted or resubmitted by any of these actions.
|
|
114
|
+
|
|
115
|
+
The left navigation can collapse, and all three lists scroll within their pane,
|
|
116
|
+
including short desktop windows and narrow screens. Directory configuration is
|
|
117
|
+
validated and persisted locally, with only keys/labels advertised to room peers.
|
|
118
|
+
Offline saves sync on reconnect; publication failures explicitly say that the
|
|
119
|
+
local save succeeded but peers have not yet received the change.
|
|
120
|
+
|
|
121
|
+
## Agent tools
|
|
122
|
+
|
|
123
|
+
Only three tools are registered: `team_rooms`, `team_task_send`, and `team_tasks`.
|
|
124
|
+
Approval is not exposed to the agent, and remote titles, briefs, and display names
|
|
125
|
+
never enter the current Agent context.
|
|
126
|
+
|
|
127
|
+
## Updates
|
|
128
|
+
|
|
129
|
+
The package version is bumped for every release. Automatic update checks only
|
|
130
|
+
work when the plugin is installed from an npm registry package:
|
|
131
|
+
|
|
132
|
+
- **npm install**: the plugin manager can compare the installed version with the
|
|
133
|
+
registry and offer an update.
|
|
134
|
+
- **Git URL or local directory**: there is no default registry source, so the
|
|
135
|
+
plugin manager shows "unable to check for updates"; reinstall the latest
|
|
136
|
+
commit or release tarball instead.
|
|
137
|
+
|
|
138
|
+
This package is currently `private: true`, so it is not published to npm and a
|
|
139
|
+
Git/local install cannot auto-check. Publishing requires setting `private` to
|
|
140
|
+
`false`, choosing a reachable package name/registry, and bumping the version for
|
|
141
|
+
each release.
|
|
142
|
+
|
|
143
|
+
## Development
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
npm ci
|
|
147
|
+
npm test # Host, connection, checkpoint and local setup regressions
|
|
148
|
+
npm run preview # http://127.0.0.1:4371, in-memory sample data
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`npm run test:flow` and `npm run test:integration` additionally need the Rust
|
|
152
|
+
server checkout; see the comments in those scripts. Browser regression
|
|
153
|
+
(`npm run test:client`) needs `playwright/test` and Chromium installed separately.
|
|
154
|
+
`npm run test:tasks` additionally covers directory configuration, independent
|
|
155
|
+
deletion/restoration, navigation collapse and 160-task scrolling at desktop and
|
|
156
|
+
mobile sizes, using fixture data and the actual embedded React client.
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
[MIT](LICENSE)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Baton DSH 插件
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
Baton 的 DSH 侧:接收队友的任务、人工确认后在你配置的目录里启动会话。
|
|
6
|
+
中继服务端在独立仓库:[dsh-team-baton](https://github.com/Of-qinhai/dsh-team-baton)。
|
|
7
|
+
|
|
8
|
+
公开源码默认不连接任何服务器。你需要自己部署服务端,或向团队管理员获取服务地址和共享密钥。
|
|
9
|
+
|
|
10
|
+
## 要求
|
|
11
|
+
|
|
12
|
+
- DSH Desktop。已在 Electron 44 / Node 24 验证;其他版本可能改变
|
|
13
|
+
`sessionController` / `workspaceRegistry` / `uiWorkspace` 的接口。
|
|
14
|
+
- 一个运行中的 `baton-server`,或团队的服务地址和密钥。
|
|
15
|
+
- Node 22+ 仅用于开发测试和预览;安装版复用 DSH 的 React,不需要构建。
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
插件包自带一个**安全的占位** `cordis.patch.yml`(`serverUrl` 为空),所以可以先安装、
|
|
20
|
+
再通过 DSH profile 配置,不会因为缺少 patch 文件安装失败。
|
|
21
|
+
|
|
22
|
+
### 1. 放团队密钥
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
mkdir -p ~/.config/baton
|
|
26
|
+
printf '%s\n' '<团队密钥>' > ~/.config/baton/secret
|
|
27
|
+
chmod 700 ~/.config/baton
|
|
28
|
+
chmod 600 ~/.config/baton/secret
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`secretFile` 默认读这个路径;环境变量 `BATON_SECRET` 非空时优先。
|
|
32
|
+
|
|
33
|
+
### 2. 安装插件
|
|
34
|
+
|
|
35
|
+
在插件管理器的 Git 仓库输入框粘贴仓库地址(就是截图里显示「Git 仓库」的弹窗),
|
|
36
|
+
或 clone 后安装本地目录:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
git clone https://github.com/Of-qinhai/dsh-team-baton-client.git
|
|
40
|
+
# 然后在 DSH 里:
|
|
41
|
+
plugin_manager install_bundle target=/绝对路径/dsh-team-baton-client
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
安装需要批准。
|
|
45
|
+
|
|
46
|
+
### 3. 在 profile patch 里配置
|
|
47
|
+
|
|
48
|
+
打开 profile 的 `cordis.patch.yml`:
|
|
49
|
+
|
|
50
|
+
- macOS/Linux:`~/.dsh/profiles/<profile>/cordis.patch.yml`
|
|
51
|
+
- Windows:`%USERPROFILE%\.dsh\profiles\<profile>\cordis.patch.yml`
|
|
52
|
+
|
|
53
|
+
加一条**完整覆盖行**(同 id 会替换整个 config,所以 `serverUrl` 必须一起写):
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
56
|
+
- id: baton
|
|
57
|
+
name: '@ohmynpm/dsh-baton'
|
|
58
|
+
config:
|
|
59
|
+
serverUrl: wss://baton.example.com/ws
|
|
60
|
+
# secretFile: /绝对路径/secret # 默认 ~/.config/baton/secret
|
|
61
|
+
displayName: 你的名字
|
|
62
|
+
environments:
|
|
63
|
+
- { key: frontend, label: 前端, cwd: /绝对路径/前端 }
|
|
64
|
+
- { key: backend, label: 后端, cwd: /绝对路径/后端 }
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
不要修改 `node_modules` 下的那份 patch,它会在重装时被替换。
|
|
68
|
+
|
|
69
|
+
### 4. 重启并刷新
|
|
70
|
+
|
|
71
|
+
重启 DSH,再刷新页面。侧边栏入口在「自动化任务」下面。
|
|
72
|
+
|
|
73
|
+
非 localhost 的 `serverUrl` 必须用 `wss://`;`secretFile` 必须是绝对路径且权限 0600。
|
|
74
|
+
永远不要提交服务地址、密钥或本机路径。
|
|
75
|
+
|
|
76
|
+
## 执行环境
|
|
77
|
+
|
|
78
|
+
每个安装自己可视化配置目录:点面板顶部的文件夹按钮打开「本机执行环境」,
|
|
79
|
+
为每个环境填写 key、显示名称和本机绝对目录。配置保存在
|
|
80
|
+
`~/.dsh/baton/environments.json`(0600)。
|
|
81
|
+
|
|
82
|
+
只有 key 和名称会暴露给同房间成员,绝对路径不会离开本机。因此发送方是从
|
|
83
|
+
**对方的**已公开环境列表里选择,接收方仍映射到自己的目录。profile 配置里的
|
|
84
|
+
`environments` 只是新安装的初始种子;可视化编辑器保存后,以本机文件为准。
|
|
85
|
+
|
|
86
|
+
保存时会验证目录存在并转换为规范化绝对路径。断线时可以保存,重连后上报;
|
|
87
|
+
如果本机保存成功但上报失败,面板会明确提示,避免把“已保存”误认为“对方已收到”。
|
|
88
|
+
|
|
89
|
+
## 任务删除与列表
|
|
90
|
+
|
|
91
|
+
- 收件箱和已发出的任务均可首次删除,移入“已删除”;对方的列表和关联会话不受影响。
|
|
92
|
+
- 在“已删除”中可以恢复,也可以二次确认永久删除。你确认后无法再恢复或审批该任务。
|
|
93
|
+
- 只有双方都确认永久删除,服务端才清理在线数据库中的任务正文;保留最小的任务 ID/有效期,
|
|
94
|
+
避免网络重试重新创建已删除任务。原有七天过期策略继续生效,已有备份按保留周期过期。
|
|
95
|
+
- 删除或恢复任务始终不会删除 DSH 会话,也不会重新提交消息。
|
|
96
|
+
- 左侧导航支持折叠/展开,任务列表在收件箱、已发出的和已删除三个标签中独立滚动。
|
|
97
|
+
|
|
98
|
+
## 面板
|
|
99
|
+
|
|
100
|
+
侧边栏入口在「自动化任务」下面。点开后右侧主区域显示收件箱:左侧房间、中间任务、
|
|
101
|
+
右侧详情。只有「接受并启动」才创建会话并提交 brief;拒绝只更新状态。
|
|
102
|
+
`需核对` 只能人工确认后收起。
|
|
103
|
+
|
|
104
|
+
发送方选择环境 key,本机把它映射到自己的绝对 `cwd`;不传远端路径,也没有默认回退目录。
|
|
105
|
+
|
|
106
|
+
## Agent 工具
|
|
107
|
+
|
|
108
|
+
只注册三个工具:`team_rooms`、`team_task_send`、`team_tasks`。
|
|
109
|
+
审批入口不暴露给 Agent,远端标题、brief 和显示名不会进入当前 Agent 上下文。
|
|
110
|
+
|
|
111
|
+
## 更新
|
|
112
|
+
|
|
113
|
+
每次发布都会递增版本号。**只有从 npm registry 安装**时,插件管理器才能检查更新:
|
|
114
|
+
|
|
115
|
+
- **npm 安装**:插件管理器可以比较本地版本和 registry 版本并提示更新。
|
|
116
|
+
- **Git 地址或本地目录安装**:没有默认 registry 来源,所以会显示“无法检查更新”;
|
|
117
|
+
需要重新安装最新提交或 Release 包。
|
|
118
|
+
|
|
119
|
+
当前包仍是 `private: true`,没有发布到 npm,所以 Git/本地安装不能自动检查。
|
|
120
|
+
启用自动检查需要把 `private` 改为 `false`、选择可访问的包名/registry,并在每次发布递增版本号。
|
|
121
|
+
|
|
122
|
+
## 开发
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
npm ci
|
|
126
|
+
npm test # 51 个单元测试
|
|
127
|
+
npm run preview # http://127.0.0.1:4371,内存示例数据
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`npm run test:flow` / `npm run test:integration` 还需要 Rust 服务端源码;
|
|
131
|
+
浏览器回归 `npm run test:client` 需要单独安装 `playwright/test` 和 Chromium。
|
|
132
|
+
|
|
133
|
+
## 许可证
|
|
134
|
+
|
|
135
|
+
[MIT](LICENSE)
|