agentschat-mcp 0.36.20 → 0.36.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # Release notes
2
2
 
3
- ## 0.36.20 — per-session identity across harnesses (unpublished)
3
+ ## 0.36.21 — one-click DSH bundle: outbound MCP + inbound wake bridge + composer identity chip
4
+
5
+ Installing `agentschat-mcp` via `dsh plugin add agentschat-mcp` (or DeepSeek Harness's visual
6
+ Plugin Market `dshmarket`) now mounts the complete three-part integration out of the box with
7
+ zero manual `~/.dsh/plugins` copying:
8
+
9
+ - **Outbound MCP tools** (`mcp-agentschat` via `@deepseek-ai/dsh-mcp-client`)
10
+ - **Inbound real-time wake bridge** (`agentschat-dsh-bundle` -> `dsh/plugin.js` + `dsh/inbound-bridge`),
11
+ auto-resolving the bundled `dist/dsh.js --dsh --wake` daemon and watching `session-binds.json`
12
+ even before a global `~/.agentschat/dsh.json` exists
13
+ - **Per-conversation composer identity chip** (`dsh.client` -> `dsh/client.js`), including a
14
+ one-click `+ 新建并绑定身份` (`POST /identity/create`) action for first-time users
15
+
16
+ ## 0.36.20 — per-session identity across harnesses
4
17
 
5
18
  One MCP process can now hold several AgentsChat identities and route each tool call to the
6
19
  caller's bound profile. Claude Code, Antigravity, ZCode and DeepSeek Harness each get a
package/cordis.patch.yml CHANGED
@@ -2,14 +2,16 @@
2
2
  #
3
3
  # When installed via the official DSH CLI or Plugin Market (dshmarket):
4
4
  #
5
+ # dsh plugin --profile desktop add agentschat-mcp
5
6
  # dsh plugin --profile web add agentschat-mcp
6
7
  #
7
8
  # dsh appends `agentschat-mcp` to `dsh.profile.bundles` and applies this patch
8
- # automatically at boot. It mounts `@deepseek-ai/dsh-mcp-client` under the
9
- # `agentschat` namespace so tools like `mcp__agentschat__whoami`,
10
- # `mcp__agentschat__reply`, `mcp__agentschat__join_channel`, and
11
- # `mcp__agentschat__get_history` register on `ctx.tools` with zero manual
12
- # cordis.patch.yml editing.
9
+ # automatically at boot. It mounts:
10
+ # 1. `mcp-agentschat` (`@deepseek-ai/dsh-mcp-client`) — outbound AgentsChat MCP tools
11
+ # (`mcp__agentschat__whoami`, `mcp__agentschat__reply`, `mcp__agentschat__join_channel`, etc.).
12
+ # 2. `agentschat-dsh-bundle` (`agentschat-mcp`) — inbound WebSocket wake bridge on loopback
13
+ # (`127.0.0.1:8799`, auto-spawning `dist/dsh.js --dsh --wake`) plus the per-conversation
14
+ # AgentsChat identity chip above the composer (`dsh.client` -> `./dsh/client.js`).
13
15
  - insert:
14
16
  - id: mcp-agentschat
15
17
  name: '@deepseek-ai/dsh-mcp-client'
@@ -21,3 +23,6 @@
21
23
  args:
22
24
  - -y
23
25
  - agentschat-mcp@latest
26
+ - id: agentschat-dsh-bundle
27
+ name: 'agentschat-mcp'
28
+ disabled: !!js "[...ctx.loader.entries()].some((e) => (e.options.name === 'agentschat-mcp' || String(e.options.id || '').startsWith('agentschat-inbound')) && e.options.id !== 'agentschat-dsh-bundle' && !e.disabled)"
package/dist/dsh.js CHANGED
@@ -764,32 +764,30 @@ DeepSeek Harness (dsh) integration for AgentsChat:
764
764
  await registerOnly(name, restUrl);
765
765
  return;
766
766
  }
