dfzjb/deskpet-bridge

DeskPet Bridge - a local JS agent preset for DSH (DeepSeek Harness)

Project Overview项目介绍

DeskPet Bridge is a local JavaScript agent preset for DSH, shipped as three files with no DSH source changes. It registers three routes on DSH's built-in webServer: /get-status for agent status snapshots, /events for SSE realtime broadcasts, and /approve for submitting decisions. It also acts as a prepend answerer in DSH's approval mechanism, holding requests, pushing them to external clients over SSE, and resolving them as allowed-once or rejected via /approve, with a 120s or abort timeout returning cancelled; when no client is connected it falls back to DSH's default approval panel. Use it to programmatically observe runtime state and drive approvals. Caveat: it depends on DSH's webServer and approval event contracts and may break across incompatible DSH versions.

DeskPet Bridge 是 DSH 的本地 JavaScript 代理预设(三个文件),无需修改 DSH 源码。它向 DSH 内置 webServer 注册三条路由:/get-status 查询代理状态、/events 推送 SSE 实时事件、/approve 提交审批结果;同时以 prepend 方式注册为审批 answerer,把审批请求通过 SSE 推送给外部客户端,再由 /approve 解析为 allowed-once 或 rejected,120 秒或中止时为 cancelled,无外部客户端时回退到 DSH 默认审批面板。适用于需要程序化接管 DSH 审批与状态观察的场景。注意:依赖 DSH 的 webServer 与审批事件契约,DSH 版本不兼容时可能失效。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add github:dfzjb/deskpet-bridge

dfzjb/deskpet-bridge 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

DeskPet Bridge

English | 中文

A local JavaScript agent preset for DSH (DeepSeek Harness) that exposes the agent's runtime status over HTTP + SSE and adds a programmable approval channel.

Overview

deskpet-bridge is a standalone agent preset (three files) that you drop into DSH's .agent-presets/ directory. It requires no modification to the DSH codebase.

What it does for DSH

1. Extends DSH's web server

Registers three new routes on DSH's built-in webServer, giving DSH a few externally-callable endpoints:

Endpoint Purpose
GET /api/deskpet/v2/get-status Query the current agent status snapshot
GET /api/deskpet/v2/events Server-Sent Events realtime stream
POST /api/deskpet/v2/approve Submit an approval decision

2. Status observability

Listens to DSH's internal agent/status event, maintains a status cache (idle / running …), and counts state changes (changes) plus agent count (agentCount) — making DSH's runtime state queryable and subscribable by external programs.

3. Programmable approval channel (core)

Acts as an answerer in DSH's approval mechanism:

  • Registers on approval/request with { prepend: true }, claiming the approval ahead of DSH's default approval panel (api-proxy).
  • Holds the approval (returns a pending Promise) and pushes the request to external clients over SSE.
  • Resolves the approval when an external client submits a decision via /approveallowed-once or rejected.
  • Times out after 120 s (or on abort signal) as cancelled, so approvals never hang forever.

4. Realtime event stream

Broadcasts DSH internal events over SSE: hello / agent-status / approval-request / approval-decided / approval-expired, with a 5-second heartbeat.

5. Graceful fallback

When no external client is connected, the approval answerer calls next(), falling back to DSH's default approval panel — so DSH's original approval flow stays intact.

Files

File Purpose
agent.cordis.yml Composition entry: id: deskpet-bridge + name: ./bridge.js
bridge.js Core plugin (ESM: export name / inject / apply)
preset.yml Preset metadata (name + description)

Installation

Copy the three files into %DSH_HOME%/.agent-presets/deskpet-bridge/, then select (or set as default) the deskpet-bridge preset for your agent session.

API Contract

Base: http://127.0.0.1:3080 · Prefix: /api/deskpet/v2/

GET /get-status

{"ok":true,"status":"idle","agentCount":4,"changes":0,"connectedClients":0,"pendingApprovals":0}

GET /events (SSE, text/event-stream)

Events: hello / agent-status / approval-request / approval-decided / approval-expired

POST /approve

{"approvalId":"appr_N","decision":"approve-once"}  → 200 {"ok":true,"outcome":"allowed-once"}
{"approvalId":"appr_N","decision":"reject"}         → 200 {"ok":true,"outcome":"rejected"}
Unknown approvalId                                  → 404 {"ok":false,"error":"unknown approvalId"}

How approval works

approval/request (waterfall)
   └─ prepend answerer claims it
        ├─ external client connected → hold + push SSE approval-request
        │      └─ POST /approve → resolve allowed-once / rejected
        └─ no client → next() → DSH default approval panel

120s timeout / abort → cancelled

License

MIT — aligned with DSH's license.

上一个 Prev dsh-context-milvus 下一个 Next dsh-timeline