dsh-cothread-mcp 0.1.1 → 0.1.4
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/CHANGELOG.md +34 -0
- package/README.md +56 -18
- package/icon.svg +7 -4
- package/lib/client.js +732 -0
- package/package.json +21 -3
- package/scripts/build.mjs +61 -0
- package/src/authorization.js +144 -0
- package/src/automation.js +599 -0
- package/src/device.js +86 -0
- package/src/environments.js +18 -0
- package/src/events.js +7 -0
- package/src/index.js +81 -25
- package/src/service.js +640 -0
- package/src/state.js +78 -0
- package/src/version.js +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.4
|
|
4
|
+
- Fix the automation task update failing with `cannot get property "sessions" without inject`. The session-naming helper read the host's session registry through the context's property access, which Cordis rejects unless the plugin declares the service as an injected dependency; the error escaped the task assembly and left the settings saved but the automation task unchanged. The service is now read the same lenient way as every other host service the plugin uses, so a missing registry only means the session stays unnamed.
|
|
5
|
+
|
|
6
|
+
## 0.1.3
|
|
7
|
+
- Remove the custom environment: only 正式环境 and 本地环境 remain. The environment picker in the settings page and the one in the sidebar's account menu no longer offer a custom option, and the custom service-address input is gone. A configuration saved with the old custom environment is normalized to 正式环境 instead of failing to load, so the plugin keeps working after the update. The authorization flow itself is unchanged.
|
|
8
|
+
- Match the sidebar entry to the native DSH account row: the account label keeps the native 14px weight, the environment name is 12px, and the row's inline padding is 8px on both sides, so the CoThread row, the MiniMax usage row and the native account row line up. The signed-in menu now offers 「自动化设置」 with a gear glyph instead of 「共序自动化」, and the sidebar panel entry uses the native workspace-tree glyph so its stroke weight and padding match the other panel rows.
|
|
9
|
+
- The sidebar account entry now opens a native-style menu when signed in, with 「共序自动化」 (switches to the sidebar's CoThread automation panel) and 「退出登录」, instead of the previous account card. The entry keeps its own row above the DSH account row and matches the native account row's metrics (44px row, 24px avatar, 14px label).
|
|
10
|
+
- Rename the user-facing wording from 「本地执行器」 to 「Agent 插件」 to match the service's new terminology. Protocol paths, table names and code identifiers are unchanged.
|
|
11
|
+
- Add `npm run build`: the release flow had no build step because the browser bundle is hand-written, so the script validates the release instead — every source file parses, the packaging manifest covers what is actually published, and the CHANGELOG carries the current version.
|
|
12
|
+
- Add a CoThread account entry at the sidebar foot, above the DSH account row: when signed out it shows the CoThread logo and 「未授权」, and clicking it opens the environment picker to start the browser authorization; when signed in it shows the account avatar and nickname followed by the current environment, and clicking it opens the account details with a sign-out button. The 「共序自动化」 settings page is unchanged.
|
|
13
|
+
- Keep one stable device identity per machine: the device id is persisted in `~/.dsh/plugins/dsh-cothread-mcp/device.json` and reused on every authorization. The CoThread server matches devices by `device_id`, so a fresh id on every run made each authorization look like a new device, revoked the old one and collided with the "one active binding per member" unique index ("记录已存在" in the browser). A missing, corrupt or non-UUID file heals itself instead of breaking the login.
|
|
14
|
+
- Save the device identity after a successful authorization: the plugin's own device id is persisted, while the server-side executor id is kept separately as `executorId` for troubleshooting only and never overwrites the device id.
|
|
15
|
+
- Read the version reported to the server from `package.json` instead of hard-coding it, so the device panel shows the plugin's real version.
|
|
16
|
+
- Stop hanging on an abandoned browser authorization: the plugin polls the server's existing authorization poll endpoint, so "user denied" and "expired" end immediately with a readable reason instead of waiting for the timeout. A poll that reports the result as already claimed is treated as a normal terminal state, and a short grace period is given for the loopback callback before reporting that the credential never arrived.
|
|
17
|
+
- Add a 「取消授权」 button and cancel the pending authorization when the environment changes, so a closed browser page no longer leaves the plugin stuck at "等待浏览器授权" and unable to switch environments.
|
|
18
|
+
|
|
19
|
+
## 0.1.2
|
|
20
|
+
|
|
21
|
+
- Rebuild the CoThread integration on top of DSH's native automation tasks: every configured project now maps to one task named 「共序-{项目名}」, bound to the chosen workspace, with a "new session, reused" target. Saving the settings creates the task, changing the configuration updates it, removing the project deletes it, and moving a project to another workspace rebuilds it.
|
|
22
|
+
- The plugin now owns the patrol loop: every 15 seconds it reads the project's active iteration, works out which @-mentions and pending tasks are new, writes that scope (thread id, message cursor, item ids) into the automation task, and wakes the task. The task content pins the three allowed tools (`list_messages`, `list_tasks`, `read_message`), so the agent no longer wanders through unrelated data.
|
|
23
|
+
- The agent stays silent when there is nothing to report: the task content states that an empty final answer is the expected result, and only the items listed in the scope count as new content.
|
|
24
|
+
- The 「复述」 output is reduced to the content itself, one entry per item, without headings, summaries, advice or closing remarks.
|
|
25
|
+
- "Already taken" is tracked by the plugin instead of the service: messages advance a read cursor (`afterMessageId`) and pending tasks are remembered by id and revision, so the same task is not announced on every patrol; a task is announced again once its revision changes. The state is stored per profile and survives restarts.
|
|
26
|
+
- Adopt an existing task by title when the local mapping is lost, and delete same-title duplicates, so restarting several instances no longer leaves a pile of duplicate tasks and sessions behind.
|
|
27
|
+
- Refuse to switch environments while the current one is still signed in: each environment keeps its own credentials, so the environment picker stays disabled until the user logs out. When the configuration changes environment from elsewhere anyway, the old environment's credentials are cleared.
|
|
28
|
+
- Refuse to log out while the current environment still has projects: the plugin checks first and shows which projects are left, because those projects still own automation tasks and sessions. Switching environments no longer requires deleting projects - each environment keeps its own projects and its own automation tasks, and switching only affects the current environment.
|
|
29
|
+
- Create the automation session as soon as a project row is saved, name it after the project, and bind the automation task to it, so the session can be opened right away instead of appearing only after the first patrol. The session button now shows the bound session name and a chevron instead of a bare icon.
|
|
30
|
+
- Remember the session each automation task is bound to, and rebind to it when the task has to be rebuilt. DSH upgrades can make old task records unreadable (the Host discards records that no longer match its schema), which used to strand every automation on a brand new session; the plugin now reconnects to the previous session and only creates a new one when that session is gone or archived. Removing a project also archives the remembered session even when the task itself can no longer be read.
|
|
31
|
+
- Name the settings page and the sidebar entry 「共序自动化」, and replace the delivery-mode picker with one 「复述 / 思路」 action per trigger.
|
|
32
|
+
- Save each project row on its own: the per-row icon button writes only that row and creates the project's automation task when there is none, or updates the existing task when there is one.
|
|
33
|
+
- A project that has been saved once is locked: its project and workspace can no longer be changed, only its actions can still be adjusted, and switching project means deleting the row first.
|
|
34
|
+
- Deleting a project now inspects the automation task and session first and asks for a second confirmation that spells out the task title, task id and session id that will be ended and archived; only after confirming does the task end, the session get archived and the row disappear.
|
|
35
|
+
- 「打开自动化会话」 is now a single icon button next to the row, alongside the per-row save button.
|
|
36
|
+
|
|
3
37
|
## 0.1.1
|
|
4
38
|
|
|
5
39
|
- Widen `engines.dsh` to `>=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-0 <0.3.0-0` so the declared host range admits the DSH 0.2.2 pre-release line this plugin is verified on. The previous single-clause range excluded 0.2.2 pre-releases even though the peer ranges already accepted them.
|
package/README.md
CHANGED
|
@@ -14,28 +14,66 @@ dsh plugin --profile web add dsh-cothread-mcp
|
|
|
14
14
|
|
|
15
15
|
安装后重启 DeepSeek Harness。
|
|
16
16
|
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
## 登录与配置
|
|
18
|
+
|
|
19
|
+
点击 DSH 左侧栏的「共序自动化」,在右侧管理页面选择正式环境或本地环境并点击「授权登录」;也可以在 DSH 设置的「共序自动化」页面完成授权。在打开的共序页面登录并确认授权;共序支持时,成功页可点击「打开 DSH」返回桌面端。正式环境为 `https://cothread.z2l.top/`,本地环境为 `http://127.0.0.1:3100/`。环境选择在点「授权登录」时一并保存;各环境的项目配置分别保留。
|
|
20
|
+
|
|
21
|
+
授权复用共序 Agent 插件协议:同一账号已有的 Agent 插件可能被替换,未结束的任务可能被取消。设备凭据按环境分别存入 DSH 凭据库;插件通过设备凭据获取 MCP 账号令牌,工具名前缀默认为 `mcp__cothread-mcp__`。退出登录只移除当前环境的本机凭据,服务端设备仍需在共序中撤销。
|
|
22
|
+
|
|
23
|
+
### 设备身份
|
|
24
|
+
|
|
25
|
+
授权用的设备身份落在一台机器一份的文件里:`~/.dsh/plugins/dsh-cothread-mcp/device.json`(`DSH_HOME` 优先),内容形如 `{ "deviceId": "<uuid>", "executorId": "<服务端记录 id>" }`。它不在按 profile 分目录的 `state/` 下面:设备身份是机器级的,同一台机器上的多个 profile 应当共用同一个。文件缺失、损坏或者内容不是合法 UUID 时会重新生成一个并写回,不会因此中断授权。
|
|
26
|
+
|
|
27
|
+
这个 deviceId 必须稳定,不能每次授权都换新的。共序服务端按 `device_id` 认设备:同一个 deviceId 再次授权会复用同一条连接器记录,而换成新的 deviceId 会被当成一台新设备——旧记录被撤销、新记录被创建,服务端「一个成员只能有一条 active 绑定」的唯一索引随之被占用,浏览器点「确认授权」只会得到「记录已存在」。所以插件把 deviceId 持久化下来,每次授权都带同一个。
|
|
28
|
+
|
|
29
|
+
授权成功后,服务端那条连接器记录的 id(`executorId`)只用于排查问题,不会覆盖掉自己的 deviceId。设备面板里显示的版本号取自插件的 `package.json`,跟着插件版本走。
|
|
30
|
+
|
|
31
|
+
授权失败时的可观测性有个限制:浏览器点「确认授权」后,服务端是在一个事务里同时写入连接器记录和绑定关系的,事务失败(比如撞上上面那个唯一索引)就会整体回滚,也不会回调本机的回环口——插件拿不到失败原因,只能等到超时。这种情况下只能重新发起一次授权。
|
|
32
|
+
|
|
33
|
+
浏览器那一侧点「拒绝」,或者关掉授权页面,回环回调可能永远不来(回调是授权页面发出来的,页面关了就没了)。为了不让插件干等,插件会按服务端已有的 poll 接口轮询这次授权的状态:「用户已拒绝」会立刻结束并给出原因,授权过期也一样。轮询拿到「授权结果已经被领取」时不再重试,留一段宽限时间等回环回调,等到还没消息就明确报错。
|
|
34
|
+
|
|
35
|
+
### 侧边栏的共序账号入口
|
|
36
|
+
|
|
37
|
+
左侧边栏底部的 DSH 账号上方有一行共序入口。
|
|
38
|
+
|
|
39
|
+
未授权时显示共序 logo 与「未授权」,点开是环境选择器:选一个环境就在浏览器里完成授权。授权成功后这一行变成共序账号的头像与昵称,后面跟着当前环境名;再点开是一个菜单,两个选项:「共序自动化」切到侧边栏上的共序自动化面板,「退出登录」退出当前环境的登录。
|
|
40
|
+
|
|
41
|
+
这一行读的是当前环境的登录状态,各环境的登录互相独立:某个环境登录着并不会让其它环境也变成已授权。退出登录同样受「当前环境还有项目就不能退」的限制,被拦下时弹窗会列出还剩哪些项目。
|
|
42
|
+
|
|
43
|
+
授权页打开后如果关掉了页面,可以点「取消授权」结束等待:取消之后不会再占着「已有授权请求正在进行」,可以重新发起授权,也可以切换环境(切换环境同样会作废旧环境那次待决的授权)。
|
|
44
|
+
|
|
45
|
+
当前环境还有项目时不能退出登录:这些项目挂着自动化任务和自动化会话,退出后它们会失去凭据继续跑。点「退出登录」会先检查并弹出提示,列出还剩哪些项目,请先删除全部项目再退出。
|
|
46
|
+
|
|
47
|
+
没有退出登录就不能切换环境:各环境的凭据是分开存的,当前环境还登录着时环境选择器不可用,请先退出登录再切换。切换环境本身不需要删除项目——每个环境的项目各自保存、各自维护自动化任务,切换只影响当前环境。
|
|
48
|
+
|
|
49
|
+
授权成功后自动获取项目列表并按环境和设备凭据缓存在本机;项目变更后可点击「获取项目列表」手动刷新,失败时保留原缓存。已配置项目不在最近成功获取的列表中时会标红。每行选择项目与 DSH 工作区,并分别为「被 @ 时」和「任务待处理时」选择动作:**复述**只把内容复述出来提醒你关注,**思路**让 Agent 先分析,再回复消息或处理任务。
|
|
50
|
+
|
|
51
|
+
每一行项目单独保存:点行尾的保存图标按钮,只落这一行的配置,并同步它自己的 DSH 原生自动化任务——每个项目一个,命名为「共序-项目名称」,关联所选工作区。保存时会立刻建出这个项目的自动化会话(命名为「共序-项目名称」),并把自动化任务绑在这个会话上,保存完就能直接打开会话、看到它的名字。没有任务就新建,有任务就更新(改动作、改标题都会写进任务内容);关联的工作区变了则删除旧任务、归档旧会话、重建新任务;历史遗留的同名重复任务会被一并清理。任务默认每 5 分钟巡检一次(`intervalSeconds` 可调,宿主最短 60 秒)。
|
|
52
|
+
|
|
53
|
+
保存过一次的项目就锁定了:项目与关联工作区不能再改,要换只能先删除再重新添加,动作仍然可以调整。删除前会先检查这个项目有没有自动化任务和自动化会话,弹出二次确认框,列出任务标题、任务 ID 和会话 ID,讲清楚会结束什么、会归档什么;确认之后才真的结束自动化任务、归档自动化会话,并移除这一行的配置。任务还没投递过时会话尚未建立,这时只结束任务。
|
|
54
|
+
|
|
55
|
+
行尾的会话按钮显示绑定的会话名称和向右尖括号,点它可以打开该项目的自动化会话。
|
|
56
|
+
|
|
57
|
+
插件会记住每个项目的自动化任务和它绑定的会话。DSH 升级后如果旧任务记录读不出来(例如存储格式变化),插件重建任务时会接回原来的会话,自动化接着在上次的会话里跑,不会凭空多出一个会话;原来的会话已经归档或不存在时才另建。删除项目时,即使任务已经读不到,也会按记住的会话 ID 归档旧会话。
|
|
58
|
+
|
|
59
|
+
插件每 15 秒巡检一次:读取项目当前的活跃迭代,算出这一轮「新的被 @ 消息」和「待处理任务」,把它们写进该项目的自动化任务内容,再触发任务。任务内容里已经写明了会话 ID、消息起点和待处理项的 ID,并且只允许调用 `list_messages`、`list_tasks`、`read_message` 三个共序工具,避免 Agent 自己到处翻找。
|
|
60
|
+
|
|
61
|
+
没有新内容时任务内容里的清单是空的,Agent 应当保持沉默(最终回答留空)。「复述」只按下面格式逐条写出内容本身,不加总结、建议、评价和小标题:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
@发送人 · 会话名 · HH:MM
|
|
65
|
+
消息原文
|
|
34
66
|
```
|
|
35
67
|
|
|
68
|
+
待处理任务则是「待处理 · 任务名 · 负责人」加任务描述。
|
|
69
|
+
|
|
70
|
+
「已被取过」由插件在本机记录:消息用读取位置(`afterMessageId`)推进,任务用任务 ID 加版本号记录,提醒过的任务不会每轮重复提醒,任务有更新(版本变化)才再提醒一次。状态按 profile 分文件存放,重启不会丢。
|
|
71
|
+
|
|
72
|
+
巡检只读取当前账号有权限的迭代与任务;更改工作区或授权会改变会话归属。关闭 DSH 后不会运行。
|
|
73
|
+
|
|
36
74
|
## 安全说明
|
|
37
75
|
|
|
38
|
-
-
|
|
76
|
+
- 设备凭据存放在 DSH 凭据库,MCP 账号令牌由宿主获取,不放入工具参数或日志。
|
|
39
77
|
- 服务端按账号身份与项目成员权限校验,插件不额外放大权限。
|
|
40
78
|
- 只读成员可读取,写入类操作受服务端权限约束。
|
|
41
79
|
|
package/icon.svg
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
<path d="
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="none">
|
|
2
|
+
<title>共序 CoThread</title>
|
|
3
|
+
<rect width="64" height="64" rx="18" fill="#395D40"/>
|
|
4
|
+
<path d="M44 19H29C20.7 19 14 25.7 14 34s6.7 15 15 15h15" stroke="#F3F6EC" stroke-width="6" stroke-linecap="round"/>
|
|
5
|
+
<path d="M22 15v17c0 7.2 5.8 13 13 13s13-5.8 13-13V22" stroke="#B7D295" stroke-width="6" stroke-linecap="round"/>
|
|
6
|
+
<path d="M18.5 23.3A15 15 0 0 1 29 19h8" stroke="#F3F6EC" stroke-width="6" stroke-linecap="round"/>
|
|
7
|
+
<circle cx="48" cy="16" r="3" fill="#B7D295"/>
|
|
5
8
|
</svg>
|