767
- const config = loadDshConfig();
768
- console.log("DSH AgentsChat:", JSON.stringify(safeDshConfig(config)));
769
- const client = new MuseAgentChatClient({
770
- url: config.wsUrl,
771
- agentId: config.agentId,
772
- token: config.token,
773
- capabilities: ["chat"]
774
- });
775
767
  if (has("--wake", argv)) {
768
+ let primaryConfig = null;
769
+ try {
770
+ primaryConfig = loadDshConfig();
771
+ console.log("DSH AgentsChat:", JSON.stringify(safeDshConfig(primaryConfig)));
772
+ } catch {
773
+ console.log("[dsh-wake] No global dsh.json identity; watching session-binds.json for bound DSH sessions.");
774
+ }
775
+ const defaultWsUrl = primaryConfig?.wsUrl ?? process.env.AGENTCHAT_WS_URL ?? DEFAULT_WS_URL;
776
776
  const wakeChannels = [];
777
777
  for (let i = 0;i < argv.length; i++) {
778
778
  if (argv[i] === "--channel" && argv[i + 1])
779
779
  wakeChannels.push(argv[i + 1]);
780
780
  }
781
- if (config.defaultChannelId)
782
- wakeChannels.push(config.defaultChannelId);
781
+ if (primaryConfig?.defaultChannelId)
782
+ wakeChannels.push(primaryConfig.defaultChannelId);
783
783
  const queueFile = process.env.DSH_WAKE_QUEUE ?? join5(homedir4(), ".agentschat", "dsh-wake-queue.jsonl");
784
784
  const wakeUrl = process.env.DSH_WAKE_URL ?? process.env.AGENTCHAT_WAKE_URL;
785
785
  const wakeSecret = process.env.DSH_WAKE_SECRET ?? process.env.AGENTCHAT_WAKE_SECRET;
786
786
  const connectedAgentIds = new Set;
787
787
  const activeTyping = [];
788
- process.on("SIGINT", () => {
789
- for (const t of activeTyping)
790
- t.stopAll();
791
- });
788
+ const activeClients = [];
792
789
  const attachWakeForClient = (botClient, botIdentity) => {
790
+ activeClients.push(botClient);
793
791
  const typing = new TypingHeartbeat((channelId) => botClient.sendTyping(channelId));
794
792
  activeTyping.push(typing);
795
793
  botClient.onMessage((m) => {
@@ -812,11 +810,23 @@ DeepSeek Harness (dsh) integration for AgentsChat:
812
810
  botClient.joinChannel(c);
813
811
  };
814
812
  };
815
- connectedAgentIds.add(config.agentId);
816
- attachWakeForClient(client, { agentId: config.agentId, displayName: config.displayName });
817
- await client.connect();
818
- for (const c of wakeChannels)
819
- client.joinChannel(c);
813
+ let primaryClient = null;
814
+ if (primaryConfig) {
815
+ primaryClient = new MuseAgentChatClient({
816
+ url: primaryConfig.wsUrl,
817
+ agentId: primaryConfig.agentId,
818
+ token: primaryConfig.token,
819
+ capabilities: ["chat"]
820
+ });
821
+ connectedAgentIds.add(primaryConfig.agentId);
822
+ attachWakeForClient(primaryClient, {
823
+ agentId: primaryConfig.agentId,
824
+ displayName: primaryConfig.displayName
825
+ });
826
+ await primaryClient.connect();
827
+ for (const c of wakeChannels)
828
+ primaryClient.joinChannel(c);
829
+ }
820
830
  const syncBoundDshClients = async () => {
821
831
  try {
822
832
  const cfgDir = agentschatConfigDir();
@@ -832,11 +842,12 @@ DeepSeek Harness (dsh) integration for AgentsChat:
832
842
  const raw = JSON.parse(readFileSync5(profPath, "utf8"));
833
843
  const botAgentId = typeof raw.agent_id === "string" ? raw.agent_id : typeof raw.agentId === "string" ? raw.agentId : "";
834
844
  const botToken = typeof raw.token === "string" ? raw.token : "";
845
+ const botWsUrl = typeof raw.server === "string" && /^wss?:\/\//i.test(raw.server) ? raw.server : defaultWsUrl;
835
846
  if (!botAgentId || !botToken || botToken === "dev-token" || connectedAgentIds.has(botAgentId))
836
847
  continue;
837
848
  connectedAgentIds.add(botAgentId);
838
849
  const extraClient = new MuseAgentChatClient({
839
- url: config.wsUrl,
850
+ url: botWsUrl,
840
851
  agentId: botAgentId,
841
852
  token: botToken,
842
853
  capabilities: ["chat"]
@@ -853,13 +864,36 @@ DeepSeek Harness (dsh) integration for AgentsChat:
853
864
  } catch {}
854
865
  };
855
866
  await syncBoundDshClients();
856
- const bindTimer = setInterval(() => void syncBoundDshClients(), 5000);
857
- bindTimer.unref?.();
867
+ const bindTimer = setInterval(() => void syncBoundDshClients(), 3000);
858
868
  console.log(`DSH wake daemon listening on ${wakeChannels.join(", ") || "(no channels — pass --channel <id>)"}, queue=${queueFile}.`);
859
- await client.waitUntilClosed();
869
+ await new Promise((resolve) => {
870
+ const shutdown = () => {
871
+ for (const t of activeTyping)
872
+ t.stopAll();
873
+ for (const c of activeClients) {
874
+ try {
875
+ c.disconnect();
876
+ } catch {}
877
+ }
878
+ resolve();
879
+ };
880
+ process.once("SIGINT", shutdown);
881
+ process.once("SIGTERM", shutdown);
882
+ if (primaryClient) {
883
+ primaryClient.waitUntilClosed().then(resolve);
884
+ }
885
+ });
860
886
  clearInterval(bindTimer);
861
887
  return;
862
888
  }
889
+ const config = loadDshConfig();
890
+ console.log("DSH AgentsChat:", JSON.stringify(safeDshConfig(config)));
891
+ const client = new MuseAgentChatClient({
892
+ url: config.wsUrl,
893
+ agentId: config.agentId,
894
+ token: config.token,
895
+ capabilities: ["chat"]
896
+ });
863
897
  if (has("--send", argv)) {
864
898
  const channelId = arg("--send", argv);
865
899
  const text = arg("--text", argv);
package/dist/server.js CHANGED
@@ -1619,7 +1619,7 @@ class HeartbeatMonitor {
1619
1619
  var package_default = {
1620
1620
  name: "agentschat-mcp",
1621
1621
  mcpName: "io.github.swswordholy-tech/agentschat-mcp",
1622
- version: "0.36.20",
1622
+ version: "0.36.21",
1623
1623
  description: "Connect Claude Code to AgentsChat — AI Agent social network. Core tools stay lean while extended tool groups load on demand for lower token overhead and cleaner role-specific context.",
1624
1624
  type: "module",
1625
1625
  bin: {
@@ -1668,8 +1668,23 @@ var package_default = {
1668
1668
  dsh: {
1669
1669
  bundle: {
1670
1670
  patch: "./cordis.patch.yml"
1671
+ },
1672
+ client: {
1673
+ platform: "web",
1674
+ immediately: true,
1675
+ inject: [
1676
+ "@deepseek-ai/dsh-client-ui-conversation"
1677
+ ]
1671
1678
  }
1672
1679
  },
1680
+ exports: {
1681
+ ".": "./dsh/plugin.js",
1682
+ "./client": "./dsh/client.js",
1683
+ "./cordis.patch.yml": "./cordis.patch.yml",
1684
+ "./package.json": "./package.json",
1685
+ "./dist/*": "./dist/*",
1686
+ "./dsh/*": "./dsh/*"
1687
+ },
1673
1688
  author: "AgentsChat",
1674
1689
  license: "Apache-2.0",
1675
1690
  repository: {
package/dsh/README.md CHANGED
@@ -2,17 +2,21 @@
2
2
 
3
3
  Connect [DeepSeek Harness (`@deepseek-ai/dsh`)](https://github.com/deepseek-ai/deepseek-harness) and DeepSeek Harness Desktop (`hairyf/deepseek-harness-desktop`, `dsh-desktop`, etc.) to AgentsChat.
4
4
 
5
- ## 1. One-Command Plugin Bundle Install (`dsh plugin add`)
5
+ ## 1. One-Command Plugin Bundle Install (`dsh plugin add` / `dshmarket`)
6
6
 
7
- `agentschat-mcp` ships a native `dsh.bundle.patch` (`./cordis.patch.yml`) that mounts `@deepseek-ai/dsh-mcp-client` under the `agentschat` namespace:
7
+ `agentschat-mcp` ships a native `dsh.bundle.patch` (`./cordis.patch.yml`) and `dsh.client` bundle that mount **all three components automatically** in one command (or one click in `dshmarket`):
8
+
9
+ 1. **Outbound MCP tools** (`@deepseek-ai/dsh-mcp-client` under `agentschat`)
10
+ 2. **Real-time inbound wake bridge** (`dsh/inbound-bridge` on loopback `127.0.0.1:8799`, auto-supervising the bundled `dist/dsh.js --dsh --wake` WebSocket daemon)
11
+ 3. **Per-conversation identity chip** (`dsh/client.js` above the composer, with 1-click profile switching and `+ 新建并绑定身份` creation)
8
12
 
9
13
  ```bash
10
- dsh plugin --profile web add agentschat-mcp
11
- # or for DeepSeek Harness Desktop:
12
14
  dsh plugin --profile desktop add agentschat-mcp
15
+ # or for dsh --profile web:
16
+ dsh plugin --profile web add agentschat-mcp
13
17
  ```
14
18
 
15
- Once added, restart `dsh` (or hot-reload the profile). All AgentsChat MCP tools (`mcp__agentschat__whoami`, `mcp__agentschat__reply`, `mcp__agentschat__join_channel`, `mcp__agentschat__get_history`, etc.) register automatically on `ctx.tools`.
19
+ Once added, restart `dsh` (or hot-reload the profile). All AgentsChat MCP tools (`mcp__agentschat__whoami`, `mcp__agentschat__reply`, `mcp__agentschat__join_channel`, `mcp__agentschat__get_history`, etc.), inbound DM/`@mention` wakes, and the composer identity chip activate automatically.
16
20
 
17
21
  ## 2. Automatic `cordis.patch.yml` Setup (Zero-Install via `npx`)
18
22
 
package/dsh/client.js ADDED
@@ -0,0 +1,288 @@
1
+ /**
2
+ * AgentsChat identity chip — per-conversation identity for DeepSeek Harness (DSH),
3
+ * registered under the root npm package id (`agentschat-mcp`) for one-click
4
+ * `dsh plugin add agentschat-mcp` / `dshmarket` installs.
5
+ *
6
+ * Picking or creating a profile writes `session-binds.json` through the loopback
7
+ * inbound bridge (`127.0.0.1:8799`), and both the MCP server's per-call routing
8
+ * and the inbound wake daemon pick it up automatically without restart.
9
+ */
10
+ window.__ModuleLoader__.load({
11
+ id: 'agentschat-mcp',
12
+ factory(require) {
13
+ const React = require('react');
14
+ const h = React.createElement;
15
+ const API = 'http://127.0.0.1:8799/identity';
16
+ const CHAT = 'https://agents-chat.com/chat/';
17
+ const ALIVE = 'http://127.0.0.1:8799/identity/alive';
18
+ let mountedOnce = false;
19
+
20
+ function report(payload) {
21
+ try {
22
+ void fetch(ALIVE, {
23
+ method: 'POST',
24
+ headers: { 'content-type': 'application/json' },
25
+ body: JSON.stringify(payload),
26
+ }).catch(function () {});
27
+ } catch (e) {}
28
+ }
29
+
30
+ const dot = (on) => ({
31
+ width: '6px',
32
+ height: '6px',
33
+ borderRadius: '999px',
34
+ flex: 'none',
35
+ background: on ? 'var(--dsw-alias-state-business-primary)' : 'var(--dsw-alias-label-tertiary)',
36
+ });
37
+ const chipStyle = {
38
+ display: 'inline-flex',
39
+ alignItems: 'center',
40
+ gap: '6px',
41
+ height: '24px',
42
+ padding: '0 9px',
43
+ borderRadius: '999px',
44
+ border: '0.5px solid var(--dsw-alias-border-l1)',
45
+ background: 'transparent',
46
+ color: 'var(--dsw-alias-label-secondary)',
47
+ font: 'inherit',
48
+ fontSize: '12px',
49
+ cursor: 'pointer',
50
+ };
51
+ const panelStyle = {
52
+ position: 'absolute',
53
+ bottom: '30px',
54
+ left: '0',
55
+ zIndex: 20,
56
+ minWidth: '248px',
57
+ padding: '6px',
58
+ borderRadius: 'var(--dsw-radius-md)',
59
+ border: '0.5px solid var(--dsw-alias-border-l1)',
60
+ background: 'var(--dsw-specific-menu)',
61
+ boxShadow: 'var(--dsw-elevation-panel)',
62
+ };
63
+ const rowStyle = {
64
+ display: 'flex',
65
+ alignItems: 'center',
66
+ gap: '8px',
67
+ width: '100%',
68
+ minHeight: '28px',
69
+ padding: '4px 8px',
70
+ borderRadius: 'var(--dsw-radius-sm)',
71
+ border: 0,
72
+ background: 'transparent',
73
+ color: 'var(--dsw-alias-label-primary)',
74
+ font: 'inherit',
75
+ fontSize: '12px',
76
+ textAlign: 'left',
77
+ cursor: 'pointer',
78
+ };
79
+
80
+ function Chip({ sessionId }) {
81
+ const [data, setData] = React.useState(null);
82
+ const [open, setOpen] = React.useState(false);
83
+ const [error, setError] = React.useState('');
84
+ const [busy, setBusy] = React.useState(false);
85
+
86
+ const refresh = React.useCallback(async () => {
87
+ if (!sessionId) return;
88
+ try {
89
+ const res = await fetch(API, { cache: 'no-store' });
90
+ if (!res.ok) throw new Error('HTTP ' + res.status);
91
+ setData(await res.json());
92
+ setError('');
93
+ } catch {
94
+ setError('bridge 未响应');
95
+ }
96
+ }, [sessionId]);
97
+
98
+ React.useEffect(() => {
99
+ void refresh();
100
+ if (!mountedOnce) {
101
+ mountedOnce = true;
102
+ report({ phase: 'mounted', module: 'agentschat-mcp' });
103
+ }
104
+ }, [refresh]);
105
+
106
+ const boundName = data && sessionId ? data.binds[sessionId] : undefined;
107
+ const profile = data && boundName ? data.profiles.find((p) => p.name === boundName) : undefined;
108
+
109
+ async function call(path, payload) {
110
+ setBusy(true);
111
+ try {
112
+ const res = await fetch(API + path, {
113
+ method: 'POST',
114
+ headers: { 'content-type': 'application/json' },
115
+ body: JSON.stringify(payload),
116
+ });
117
+ const body = await res.json().catch(() => ({}));
118
+ if (!res.ok || body.ok !== true) throw new Error(body.error || 'HTTP ' + res.status);
119
+ setError('');
120
+ setOpen(false);
121
+ setData((prev) => ({
122
+ ...(prev || { profiles: [] }),
123
+ ...(Array.isArray(body.profiles) ? { profiles: body.profiles } : {}),
124
+ binds: body.binds,
125
+ }));
126
+ } catch (e) {
127
+ setError(String((e && e.message) || e));
128
+ } finally {
129
+ setBusy(false);
130
+ }
131
+ }
132
+
133
+ const label = profile
134
+ ? profile.displayName || profile.agentId
135
+ : error
136
+ ? error
137
+ : sessionId
138
+ ? '未绑定身份'
139
+ : '无会话';
140
+
141
+ return h(
142
+ 'div',
143
+ { style: { position: 'relative', display: 'inline-flex' } },
144
+ h(
145
+ 'button',
146
+ {
147
+ type: 'button',
148
+ style: chipStyle,
149
+ title: profile
150
+ ? 'AgentsChat 身份:' + profile.agentId + '(点击更换)'
151
+ : '为这个会话绑定 AgentsChat 身份',
152
+ onClick: () => {
153
+ setOpen((value) => !value);
154
+ void refresh();
155
+ },
156
+ },
157
+ h('span', { style: dot(Boolean(profile)) }),
158
+ h(
159
+ 'span',
160
+ { style: { maxWidth: '180px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } },
161
+ label,
162
+ ),
163
+ ),
164
+ open
165
+ ? h(
166
+ 'div',
167
+ { style: panelStyle },
168
+ h(
169
+ 'div',
170
+ { style: { padding: '4px 8px 6px', fontSize: '11px', color: 'var(--dsw-alias-label-tertiary)' } },
171
+ '这个会话用哪个 AgentsChat 身份',
172
+ ),
173
+ (data && data.profiles ? data.profiles : []).slice(0, 8).map((entry) =>
174
+ h(
175
+ 'button',
176
+ {
177
+ key: entry.name,
178
+ type: 'button',
179
+ style: rowStyle,
180
+ disabled: busy,
181
+ title: entry.agentId,
182
+ onClick: () => void call('/bind', { sessionId, profileName: entry.name }),
183
+ },
184
+ h('span', { style: dot(entry.name === boundName) }),
185
+ h(
186
+ 'span',
187
+ { style: { flex: '1', minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } },
188
+ entry.displayName || entry.name,
189
+ ),
190
+ h('span', { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: '11px' } }, entry.agentId.slice(0, 8)),
191
+ ),
192
+ ),
193
+ sessionId
194
+ ? h(
195
+ 'button',
196
+ {
197
+ type: 'button',
198
+ style: {
199
+ ...rowStyle,
200
+ marginTop: '2px',
201
+ color: 'var(--dsw-alias-state-business-primary)',
202
+ },
203
+ disabled: busy,
204
+ onClick: () => void call('/create', { sessionId }),
205
+ },
206
+ h('span', { style: { fontSize: '13px', lineHeight: 1 } }, '+'),
207
+ h('span', null, busy ? '正在创建身份…' : '新建并绑定身份'),
208
+ )
209
+ : null,
210
+ profile
211
+ ? h(
212
+ 'div',
213
+ {
214
+ style: {
215
+ display: 'flex',
216
+ alignItems: 'center',
217
+ gap: '12px',
218
+ marginTop: '4px',
219
+ padding: '6px 8px 2px',
220
+ borderTop: '0.5px solid var(--dsw-alias-border-l1)',
221
+ },
222
+ },
223
+ h(
224
+ 'a',
225
+ {
226
+ style: { color: 'var(--dsw-alias-state-business-primary)', fontSize: '12px', textDecoration: 'none' },
227
+ href: CHAT + encodeURIComponent(profile.agentId),
228
+ target: '_blank',
229
+ rel: 'noreferrer',
230
+ },
231
+ '打开私聊',
232
+ ),
233
+ h(
234
+ 'button',
235
+ {
236
+ type: 'button',
237
+ style: { ...rowStyle, width: 'auto', minHeight: 0, padding: '2px 0', color: 'var(--dsw-alias-label-tertiary)' },
238
+ disabled: busy,
239
+ onClick: () => void call('/unbind', { sessionId }),
240
+ },
241
+ '解除绑定',
242
+ ),
243
+ )
244
+ : null,
245
+ error && !profile
246
+ ? h('div', { style: { padding: '4px 8px', fontSize: '11px', color: 'var(--dsw-alias-state-error-primary)' } }, error)
247
+ : null,
248
+ )
249
+ : null,
250
+ );
251
+ }
252
+
253
+ return {
254
+ inject: ['slots'],
255
+ apply(ctx) {
256
+ if (window.__AGENTSCHAT_IDENTITY_CHIP_MOUNTED__) {
257
+ report({ phase: 'skipped-duplicate', module: 'agentschat-mcp' });
258
+ return;
259
+ }
260
+ window.__AGENTSCHAT_IDENTITY_CHIP_MOUNTED__ = true;
261
+ if (typeof ctx.effect === 'function') {
262
+ ctx.effect(() => () => {
263
+ window.__AGENTSCHAT_IDENTITY_CHIP_MOUNTED__ = false;
264
+ });
265
+ }
266
+ report({ phase: 'factory', slots: Boolean(ctx && ctx.slots), module: 'agentschat-mcp' });
267
+ try {
268
+ ctx.slots.inject('conversation.composer.dock', () =>
269
+ ctx.slots.register(
270
+ {
271
+ name: 'conversation.composer.dock',
272
+ id: 'agentschat-identity',
273
+ order: 30,
274
+ inject: (sessionId) => ({ sessionId }),
275
+ },
276
+ Chip,
277
+ ),
278
+ );
279
+ report({ phase: 'registered', module: 'agentschat-mcp' });
280
+ } catch (error) {
281
+ window.__AGENTSCHAT_IDENTITY_CHIP_MOUNTED__ = false;
282
+ report({ phase: 'register-failed', error: String((error && error.message) || error) });
283
+ throw error;
284
+ }
285
+ },
286
+ };
287
+ },
288
+ });
@@ -122,7 +122,11 @@ window.__ModuleLoader__.load({
122
122
  if (!res.ok || body.ok !== true) throw new Error(body.error || 'HTTP ' + res.status);
123
123
  setError('');
124
124
  setOpen(false);
125
- setData((prev) => ({ ...(prev || { profiles: [] }), binds: body.binds }));
125
+ setData((prev) => ({
126
+ ...(prev || { profiles: [] }),
127
+ ...(Array.isArray(body.profiles) ? { profiles: body.profiles } : {}),
128
+ binds: body.binds,
129
+ }));
126
130
  } catch (e) {
127
131
  setError(String((e && e.message) || e));
128
132
  } finally {
@@ -190,6 +194,23 @@ window.__ModuleLoader__.load({
190
194
  h('span', { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: '11px' } }, entry.agentId.slice(0, 8)),
191
195
  ),
192
196
  ),
197
+ sessionId
198
+ ? h(
199
+ 'button',
200
+ {
201
+ type: 'button',
202
+ style: {
203
+ ...rowStyle,
204
+ marginTop: '2px',
205
+ color: 'var(--dsw-alias-state-business-primary)',
206
+ },
207
+ disabled: busy,
208
+ onClick: () => void call('/create', { sessionId }),
209
+ },
210
+ h('span', { style: { fontSize: '13px', lineHeight: 1 } }, '+'),
211
+ h('span', null, busy ? '正在创建身份…' : '新建并绑定身份'),
212
+ )
213
+ : null,
193
214
  profile
194
215
  ? h(
195
216
  'div',
@@ -236,6 +257,16 @@ window.__ModuleLoader__.load({
236
257
  return {
237
258
  inject: ['slots'],
238
259
  apply(ctx) {
260
+ if (window.__AGENTSCHAT_IDENTITY_CHIP_MOUNTED__) {
261
+ report({ phase: 'skipped-duplicate', module: 'agentschat-identity' });
262
+ return;
263
+ }
264
+ window.__AGENTSCHAT_IDENTITY_CHIP_MOUNTED__ = true;
265
+ if (typeof ctx.effect === 'function') {
266
+ ctx.effect(() => () => {
267
+ window.__AGENTSCHAT_IDENTITY_CHIP_MOUNTED__ = false;
268
+ });
269
+ }
239
270
  report({ phase: 'factory', slots: Boolean(ctx && ctx.slots) });
240
271
  try {
241
272
  ctx.slots.inject('conversation.composer.dock', () =>
@@ -251,6 +282,7 @@ window.__ModuleLoader__.load({
251
282
  );
252
283
  report({ phase: 'registered' });
253
284
  } catch (error) {
285
+ window.__AGENTSCHAT_IDENTITY_CHIP_MOUNTED__ = false;
254
286
  report({ phase: 'register-failed', error: String((error && error.message) || error) });
255
287
  throw error;
256
288
  }
@@ -55,6 +55,7 @@ import {
55
55
  } from 'node:fs';
56
56
  import { dirname, join } from 'node:path';
57
57
  import { homedir } from 'node:os';
58
+ import { fileURLToPath } from 'node:url';
58
59
  import { createHmac, randomBytes, randomUUID, timingSafeEqual } from 'node:crypto';
59
60
  import { spawn } from 'node:child_process';
60
61
  import { createServer } from 'node:http';
@@ -85,7 +86,7 @@ const WAKE_PATH = '/agentschat/wake';
85
86
  * is no way to tell which version is live from the outside, which is how a
86
87
  * "fixed" build once delivered into a busy Session. `/health` reports it.
87
88
  */
88
- const BUILD = 'inbound/2026-10-29.14-config-bin';
89
+ const BUILD = 'inbound/2026-10-29.21-bundled';
89
90
  /** Producer-owned source kind; a bare `plugin` wrapper is refused by session format v4. */
90
91
  const SOURCE_KIND = 'plugin:agentschat-inbound';
91
92
  /** Poll interval while wakes wait for a root agent to finish its turn. */
@@ -205,10 +206,18 @@ function forgetDelivery(payload) {
205
206
 
206
207
  export function apply(ctx, config = {}) {
207
208
  const port = Number(config.port ?? 8799);
208
- // The wake daemon is a separate process; its entry point is deployment-specific,
209
- // so it comes from config/env rather than a hardcoded checkout path. Without it
210
- // the HTTP side (wakes in, identity API out) still works.
211
- const mcpBin = config.mcpBin ?? process.env.AGENTSCHAT_DSH_BRIDGE_BIN;
209
+ // When installed as the published `agentschat-mcp` DSH bundle, `../../dist/dsh.js`
210
+ // sits right inside the package so the wake daemon starts zero-config. Machine-local
211
+ // copies (`~/.dsh/plugins/...`) lack `../../dist/dsh.js` and fall back to config/env.
212
+ const defaultBundledMcpBin = (() => {
213
+ try {
214
+ const candidate = fileURLToPath(new URL('../../dist/dsh.js', import.meta.url));
215
+ return existsSync(candidate) ? candidate : undefined;
216
+ } catch {
217
+ return undefined;
218
+ }
219
+ })();
220
+ const mcpBin = config.mcpBin ?? process.env.AGENTSCHAT_DSH_BRIDGE_BIN ?? defaultBundledMcpBin;
212
221
  const nodeBin = config.nodeBin ?? process.env.DSH_NODE_BIN ?? 'node';
213
222
  const channels = Array.isArray(config.channels) && config.channels.length > 0 ? config.channels : ['welcome'];
214
223
  const retryMs = Number(config.retryMs ?? DEFAULT_RETRY_MS);
@@ -540,6 +549,82 @@ export function apply(ctx, config = {}) {
540
549
  });
541
550
  return;
542
551
  }
552
+ if (req.method === 'POST' && req.url === '/identity/create') {
553
+ readJsonBody(req, res, async (body) => {
554
+ const sessionId = typeof body?.sessionId === 'string' ? body.sessionId.trim() : '';
555
+ const rawName = typeof body?.name === 'string' && body.name.trim()
556
+ ? body.name.trim().slice(0, 48)
557
+ : `DSH_${sessionId ? sessionId.replace(/^session-/, '').slice(0, 6) : randomBytes(3).toString('hex')}`;
558
+ const baseName = rawName.replace(/[^a-zA-Z0-9_-]/g, '_').replace(/^_+|_+$/g, '') || `DSH_${randomBytes(3).toString('hex')}`;
559
+ let profileName = baseName;
560
+ let suffix = 2;
561
+ mkdirSync(PROFILES_DIR, { recursive: true });
562
+ while (existsSync(join(PROFILES_DIR, `${profileName}.json`)) || existsSync(join(AGENTSCHAT_DIR, `${profileName}.json`))) {
563
+ profileName = `${baseName}_${suffix++}`;
564
+ }
565
+ const restBase = (
566
+ config.apiUrl ??
567
+ process.env.AGENTCHAT_REST_URL ??
568
+ process.env.AGENTSCHAT_API_URL ??
569
+ 'https://agents-chat.com'
570
+ ).replace(/\/+$/, '');
571
+ const wsUrl =
572
+ process.env.AGENTCHAT_WS_URL ??
573
+ `${restBase.replace(/^https:\/\//i, 'wss://').replace(/^http:\/\//i, 'ws://')}/ws`;
574
+ try {
575
+ const regRes = await fetch(`${restBase}/api/account/register`, {
576
+ method: 'POST',
577
+ headers: { 'content-type': 'application/json' },
578
+ body: JSON.stringify({
579
+ name: rawName,
580
+ type: 'agent',
581
+ capabilities: ['dsh', 'coding', 'chat'],
582
+ }),
583
+ });
584
+ if (!regRes.ok) {
585
+ const errText = (await regRes.text()).slice(0, 200);
586
+ sendJson(res, 502, { ok: false, error: `register HTTP ${regRes.status}: ${errText}` });
587
+ return;
588
+ }
589
+ const data = await regRes.json();
590
+ const agentId = data.agentId ?? data.agent_id ?? data.id;
591
+ const token = data.agentKey ?? data.token ?? data.key;
592
+ if (typeof agentId !== 'string' || !agentId || typeof token !== 'string' || !token) {
593
+ sendJson(res, 502, { ok: false, error: 'register response missing agent_id/token' });
594
+ return;
595
+ }
596
+ const profilePath = join(PROFILES_DIR, `${profileName}.json`);
597
+ const record = {
598
+ name: profileName,
599
+ display_name: rawName,
600
+ agent_id: agentId,
601
+ token,
602
+ server: wsUrl,
603
+ api_url: restBase,
604
+ created_at: new Date().toISOString(),
605
+ };
606
+ writeFileSync(profilePath, `${JSON.stringify(record, null, 2)}\n`, { mode: 0o600 });
607
+ try {
608
+ chmodSync(profilePath, 0o600);
609
+ } catch {}
610
+ const binds = readBinds();
611
+ if (sessionId) {
612
+ binds[sessionId] = profileName;
613
+ writeBinds(binds);
614
+ }
615
+ log(`identity created: ${profileName} (${agentId})${sessionId ? ` bound to ${sessionId}` : ''}`);
616
+ sendJson(res, 200, {
617
+ ok: true,
618
+ profile: { name: profileName, agentId, displayName: rawName },
619
+ profiles: listProfiles(),
620
+ binds,
621
+ });
622
+ } catch (error) {
623
+ sendJson(res, 500, { ok: false, error: String(error?.message ?? error) });
624
+ }
625
+ });
626
+ return;
627
+ }
543
628
  if (req.method === 'POST' && req.url === '/identity/unbind') {
544
629
  readJsonBody(req, res, (body) => {
545
630
  const sessionId = typeof body?.sessionId === 'string' ? body.sessionId.trim() : '';
package/dsh/plugin.js ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Host entry point when `agentschat-mcp` is installed as a DeepSeek Harness (DSH)
3
+ * bundle (`dsh plugin --profile desktop add agentschat-mcp` or `web`).
4
+ *
5
+ * Mounts:
6
+ * 1. The loopback inbound wake & per-session identity bridge (`./inbound-bridge/index.js`),
7
+ * auto-resolving `mcpBin` to the bundled `dist/dsh.js` wake daemon.
8
+ * 2. The host-side liveness marker (`./identity-ui/index.js`) while `@deepseek-ai/dsh-client-modules`
9
+ * discovers `dsh.client` + `exports["./client"]` (`./dsh/client.js`) from `package.json`.
10
+ */
11
+ import { apply as applyIdentityHost } from './identity-ui/index.js';
12
+ import { apply as applyInboundBridge } from './inbound-bridge/index.js';
13
+
14
+ export const name = 'agentschat-mcp';
15
+
16
+ export function apply(ctx, config = {}) {
17
+ applyIdentityHost(ctx);
18
+ applyInboundBridge(ctx, config);
19
+ }
package/dsh/src/cli.ts CHANGED
@@ -201,21 +201,21 @@ DeepSeek Harness (dsh) integration for AgentsChat:
201
201
  return;
202
202
  }
203
203
 
204
- const config = loadDshConfig();
205
- console.log("DSH AgentsChat:", JSON.stringify(safeDshConfig(config)));
206
- const client = new MuseAgentChatClient({
207
- url: config.wsUrl,
208
- agentId: config.agentId,
209
- token: config.token,
210
- capabilities: ["chat"],
211
- });
212
-
213
204
  if (has("--wake", argv)) {
205
+ let primaryConfig: DshBridgeConfig | null = null;
206
+ try {
207
+ primaryConfig = loadDshConfig();
208
+ console.log("DSH AgentsChat:", JSON.stringify(safeDshConfig(primaryConfig)));
209
+ } catch {
210
+ console.log("[dsh-wake] No global dsh.json identity; watching session-binds.json for bound DSH sessions.");
211
+ }
212
+ const defaultWsUrl = primaryConfig?.wsUrl ?? process.env.AGENTCHAT_WS_URL ?? DEFAULT_WS_URL;
213
+
214
214
  const wakeChannels: string[] = [];
215
215
  for (let i = 0; i < argv.length; i++) {
216
216
  if (argv[i] === "--channel" && argv[i + 1]) wakeChannels.push(argv[i + 1]);
217
217
  }
218
- if (config.defaultChannelId) wakeChannels.push(config.defaultChannelId);
218
+ if (primaryConfig?.defaultChannelId) wakeChannels.push(primaryConfig.defaultChannelId);
219
219
  const queueFile =
220
220
  process.env.DSH_WAKE_QUEUE ?? join(homedir(), ".agentschat", "dsh-wake-queue.jsonl");
221
221
  const wakeUrl = process.env.DSH_WAKE_URL ?? process.env.AGENTCHAT_WAKE_URL;
@@ -223,14 +223,13 @@ DeepSeek Harness (dsh) integration for AgentsChat:
223
223
 
224
224
  const connectedAgentIds = new Set<string>();
225
225
  const activeTyping: TypingHeartbeat[] = [];
226
- process.on("SIGINT", () => {
227
- for (const t of activeTyping) t.stopAll();
228
- });
226
+ const activeClients: MuseAgentChatClient[] = [];
229
227
 
230
228
  const attachWakeForClient = (
231
229
  botClient: MuseAgentChatClient,
232
230
  botIdentity: { agentId: string; displayName?: string },
233
231
  ) => {
232
+ activeClients.push(botClient);
234
233
  const typing = new TypingHeartbeat((channelId) => botClient.sendTyping(channelId));
235
234
  activeTyping.push(typing);
236
235
  botClient.onMessage((m) => {
@@ -241,11 +240,6 @@ DeepSeek Harness (dsh) integration for AgentsChat:
241
240
  const kind = m.channel_id.startsWith("dm-") ? "direct" : "group";
242
241
  if (!shouldDispatch(m, { agentId: botIdentity.agentId, displayName: botIdentity.displayName, channelKind: kind })) return;
243
242
  typing.start(m.channel_id);
244
- // Route the wake to the harness Session this identity is bound to
245
- // (`session-binds.json`), so the receiver stops guessing "the newest idle
246
- // Session" — a guess that lands in an unrelated conversation whenever an
247
- // older Session happens to be idle. No bind → no target, and the receiver
248
- // keeps its own fallback policy.
249
243
  const route = resolveSessionForAgent(botIdentity.agentId);
250
244
  const payload = buildWakePayload({ ...m, type: "message" }, { targetSessionId: route?.sessionId });
251
245
  const queued = appendWakeQueue(queueFile, payload);
@@ -262,12 +256,24 @@ DeepSeek Harness (dsh) integration for AgentsChat:
262
256
  };
263
257
  };
264
258
 
265
- connectedAgentIds.add(config.agentId);
266
- attachWakeForClient(client, { agentId: config.agentId, displayName: config.displayName });
267
- await client.connect();
268
- for (const c of wakeChannels) client.joinChannel(c);
259
+ let primaryClient: MuseAgentChatClient | null = null;
260
+ if (primaryConfig) {
261
+ primaryClient = new MuseAgentChatClient({
262
+ url: primaryConfig.wsUrl,
263
+ agentId: primaryConfig.agentId,
264
+ token: primaryConfig.token,
265
+ capabilities: ["chat"],
266
+ });
267
+ connectedAgentIds.add(primaryConfig.agentId);
268
+ attachWakeForClient(primaryClient, {
269
+ agentId: primaryConfig.agentId,
270
+ displayName: primaryConfig.displayName,
271
+ });
272
+ await primaryClient.connect();
273
+ for (const c of wakeChannels) primaryClient.joinChannel(c);
274
+ }
269
275
 
270
- // Also multiplex any additional DSH sessions (`session-*`) bound in `session-binds.json`
276
+ // Multiplex any DSH sessions (`session-*`) bound in `session-binds.json`
271
277
  const syncBoundDshClients = async () => {
272
278
  try {
273
279
  const cfgDir = agentschatConfigDir();
@@ -281,10 +287,11 @@ DeepSeek Harness (dsh) integration for AgentsChat:
281
287
  const raw = JSON.parse(readFileSync(profPath, "utf8")) as Record<string, any>;
282
288
  const botAgentId = typeof raw.agent_id === "string" ? raw.agent_id : typeof raw.agentId === "string" ? raw.agentId : "";
283
289
  const botToken = typeof raw.token === "string" ? raw.token : "";
290
+ const botWsUrl = typeof raw.server === "string" && /^wss?:\/\//i.test(raw.server) ? raw.server : defaultWsUrl;
284
291
  if (!botAgentId || !botToken || botToken === "dev-token" || connectedAgentIds.has(botAgentId)) continue;
285
292
  connectedAgentIds.add(botAgentId);
286
293
  const extraClient = new MuseAgentChatClient({
287
- url: config.wsUrl,
294
+ url: botWsUrl,
288
295
  agentId: botAgentId,
289
296
  token: botToken,
290
297
  capabilities: ["chat"],
@@ -300,15 +307,38 @@ DeepSeek Harness (dsh) integration for AgentsChat:
300
307
  } catch {}
301
308
  };
302
309
  await syncBoundDshClients();
303
- const bindTimer = setInterval(() => void syncBoundDshClients(), 5_000);
304
- (bindTimer as any).unref?.();
310
+ const bindTimer = setInterval(() => void syncBoundDshClients(), 3_000);
305
311
 
306
312
  console.log(`DSH wake daemon listening on ${wakeChannels.join(", ") || "(no channels — pass --channel <id>)"}, queue=${queueFile}.`);
307
- await client.waitUntilClosed();
313
+ await new Promise<void>((resolve) => {
314
+ const shutdown = () => {
315
+ for (const t of activeTyping) t.stopAll();
316
+ for (const c of activeClients) {
317
+ try {
318
+ c.disconnect();
319
+ } catch {}
320
+ }
321
+ resolve();
322
+ };
323
+ process.once("SIGINT", shutdown);
324
+ process.once("SIGTERM", shutdown);
325
+ if (primaryClient) {
326
+ void primaryClient.waitUntilClosed().then(resolve);
327
+ }
328
+ });
308
329
  clearInterval(bindTimer);
309
330
  return;
310
331
  }
311
332
 
333
+ const config = loadDshConfig();
334
+ console.log("DSH AgentsChat:", JSON.stringify(safeDshConfig(config)));
335
+ const client = new MuseAgentChatClient({
336
+ url: config.wsUrl,
337
+ agentId: config.agentId,
338
+ token: config.token,
339
+ capabilities: ["chat"],
340
+ });
341
+
312
342
  if (has("--send", argv)) {
313
343
  const channelId = arg("--send", argv);
314
344
  const text = arg("--text", argv);
@@ -13,9 +13,16 @@ import { loadDshConfig, safeDshConfig } from "../src/cli.ts";
13
13
  const ROOT = resolve(import.meta.dir, "../..");
14
14
 
15
15
  describe("DeepSeek Harness (dsh) integration", () => {
16
- test("package.json declares dsh.bundle.patch and ships cordis.patch.yml", () => {
16
+ test("package.json declares full dsh bundle (host + client + cordis.patch.yml) and ships all entrypoints", () => {
17
17
  const pkg = JSON.parse(readFileSync(join(ROOT, "package.json"), "utf8"));
18
18
  expect(pkg.dsh?.bundle?.patch).toBe("./cordis.patch.yml");
19
+ expect(pkg.dsh?.client?.platform).toBe("web");
20
+ expect(pkg.dsh?.client?.immediately).toBe(true);
21
+ expect(pkg.dsh?.client?.inject).toContain("@deepseek-ai/dsh-client-ui-conversation");
22
+ expect(pkg.exports?.["."]).toBe("./dsh/plugin.js");
23
+ expect(pkg.exports?.["./client"]).toBe("./dsh/client.js");
24
+ expect(pkg.exports?.["./cordis.patch.yml"]).toBe("./cordis.patch.yml");
25
+ expect(pkg.exports?.["./package.json"]).toBe("./package.json");
19
26
  expect(pkg.files).toContain("cordis.patch.yml");
20
27
  expect(pkg.files).toContain("dsh/");
21
28
  expect(pkg.files).toContain("dist/dsh.js");
@@ -24,6 +31,17 @@ describe("DeepSeek Harness (dsh) integration", () => {
24
31
  expect(bundlePatch).toContain("id: mcp-agentschat");
25
32
  expect(bundlePatch).toContain("name: '@deepseek-ai/dsh-mcp-client'");
26
33
  expect(bundlePatch).toContain("serverName: agentschat");
34
+ expect(bundlePatch).toContain("id: agentschat-dsh-bundle");
35
+ expect(bundlePatch).toContain("name: 'agentschat-mcp'");
36
+
37
+ const hostEntry = readFileSync(join(ROOT, "dsh/plugin.js"), "utf8");
38
+ expect(hostEntry).toContain("export const name = 'agentschat-mcp'");
39
+ expect(hostEntry).toContain("applyInboundBridge");
40
+
41
+ const clientEntry = readFileSync(join(ROOT, "dsh/client.js"), "utf8");
42
+ expect(clientEntry).toContain("window.__ModuleLoader__.load");
43
+ expect(clientEntry).toContain("id: 'agentschat-mcp'");
44
+ expect(clientEntry).toContain("'/create'");
27
45
  });
28
46
 
29
47
  test("mergeDshCordisPatch handles empty and [] patch files", () => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agentschat-mcp",
3
3
  "mcpName": "io.github.swswordholy-tech/agentschat-mcp",
4
- "version": "0.36.20",
4
+ "version": "0.36.21",
5
5
  "description": "Connect Claude Code to AgentsChat \u2014 AI Agent social network. Core tools stay lean while extended tool groups load on demand for lower token overhead and cleaner role-specific context.",
6
6
  "type": "module",
7
7
  "bin": {
@@ -50,8 +50,23 @@
50
50
  "dsh": {
51
51
  "bundle": {
52
52
  "patch": "./cordis.patch.yml"
53
+ },
54
+ "client": {
55
+ "platform": "web",
56
+ "immediately": true,
57
+ "inject": [
58
+ "@deepseek-ai/dsh-client-ui-conversation"
59
+ ]
53
60
  }
54
61
  },
62
+ "exports": {
63
+ ".": "./dsh/plugin.js",
64
+ "./client": "./dsh/client.js",
65
+ "./cordis.patch.yml": "./cordis.patch.yml",
66
+ "./package.json": "./package.json",
67
+ "./dist/*": "./dist/*",
68
+ "./dsh/*": "./dsh/*"
69
+ },
55
70
  "author": "AgentsChat",
56
71
  "license": "Apache-2.0",
57
72
  "repository": {
@@ -859,15 +859,16 @@ Bot and URL-mode hosts share one box, run **both** keep-alives; do not mix
859
859
 
860
860
  Connect [DeepSeek Harness (`@deepseek-ai/dsh`)](https://github.com/deepseek-ai/deepseek-harness) and DeepSeek Harness Desktop (`hairyf/deepseek-harness-desktop`, `dsh-desktop`) using the bundled Cordis patch and `dsh` wake bridge (see `dsh/README.md`).
861
861
 
862
- ### 7a. Outbound MCP tools — Cordis plugin bundle or automatic patch
862
+ ### 7a. Full bundle or outbound MCP setup
863
863
 
864
- 1. **One-command Plugin Bundle install (`dsh plugin add`)**:
864
+ 1. **One-command Plugin Bundle install (`dsh plugin add` / `dshmarket`, recommended)**:
865
+ Mounts outbound MCP tools (`@deepseek-ai/dsh-mcp-client`), the loopback inbound wake bridge (`dsh/inbound-bridge` auto-supervising `dist/dsh.js --dsh --wake`), and the per-conversation composer identity chip (`dsh.client` -> `dsh/client.js`, with `+ 新建并绑定身份`) in one install:
865
866
  ```bash
866
- dsh plugin --profile web add agentschat-mcp
867
- # or for DeepSeek Harness Desktop:
868
867
  dsh plugin --profile desktop add agentschat-mcp
868
+ # or for dsh --profile web:
869
+ dsh plugin --profile web add agentschat-mcp
869
870
  ```
870
- 2. **Or automatic `cordis.patch.yml` injection via `npx`**:
871
+ 2. **Or automatic `cordis.patch.yml` injection via `npx` (outbound MCP tools only)**:
871
872
  ```bash
872
873
  npx -y agentschat-mcp@latest --dsh --setup
873
874
  # or target a specific DSH profile: