dsh-postapi-bridge: HTTP Gateway and Web Multi-Account Authentication for DSH

Preface

DeepSeek Harness (DSH) defaults to targeting local browsers: sessions rely on Cookies, and core capabilities utilize /api/* RPC. If you want to connect Agent scheduling to MaiBot, Feishu, WeChat bots, or CI/CD, the common approach is to write an additional proxy layer or run scripts only on 127.0.0.1—public domain names, intra-container calls, and cross-origin Bearer authentication often require separate setups.

Below is an introduction to the community plugin dsh-postapi-bridge (Maintainer: ptrel1, Category: Networking Tools). It adds a login page, multi-account management, and a machine-side REST gateway to the DSH web profile, allowing external systems to schedule tasks and invoke MCP tools via Token-based POST requests without modifying the DSH core source code. (In DSH 0.1.5+ scenarios, the official connection layer already provides a /api login gate; this plugin handles the human channel and the machine channel itself).

What is this

dsh-postapi-bridge is a dual-sided extension plugin for DSH: one side handles human Web login and user management; the other side provides a lightweight HTTP POST / RESTful task scheduling and session-related gateway for external systems (including a direct invocation entry for MCP tools).

The package with the same name on npm is still stuck at 0.1.0. Documentation explicitly states it lacks subsequent security hardening and wiring. You should rely on the GitHub repository and avoid installing from the registry using dsh plugin add dsh-postapi-bridge.

Core Features

Human Web Channel

  1. Provides /login and /logout for login and session management (with an adaptive theme login page).
  2. Supports independent permissions for multi-accounts and a Web account management panel.
  3. Local loopback (e.g., 127.0.0.1) can allow direct passwordless access according to DSH and plugin semantics; public unauthenticated access is constrained by both official and plugin rules (DSH 0.1.5+ returning 401 for unauthenticated /api/* is expected behavior, not a fault).

Machine POST API Channel

Aimed at MaiBot, WeChat bots, Feishu, CI/CD, etc., providing an HTTP API that does not rely on Cookies:

  • Authentication: Authorization: Bearer <Token> or X-Gateway-Token.
  • Non-local requests to /api/dsh/v1/* adopt a fail-closed policy: all requests without a valid Token are rejected; /api/dsh/v1/health health checks are exempt from Token requirements.
  • Strict loopback determination does not rely solely on forgeable X-Forwarded-For headers for authentication exemption (see documentation v0.6.4 security hardening notes).

Main HTTP Interfaces

Path Method Auth Description
/login GET / POST Form Username/Password Web login and session
/logout GET / POST Cookie Logout
/api/dsh/v1/health GET Passwordless or Token Health and status; when audit is enabled, response includes "audited": true
/api/dsh/v1/task POST Bearer / X-Gateway-Token Schedule DSH engine to dispatch Agent tasks
/api/dsh/v1/mcp/tool POST Bearer / X-Gateway-Token Directly invoke DSH tools (e.g., bash, read)

Provenance Auditing (Since v0.3.0)

Auditing can be logged for /api/dsh/v1/* requests: process log prefix [postapi-audit], and data/access-log.jsonl in the plugin data directory (default rotation retains 3 files when exceeding 5MB). Call sources can be distinguished via config.channels or the environment variable DSH_GATEWAY_CHANNELS (JSON, mapping token to channel name); config.accessLogDir allows customizing the audit directory. DSH web service must be restarted after modifying configuration.

Relationship with DSH Long Tasks (Background)

When external systems drive long tasks via the gateway, DSH compaction first performs syntax-level pruning on oversized tool results (dsh-compaction-tool-result-pruner), and if the budget is still exceeded, it proceeds to LLM summarization (dsh-compaction-basic). This helps control context size for gateway long-flows spanning multiple POSTs; details can be found in the explanation table in the repository README.

Installation and Activation

Installation from GitHub source to the web profile is recommended:

dsh plugin --profile web add git+https://github.com/ptrel1/dsh-postapi-bridge.git

Restart the DSH web service after installation to activate the plugin:

supervisorctl restart dsh-web

For local development or customization, you can mount a local directory using the link method (adjust paths for your machine), which also requires restarting dsh-web. Example from documentation:

cd ~/.dsh/profiles/web
dsh plugin --profile web add link:/main/app/github/dsh-postapi-bridge
supervisorctl restart dsh-web

Configuration items such as machine channel Tokens and channel mappings should follow the repository README and plugin settings; restart as described above after changing configuration.

Typical Usage Approach

The documentation does not provide complete curl request body examples, but the interface semantics are clear. You can test following these steps:

  1. Complete installation and restart dsh-web, configure the gateway Token (and optional config.channels).
  2. Call the health check to confirm service and audit status:
curl -sS "https://your-domain/api/dsh/v1/health"
  1. Schedule tasks or invoke tools directly with a Token (replace YOUR_TOKEN and JSON body with actual values; body fields follow repository documentation):
curl -sS -X POST "https://your-domain/api/dsh/v1/task" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
curl -sS -X POST "https://your-domain/api/dsh/v1/mcp/tool" \
  -H "X-Gateway-Token: YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
  1. On the human side, access /login in a browser to complete Web login; for public deployments, ensure you understand both the official DSH gate for /api/* and the plugin’s Token requirements for the machine channel.

For client-side integration with MaiBot, the documentation mentions compatibility with maibot_dsh_bridge; specific wiring should follow the respective repository documentation.

Use Cases and Notes

Who is it for

  • Those who need to expose DSH Agent tasks to bots, IM, or pipelines, and prefer standard HTTP + Token rather than just local Cookies.
  • Those who need to provide Web multi-account login and management behind a public network or reverse proxy, coexisting with the machine API.
  • Those already using or planning to use the DSH web profile (plugin dsh.client.platform is web).

Please be aware before use

  1. The plugin runs with the same permissions as the DSH process; please read the source code and MIT license at https://github.com/ptrel1/dsh-postapi-bridge before installation, and assess public exposure and Token custody yourself.
  2. Do not use the lagging npm package; the installation command should follow git+https://github.com/ptrel1/dsh-postapi-bridge.git in the README.
  3. Before DSH 0.1.5, the README described needing to modify source code to add requireSession; 0.1.5+ officially has a built-in browserAuth gate, so patching is generally no longer needed. For complete decisions on public network security and topology, see skill/public-network-auth-guide.md in the repository (if it exists).
  4. Community directories like SkillHub are independent of DeepSeek / High-Flyer and are used for plugin discovery; they are not equivalent to official app stores.

Conclusion

dsh-postapi-bridge consolidates “Web multi-account login” and “Machine-side POST / REST gateway” into a single DSH plugin: humans use /login, while automation uses /api/dsh/v1/task and /api/dsh/v1/mcp/tool, supplemented by auditing and machine channel fail-closed policies.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye