deepseek-harness
deepseek-ai
DeepSeek Harness: Everything is a Plugin.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:UllrAI/dsh-mqtt
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English | 中文
MQTT protocol driver and agent worker gateway for DeepSeek Harness (DSH).
dsh-mqtt turns a DSH process into an MQTT-addressable agent worker. A client can submit work, observe normalized execution events, steer or inject context into a running turn, cancel it, and receive a correlated final result. The DSH host only makes an outbound broker connection, so the worker can stay behind NAT or a firewall without exposing an HTTP server.
[!IMPORTANT] Version
0.1.2adds the live Worker management UI and controller authorization, and currently targets DSH0.1.0-rc.7. DSH itself is a developer preview and may introduce breaking changes.
submit, steer, inject, and cancel commands;session/event, agent status, and agent error output;This is a long-running host plugin, not an mqtt_publish or mqtt_subscribe model tool. The MQTT subscription lives with the DSH process and wakes or controls Agents when messages arrive.
Good fits include:
It is not intended to replace a synchronous HTTP API, a general MQTT client tool, or a workflow/job system with visibility timeouts, priority queues, dependency graphs, dead-letter processing, or exactly-once execution.
client / CI / SaaS
│ request.submit (MQTT)
▼
MQTT broker
│
▼
dsh-mqtt gateway ── create/resume ──► DSH Agent
▲ │
└──── events / terminal result ────┘
The implementation uses DSH's public Agent and event surfaces:
ctx.agents.create() and ctx.agents.resume();ctx.agentDefaultModel.currentSelection() and Agent-scoped model selection;agent.followup(), agent.steer(), agent.inject(), and agent.cancel();session/event, agent/status, and agent/error.It does not depend on DSH Web UI internals.
^22.19.0 or >=24;pnpm on PATH (DSH forwards plugin management to pnpm);DEEPSEEK_API_KEY;For a loopback-only development broker:
mosquitto -p 1883 -v
Mosquitto 2 binds locally when started without a listener configuration. Do not expose an anonymous development broker to another network.
A hosted broker is convenient when the DSH worker and its callers are on different networks. The following services expose standard MQTT endpoints and are examples rather than endorsements:
| Service | Notes |
|---|---|
| MQTT.pro | Serverless managed MQTT broker with TLS/SSL, username/password authentication, and ACLs. |
| RunMQTT | Managed isolated brokers with device identities, reusable topic policies, MQTT over TLS, and secure WebSocket access. |
| EMQX Cloud | Fully managed MQTT with retained messages, shared subscriptions, rules, and data integrations. |
| HiveMQ Cloud | Managed MQTT 3.1.1/5 with TLS, WebSockets, credentials, and topic permissions. |
| shiftr.io | Cloud MQTT platform with connection/topic visualization plus HTTP and webhook integrations. |
Copy the endpoint, port, username, and password generated by the provider into the connection examples below. Check the provider's current protocol-version, region, authentication, ACL, persistence, and quota documentation before production use. A listing here does not imply that every plan supports every feature.
DSH installs plugins into a profile. The web profile is convenient for a first run because the normal DSH UI remains available. A dedicated profile such as mqtt-worker can be used for unattended deployments.
From npm:
npx @deepseek-ai/dsh plugin --profile web add dsh-mqtt@0.1.2
From a local checkout:
git clone https://github.com/UllrAI/dsh-mqtt.git
cd dsh-mqtt
npx @deepseek-ai/dsh plugin --profile web add .
Directly from GitHub:
npx @deepseek-ai/dsh plugin --profile web add github:UllrAI/dsh-mqtt
Git dependencies build through the package prepare script. pnpm 10 and later may reject the first installation and print an allowBuilds key. Add the exact key from that message under allowBuilds in ~/.dsh/profiles/web/pnpm-workspace.yaml (or $DSH_HOME/profiles/web/pnpm-workspace.yaml), then run the command again. A local checkout or built tarball does not need this allowance.
pnpm may also report missing DSH peer dependencies while installing an out-of-tree bundle. The DSH launcher supplies its own matching core packages through the profile fallback at boot; --dump-config and the startup check below are the authoritative validation.
Edit ~/.dsh/profiles/web/cordis.patch.yml, or the equivalent path below $DSH_HOME. The bundle already inserts a row named mqtt-gateway; the profile patch replaces that row's complete configuration.
- id: mqtt-gateway
config:
url: mqtt://127.0.0.1:1883
namespace: ullrai
nodeId: mac-mini
displayName: Mac mini · development
# The Worker management UI listens on loopback by default.
managementHost: 127.0.0.1
managementPort: 3210
requireControllerAuth: true
workspaces:
repo-foo: /absolute/path/to/repo-foo
defaultWorkspace: repo-foo
# Use an absolute path so state does not depend on the launch directory.
stateFile: /absolute/path/to/dsh-mqtt-state.json
capabilities: [coding]
Path fields are resolved by Node.js. ~ and environment variables are not expanded inside these values; use absolute paths. Relative paths are resolved from the directory where DSH is launched.
Inspect the composed profile without booting it:
npx @deepseek-ai/dsh --profile web --dump-config
Then start DSH from the desired workspace:
export DEEPSEEK_API_KEY='...'
npx @deepseek-ai/dsh --profile web
After the plugin starts, open this URL on the Worker machine:
http://127.0.0.1:3210/
Broker, Agent, model, workspace, and capacity data come from live Gateway checks. The UI creates controller invitations, approves access, reports last use, and revokes controllers. Set managementPort: 0 to disable it.
The management server binds to loopback by default. A non-loopback managementHost requires managementToken or managementTokenEnv; the UI asks for that token and keeps it only for the current browser session, while API clients send Authorization: Bearer <token>. Cross-origin API access is disabled unless managementCorsOrigin is set explicitly. Never expose an unauthenticated management endpoint to a network.
requireControllerAuth: true, pending, expired, or revoked tokens cannot submit or control work.Programmatic controllers can use the exported MqttControllerClient. It adds controller_id and token to commands, subscribes to status/events/results, and provides waitForResult().
The retained status message should appear at:
mosquitto_sub -h 127.0.0.1 -q 1 -v \
-t 'dsh/v1/ullrai/nodes/mac-mini/status'
Subscribe before publishing because events and results are deliberately not retained:
export BASE='dsh/v1/ullrai/nodes/mac-mini'
export REQUEST_ID="request-$(date +%s)"
mosquitto_sub -h 127.0.0.1 -q 1 -v \
-t "$BASE/requests/$REQUEST_ID/events" \
-t "$BASE/requests/$REQUEST_ID/result"
In another terminal, using the same BASE and REQUEST_ID:
export NOW="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
mosquitto_pub -h 127.0.0.1 -q 1 \
-t "$BASE/requests" \
-m "{\"version\":1,\"id\":\"$REQUEST_ID\",\"type\":\"request.submit\",\"timestamp\":\"$NOW\",\"input\":\"Run the tests and summarize the failures.\",\"workspace\":\"repo-foo\"}"
The gateway publishes request.accepted, request.session, Agent/session events, and one final request.result:
{
"version": 1,
"id": "request-1755417600",
"type": "request.result",
"timestamp": "2026-08-17T12:04:00.000Z",
"status": "completed",
"session_id": "mqtt-6a0fe184-bb2a-45d4-941b-e079923b93db",
"summary": "All tests passed.",
"error": null
}
Every topic is scoped by protocol version, namespace, and node:
dsh/v1/{namespace}/nodes/{nodeId}/requests
dsh/v1/{namespace}/nodes/{nodeId}/requests/{requestId}/control
dsh/v1/{namespace}/nodes/{nodeId}/requests/{requestId}/events
dsh/v1/{namespace}/nodes/{nodeId}/requests/{requestId}/result
dsh/v1/{namespace}/nodes/{nodeId}/status
Current delivery settings are:
| Topic | Direction | QoS | Retained |
|---|---|---|---|
requests |
client → gateway | subscribe at 1; publish at 1 recommended | rejected if retained |
requests/{id}/control |
client → gateway | subscribe at 1; publish at 1 recommended | rejected if retained |
requests/{id}/events |
gateway → client | 1 | no |
requests/{id}/result |
gateway → client | 1 | no |
status |
gateway → client | 1 | yes |
The gateway never executes a retained command. Retain is reserved for node presence.
namespace, nodeId, workspace aliases, request IDs, command IDs, and Session IDs are topic-safe identifiers. Request, command, and Session IDs match:
[A-Za-z0-9][A-Za-z0-9._:-]{0,127}
Messages are UTF-8 JSON. Request-scoped input contains:
{
"version": 1,
"id": "request-01",
"type": "request.submit",
"timestamp": "2026-08-17T12:00:00Z"
}
timestamp must be a syntactically and calendrically valid RFC 3339 date-time. Version 1 validates its form but does not currently enforce clock skew or a freshness window. Use unguessable, never-reused IDs and broker authentication to prevent replay.
Unknown fields are ignored within protocol version 1. Unknown types and invalid values are rejected without execution.
{
"version": 1,
"id": "request-01",
"type": "request.submit",
"timestamp": "2026-08-17T12:00:00Z",
"input": "Upgrade the dependency and run the tests.",
"workspace": "repo-foo",
"metadata": {
"source": "ci",
"pull_request": 42
}
}
| Field | Required | Meaning |
|---|---|---|
version |
yes | Must be 1. |
id |
yes | Request correlation and deduplication key. |
type |
yes | Must be request.submit. |
timestamp |
yes | RFC 3339 date-time. |
input |
yes | Non-empty instruction sent through agent.followup(). |
workspace |
for a new Session unless defaultWorkspace is set |
Configured alias, never an arbitrary path. |
session_id |
no | Continue a permitted DSH Session. |
metadata |
no | Opaque JSON object; size-limited and echoed in request.accepted. Do not place secrets in it. |
Controls are accepted only while the correlated request is active. Every control needs a unique command_id for QoS 1 deduplication.
Steer the current turn:
{
"version": 1,
"id": "request-01",
"command_id": "command-01",
"type": "request.steer",
"timestamp": "2026-08-17T12:01:00Z",
"input": "Fix the integration tests first."
}
Inject additional input:
{
"version": 1,
"id": "request-01",
"command_id": "command-02",
"type": "request.inject",
"timestamp": "2026-08-17T12:01:10Z",
"input": "The staging service is unavailable."
}
Cancel:
{
"version": 1,
"id": "request-01",
"command_id": "command-03",
"type": "request.cancel",
"timestamp": "2026-08-17T12:02:00Z",
"reason": "user_cancelled"
}
Publish controls to requests/{id}/control. A failed control is not a terminal request result. It produces request.control.failed or request.control.rejected; retry it with a new command_id after addressing the cause.
All events use this envelope:
{
"version": 1,
"id": "request-01",
"type": "agent.output.delta",
"timestamp": "2026-08-17T12:00:05.000Z",
"sequence": 7,
"data": { "text": "I found three failing tests..." }
}
Gateway lifecycle events do not have a sequence. Normalized DSH Session events preserve the DSH sequence when one is available. Clients must tolerate missing sequence values, duplicates, and gaps.
With the default eventExposure: safe:
agent.output.delta and session.assistant/message;{ "redacted": true };eventExposure: full publishes cloned raw DSH event data with a session. type prefix. Use it only with trusted subscribers; it can contain prompts, reasoning, tool arguments, tool output, paths, and secrets.
Every accepted request eventually has a stored status of completed, failed, or cancelled. A result contains error: null or:
{
"code": "CAPACITY_EXCEEDED",
"message": "gateway has reached its active request limit",
"retryable": true
}
Common error codes include RETAINED_COMMAND, REQUEST_ID_CONFLICT, CAPACITY_EXCEEDED, SESSION_NOT_OWNED, SESSION_BUSY, WORKSPACE_REQUIRED, WORKSPACE_NOT_ALLOWED, AGENT_START_FAILED, CONTROL_FAILED, GATEWAY_RESTARTED, and GATEWAY_STOPPED.
A terminal result describes the Agent request. It does not make tool calls or other external side effects transactional.
For a new request, the gateway creates a random mqtt-{uuid} DSH Session and returns its ID. To continue it, submit a new request ID with that session_id:
{
"version": 1,
"id": "request-02",
"type": "request.submit",
"timestamp": "2026-08-17T12:10:00Z",
"input": "Now implement the first fix.",
"session_id": "mqtt-6a0fe184-bb2a-45d4-941b-e079923b93db"
}
By default, only Sessions recorded as created or used by this gateway may be resumed. Their ownership records persist independently of request deduplication expiry.
allowExternalSessions: true permits any broker client with publish access to request a syntactically valid DSH Session ID. MQTT application messages do not carry a trustworthy publisher identity to the plugin, so dsh-mqtt cannot authorize a Session per end user. Enabling this option expands the trust boundary to every principal allowed to publish to that node's request topic. Prefer node/namespace isolation and broker ACLs.
Only one active MQTT request may control a Session at a time.
The gateway publishes retained online status after each successful connection:
{
"version": 1,
"type": "node.status",
"timestamp": "2026-08-17T12:00:00.000Z",
"node_id": "mac-mini",
"display_name": "Mac mini · development",
"state": "ready",
"online": true,
"heartbeat_at": "2026-08-17T12:00:00.000Z",
"expires_at": "2026-08-17T12:00:30.000Z",
"active_requests": 0,
"request_capacity": 16,
"workspaces": [{ "alias": "repo-foo", "status": "ready" }],
"controller_auth_required": true,
"gateway_version": "0.1.2",
"protocol_version": 1,
"capabilities": ["coding"],
"health": [
{ "name": "broker", "status": "ready" },
{ "name": "agent", "status": "ready" },
{ "name": "model", "status": "ready" },
{ "name": "workspace:repo-foo", "status": "ready" }
]
}
state is one of starting, connecting, ready, busy, degraded, offline, or stopped. Controllers must not trust a retained online: true forever: when the current time passes expires_at, treat the node as stale until a new heartbeat arrives. Presence exposes workspace aliases, never filesystem paths.
It configures a retained offline Last Will on the same topic and explicitly publishes offline status during graceful shutdown. A Last Will timestamp is created when the connection is configured, not when the broker detects the disconnect; use broker receipt time when exact offline timing matters.
MQTT QoS 1 is at least once. dsh-mqtt uses the request payload fingerprint plus id, and the control payload fingerprint plus command_id, to avoid executing identical redeliveries twice. Reusing an ID with different content is rejected.
The JSON state file is written through a same-directory temporary file and atomic rename, with file mode 0600 on platforms that support POSIX permissions. It stores:
On startup, an accepted or active request left by a previous process is marked failed with GATEWAY_RESTARTED, and its result is published after reconnect. On graceful shutdown, active requests are cancelled and stored as GATEWAY_STOPPED.
Terminal request and control records expire after dedupTtlSeconds (seven days by default). Session ownership records do not currently expire. Do not reuse request IDs after the TTL: an expired ID is treated as new and may execute again.
Outbound QoS 1 publication returns once MQTT.js has accepted the packet into its outgoing store, rather than waiting indefinitely for a broker acknowledgement. The default MQTT.js outgoing store is in memory. Therefore:
For reliable result reception, use a persistent client Session or subscribe before submitting. If a result is missed, subscribe to its result topic and resend the exact original request with the same ID. The gateway republishes a stored terminal result without invoking the Agent again.
| Option | Default | Description |
|---|---|---|
url |
mqtt://127.0.0.1:1883 |
mqtt, mqtts, ws, or wss broker URL. |
namespace |
local |
Topic namespace; 1–64 topic-safe characters. |
nodeId |
dsh-node |
Node topic segment; 1–64 topic-safe characters. |
clientId |
dsh-mqtt-{namespace}-{nodeId} |
Stable MQTT client ID. |
protocolVersion |
5 |
5 for MQTT 5, 4 for MQTT 3.1.1. |
clean |
false |
MQTT clean-session/start flag. Keep false for offline command delivery. |
keepaliveSeconds |
30 |
MQTT keepalive. |
connectTimeoutMs |
10000 |
Initial connection timeout. |
reconnectPeriodMs |
1000 |
Reconnect delay; 0 disables reconnect. |
sessionExpirySeconds |
86400 |
MQTT 5 Session expiry; ignored for MQTT 3.1.1. |
username, password |
unset | Direct broker credentials. Avoid storing password in a profile. |
usernameEnv, passwordEnv |
unset | Environment variable names containing broker credentials. Mutually exclusive with direct values. |
caFile |
unset | Absolute CA bundle path for TLS. |
certFile, keyFile |
unset | Client certificate and private key paths for mutual TLS. |
rejectUnauthorized |
true |
Verify broker TLS certificates. Do not disable in production. |
stateFile |
.dsh-mqtt/state.json |
Durable deduplication/result/Session-ownership JSON file. |
workspaces |
{} |
Alias-to-directory allowlist for new Sessions. |
defaultWorkspace |
unset | Alias used when a new request omits workspace. |
allowExternalSessions |
false |
Permit continuation of Sessions not recorded by this gateway. See the security warning above. |
provider, model, maxTokens |
current DSH profile selection | Optional Agent creation overrides. provider and model must be set together; otherwise the gateway reads ctx.agentDefaultModel. |
capabilities |
[] |
Informational values published in online presence. |
eventExposure |
safe |
safe normalized events or full raw event data. |
maxMessageBytes |
65536 |
Maximum inbound MQTT payload size. |
maxMetadataBytes |
8192 |
Maximum serialized metadata size; cannot exceed maxMessageBytes. |
maxInputChars |
32768 |
Maximum input length in JavaScript characters. |
maxActiveRequests |
16 |
Maximum accepted/active requests. |
dedupTtlSeconds |
604800 |
Terminal request/control retention. |
The gateway supports direct MQTT username/password values or environment-backed credentials. Prefer environment variables for unattended deployments so the password is not stored in the DSH profile.
This is suitable only for a loopback interface, VPN, or otherwise trusted private network. MQTT username/password authentication does not encrypt the credentials or payload.
- id: mqtt-gateway
config:
url: mqtt://broker.internal.example:1883
namespace: ullrai
nodeId: mac-mini
username: dsh-mac-mini
password: replace-with-broker-password
The direct password form is shown for completeness. Do not commit a real password to the profile. Use mqtts:// or wss:// whenever traffic crosses an untrusted network.
This is the recommended configuration for a cloud broker:
- id: mqtt-gateway
config:
url: mqtts://broker.example.com:8883
namespace: ullrai
nodeId: mac-mini
usernameEnv: DSH_MQTT_USERNAME
passwordEnv: DSH_MQTT_PASSWORD
rejectUnauthorized: true
stateFile: /var/lib/dsh-mqtt/state.json
workspaces:
repo-foo: /srv/repos/repo-foo
export DSH_MQTT_USERNAME='dsh-mac-mini'
export DSH_MQTT_PASSWORD='...'
npx @deepseek-ai/dsh --profile web
Use the exact hostname and port supplied by the broker. A public-CA certificate normally needs no caFile; hostname and certificate verification remain enabled by default. Secure WebSocket endpoints use wss:// with the provider's path and the same credential fields.
For a private CA or a broker that requires a client certificate, add the relevant files to the TLS configuration:
- id: mqtt-gateway
config:
url: mqtts://broker.internal.example:8883
namespace: ullrai
nodeId: mac-mini
usernameEnv: DSH_MQTT_USERNAME
passwordEnv: DSH_MQTT_PASSWORD
caFile: /etc/dsh-mqtt/ca.pem
certFile: /etc/dsh-mqtt/client.pem
keyFile: /etc/dsh-mqtt/client-key.pem
rejectUnauthorized: true
caFile supplies the trusted CA bundle. certFile and keyFile enable mutual TLS and must be configured together when the broker requires them. A broker can require mTLS in addition to, or instead of, username/password authentication. Do not set rejectUnauthorized: false in production.
The broker is the principal authentication and authorization boundary. Separate gateway and client credentials and grant only the required direction for one namespace/node.
Illustrative Mosquitto ACL intent:
user dsh-gateway-mac-mini
topic read dsh/v1/ullrai/nodes/mac-mini/requests
topic read dsh/v1/ullrai/nodes/mac-mini/requests/+/control
topic write dsh/v1/ullrai/nodes/mac-mini/requests/+/events
topic write dsh/v1/ullrai/nodes/mac-mini/requests/+/result
topic write dsh/v1/ullrai/nodes/mac-mini/status
user automation-client
topic write dsh/v1/ullrai/nodes/mac-mini/requests
topic write dsh/v1/ullrai/nodes/mac-mini/requests/+/control
topic read dsh/v1/ullrai/nodes/mac-mini/requests/+/events
topic read dsh/v1/ullrai/nodes/mac-mini/requests/+/result
topic read dsh/v1/ullrai/nodes/mac-mini/status
Also use TLS, disable anonymous access, protect the state file and workspace directories, and avoid broad grants such as unrestricted dsh/# read/write access. Anyone who can publish to a node can cause its Agent to use the local tools and credentials available to that DSH process.
pnpm install
pnpm lint
pnpm typecheck
pnpm test
pnpm test:coverage
pnpm build
pnpm publint
pnpm check
pnpm check runs lint, TypeScript checking, coverage tests, build, and package export validation. Integration tests start a real in-process Aedes MQTT broker and verify subscription, publication, QoS 1 acknowledgement timing, and Last Will behavior.
To inspect the publishable package:
pnpm pack
Releases are tag-driven. Update package.json and CHANGELOG.md, commit the changes, and push a matching non-prerelease tag:
git tag v0.1.2
git push origin v0.1.2
The Release workflow verifies that the tag matches package.json, installs from the frozen lockfile, runs pnpm check, publishes the package to npm, and creates a GitHub Release with generated notes. A retry skips npm publication when that exact version already exists. Configure an npm granular automation token as the repository secret NPM_TOKEN; it must be allowed to publish dsh-mqtt. The workflow intentionally rejects prerelease tags until a separate prerelease policy is defined. Do not create a tag until the version, changelog, and release contents are ready.
The public module exports the Cordis plugin plus MqttAgentGateway, RequestStore, and TopicLayout. dsh-mqtt/protocol exports protocol types, parsers, fingerprints, and envelope builders.
0.1.0-rc.7 APIs.reconnectPeriodMs; requests and presence are handled after a connection is established.reply_to; response topics are derived from the request ID.safe event mode is a conservative projection, not a data-loss-prevention system.MIT © 2026 UllrAI
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: 无有效分类标签。