Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Native bridge tests
on: [push, pull_request]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci --ignore-scripts
- run: npm test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*.tgz
58 changes: 58 additions & 0 deletions NATIVE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Native mention listener (review draft)

This optional Cordis plugin uses the existing Commonly CLI runtime consumer and receives Commonly mentions and queues a follow-up on an **already open, explicitly named dsh session**. It posts that turn's final text to the originating pod and acknowledges the event with its current delivery nonce. It never creates or replaces a Commonly identity. The default MCP bundle is unchanged.

Status: tested with real Cordis 4.0.5 and dsh's 0.2.1-rc.2 message factory. The runtime-consumer seam is exercised by the Commonly CLI's run-loop tests. The full native-to-Commonly combination has not been walked. No live Commonly credential or model-provider call has been exercised. Do not describe this draft as shipped or use it with a public/untrusted agent.

The plugin requires a published Commonly CLI release containing `src/runtime.js`. Its [prerequisite PR #2637](https://github.com/Team-Commonly/commonly/pull/2637) must merge, publish the CLI and deploy the backend policy first. Until then activation fails with a dependency error.

## Configuration

Install the candidate branch into a disposable dsh profile, then add a row to that profile's `cordis.patch.yml`:

```yaml
- id: mcp-commonly
disabled: true
- insert:
- id: commonly-native
name: commonly-dsh/native
config:
apiUrl: !!js process.env.COMMONLY_API_URL
token: !!js process.env.COMMONLY_AGENT_TOKEN
agentName: !!js process.env.COMMONLY_AGENT_NAME
instanceId: default
statePath: !!js process.env.COMMONLY_DSH_STATE_PATH
bindings:
- podId: 'YOUR_24_HEX_POD_ID'
sessionId: 'YOUR_ALREADY_OPEN_DSH_SESSION_ID'
```

Use a Commonly **agent runtime token**, not a human login token. The token's owner must authorize the connected agent. Launch with these environment variables set; never paste the token into a tracked file. Set `COMMONLY_DSH_STATE_PATH` to an absolute private file path outside the workspace the model edits. The journal stores reply text while delivery is pending and is written with mode 0600. It does not store the token.

Use one dedicated session per pod. A second pod cannot share a session, and an unbound pod stops the bridge before it enters a model prompt. Open all bound sessions before enabling the row. Do not use the same identity with `commonly agent run` or another event consumer at the same time. The journal lock excludes a second native listener using that same journal, not unrelated clients.

The CLI owns inbox batching, pod-separated context, claims, cascade admission, memory reads, reply suppression and delivery-nonce acknowledgement. The plugin replaces only its subprocess adapter with a native dsh follow-up. Native mode disables the bundle's shared-token MCP row; it never copies per-turn credentials into process.env or a global dsh tool. Kernel memory writes and Commonly-specific model tools are not added here. Use a disposable agent in a private test pod until reviewed.

## Delivery and recovery

- Session events identify the queued relay by its dsh message ID. Other sessions, other turns and local human replies are excluded. `whenIdle()` alone is not treated as proof that a particular relay completed.
- `NO_REPLY` suppresses posting. Replies preserve the source message and thread references when supplied by the event.
- Completed native responses are journaled before returning to the CLI. Repeating the same batch can reuse the response without another model call; a changed batch overlapping prior inputs stops for review.
- An interrupted native turn is ambiguous and stops the listener. Posts, deduplication and acknowledgements retain the existing CLI semantics, including its crash windows. There is no exactly-once claim. A failed model turn or timeout requires manual review.
- On unload the plugin stops its HTTP loop and session observers, flushes completed session work and releases its journal lock. It does not cancel an unrelated human turn. CLI stop prevents subsequent polls; an HTTP request already in flight may still finish.

For recovery, stop the listener and inspect the journal together with the exact dsh session and Commonly pod. A `turn` record must be resolved from observed delivery before changing it. Never delete the whole journal to retry: that loses deduplication. A leftover `.lock` after a process crash may be removed only after verifying its old process is gone. Token rotation or changed bindings deliberately refuses the old journal until reviewed.

## Verification before release

Run `npm ci --ignore-scripts && npm test` on Node 22 or newer. Then walk a disposable Commonly agent and private pod against the pinned dsh version: send a real mention, observe exactly one reply under that agent, retry an ack, restart the plugin, test a failed turn, and prove another pod's content cannot enter the bound session. Record the actual model and runtime versions. Review the runtime entry and native adapter for code/security before publishing the Chinese demo. Session model/workspace must match the seat configuration; native mode refuses unsupported model/provider/effort overrides instead of silently ignoring them.

References: [dsh agent contract](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/core/agent), [dsh session events](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/core/session), [Commonly CAP](https://github.com/Team-Commonly/commonly/blob/main/docs/adr/ADR-004-commonly-agent-protocol.md).

## Operator-only security boundary

A pod member can make the bound session act as the operator's workspace. Native sessions retain their existing workspace tools and history. They are for the trusted human operator only. Every bound pod must be created by the same human who installed this identity, invite-only, unreadable publicly, unlisted and unbridged, with exactly that operator and this canonical agent as members. Peer bots and all agent DM pod types are refused too. All active installations must have that same human operator. Use a dedicated session whose existing history is trusted by that operator. This is not a sandbox or a community bot.

The backend `GET /api/agents/runtime/pods/:podId/operator-only` must be deployed from PR #2637. The plugin verifies its token identity and every binding before starting the consumer, then rechecks before every native call and before returning any response (including cached replies). An old server, API error, changed membership or bridge refuses and requires review; a local configuration flag cannot authorize it. These checks are snapshots, not a transaction with model execution or posting: concurrent policy changes still leave a check-to-use window. Disabling the plugin does not revoke past session access or erase its history. No live security walk has been performed.

The inspected dsh 0.2.1-rc.2 host resolves `@deepseek-ai/dsh-llm` to its nested Zod 4.4.3, which is affected by GHSA-mrhx-c7xc-m3w5. The host supplies this peer dependency; the top-level patched Zod does not replace that nested copy. This remains a release hold.
56 changes: 56 additions & 0 deletions NATIVE.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 原生 @提及监听器(待评审草稿)

这个可选的 Cordis 插件复用 Commonly CLI 的事件消费循环,把 Commonly 的 @提及送入**已经打开、明确绑定的 dsh 会话**。会话生成最终回答后,插件将文字回送到原来的 pod,并使用本次投递的 nonce 确认事件。插件复用现有 Commonly agent 身份,不创建新身份。默认 MCP 配置包保持不变。

目前只验证了 Cordis 4.0.5、dsh 0.2.1-rc.2 的消息工厂的消息工厂测试。**尚未验证真实 Commonly 授权或模型调用,不是已发布功能。** 不要用于陌生人可访问的 agent。

需要包含 `src/runtime.js` 的新版 Commonly CLI 先[合并 #2637](https://github.com/Team-Commonly/commonly/pull/2637)并发布。此前启用会明确报依赖错误。

## 配置

在一次性测试 profile 安装候选分支,并向该 profile 的 `cordis.patch.yml` 添加以下行:

```yaml
- id: mcp-commonly
disabled: true
- insert:
- id: commonly-native
name: commonly-dsh/native
config:
apiUrl: !!js process.env.COMMONLY_API_URL
token: !!js process.env.COMMONLY_AGENT_TOKEN
agentName: !!js process.env.COMMONLY_AGENT_NAME
instanceId: default
statePath: !!js process.env.COMMONLY_DSH_STATE_PATH
bindings:
- podId: 'YOUR_24_HEX_POD_ID'
sessionId: 'YOUR_ALREADY_OPEN_DSH_SESSION_ID'
```

必须使用 Commonly **agent runtime token**,不能使用人的登录 token。通过启动环境传入,不能写入受版本控制的文件。`COMMONLY_DSH_STATE_PATH` 使用工作区外的私有绝对路径,避免模型编辑。日志文件权限为 0600,可能暂存尚未投递的回答,但不保存 token。

每个 pod 独占一个 dsh 会话。启用前先打开全部绑定会话。不能把不同 pod 绑定到同一会话。遇到未绑定的 pod,插件停止,不把内容交给模型。同一身份不要同时运行 `commonly agent run` 或其他事件消费者;文件锁只防止使用同一日志的两个原生监听器同时启动。

CLI 负责批次、按 pod 隔离的上下文、消息抢占、级联限制、记忆读取、重复发言抑制和投递 nonce 确认。插件只把子进程适配器替换成原生 dsh follow-up。原生模式禁用共享 token 的 MCP 行,不把每轮凭证写入 process.env 或全局工具。这里没有增加 kernel 记忆写入及 Commonly 专用模型工具,仍需代码和安全评审及真实组合走查。

## 投递与恢复

插件按照 dsh 消息 ID 找到实际消费该提及的 turn,只取该 turn 的最终文字。其他会话、其他 turn 和本地人的回答不会被当作回复。仅仅“会话空闲”不等于该消息处理完成。

模型返回完整的 `NO_REPLY` 时不发言。有源消息和线程标识时保留对应关系。原生回答先写入日志,再返回 CLI。同一批次重试可复用回答而不再次调用模型;与旧输入重叠的变更批次会停止供核对。发送与确认仍采用 CLI 的既有语义,包括其崩溃窗口。

模型运行中发生崩溃或不确定故障时,插件停止并要求检查日志,不自动重复操作。本草稿不承诺 exactly-once。失败 turn、超时或不确定发送都需要人工核对。卸载会停止轮询和监听并释放文件锁,不取消人的其他 turn。

恢复前先停止插件,结合 dsh 会话和 Commonly pod 核对 `turn` 记录。不要删除整份日志来“重试”,否则会丢失去重记录。进程崩溃留下的 `.lock` 只有在确认旧进程已退出后才能删除。更换 token 或绑定后,旧日志也需要核对。

发布前在 Node 22+ 运行 `npm ci --ignore-scripts && npm test`,然后用一次性 agent 做真实提及、单次回复、确认重试、重启、失败 turn 和跨 pod 隔离验证。记录实际模型和版本,经代码、安全评审并完成整条链路验证后,再发布中文演示文章。

CLI 的 stop 阻止后续轮询,不撤回已经发出的 HTTP 请求。原生会话的模型和工作目录需与 seat 设置一致;不支持的 model/provider/effort 覆盖会被拒绝。

## 仅限操作者的安全边界

原生会话保留现有工作区工具和历史,只能接收可信操作者的指令。绑定的 Pod 必须由安装该身份的同一位真人创建,仅邀请加入、非公开、未列入社区、没有外部桥接,成员只能是该操作者和准确匹配的本 Agent;其他机器人以及 Agent 私信类型的 Pod 也不允许。所有活跃安装必须属于同一操作者。请使用历史内容可信的专用会话。这不是沙箱,也不能用作社区机器人。

必须先部署 PR #2637 的 `GET /api/agents/runtime/pods/:podId/operator-only`。插件在启动前验证全部绑定,每次调用模型前和返回回复前(包括缓存回复)重新验证。旧服务、网络错误、成员或桥接变化均拒绝继续,需要人工检查;本地配置无法绕过验证。这些检查是快照,与模型执行和发帖并非原子事务,仍有并发变更窗口。停用插件不会撤销历史访问或清空会话。目前没有完成线上安全验证。

本次检查的 dsh 0.2.1-rc.2 宿主中,dsh-llm 实际解析到其嵌套的 Zod 4.4.3,受 GHSA-mrhx-c7xc-m3w5 影响。顶层修复版本不能替换该嵌套副本,仍阻止发布。
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ This removes the bundle from that dsh profile. Remove or revoke the agent's Comm
The bundle declares dsh `>=0.2.1-rc.2 <0.3.0`. It uses dsh's supported `dsh.bundle` patch format and stdio MCP client. The exact installation and tool-call walk for this repository is recorded in [WALK.md](WALK.md); until that walk is filled in, treat the steps above as setup instructions rather than a claim that every profile and platform has been exercised.

Apache-2.0. This project is maintained by Team Commonly and is not part of DeepSeek Harness.

## Native mention listener draft

An opt-in [native Cordis adapter](NATIVE.md) is under review. It delegates delivery policies to the Commonly CLI and requires its new runtime entry to merge and publish. The default MCP bundle does not start a mention listener. No live authenticated native walk or publication is claimed.
4 changes: 4 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ dsh plugin --profile web remove commonly-dsh
配置包声明支持 dsh `>=0.2.1-rc.2 <0.3.0`,使用官方的 `dsh.bundle` 补丁格式和 stdio MCP 客户端。本仓库的实际安装与工具调用记录在 [WALK.md](WALK.md)。在该记录完成前,上述内容只是配置步骤,不表示所有 profile 和平台都已经实测。

Apache-2.0。本项目由 Team Commonly 维护,不属于 DeepSeek Harness 官方项目。

## 原生提及监听器草稿

可选的[原生 Cordis 适配器](NATIVE.zh.md)正在评审,复用 Commonly CLI 的投递策略,需要新版 runtime 入口先合并发布。默认 MCP 包不会监听提及。尚未完成真实授权走查或发布。
15 changes: 15 additions & 0 deletions cordis.native.patch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Optional native listener; configure and enable explicitly after review.
# Native mode uses the CLI's per-turn credentials, never the MCP row's shared token.
- id: mcp-commonly
disabled: true
- insert:
- id: commonly-native
name: commonly-dsh/native
disabled: true
config:
apiUrl: !!js process.env.COMMONLY_API_URL
token: !!js process.env.COMMONLY_AGENT_TOKEN
agentName: !!js process.env.COMMONLY_AGENT_NAME
instanceId: default
statePath: !!js process.env.COMMONLY_DSH_STATE_PATH
bindings: []
15 changes: 15 additions & 0 deletions docs/chinese-launch-draft.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 给你的 DSH 一个团队房间

状态:内部投稿草稿,等待真实授权演示、CLI runtime 入口发布及代码/安全评审。不得把下面的场景写成已经走通的产品证明。

你在 dsh 里写代码,同事的 agent 却运行在 Claude Code 或 Codex。它们不必迁到同一种运行时,也可以在 Commonly 的同一个房间沟通。

第一步已经有一个轻量入口:Commonly 的 dsh MCP 配置包。它把读上下文、发消息等工具带入 dsh,但不会自己收到后台 @提及。

接下来的原生插件让“收到提及”进入 dsh 自己的会话循环。每个 pod 明确绑定到独立会话,模型的最终回答送回原 pod。它复用既有 agent 身份,不会为了换运行时再造一个新队友。

这里容易说过头的地方是可靠性。“模型已经回答”和“房间已经收到”不是一件事。原生适配器记录生成结果,而发送和确认复用已有 CLI 消费循环。中断的模型 turn 会停止供检查,避免不确定地再次生成。这个组合仍保留 CLI 的既有投递语义,不承诺 exactly-once。

演示脚本(尚未录制):在私有测试 pod 用 Codex 队友提及 dsh;展示 dsh 绑定会话中的同一条输入;展示 Commonly 中只有一次、以正确 agent 身份发出的回答;再用第二个 pod 展示会话隔离。录制前发布 CLI runtime 入口,评审原生适配器,完成真实授权走查。

备选投稿:QbitAI / 知乎。标题、录屏、实测版本与可安装链接齐备后再联系编辑;本草稿不代表已经投稿或刊登。
Loading
Loading