# Agent notes for dsh-gateway

Read [README.md](README.md) before installing or pairing. This file is the machine path.

## Product

- Public name: **dsh-gateway**. Loader / settings id: `dsh-messaging-gateway`.
- One DSH Host, one Gateway. Slack and Feishu are Platforms on that Gateway, not two products.
- This is enforced before state load/resume by the cross-process lease beside
  `state.json`. A second or process-inaccessible Host must leave its Gateway
  inactive; never delete `instance.lock` to make it win.
- No shared bot. The human creates their own Slack app and Feishu app. Tokens stay on that Host.

## Install

Default for stock DeepSeek Harness **0.2.0-rc.2** (`dsh-v0.2.0-rc.2`, SHA `639ed015397290b3745d163aafe02ffee4aa3f84`, npm `@deepseek-ai/dsh@0.2.0-rc.2`): official `dsh`. Those users have no Creator Mode and no DSHX. **pnpm** must be on PATH. Harness peers are `>=0.2.0-rc.1 <0.2.1`: that range accepts `0.2.0-rc.2` and stable `0.2.0`, and rejects `0.2.0` alphas and `0.1.7-rc.2`. Cordis is `^4.0.4`. Settings fields are volatile profile config; the 消息 page writes them through `configForms`.

```sh
dsh plugin --profile web add github:aa2246740/dsh-gateway
```

If `dsh` is not on PATH: `npx @deepseek-ai/dsh plugin --profile web add github:aa2246740/dsh-gateway`.

This package declares `dsh.bundle.patch` and commits `lib/`, so the git spec boots without a `prepare` script (pnpm ≥10 would otherwise block that script until `allowBuilds`).

Then the human restarts that Host and reloads the page. `dsh plugin add` only writes the profile.

From a local clone: `dsh plugin --profile web add file:./dsh-gateway`.

Do not send stock users through DSHX, Creator Mode, or `my-plugins`.


## Pair

1. Open **DSH → Settings → 消息**.
2. Copy the Slack manifest from that page (`复制 Manifest`), not from memory.
3. In the locally authenticated Settings page, explicitly confirm the human’s own member id / open_id, never the bot’s.
4. Verify with `GET /plugins/dsh-messaging-gateway/list` and the 消息 badges (`已绑定` / `已连接`).
5. Prove a DM: send a short message to the bot, then open the matching row under the sidebar Messaging dock.

## Done when

- Settings → 消息 shows the platform as 已绑定 / 已连接.
- `GET /plugins/dsh-messaging-gateway/list` includes that platform.
- A DM to the bot gets a DSH reply. Channel messages without @mention stay silent.

## Guardrails

- Never print, commit, or paste `xoxb-`, `xapp-`, Feishu App Secret, or `state.json` into chat, git, or evidence.
- Do not approve pairing by editing `$DSH_HOME/messaging-gateway/state.json` unless the human asked for that recovery path.
- Do not restart an adopted official DSH.app from a managed shell. The human restarts it.
- Do not run a second Web Host against the same `DSH_HOME`. Use the existing
  DSH.app or direct `dsh web` Host; isolated cold-boot tests need another Home.
- Guest pairing codes exist after an Owner is configured. The 消息 page does not yet approve guests. An unbound platform stays closed until the human explicitly confirms its Owner in the locally authenticated Settings page.
## Commands the human can send from Slack / Feishu

`/help` `/model` `/new` `/reset` `/compact` `/dsh <command>`

Threads on Slack that block `/` use `!` instead (`!help`, `!new`).

## Chat feel

Gateway-created Feishu sessions (DM and @-mentioned groups) get a short speaking contract at **session setup**. Delivery sends the first spoken sentence early, then the rest of that reply as one bubble; do not period-split a digest. Feishu turn-start is a Typing reaction on the user message, not a leftover Working… bubble. Markdown goes out as `post`+`md`. Slack keeps its existing delivery and tone. Feishu approvals are interactive cards. Slack approvals stay plaintext. Spec decisions live in this repo (`src/feishu-voice.ts`, delivery in `src/runtime.ts`, cards in `src/feishu-card.ts`). Do not paste Grok Bot handbook / system-prompt text here.

Desktop-created sessions stay stock DSH. Same gateway session opened in the Computer sidebar keeps that feel; that is not a leak.
