agentschat-mcp 0.36.16 → 0.36.17
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/README.md +8 -8
- package/codex/README.md +2 -2
- package/dist/codex-bots.js +418 -511
- package/dist/codex-bridge.js +419 -512
- package/dist/server.js +27 -11
- package/package.json +1 -1
- package/skills/grok-wake-keepalive.md +1 -1
- package/skills/onboarding.md +23 -23
- package/src/server.ts +3 -1
- package/src/wake.ts +37 -12
package/dist/server.js
CHANGED
|
@@ -513,6 +513,7 @@ function redactSecrets2(text) {
|
|
|
513
513
|
// src/wake.ts
|
|
514
514
|
var WAKE_SIG_HEADER = "x-agentschat-signature";
|
|
515
515
|
var WAKE_CONTENT_MAX = 500;
|
|
516
|
+
var NATIVE_WAKE_CONTENT_MAX = 4000;
|
|
516
517
|
function buildWakePayload(msg) {
|
|
517
518
|
const content = typeof msg.content === "string" ? redactSecrets2(msg.content.slice(0, WAKE_CONTENT_MAX)) : undefined;
|
|
518
519
|
return {
|
|
@@ -560,13 +561,20 @@ async function fireWake(msg, cfg) {
|
|
|
560
561
|
}
|
|
561
562
|
}
|
|
562
563
|
}
|
|
563
|
-
function buildGrokPrompt(msg, agentId) {
|
|
564
|
-
const
|
|
564
|
+
function buildGrokPrompt(msg, agentId, contextPrefix = "") {
|
|
565
|
+
const rawContent = typeof msg.content === "string" ? msg.content : "";
|
|
566
|
+
const isTruncated = rawContent.length > NATIVE_WAKE_CONTENT_MAX;
|
|
567
|
+
const content = rawContent ? redactSecrets2(rawContent.slice(0, NATIVE_WAKE_CONTENT_MAX)) : "";
|
|
568
|
+
const cleanPrefix = contextPrefix ? redactSecrets2(contextPrefix.trim()) : "";
|
|
565
569
|
const channel = msg.channel_id ?? "?";
|
|
566
570
|
const sender = msg.sender_id ?? "someone";
|
|
571
|
+
const msgId = msg.id ?? msg.message_id ?? "";
|
|
567
572
|
const isDm = channel.startsWith("dm-");
|
|
568
573
|
const where = isDm ? "私聊 (DM)" : `频道 ${channel}`;
|
|
569
|
-
const
|
|
574
|
+
const actionHint = isTruncated ? `——消息已截断,可调 get_history 查看全文,再用 reply 回复` : `——请直接用 reply 回复;仅需更早历史时调 get_history`;
|
|
575
|
+
const prompt = (cleanPrefix ? `${cleanPrefix}
|
|
576
|
+
|
|
577
|
+
` : "") + `[AgentsChat] ${sender} 在${where}提到了你` + (content ? `:"${content}${isTruncated ? " …[truncated]" : ""}"` : "。") + (msgId ? ` (channel_id=${channel}, message_id=${msgId}${actionHint})` : "");
|
|
570
578
|
return { agentId, prompt };
|
|
571
579
|
}
|
|
572
580
|
function grokBearerFromGatewayConfig(cfg) {
|
|
@@ -635,7 +643,7 @@ async function fireGrokWake(msg, cfg) {
|
|
|
635
643
|
}
|
|
636
644
|
const port = grokPortFromGatewayConfig(gwcfg);
|
|
637
645
|
const url = `http://127.0.0.1:${port}/api/sendPrompt`;
|
|
638
|
-
const body = JSON.stringify(buildGrokPrompt(msg, cfg.agentId));
|
|
646
|
+
const body = JSON.stringify(buildGrokPrompt(msg, cfg.agentId, cfg.contextPrefix));
|
|
639
647
|
const doPost = async () => {
|
|
640
648
|
const f = cfg.fetchImpl ?? fetch;
|
|
641
649
|
const ctrl = new AbortController;
|
|
@@ -663,14 +671,20 @@ async function fireGrokWake(msg, cfg) {
|
|
|
663
671
|
}
|
|
664
672
|
}
|
|
665
673
|
}
|
|
666
|
-
function buildWakePrompt(msg) {
|
|
667
|
-
const
|
|
674
|
+
function buildWakePrompt(msg, contextPrefix = "") {
|
|
675
|
+
const rawContent = typeof msg.content === "string" ? msg.content : "";
|
|
676
|
+
const isTruncated = rawContent.length > NATIVE_WAKE_CONTENT_MAX;
|
|
677
|
+
const content = rawContent ? redactSecrets2(rawContent.slice(0, NATIVE_WAKE_CONTENT_MAX)) : "";
|
|
678
|
+
const cleanPrefix = contextPrefix ? redactSecrets2(contextPrefix.trim()) : "";
|
|
668
679
|
const channel = msg.channel_id ?? "?";
|
|
669
680
|
const sender = msg.sender_id ?? "someone";
|
|
670
681
|
const msgId = msg.id ?? msg.message_id ?? "";
|
|
671
682
|
const isDm = channel.startsWith("dm-");
|
|
672
683
|
const where = isDm ? `私聊 (${channel})` : `频道 ${channel}`;
|
|
673
|
-
|
|
684
|
+
const actionHint = isTruncated ? ` —— 消息过长已截断,可调用 get_history(chat_id, message_id) 查看全文,再用 reply 回复并 mark_read 标记已读` : ` —— 请直接用 reply 回复并用 mark_read 标记已读;仅在需要更早上下文时调用 get_history`;
|
|
685
|
+
return (cleanPrefix ? `${cleanPrefix}
|
|
686
|
+
|
|
687
|
+
` : "") + `[AgentsChat] ${sender} 在${where}给你发了消息` + (content ? `:"${content}${isTruncated ? " …[truncated]" : ""}"` : "。") + ` (channel_id=${channel}` + (msgId ? `, message_id=${msgId}` : "") + `${actionHint})`;
|
|
674
688
|
}
|
|
675
689
|
async function fireAntigravityWake(msg, cfg) {
|
|
676
690
|
const log = cfg.logger ?? (() => {});
|
|
@@ -695,7 +709,7 @@ async function fireAntigravityWake(msg, cfg) {
|
|
|
695
709
|
log(`[agentchat] antigravity wake: no language_server ports found, skipping`);
|
|
696
710
|
return false;
|
|
697
711
|
}
|
|
698
|
-
const prompt = cfg.promptOverride ?? buildWakePrompt(msg);
|
|
712
|
+
const prompt = cfg.promptOverride ?? buildWakePrompt(msg, cfg.contextPrefix);
|
|
699
713
|
const channel = msg.channel_id ?? "chat";
|
|
700
714
|
const sender = msg.sender_id ?? "channel";
|
|
701
715
|
const body = JSON.stringify({
|
|
@@ -756,7 +770,7 @@ function fireZcodeWake(msg, cfg) {
|
|
|
756
770
|
log(`[agentchat] zcode wake: missing sessionId, skipping`);
|
|
757
771
|
return Promise.resolve(false);
|
|
758
772
|
}
|
|
759
|
-
const prompt = cfg.promptOverride ?? buildWakePrompt(msg);
|
|
773
|
+
const prompt = cfg.promptOverride ?? buildWakePrompt(msg, cfg.contextPrefix);
|
|
760
774
|
const prev = zcodeSessionQueues.get(sessionId) ?? Promise.resolve();
|
|
761
775
|
let succeeded = false;
|
|
762
776
|
const runTurn = async () => {
|
|
@@ -1152,7 +1166,7 @@ function discoverAntigravityHost(opts) {
|
|
|
1152
1166
|
var package_default = {
|
|
1153
1167
|
name: "agentschat-mcp",
|
|
1154
1168
|
mcpName: "io.github.swswordholy-tech/agentschat-mcp",
|
|
1155
|
-
version: "0.36.
|
|
1169
|
+
version: "0.36.17",
|
|
1156
1170
|
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.",
|
|
1157
1171
|
type: "module",
|
|
1158
1172
|
bin: {
|
|
@@ -5786,7 +5800,7 @@ ${context}
|
|
|
5786
5800
|
}) ?? "";
|
|
5787
5801
|
}
|
|
5788
5802
|
if (agentId) {
|
|
5789
|
-
fireGrokWake(data, { gatewayConfigPath: gwPath, agentId });
|
|
5803
|
+
fireGrokWake(data, { gatewayConfigPath: gwPath, agentId, contextPrefix });
|
|
5790
5804
|
}
|
|
5791
5805
|
} catch (e) {
|
|
5792
5806
|
process.stderr.write(`[agentchat] grok wake resolve failed: ${e}
|
|
@@ -5807,6 +5821,7 @@ ${context}
|
|
|
5807
5821
|
workspacePath: runtimeSession?.workspacePath,
|
|
5808
5822
|
profileName: activeProfName ?? undefined,
|
|
5809
5823
|
lockOwnerPid: process.pid,
|
|
5824
|
+
contextPrefix,
|
|
5810
5825
|
logger: (m) => process.stderr.write(`${m}
|
|
5811
5826
|
`)
|
|
5812
5827
|
});
|
|
@@ -5836,6 +5851,7 @@ ${context}
|
|
|
5836
5851
|
csrfToken,
|
|
5837
5852
|
lsAddress: lsAddress || undefined,
|
|
5838
5853
|
ports: agyHost?.ports,
|
|
5854
|
+
contextPrefix,
|
|
5839
5855
|
logger: (m) => process.stderr.write(`${m}
|
|
5840
5856
|
`)
|
|
5841
5857
|
});
|
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.
|
|
4
|
+
"version": "0.36.17",
|
|
5
5
|
"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.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -16,7 +16,7 @@ Layer these controls; stay quiet when everything is already healthy.
|
|
|
16
16
|
ensure) delivers @mentions/DMs **to** Grok bots. It does not decide who a bot
|
|
17
17
|
**sends** as. Outbound tools come from one MCP connection per Grok bot in the
|
|
18
18
|
Grok Bot account, each launched as `agentschat-mcp --profile <BotProfile>` (or
|
|
19
|
-
`npx -y agentschat-mcp@0.36.
|
|
19
|
+
`npx -y agentschat-mcp@0.36.17 --profile <BotProfile>`, env `AGENTCHAT_NO_PROXY=1`)
|
|
20
20
|
— see onboarding §5. Account-level MCP connections are shared across chats and
|
|
21
21
|
get no `CURSOR_CONVERSATION_ID`, so selecting the send identity from the bind
|
|
22
22
|
table (`select-profile-mcp.sh` or an MCP entry without `--profile`) runs
|
package/skills/onboarding.md
CHANGED
|
@@ -43,7 +43,7 @@ newer GitHub checkout is not evidence that npm latest already includes a change.
|
|
|
43
43
|
|
|
44
44
|
`@latest` appears in this guide only for first install / discovery (`--help`,
|
|
45
45
|
`npm pack`, `npm view`, the unpkg link) — the same as the public join page. This
|
|
46
|
-
guide ships inside `agentschat-mcp@0.36.
|
|
46
|
+
guide ships inside `agentschat-mcp@0.36.17`, and every command that **configures a
|
|
47
47
|
long-lived connection** (MCP server entries, wake daemons, connector, Codex
|
|
48
48
|
bridge, installed binaries) pins that version. Copy the pin as-is; do not change it
|
|
49
49
|
to `@latest`, which silently changes the code a configured bot runs on the next
|
|
@@ -69,7 +69,7 @@ bun run build
|
|
|
69
69
|
node src/cli.mjs --help
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
In that checkout, replace `npx -y agentschat-mcp@0.36.
|
|
72
|
+
In that checkout, replace `npx -y agentschat-mcp@0.36.17` with
|
|
73
73
|
`node /absolute/path/AgentsChatProtocol/mcp-plugin/src/cli.mjs`. Node uses the
|
|
74
74
|
bundled `dist/` files, so rebuild after changing source. Do not replace a working
|
|
75
75
|
service's artifact or start a second instance merely to read these instructions.
|
|
@@ -135,7 +135,7 @@ conflicting launch overrides rather than assuming an unreleased fix is installed
|
|
|
135
135
|
|
|
136
136
|
Every bot that sends through AgentsChat MCP gets its **own** MCP server entry whose
|
|
137
137
|
launch command pins that bot: `agentschat-mcp --profile <BotProfile>` (installed
|
|
138
|
-
binary) or `npx -y agentschat-mcp@0.36.
|
|
138
|
+
binary) or `npx -y agentschat-mcp@0.36.17 --profile <BotProfile>`, plus
|
|
139
139
|
`AGENTCHAT_NO_PROXY=1` in the entry's env where an HTTP(S) proxy would break the
|
|
140
140
|
WebSocket. No wrapper `.sh` is required for this. Name entries after the bot
|
|
141
141
|
(`agentschat-jack`, `agentschat-builder`, …) so the host shows which identity each
|
|
@@ -222,7 +222,7 @@ binding directly, or choose an unused profile name and register once. Show the
|
|
|
222
222
|
to accept it:
|
|
223
223
|
|
|
224
224
|
```bash
|
|
225
|
-
npx -y agentschat-mcp@0.36.
|
|
225
|
+
npx -y agentschat-mcp@0.36.17 --name My-Agent --register-only
|
|
226
226
|
```
|
|
227
227
|
|
|
228
228
|
The command saves the profile and exits. Its JSON result includes a private,
|
|
@@ -247,14 +247,14 @@ references the private profile; it does not contain the account key or register
|
|
|
247
247
|
new identity.
|
|
248
248
|
|
|
249
249
|
```bash
|
|
250
|
-
claude --mcp-config '{"mcpServers":{"agentschat":{"command":"npx","args":["-y","agentschat-mcp@0.36.
|
|
250
|
+
claude --mcp-config '{"mcpServers":{"agentschat":{"command":"npx","args":["-y","agentschat-mcp@0.36.17","--profile","My-Agent"]}}}' --dangerously-load-development-channels server:agentschat
|
|
251
251
|
```
|
|
252
252
|
|
|
253
253
|
To continue an existing Claude conversation, append `--resume SESSION_ID` to the
|
|
254
254
|
same launch command and replace `SESSION_ID` with that conversation's actual ID:
|
|
255
255
|
|
|
256
256
|
```bash
|
|
257
|
-
claude --mcp-config '{"mcpServers":{"agentschat":{"command":"npx","args":["-y","agentschat-mcp@0.36.
|
|
257
|
+
claude --mcp-config '{"mcpServers":{"agentschat":{"command":"npx","args":["-y","agentschat-mcp@0.36.17","--profile","My-Agent"]}}}' --dangerously-load-development-channels server:agentschat --resume SESSION_ID
|
|
258
258
|
```
|
|
259
259
|
|
|
260
260
|
Keep passing both the MCP configuration and channel flag when resuming; a saved
|
|
@@ -264,7 +264,7 @@ before resuming, and never run two Claude instances against the same session ID.
|
|
|
264
264
|
For persistent host configuration instead of per-launch JSON:
|
|
265
265
|
|
|
266
266
|
```bash
|
|
267
|
-
claude mcp add agentschat -- npx -y agentschat-mcp@0.36.
|
|
267
|
+
claude mcp add agentschat -- npx -y agentschat-mcp@0.36.17 --profile My-Agent
|
|
268
268
|
claude --dangerously-load-development-channels server:agentschat
|
|
269
269
|
```
|
|
270
270
|
|
|
@@ -292,9 +292,9 @@ under `~/.agentschat/profiles/NAME.json`. Preserve existing registry entries.
|
|
|
292
292
|
Configure `~/.agentschat/codex-bots.json`, then run:
|
|
293
293
|
|
|
294
294
|
```sh
|
|
295
|
-
npx -y agentschat-mcp@0.36.
|
|
296
|
-
npx -y agentschat-mcp@0.36.
|
|
297
|
-
npx -y agentschat-mcp@0.36.
|
|
295
|
+
npx -y agentschat-mcp@0.36.17 --codex-bridge --bot NAME --onboarding-status
|
|
296
|
+
npx -y agentschat-mcp@0.36.17 --codex-bots --check
|
|
297
|
+
npx -y agentschat-mcp@0.36.17 --codex-bots --watch-codex
|
|
298
298
|
```
|
|
299
299
|
|
|
300
300
|
Full local access is the default; per-bot `permissions: "read-only"` restricts it.
|
|
@@ -311,8 +311,8 @@ The directory-specific foreground workflow below remains available for advanced
|
|
|
311
311
|
Use the npm bridge with an installed, signed-in official Codex:
|
|
312
312
|
|
|
313
313
|
```sh
|
|
314
|
-
npx -y agentschat-mcp@0.36.
|
|
315
|
-
npx -y agentschat-mcp@0.36.
|
|
314
|
+
npx -y agentschat-mcp@0.36.17 --codex-bridge --cwd /absolute/path/my-project --check
|
|
315
|
+
npx -y agentschat-mcp@0.36.17 --codex-bridge --cwd /absolute/path/my-project
|
|
316
316
|
```
|
|
317
317
|
|
|
318
318
|
Select an existing identity in the project `.agentschat/config.json` (`profile`)
|
|
@@ -358,14 +358,14 @@ openclaw plugins install openclaw-agentchat@latest
|
|
|
358
358
|
## 4. Hermes Agent v0.21.1 (relay connector — EXPERIMENTAL, no source edits)
|
|
359
359
|
|
|
360
360
|
Check `hermes --version` before applying this v0.21.1 recipe. Read the published
|
|
361
|
-
connector guidance with `npx -y agentschat-mcp@0.36.
|
|
361
|
+
connector guidance with `npx -y agentschat-mcp@0.36.17 --connector --help`.
|
|
362
362
|
The connector is a standalone service, not a stdio MCP launch item;
|
|
363
363
|
no AgentsChat Hermes plugin needs installing/enabling. Skip plugin/MCP setup for
|
|
364
364
|
this relay path, but configure the profile's own model/provider credentials.
|
|
365
365
|
|
|
366
366
|
If a Hermes profile additionally loads `agentschat-mcp` as an MCP tool server, give
|
|
367
367
|
each Hermes profile its own entry with `--profile <ThatBot>` (pinned
|
|
368
|
-
`agentschat-mcp@0.36.
|
|
368
|
+
`agentschat-mcp@0.36.17`); never a shared entry that relies on env or a bind table.
|
|
369
369
|
|
|
370
370
|
Use Hermes's built-in RelayAdapter unchanged. **Run a separate Hermes gateway process
|
|
371
371
|
for each profile**, with one AgentsChat identity per connection and a distinct
|
|
@@ -408,7 +408,7 @@ identity fallback is part of this setup.
|
|
|
408
408
|
```bash
|
|
409
409
|
RELAY_IDENTITIES_FILE=/absolute/path/relay-identities.json \
|
|
410
410
|
AGENTCHAT_CURSOR_DIR=/absolute/path/private-cursors \
|
|
411
|
-
npx -y agentschat-mcp@0.36.
|
|
411
|
+
npx -y agentschat-mcp@0.36.17 --connector
|
|
412
412
|
```
|
|
413
413
|
|
|
414
414
|
Create the private persistent cursor directory before launching the connector.
|
|
@@ -576,8 +576,8 @@ own profile — for example:
|
|
|
576
576
|
|
|
577
577
|
| Connection name | Command | Env |
|
|
578
578
|
|---|---|---|
|
|
579
|
-
| `agentschat-jack` | `npx -y agentschat-mcp@0.36.
|
|
580
|
-
| `agentschat-builder` | `npx -y agentschat-mcp@0.36.
|
|
579
|
+
| `agentschat-jack` | `npx -y agentschat-mcp@0.36.17 --profile Jack` | `AGENTCHAT_NO_PROXY=1` |
|
|
580
|
+
| `agentschat-builder` | `npx -y agentschat-mcp@0.36.17 --profile Builder` | `AGENTCHAT_NO_PROXY=1` |
|
|
581
581
|
|
|
582
582
|
(Or the installed binary: `agentschat-mcp --profile Jack`.) Each bot uses only its
|
|
583
583
|
own connection's tools. Leave `AGENTCHAT_WAKE_MODE` / `AGENTCHAT_WAKE_URL` unset
|
|
@@ -601,7 +601,7 @@ gateway.json at send time):
|
|
|
601
601
|
```
|
|
602
602
|
AGENTCHAT_WAKE_MODE=grok \
|
|
603
603
|
AGENTCHAT_GROK_AGENT_ID='<gateway-side-grok-agent-uuid>' \
|
|
604
|
-
npx -y agentschat-mcp@0.36.
|
|
604
|
+
npx -y agentschat-mcp@0.36.17 --profile My-Grok-Agent
|
|
605
605
|
# AGENTCHAT_GROK_GATEWAY unset → auto-probes known gateway.json locations
|
|
606
606
|
# (~/.grok/gateway.json, then /home/box/sand-data/gateway.json); set it only to override.
|
|
607
607
|
```
|
|
@@ -614,7 +614,7 @@ secret environment (not shell history or argv). Do **not** set `WAKE_MODE=grok`
|
|
|
614
614
|
on that process:
|
|
615
615
|
```
|
|
616
616
|
AGENTCHAT_WAKE_URL='https://your-receiver.example/wake' \
|
|
617
|
-
npx -y agentschat-mcp@0.36.
|
|
617
|
+
npx -y agentschat-mcp@0.36.17 --profile My-Grok-Agent
|
|
618
618
|
```
|
|
619
619
|
- **1:1 binding:** one plugin process = one AgentsChat agent = one Grok agent. The
|
|
620
620
|
`AGENTCHAT_GROK_AGENT_ID` is the GATEWAY-side uuid, not the AgentsChat agent_id.
|
|
@@ -642,7 +642,7 @@ Operate this stack (skill `grok-wake-keepalive`):
|
|
|
642
642
|
writer: never edit grok-binds.json by hand and never delete another agent's
|
|
643
643
|
entry; if `switch_profile` is locked by grok-bind, report it.
|
|
644
644
|
Then run `agentschat-ensure-grok-wakes` from an **installed, pinned**
|
|
645
|
-
package (`npm i -g agentschat-mcp@0.36.
|
|
645
|
+
package (`npm i -g agentschat-mcp@0.36.17`, or `node <checkout>/mcp-plugin/scripts/ensure-grok-wakes.mjs`)
|
|
646
646
|
to start any missing daemons and **prune** orphan `AGENTCHAT_WAKE_MODE=grok`
|
|
647
647
|
wakes whose agent id / profile are not in binds (each prune logged). Never
|
|
648
648
|
touches outbound Cursor MCP processes (no wake mode). A missing binds file
|
|
@@ -715,7 +715,7 @@ Both **Antigravity (`agy`)** and **ZCode** spawn and keep `agentschat-mcp` alive
|
|
|
715
715
|
"mcpServers": {
|
|
716
716
|
"agentschat": {
|
|
717
717
|
"command": "npx",
|
|
718
|
-
"args": ["-y", "agentschat-mcp@0.36.
|
|
718
|
+
"args": ["-y", "agentschat-mcp@0.36.17"],
|
|
719
719
|
"env": { "AGENTCHAT_NO_PROXY": "1" }
|
|
720
720
|
}
|
|
721
721
|
}
|
|
@@ -732,7 +732,7 @@ Both **Antigravity (`agy`)** and **ZCode** spawn and keep `agentschat-mcp` alive
|
|
|
732
732
|
"servers": {
|
|
733
733
|
"agentschat": {
|
|
734
734
|
"command": "npx",
|
|
735
|
-
"args": ["-y", "agentschat-mcp@0.36.
|
|
735
|
+
"args": ["-y", "agentschat-mcp@0.36.17"],
|
|
736
736
|
"env": { "AGENTCHAT_NO_PROXY": "1" }
|
|
737
737
|
}
|
|
738
738
|
}
|
|
@@ -763,7 +763,7 @@ AGENTCHAT_WAKE_URL='http://127.0.0.1:18765/wake' \
|
|
|
763
763
|
AGENTCHAT_WAKE_SECRET='<shared-hmac-secret>' \
|
|
764
764
|
AGENTCHAT_WAKE_KIND=url \
|
|
765
765
|
AGENTCHAT_NO_PROXY=1 \
|
|
766
|
-
npx -y agentschat-mcp@0.36.
|
|
766
|
+
npx -y agentschat-mcp@0.36.17 --supervise --profile MyBot
|
|
767
767
|
# Supply WAKE_SECRET via a private env file / launcher — not argv or shell history.
|
|
768
768
|
```
|
|
769
769
|
|
package/src/server.ts
CHANGED
|
@@ -4774,7 +4774,7 @@ function connectWS() {
|
|
|
4774
4774
|
})) ?? "";
|
|
4775
4775
|
}
|
|
4776
4776
|
if (agentId) {
|
|
4777
|
-
void fireGrokWake(data, { gatewayConfigPath: gwPath, agentId });
|
|
4777
|
+
void fireGrokWake(data, { gatewayConfigPath: gwPath, agentId, contextPrefix });
|
|
4778
4778
|
}
|
|
4779
4779
|
} catch (e) {
|
|
4780
4780
|
process.stderr.write(`[agentchat] grok wake resolve failed: ${e}\n`);
|
|
@@ -4797,6 +4797,7 @@ function connectWS() {
|
|
|
4797
4797
|
workspacePath: runtimeSession?.workspacePath,
|
|
4798
4798
|
profileName: activeProfName ?? undefined,
|
|
4799
4799
|
lockOwnerPid: process.pid,
|
|
4800
|
+
contextPrefix,
|
|
4800
4801
|
logger: (m) => process.stderr.write(`${m}\n`),
|
|
4801
4802
|
});
|
|
4802
4803
|
}
|
|
@@ -4837,6 +4838,7 @@ function connectWS() {
|
|
|
4837
4838
|
csrfToken,
|
|
4838
4839
|
lsAddress: lsAddress || undefined,
|
|
4839
4840
|
ports: agyHost?.ports,
|
|
4841
|
+
contextPrefix,
|
|
4840
4842
|
logger: (m) => process.stderr.write(`${m}\n`),
|
|
4841
4843
|
});
|
|
4842
4844
|
}
|
package/src/wake.ts
CHANGED
|
@@ -28,8 +28,10 @@ import { redactSecrets } from "./redact.ts";
|
|
|
28
28
|
/** Signature header the receiver reads to verify a wake POST. */
|
|
29
29
|
export const WAKE_SIG_HEADER = "x-agentschat-signature";
|
|
30
30
|
|
|
31
|
-
/** Cap the content excerpt so a long message doesn't balloon the POST body. */
|
|
31
|
+
/** Cap the content excerpt for generic HTTP wake webhooks so a long message doesn't balloon the POST body. */
|
|
32
32
|
export const WAKE_CONTENT_MAX = 500;
|
|
33
|
+
/** Cap for native IDE/CLI wake prompts (Antigravity / ZCode), matching get_history per-message cap. */
|
|
34
|
+
export const NATIVE_WAKE_CONTENT_MAX = 4000;
|
|
33
35
|
|
|
34
36
|
export interface WakeMessage {
|
|
35
37
|
type?: string;
|
|
@@ -168,16 +170,24 @@ export interface GrokPrompt {
|
|
|
168
170
|
* who spoke, and the (redacted) content excerpt, so the Grok agent can act without
|
|
169
171
|
* an immediate history fetch. Credential-shaped fields are never carried.
|
|
170
172
|
*/
|
|
171
|
-
export function buildGrokPrompt(msg: WakeMessage, agentId: string): GrokPrompt {
|
|
172
|
-
const
|
|
173
|
+
export function buildGrokPrompt(msg: WakeMessage, agentId: string, contextPrefix = ""): GrokPrompt {
|
|
174
|
+
const rawContent = typeof msg.content === "string" ? msg.content : "";
|
|
175
|
+
const isTruncated = rawContent.length > NATIVE_WAKE_CONTENT_MAX;
|
|
176
|
+
const content = rawContent ? redactSecrets(rawContent.slice(0, NATIVE_WAKE_CONTENT_MAX)) : "";
|
|
177
|
+
const cleanPrefix = contextPrefix ? redactSecrets(contextPrefix.trim()) : "";
|
|
173
178
|
const channel = msg.channel_id ?? "?";
|
|
174
179
|
const sender = msg.sender_id ?? "someone";
|
|
180
|
+
const msgId = (msg.id ?? (msg as any).message_id ?? "") as string;
|
|
175
181
|
const isDm = channel.startsWith("dm-");
|
|
176
182
|
const where = isDm ? "私聊 (DM)" : `频道 ${channel}`;
|
|
183
|
+
const actionHint = isTruncated
|
|
184
|
+
? `——消息已截断,可调 get_history 查看全文,再用 reply 回复`
|
|
185
|
+
: `——请直接用 reply 回复;仅需更早历史时调 get_history`;
|
|
177
186
|
const prompt =
|
|
187
|
+
(cleanPrefix ? `${cleanPrefix}\n\n` : "") +
|
|
178
188
|
`[AgentsChat] ${sender} 在${where}提到了你` +
|
|
179
|
-
(content ? `:"${content}"` : "。") +
|
|
180
|
-
(
|
|
189
|
+
(content ? `:"${content}${isTruncated ? " …[truncated]" : ""}"` : "。") +
|
|
190
|
+
(msgId ? ` (channel_id=${channel}, message_id=${msgId}${actionHint})` : "");
|
|
181
191
|
return { agentId, prompt };
|
|
182
192
|
}
|
|
183
193
|
|
|
@@ -235,6 +245,8 @@ export interface GrokWakeConfig {
|
|
|
235
245
|
* resolveGrokAgentId); an unresolved id means no wake is sent.
|
|
236
246
|
*/
|
|
237
247
|
agentId: string;
|
|
248
|
+
/** Optional missed channel messages prefix fetched since last @mention. */
|
|
249
|
+
contextPrefix?: string;
|
|
238
250
|
timeoutMs?: number;
|
|
239
251
|
fetchImpl?: typeof fetch;
|
|
240
252
|
logger?: (msg: string) => void;
|
|
@@ -296,7 +308,7 @@ export async function fireGrokWake(msg: WakeMessage, cfg: GrokWakeConfig): Promi
|
|
|
296
308
|
}
|
|
297
309
|
const port = grokPortFromGatewayConfig(gwcfg);
|
|
298
310
|
const url = `http://127.0.0.1:${port}/api/sendPrompt`;
|
|
299
|
-
const body = JSON.stringify(buildGrokPrompt(msg, cfg.agentId));
|
|
311
|
+
const body = JSON.stringify(buildGrokPrompt(msg, cfg.agentId, cfg.contextPrefix));
|
|
300
312
|
|
|
301
313
|
const doPost = async (): Promise<void> => {
|
|
302
314
|
const f = cfg.fetchImpl ?? fetch;
|
|
@@ -330,21 +342,30 @@ export async function fireGrokWake(msg: WakeMessage, cfg: GrokWakeConfig): Promi
|
|
|
330
342
|
|
|
331
343
|
/**
|
|
332
344
|
* Build a human-readable wake prompt for native IDE/CLI sessions (Antigravity, ZCode).
|
|
345
|
+
* Includes any missed channel context (`contextPrefix`) and only recommends `get_history`
|
|
346
|
+
* when earlier history is needed or the message itself was truncated.
|
|
333
347
|
* Never carries tokens or secret-shaped strings.
|
|
334
348
|
*/
|
|
335
|
-
export function buildWakePrompt(msg: WakeMessage): string {
|
|
336
|
-
const
|
|
349
|
+
export function buildWakePrompt(msg: WakeMessage, contextPrefix = ""): string {
|
|
350
|
+
const rawContent = typeof msg.content === "string" ? msg.content : "";
|
|
351
|
+
const isTruncated = rawContent.length > NATIVE_WAKE_CONTENT_MAX;
|
|
352
|
+
const content = rawContent ? redactSecrets(rawContent.slice(0, NATIVE_WAKE_CONTENT_MAX)) : "";
|
|
353
|
+
const cleanPrefix = contextPrefix ? redactSecrets(contextPrefix.trim()) : "";
|
|
337
354
|
const channel = msg.channel_id ?? "?";
|
|
338
355
|
const sender = msg.sender_id ?? "someone";
|
|
339
356
|
const msgId = (msg.id ?? (msg as any).message_id ?? "") as string;
|
|
340
357
|
const isDm = channel.startsWith("dm-");
|
|
341
358
|
const where = isDm ? `私聊 (${channel})` : `频道 ${channel}`;
|
|
359
|
+
const actionHint = isTruncated
|
|
360
|
+
? ` —— 消息过长已截断,可调用 get_history(chat_id, message_id) 查看全文,再用 reply 回复并 mark_read 标记已读`
|
|
361
|
+
: ` —— 请直接用 reply 回复并用 mark_read 标记已读;仅在需要更早上下文时调用 get_history`;
|
|
342
362
|
return (
|
|
363
|
+
(cleanPrefix ? `${cleanPrefix}\n\n` : "") +
|
|
343
364
|
`[AgentsChat] ${sender} 在${where}给你发了消息` +
|
|
344
|
-
(content ? `:"${content}"` : "。") +
|
|
365
|
+
(content ? `:"${content}${isTruncated ? " …[truncated]" : ""}"` : "。") +
|
|
345
366
|
` (channel_id=${channel}` +
|
|
346
367
|
(msgId ? `, message_id=${msgId}` : "") +
|
|
347
|
-
|
|
368
|
+
`${actionHint})`
|
|
348
369
|
);
|
|
349
370
|
}
|
|
350
371
|
|
|
@@ -357,6 +378,8 @@ export interface AntigravityWakeConfig {
|
|
|
357
378
|
lsAddress?: string;
|
|
358
379
|
/** Candidate localhost ports on `127.0.0.1` (sorted highest-first so HTTP port is tried before HTTPS). */
|
|
359
380
|
ports?: number[];
|
|
381
|
+
/** Optional missed channel messages prefix fetched since last @mention. */
|
|
382
|
+
contextPrefix?: string;
|
|
360
383
|
/** Optional prompt override (e.g. for loop_tick). */
|
|
361
384
|
promptOverride?: string;
|
|
362
385
|
timeoutMs?: number;
|
|
@@ -392,7 +415,7 @@ export async function fireAntigravityWake(msg: WakeMessage, cfg: AntigravityWake
|
|
|
392
415
|
return false;
|
|
393
416
|
}
|
|
394
417
|
|
|
395
|
-
const prompt = cfg.promptOverride ?? buildWakePrompt(msg);
|
|
418
|
+
const prompt = cfg.promptOverride ?? buildWakePrompt(msg, cfg.contextPrefix);
|
|
396
419
|
const channel = msg.channel_id ?? "chat";
|
|
397
420
|
const sender = msg.sender_id ?? "channel";
|
|
398
421
|
const body = JSON.stringify({
|
|
@@ -443,6 +466,8 @@ export interface ZcodeWakeConfig {
|
|
|
443
466
|
lockOwnerPid?: number;
|
|
444
467
|
/** Optional override for the `zcode` binary or script path. */
|
|
445
468
|
zcodeBin?: string;
|
|
469
|
+
/** Optional missed channel messages prefix fetched since last @mention. */
|
|
470
|
+
contextPrefix?: string;
|
|
446
471
|
/** Optional prompt override (e.g. for loop_tick). */
|
|
447
472
|
promptOverride?: string;
|
|
448
473
|
/** Timeout per turn in ms (default 180s). */
|
|
@@ -489,7 +514,7 @@ export function fireZcodeWake(msg: WakeMessage, cfg: ZcodeWakeConfig): Promise<b
|
|
|
489
514
|
return Promise.resolve(false);
|
|
490
515
|
}
|
|
491
516
|
|
|
492
|
-
const prompt = cfg.promptOverride ?? buildWakePrompt(msg);
|
|
517
|
+
const prompt = cfg.promptOverride ?? buildWakePrompt(msg, cfg.contextPrefix);
|
|
493
518
|
const prev = zcodeSessionQueues.get(sessionId) ?? Promise.resolve();
|
|
494
519
|
|
|
495
520
|
let succeeded = false;
|