dsh-bili-scroll
c1overzz
DSH 插件:每天替你刷一轮 B站,读字幕挑出值得的、写一份日报,值得的 @ 你
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:yhuan416/dsh-opencode-client
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English | 中文
OpenCode as a native dsh subagent backend, plus a client for every remote opencode serve.
The plugin connects to one or more remote opencode serve instances, exposes their projects,
sessions and messages to dsh as tools and HTTP routes, delegates tasks into them, and registers
each server as a native dsh subagent provider (opencode-<serverId>).
Primary role: register OpenCode as a native dsh subagent backend (
opencode_subagent_<server>) and expose remote sessions/workspaces as tools (opencode_subagent,opencode_prompt, shell/git/read/find, catalogs). The embedded OpenCode Web UI is an optional convenience for full-fidelity work, not a replacement for the OpenCode client.
# 1. install the plugin into the web profile (bundle selection is composed at restart)
dsh plugin --profile web add /path/to/dsh-opencode-client
# 2. configure at least one server (full schema in Configuration)
# config.servers: [{ id: n100, url: "http://192.168.4.50:4096" }]
# 3. restart dsh web
dsh web
Verify:
GET /api/opencode-client/list answers with the configured servers).opencode_sessions — it lists remote sessions, so the HTTP path to
opencode serve works end to end.opencode_subagent_<server>) — see
Subagent seam.Prerequisite: opencode serve must be reachable from the dsh host. It binds 127.0.0.1 by
default — bind 0.0.0.0 or put it behind an SSH tunnel, and set OPENCODE_SERVER_PASSWORD.
OpenCode's own architecture: opencode serve exposes an OpenAPI HTTP server "that an opencode
client can use"; the TUI / Web / SDK are clients of it. This plugin is another client, hosted in
dsh.
flowchart LR
BROWSER["browser<br/>dsh Web UI"] -->|"same-origin HTTP"| DSH["dsh web<br/>host process"]
subgraph PLUGIN["dsh-opencode-client plugin"]
direction TB
CLIENT["client bundle<br/>plugin page · sidebar tab"]
ROUTES["routes<br/>/api/opencode-client/*"]
TOOLS["tools<br/>26 × opencode_*"]
PROVIDER["provider<br/>opencode-<serverId>"]
SSE["sse<br/>/global/event consumer"]
end
DSH --> CLIENT
DSH --> ROUTES
DSH --> TOOLS
DSH --> PROVIDER
ROUTES -->|"v1 HTTP API"| N100["opencode serve · n100"]
TOOLS -->|"v1 HTTP API"| N100
PROVIDER -->|"v1 HTTP API"| N100
ROUTES -->|"v1 HTTP API"| M65["opencode serve · m65"]
TOOLS -->|"v1 HTTP API"| M65
PROVIDER -->|"v1 HTTP API"| M65
N100 -.->|"SSE /global/event"| SSE
M65 -.->|"SSE /global/event"| SSE
CLIENT -.->|"iframe: native OpenCode UI"| N100
The browser only talks to the dsh origin — lib/client.js renders the plugin page and the
right-sidebar tab and embeds the native OpenCode UI in an iframe. lib/routes.js
(/api/opencode-client/*) and the model-facing opencode_* tools (lib/tools.js) make
deterministic v1 HTTP calls; lib/provider.js (opencode-<serverId>) and lib/session-run.js
drive delegated runs; lib/sse.js subscribes to each server's event stream (v1 /global/event,
v2 /api/event with Basic auth; with reconnect) for live progress, idle-based completion and permission/question bridging.
More: ARCHITECTURE.md · docs/ARCHITECTURE.zh.md.
26 model-facing opencode_* tools, host routes, one native subagent provider per server.
opencode-<serverId>; pair with @deepseek-ai/dsh-tool-subagent
to expose one-shot opencode_subagent_<server> tools.opencode_subagent (new session, or continue with session=; optional
agent, model and prompt-enforced schema); uses prompt_async + message polling with a
blocking-prompt fallback, and returns the final answer plus the session id.opencode_prompt sends one message to an existing remote session
(fire-and-forget by default, wait=true to block); read the reply with
opencode_messages/opencode_progress and send the next message. This keeps a remote worker
session alive across dsh turns.prompt_async + SSE session.idle event-driven (returns immediately when
the remote goes idle), 5 s polling fallback, then a fallback to the blocking prompt endpoint.opencode_progress (current tool/step, elapsed, output tail) fed by SSE
tool events; delegation completes on the SSE idle event.opencode_abort stops a running remote session; a waiting delegation returns an abort
error instead of hanging. Call it from another dsh session/agent: tool calls inside one turn are
serialized, so it cannot preempt a blocking opencode_subagent in the same turn.opencode_subagent accepts a files JSON array (text/base64 → data URL file
parts).servers: [{ id, label?, url, password?, directory? }], with optional
per-server default agent and model.GET /api/opencode-client/list (server health, projects, sessions grouped by
directory).opencode_sessions + GET /api/opencode-client/sessions.opencode_messages + GET /api/opencode-client/messages (text, tool
and file parts); useful to decide whether a session is the right one to continue.opencode_session_info (title/summary/todos/diff) and opencode_share
(share/unshare link).opencode_fork, opencode_children, opencode_summarize (mutating),
opencode_init (writes AGENTS.md, requires confirm=true).opencode_search (v2 session search, v1 fallback),
opencode_mcp (MCP server status).opencode_agents + GET /api/opencode-client/agents
(primary/subagent, native/custom); call it before opencode_subagent to pick an agent name.opencode_models (providers/models, credentials stripped), opencode_commands,
opencode_skills, opencode_tools, opencode_references.opencode_command runs a remote command (e.g. init) inside a session
and returns its final text.opencode_shell, opencode_git_status, opencode_git_diff,
opencode_read_file, opencode_find (file-path or text-content search).permission: ask (default) turns remote permission requests into dsh
approval cards; allow/reject answer deterministically./global/event, v2 /api/event) with reconnect; fast
permission/question handling, live state, GET /api/opencode-client/events and /status.kind: opencode): server picker + iframe
of the real OpenCode Web UI, inside the current session page. Open it from a server's
"侧边栏打开" button or the right-sidebar add-tab guide; "全屏" overlay and "新标签" remain as
fallbacks. No reimplementation — the embedded page keeps streaming, tool cards, diffs and
permissions.# A. dsh plugin manager
dsh plugin --profile web add /path/to/dsh-opencode-client
# B. helper script: symlink + dependency + bundle selection + a starter server row
bash scripts/install-into-profile.sh http://192.168.4.50:4096 n100
or add it manually to the profile and select it as a bundle:
{
"dependencies": { "dsh-opencode-client": "file:/path/to/dsh-opencode-client" },
"dsh": { "profile": { "bundles": ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-web-app", "dsh-opencode-client"] } }
}
Restart dsh web afterwards: the bundle selection is composed at startup.
- id: opencode-client
name: dsh-opencode-client
config:
servers:
- id: n100
label: n100 opencode
url: http://192.168.4.50:4096
# apiVersion: auto # auto (probe /api/info) | 1 | 2
# password: xxx # OPENCODE_SERVER_PASSWORD (basic auth, user "opencode")
# directory: /home/yhuan/workspace # default remote dir when the caller does not give one
# agent: plan # default OpenCode agent for delegation
# model: deepseek/deepseek-chat # default model "provider/model"
- id: m65
label: 4.65 opencode
url: http://192.168.4.65:4096
permission: ask # ask (default, dsh approval card) | allow | reject
question: reject # reject (default) interactive questions or "ignore" them
pathMap: # only when local and remote path layouts differ
- { from: /home/yhuan, to: /home/yhuan }
To expose an OpenCode server as a native dsh subagent, add a tool row:
- insert:
- id: tool-opencode-n100
name: "@deepseek-ai/dsh-tool-subagent"
config:
provider: opencode-n100 # "opencode-" + server id
maxDepth: provider-managed
toolName: opencode_subagent_n100
The native opencode_subagent_<server> tools plug into dsh's ctx.subagents provider seam.
See docs/subagent-seam.md for the contract, our capability
mapping, and the applied optimizations (parent-agent attribution, event-driven wait,
idempotent dispose). Both opencode_subagent and the native provider share one
session-run lifecycle (lib/session-run.js): same session creation, interaction
tracking, async prompt + SSE idle wait and abort handling. Native subagent sessions are
titled dsh subagent: <label> so they are identifiable in the plugin page (which now
also shows session ids and the active tool of running servers).
opencode_* 工具、参数、只读/可变| Project | Role |
|---|---|
| dsh-remote-hub | Hub side: one dsh Web UI for every backend — reverse proxy, managed SSH tunnels, top-bar switcher, remote subagent providers. |
| dsh-remote-agent | Remote side: runs in each backend dsh web and publishes its launch token + identity so the hub needs no manual token copy. |
| dsh-opencode-client (this repo) | Sidecar: treats remote opencode serve instances as a dsh subagent backend and client (sessions, delegation, catalogs) — independent of dsh remotes. |
See COMPATIBILITY.md. The plugin follows independent semantic versioning, is
verified against dsh 0.2.1-rc.2 and OpenCode 1.18.10/1.18.31/1.18.33, and is not published to
npm for now (install from git or a local path). OpenCode 2 is detected at the transport layer
(apiVersion: auto) and its SSE/completion path is mapped, but the rest of the v2 API is not
migrated yet — see
docs/opencode-v2-migration.zh.md.
opencode serve binds
127.0.0.1 by default — bind 0.0.0.0 or put it behind an SSH tunnel; setting
OPENCODE_SERVER_PASSWORD is recommended.opencode_subagent (an agent is in scope); otherwise they are rejected.format=-enforced: opencode 1.18.x has an upstream
bug — after a prompt carrying format: {type:"json_schema"}, it persists a retryCount field
that makes GET /session/{id}/message return 400 (BadRequest), poisoning the session. The plugin
therefore appends a "return only JSON matching this schema" instruction and validates the result
locally (schema parameter), leaving the session readable.allow/reject.live (SSE connected) and the number of currently running sessions./api/*) is only used where v1 lacks the capability
(session search, fallback) — see TODO.md and COMPATIBILITY.md.CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: 无有效分类标签。