Introduction¶
The plugin system of DeepSeek Harness (DSH) allows agents to compose capabilities on demand. However, when integrating with third-party platforms, a common disconnect arises: “messages live elsewhere, but the model lives in DSH.” For example, Bilibili DM messages can only sit on a settings page, making it impossible for the model to reply directly. dsh-bili-gate acts as an in-process gatekeeper that routes Bilibili inbox messages into DSH sessions, letting the model decide how to respond on its own.
What It Is¶
dsh-bili-gate is a DSH plugin that provides an in-process biliEyesGate service (protocol v2) for dsh-bili-eyes. It does not connect to Bilibili directly, nor does it call any model API. It solely uses the host’s session interface (typertGateway) and session table (ctx.sessions) to deliver messages into a designated DSH session. Maintained by KILLSTARSX.
Once installed, new Bilibili inbox messages are passed to this plugin via the notify interface of dsh-bili-eyes. The plugin then calls session.prompt to inject the message body into the “Bilibili DM” session. After the model sees the message in the session, if it decides to reply, the response is sent out through the bili_dm tool (registered by dsh-bili-eyes).
Installation & Enablement¶
The plugin is linked into the profile — no npm involvement.
git clone https://github.com/KILLSTARSX/dsh-bili-gate ~/.dsh/plugins/dsh-bili-gate
On Windows, replace the target path with C:/Users/<you>/.dsh/plugins/dsh-bili-gate.
Edit the profile’s package.json (~/.dsh/profiles/<profile>/package.json) and add two entries:
{
"dependencies": {
"dsh-bili-gate": "link:C:/Users/<you>/.dsh/plugins/dsh-bili-gate"
},
"dsh": {
"profile": {
"bundles": ["...", "dsh-bili-gate"]
}
}
}
Install the link and restart DSH:
cd ~/.dsh/profiles/<profile> && pnpm install
The plugin is outside HMR’s watch scope, so both code changes and configuration changes require a restart.
Verify the installation:
tail -n 20 ~/.dsh/bili-gate.log
The log should contain two lines:
[info] apply {"cwd":"(default)","title":"Bilibili DM","dryRun":false,"gateway":true}
[info] biliEyesGate registered
gateway:false means typertGateway was not yet ready at that moment. The gatekeeper still registers successfully and will attempt to acquire it again at notify time.
Core Features¶
Gatekeeper Protocol v2¶
Each invocation from dsh-bili-eyes passes { action, ... }, and the plugin returns the result of the corresponding async method. Every action must return within 3 seconds; notify is relaxed to 20 seconds. Timeouts are treated as failures.
| Action | Parameters | Returns | Behavior |
|---|---|---|---|
hello |
{protocol:2} |
{protocol, actions, name} |
Reports protocol 2. actions does not include recentMessages — the gatekeeper cannot see group chat context and won’t pretend it can |
context |
{sessionId, session} |
{trusted, label} |
Determines whether the session belongs to the owner |
ownerMessages |
{sessionId, since, session} |
{messages:[{at,text}]} |
Fetches the owner’s messages from the host’s session table, excluding self-injected wake phrases |
notify |
{kind, text, items} |
{ok} |
Deduplicates, queues, creates session, session.prompt |
Trust Determination¶
sessionId === gatekeeper's current session → trusted (Bilibili DM (Owner))
agentPreset matches untrustedPresets → untrusted (bridged session)
cwd falls under untrustedCwd → untrusted (bridged session)
otherwise → trusted (local session)
When in doubt, treat as untrusted. In a group chat, anyone can speak — mistaking a group session for the owner would cause DMs to be sent on the owner’s behalf.
Delivery Flow¶
notify
├─ empty text ───────────────────────► {ok:false, reason:'empty-text'}
├─ dryRun ──────────────────────────► {ok:true, dryRun:true}
├─ duplicate within window ─────────► {ok:true, deduped:true}
├─ same message still in flight ────► {ok:false, reason:'in-flight'}
├─ queue full ──────────────────────► {ok:false, reason:'queue-full'}
└─ deliver
├─ reuse if sessionId exists, otherwise create (only one concurrent create)
├─ prompt(steer)
├─ session busy (agent-busy) ──► switch to prompt(queue), no message lost
├─ session gone (not-found) ───► clear state, recreate, retry once
└─ still fails ────────────────► {ok:false, reason:'deliver-failed'} (retry next time)
in-flight and queue-full intentionally return ok:false: if the caller receives ok:true, it marks the item as “delivered.” Should the delivery ultimately fail, the message would be lost. Better to let it come back next time.
Configuration¶
Configuration lives in the config block of the bundle patch (cordis.patch.yml). To override individually, add an entry with the same id in your profile patch:
- id: dsh-bili-gate
config:
cwd: 'D:/work'
sessionTitle: Bilibili DM
| Key | Default | Description |
|---|---|---|
cwd |
'' |
Working directory for new sessions. Empty = use DSH’s default workspace |
agentPreset |
'' |
Preset for new sessions. Empty = profile default |
sessionTitle |
Bilibili DM |
Renames the session after creation for easy finding in the sidebar |
ownerMid |
0 |
Only appears when promptTemplate uses {ownerHint}; 0 = no UID included |
marker |
【B站收件箱有新消息】 |
Wake phrase prefix; also used to filter out self-injected messages |
promptTemplate |
{marker} {text} |
Placeholders: {marker} {text} {ownerMid} {ownerHint} {kind} |
untrustedPresets |
qq\|wechat\|weixin\|wx\|onebot\|napcat\|bot\|group |
Regex; matched presets are treated as bridged sessions |
untrustedCwd |
'' |
One directory per line; sessions under a listed directory are treated as bridged |
dedupeWindowMs |
60000 |
Same notification is delivered only once within this window; 0 = no deduplication |
maxTextLength |
400 |
Max text length per message; truncated if exceeded |
maxQueue |
20 |
Max concurrent deliveries; exceeded returns ok:false |
sessionMaxPrompts |
100 |
Same session accumulates this many before archiving and creating a new one |
logMaxBytes |
1048576 |
Log rolls to .1 when exceeding this size |
dryRun |
false |
Log only; no session creation, no delivery |
stateFile |
'' |
Empty = $DSH_HOME/bili-gate.json |
logFile |
'' |
Empty = bili-gate.log next to the state file |
The default template is simply {marker} {text}. The message body from bili-eyes already states what needs to be done; stacking another layer of instructions only bloats the session.
Use Cases & Notes¶
Suitable for setups already using dsh-bili-eyes to fetch Bilibili inbox messages, where you want the model to reply directly within a DSH session.
The plugin runs with the current DSH process’s privileges — review the source code and license before installing. DSH 0.2 series (also tested on 0.1.5-rc.1) requires the typertGateway service. dsh-bili-eyes requires ≥ 0.8.0 (protocol v2), and Node ≥ 20. The plugin does not implement recentMessages; the gatekeeper has no visibility into group chat context.
In Short¶
dsh-bili-gate routes Bilibili inbox messages into DSH sessions, letting the model decide how to respond. It doesn’t connect to Bilibili or call any model API — it works entirely through the host’s session interface and session table. After installation, messages flow into the session automatically, and model replies go through the bili_dm tool.