kuun993/dsh-loop-engine
项目介绍Project Overview
dsh-loop-engine 是一款 DSH 插件,用于在 dsh web 中切换代理循环引擎。它通过设置页的“Loop engine”下拉菜单,在内置进程内循环、Claude Code CLI、Codex CLI 与 Pi CLI 之间切换,token 流式输出直入会话日志。需要在 dsh 0.1.1-rc.2 上使用,并在主机端分别完成对应 CLI 的登录授权。注意:切换引擎需重启 dsh web 才会生效。
dsh-loop-engine is a DSH plugin that switches the agent loop engine in dsh web. A Settings dropdown picks the driver — in-process, Claude Code CLI, Codex CLI, or Pi CLI — without editing the main repo, streaming token deltas into the session log. Use it when you need to swap runtime engines per profile. Requires dsh 0.1.1-rc.2 and the chosen CLI authenticated on the host; engine changes only apply after restarting dsh web.
请帮我了解并安装插件:【dsh-loop-engine】【https://github.com/kuun993/dsh-loop-engine】
把上面这条消息直接发给当前会话里的 DSH,让它帮你了解并安装。安装命令不一定准确,发给 DSH 更稳。Send this message to DSH in your current session. CLI install commands may not be accurate across systems — DSH will figure it out for you.
或使用命令行安装(适合开发者)Or use CLI install (for developers)
命令行安装CLI Install
dsh plugin --profile web add dsh-loop-engine
把 kuun993/dsh-loop-engine 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-loop-engine
Switch the agent loop engine of dsh web the same way you switch a model: a "Loop engine" dropdown in Settings chooses which driver runs your agents — the built-in in-process loop, the Claude Code CLI, the Codex CLI, or the Pi CLI — without changing anything in the main repository.
What it does
- Engine chosen from Settings, not from code. Pick
in-process(default),claude-code,codex, orpiin the settings page; the choice is stored durably and survives profile edits. - Claude Code execution. The Claude Code CLI drives agents, with token streaming forwarded into the session log.
- Codex execution. The driver spawns
codex app-serverand streams its token-level deltas into the session log, one turn per step. - Pi execution. The driver spawns
pi --mode rpcand streams itsmessage_updatedeltas into the session log, one statelessnew_session+promptper step. - Extensible. Adding an engine is one driver module plus one entry in the settings schema.
- Zero main-repo changes. Installed purely as a profile dependency plus one bundle layer, with no edits to the main repository.
Install
dsh plugin --profile web add dsh-loop-engine
Restart dsh web, then open Settings → Loop engine.
dsh plugin add installs the package into the web profile and registers it as
a bundle layer — the package declares dsh.bundle.patch, so no manual edit of
cordis.patch.yml is needed. It is published on npm as dsh-loop-engine.
Requirements
- dsh
0.1.1-rc.2(or a build whose peer packages match). - For the Claude Code engine: the Claude Code CLI installed and logged in on the host.
- For the Codex engine: authenticated either via
codex loginon the host or aCODEX_API_KEYenvironment entry. - For the Pi engine: authenticated the way
piexpects (its own~/.pi/agent/auth.jsonor the provider's API-key environment variable such asANTHROPIC_API_KEY). - When the harness runs from a source checkout (e.g.
pnpm dshinside thedeepseek-harnessrepository), the profile must resolve this plugin's harness peer packages to the monorepo sources via localfile:shims (the profile'sshims/directory). A deployed install with one publishednode_modulesneeds no shims.
Switching engines rewrites a small managed block in
cordis.patch.yml. Everything else you wrote in that file is preserved; only the plugin's own span changes.
Local development
To work against a checkout instead of the published package, add it with a
file: reference (build it first — the package has no prepare script, so
pnpm will not build it for you):
cd /path/to/dsh-loop-engine && pnpm install && pnpm run build
dsh plugin --profile web add file:/path/to/dsh-loop-engine
Or, from inside the checkout: dsh plugin --profile web add .
Usage
- Open Settings → Loop engine.
- Choose an engine:
- In-process (default) — the built-in loop driver;
- Claude Code CLI — the Claude Code driver;
- Codex CLI — the OpenAI Codex driver;
- Pi CLI — the Pi (earendil-works/pi) driver.
- Switching between these applies after restarting
dsh web. To return to the default, pick In-process and restart again. - To remove the plugin:
dsh plugin --profile web remove dsh-loop-engine, then restartdsh web.
Codex engine details
The driver bypasses the @openai/codex-sdk (which only exposes whole-item
output) and spawns codex app-server as a child process, speaking JSON-RPC
over stdio. The app-server streams token-level deltas via
item/agentMessage/delta and item/reasoning/summaryTextDelta, so thinking
and replies paint progressively in the session — like the Claude Code engine.
- Streaming. Reasoning deltas and agent-message deltas are forwarded live
as
assistant/chunkevents; durable messages land at the correct step boundaries with usage attached on turn completion. - Skills. The Codex engine registers a skill provider that surfaces
AGENTS.md(project root and~/.codex/AGENTS.md) through the same dsh skill-injection seam as Claude skills. - No interactive tool approval. Permissions are the declarative
sandboxMode+approvalPolicypair resolved per query from the session's permission knobs (or pinned via the plugin'ssandboxMode/approvalPolicyconfig). A sessionaskpolicy maps toon-request, whose CLI prompt degrades to a denial in the unattended dsh runtime. - No dsh subprocess sandbox integration. The driver spawns
codex app-serveritself; the dsh subprocess service (and its sandbox) does not wrap it. - No engine-specific slash commands are registered for Codex in this version.
Pi engine details
The driver spawns pi --mode rpc as a child process and speaks the strict-LF
(\n) JSONL protocol over stdio — never a generic line reader, because Pi
allows Unicode separators like U+2028 inside JSON strings. It runs one
stateless session per dsh step: a fresh new_session, then a single prompt
carrying the serialized session history. Like the Codex/Claude drivers, Pi owns
its own system prompt natively, so the dsh system-prompt assembly is not run —
the durable session log remains the sole source of model context.
- Streaming.
message_updatedeltas (text_delta/thinking_delta) are forwarded live asassistant/chunkevents; tool calls and results land astool/call+tool/result, and usage is attached onturn_end. - Sandboxed by the dsh subprocess seam. Pi has no permission system ("it
runs with the permissions of the user"), so the driver routes the whole
pichild through the dsh subprocess service and prunes--toolsto the resolved sandbox stance —read-only(default),workspace-write, ordanger-full-access(no pruning). Anaskpolicy degrades to a read-only denial because Pi has no interactive approval callback. - Skills. The Pi engine registers a skill provider that surfaces
AGENTS.md(project root and~/.pi/AGENTS.md) through the same dsh skill-injection seam. - Model/provider. Provider and model are passed to the child via
--provider/--model(a pinnedthinkingLevelis appended as:<level>); when omitted, Pi's native settings own the model.
License
MIT
vlln/dsh-navbar
SenmuuuuW/dsh-whale-report
SnowCrescenter-tech/dsh-milestone
XieZongChen/dsh-md-notes
TencentCloud/tencentcloud-agentobs-sdk-dsh
linyp/dsh-plugin-langfuse
PerryLink/dsh-checkpoint-rewind
lilwhich/dsh-plugin-gather