agentschat-mcp 0.36.16 → 0.36.18
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 +82 -25
- package/package.json +1 -1
- package/skills/grok-wake-keepalive.md +1 -1
- package/skills/onboarding.md +23 -23
- package/src/server.ts +61 -23
- package/src/session-bind.ts +23 -0
- 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 () => {
|
|
@@ -1010,9 +1024,30 @@ function saveSessionBind(configDir, sessionId, profileName) {
|
|
|
1010
1024
|
current = parseSessionBinds(JSON.parse(readFileSync3(path, "utf8")));
|
|
1011
1025
|
} catch {}
|
|
1012
1026
|
}
|
|
1027
|
+
for (const [existingSid, existingProf] of Object.entries(current)) {
|
|
1028
|
+
if (existingProf === prof && existingSid !== sid) {
|
|
1029
|
+
delete current[existingSid];
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
delete current[sid];
|
|
1013
1033
|
current[sid] = prof;
|
|
1014
1034
|
mkdirSync(configDir, { recursive: true });
|
|
1015
1035
|
safeWriteProfile(path, current);
|
|
1036
|
+
const legacyPath = join3(configDir, LEGACY_AGY_BINDS_FILENAME);
|
|
1037
|
+
if (existsSync3(legacyPath)) {
|
|
1038
|
+
try {
|
|
1039
|
+
const legacy = parseSessionBinds(JSON.parse(readFileSync3(legacyPath, "utf8")));
|
|
1040
|
+
let changed = false;
|
|
1041
|
+
for (const [existingSid, existingProf] of Object.entries(legacy)) {
|
|
1042
|
+
if (existingProf === prof && existingSid !== sid) {
|
|
1043
|
+
delete legacy[existingSid];
|
|
1044
|
+
changed = true;
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
if (changed)
|
|
1048
|
+
safeWriteProfile(legacyPath, legacy);
|
|
1049
|
+
} catch {}
|
|
1050
|
+
}
|
|
1016
1051
|
}
|
|
1017
1052
|
function removeSessionBind(configDir, sessionId) {
|
|
1018
1053
|
const sid = sessionId.trim();
|
|
@@ -1152,7 +1187,7 @@ function discoverAntigravityHost(opts) {
|
|
|
1152
1187
|
var package_default = {
|
|
1153
1188
|
name: "agentschat-mcp",
|
|
1154
1189
|
mcpName: "io.github.swswordholy-tech/agentschat-mcp",
|
|
1155
|
-
version: "0.36.
|
|
1190
|
+
version: "0.36.18",
|
|
1156
1191
|
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
1192
|
type: "module",
|
|
1158
1193
|
bin: {
|
|
@@ -1941,17 +1976,22 @@ if (!anonymousMode || explicitAgentId !== undefined || hasToken) {
|
|
|
1941
1976
|
}
|
|
1942
1977
|
}
|
|
1943
1978
|
if (!anonymousMode && AGENT_ID && !cliArgs.registerOnly && !toolOnlyMode) {
|
|
1979
|
+
const activeName = profileNameFromPath(activeProfileFile) ?? declaredName ?? null;
|
|
1980
|
+
if (activeName && runtimeSession?.runtime === "antigravity" && !process.env.ANTIGRAVITY_CONVERSATION_ID?.trim()) {
|
|
1981
|
+
const existingBoundSid = findBoundSessionForProfile(configDir, activeName, (sid) => /^[0-9a-f-]{36}$/i.test(sid));
|
|
1982
|
+
if (existingBoundSid) {
|
|
1983
|
+
runtimeSession = { sessionId: existingBoundSid, runtime: "antigravity" };
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1944
1986
|
acquireAgentLock({
|
|
1945
1987
|
lockDir,
|
|
1946
1988
|
agentId: AGENT_ID,
|
|
1947
|
-
profileName:
|
|
1989
|
+
profileName: activeName,
|
|
1948
1990
|
sessionId: runtimeSession?.sessionId ?? null,
|
|
1949
1991
|
runtime: runtimeSession?.runtime ?? "mcp"
|
|
1950
1992
|
});
|
|
1951
|
-
if (runtimeSession?.sessionId &&
|
|
1952
|
-
|
|
1953
|
-
if (activeName)
|
|
1954
|
-
saveSessionBind(configDir, runtimeSession.sessionId, activeName);
|
|
1993
|
+
if (runtimeSession?.sessionId && activeName) {
|
|
1994
|
+
saveSessionBind(configDir, runtimeSession.sessionId, activeName);
|
|
1955
1995
|
}
|
|
1956
1996
|
}
|
|
1957
1997
|
var identityGateMessage = "";
|
|
@@ -3535,16 +3575,28 @@ function applyIdentityFromProfile(newProfile, targetFile, bindSessionId) {
|
|
|
3535
3575
|
profile = newProfile;
|
|
3536
3576
|
activeProfileFile = targetFile;
|
|
3537
3577
|
anonymousMode = false;
|
|
3578
|
+
const targetProfName = profileNameFromPath(targetFile);
|
|
3538
3579
|
if (bindSessionId && bindSessionId.trim()) {
|
|
3580
|
+
const cleanSid = bindSessionId.trim();
|
|
3581
|
+
const isAgyEnv = process.env.__CFBundleIdentifier === "com.google.antigravity" || Boolean(process.env.AGY_BROWSER_WS_URL) || Boolean(discoverAntigravityHost());
|
|
3539
3582
|
runtimeSession = {
|
|
3540
|
-
sessionId:
|
|
3541
|
-
runtime: runtimeSession?.runtime ?? "custom",
|
|
3583
|
+
sessionId: cleanSid,
|
|
3584
|
+
runtime: runtimeSession?.runtime ?? (isAgyEnv && /^[0-9a-f-]{36}$/i.test(cleanSid) ? "antigravity" : "custom"),
|
|
3542
3585
|
...runtimeSession?.workspacePath ? { workspacePath: runtimeSession.workspacePath } : {}
|
|
3543
3586
|
};
|
|
3544
|
-
} else
|
|
3545
|
-
const
|
|
3546
|
-
if (
|
|
3547
|
-
runtimeSession = {
|
|
3587
|
+
} else {
|
|
3588
|
+
const existingBoundSid = findBoundSessionForProfile(configDir, targetProfName);
|
|
3589
|
+
if (existingBoundSid) {
|
|
3590
|
+
runtimeSession = {
|
|
3591
|
+
sessionId: existingBoundSid,
|
|
3592
|
+
runtime: runtimeSession?.runtime ?? (/^[0-9a-f-]{36}$/i.test(existingBoundSid) ? "antigravity" : existingBoundSid.startsWith("sess_") ? "zcode" : "custom"),
|
|
3593
|
+
...runtimeSession?.workspacePath ? { workspacePath: runtimeSession.workspacePath } : {}
|
|
3594
|
+
};
|
|
3595
|
+
} else if (!runtimeSession?.sessionId) {
|
|
3596
|
+
const agyHost = discoverAntigravityHost();
|
|
3597
|
+
if (agyHost && agyHost.openConversations.length === 1) {
|
|
3598
|
+
runtimeSession = { sessionId: agyHost.openConversations[0], runtime: "antigravity" };
|
|
3599
|
+
}
|
|
3548
3600
|
}
|
|
3549
3601
|
}
|
|
3550
3602
|
if (!toolOnlyMode) {
|
|
@@ -3807,7 +3859,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3807
3859
|
let { name, arguments: args } = request.params;
|
|
3808
3860
|
let viaExtendedCompat = false;
|
|
3809
3861
|
try {
|
|
3810
|
-
const
|
|
3862
|
+
const rawMeta = request.params?._meta;
|
|
3863
|
+
const hasExplicitMetaSession = Boolean(typeof rawMeta?.session_id === "string" && rawMeta.session_id.trim() || typeof rawMeta?.["com.zcode/request-context"]?.session_id === "string" && rawMeta["com.zcode/request-context"].session_id.trim());
|
|
3864
|
+
const metaSession = hasExplicitMetaSession || !runtimeSession ? detectRuntimeSession(process.env, rawMeta) : null;
|
|
3811
3865
|
if (metaSession && (!runtimeSession || runtimeSession.sessionId !== metaSession.sessionId || !runtimeSession.workspacePath && metaSession.workspacePath)) {
|
|
3812
3866
|
runtimeSession = metaSession;
|
|
3813
3867
|
if (anonymousMode && name !== "connect_profile" && name !== "switch_profile" && name !== "disconnect_profile") {
|
|
@@ -3838,8 +3892,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
3838
3892
|
runtime: metaSession.runtime
|
|
3839
3893
|
});
|
|
3840
3894
|
const pName = profileNameFromPath(activeProfileFile);
|
|
3841
|
-
if (pName)
|
|
3895
|
+
if (pName && (hasExplicitMetaSession || !findBoundSessionForProfile(configDir, pName))) {
|
|
3842
3896
|
saveSessionBind(configDir, metaSession.sessionId, pName);
|
|
3897
|
+
}
|
|
3843
3898
|
}
|
|
3844
3899
|
}
|
|
3845
3900
|
if (TOOL_INPUT_SCHEMAS.has(name)) {
|
|
@@ -5786,7 +5841,7 @@ ${context}
|
|
|
5786
5841
|
}) ?? "";
|
|
5787
5842
|
}
|
|
5788
5843
|
if (agentId) {
|
|
5789
|
-
fireGrokWake(data, { gatewayConfigPath: gwPath, agentId });
|
|
5844
|
+
fireGrokWake(data, { gatewayConfigPath: gwPath, agentId, contextPrefix });
|
|
5790
5845
|
}
|
|
5791
5846
|
} catch (e) {
|
|
5792
5847
|
process.stderr.write(`[agentchat] grok wake resolve failed: ${e}
|
|
@@ -5807,6 +5862,7 @@ ${context}
|
|
|
5807
5862
|
workspacePath: runtimeSession?.workspacePath,
|
|
5808
5863
|
profileName: activeProfName ?? undefined,
|
|
5809
5864
|
lockOwnerPid: process.pid,
|
|
5865
|
+
contextPrefix,
|
|
5810
5866
|
logger: (m) => process.stderr.write(`${m}
|
|
5811
5867
|
`)
|
|
5812
5868
|
});
|
|
@@ -5821,7 +5877,7 @@ ${context}
|
|
|
5821
5877
|
return;
|
|
5822
5878
|
const activeProfName = profileNameFromPath(activeProfileFile);
|
|
5823
5879
|
const allBinds = loadSessionBinds(configDir);
|
|
5824
|
-
let targetCid =
|
|
5880
|
+
let targetCid = findBoundSessionForProfile(configDir, activeProfName, (sid) => /^[0-9a-f-]{36}$/i.test(sid)) || (runtimeSession?.runtime === "antigravity" ? runtimeSession.sessionId : "") || "";
|
|
5825
5881
|
if (!targetCid && agyHost) {
|
|
5826
5882
|
if (agyHost.openConversations.length === 1) {
|
|
5827
5883
|
targetCid = agyHost.openConversations[0];
|
|
@@ -5836,6 +5892,7 @@ ${context}
|
|
|
5836
5892
|
csrfToken,
|
|
5837
5893
|
lsAddress: lsAddress || undefined,
|
|
5838
5894
|
ports: agyHost?.ports,
|
|
5895
|
+
contextPrefix,
|
|
5839
5896
|
logger: (m) => process.stderr.write(`${m}
|
|
5840
5897
|
`)
|
|
5841
5898
|
});
|
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.18",
|
|
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.18 --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.18`, 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.18` 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.18 --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.18 --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.18","--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.18","--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.18 --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.18 --codex-bridge --bot NAME --onboarding-status
|
|
296
|
+
npx -y agentschat-mcp@0.36.18 --codex-bots --check
|
|
297
|
+
npx -y agentschat-mcp@0.36.18 --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.18 --codex-bridge --cwd /absolute/path/my-project --check
|
|
315
|
+
npx -y agentschat-mcp@0.36.18 --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.18 --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.18`); 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.18 --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.18 --profile Jack` | `AGENTCHAT_NO_PROXY=1` |
|
|
580
|
+
| `agentschat-builder` | `npx -y agentschat-mcp@0.36.18 --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.18 --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.18 --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.18`, 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.18"],
|
|
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.18"],
|
|
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.18 --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
|
@@ -623,16 +623,30 @@ if (!anonymousMode || explicitAgentId !== undefined || hasToken) {
|
|
|
623
623
|
}
|
|
624
624
|
|
|
625
625
|
if (!anonymousMode && AGENT_ID && !cliArgs.registerOnly && !toolOnlyMode) {
|
|
626
|
+
const activeName = profileNameFromPath(activeProfileFile) ?? declaredName ?? null;
|
|
627
|
+
if (
|
|
628
|
+
activeName &&
|
|
629
|
+
runtimeSession?.runtime === "antigravity" &&
|
|
630
|
+
!process.env.ANTIGRAVITY_CONVERSATION_ID?.trim()
|
|
631
|
+
) {
|
|
632
|
+
const existingBoundSid = findBoundSessionForProfile(
|
|
633
|
+
configDir,
|
|
634
|
+
activeName,
|
|
635
|
+
(sid) => /^[0-9a-f-]{36}$/i.test(sid),
|
|
636
|
+
);
|
|
637
|
+
if (existingBoundSid) {
|
|
638
|
+
runtimeSession = { sessionId: existingBoundSid, runtime: "antigravity" };
|
|
639
|
+
}
|
|
640
|
+
}
|
|
626
641
|
acquireAgentLock({
|
|
627
642
|
lockDir,
|
|
628
643
|
agentId: AGENT_ID,
|
|
629
|
-
profileName:
|
|
644
|
+
profileName: activeName,
|
|
630
645
|
sessionId: runtimeSession?.sessionId ?? null,
|
|
631
646
|
runtime: runtimeSession?.runtime ?? "mcp",
|
|
632
647
|
});
|
|
633
|
-
if (runtimeSession?.sessionId &&
|
|
634
|
-
|
|
635
|
-
if (activeName) saveSessionBind(configDir, runtimeSession.sessionId, activeName);
|
|
648
|
+
if (runtimeSession?.sessionId && activeName) {
|
|
649
|
+
saveSessionBind(configDir, runtimeSession.sessionId, activeName);
|
|
636
650
|
}
|
|
637
651
|
}
|
|
638
652
|
|
|
@@ -2286,16 +2300,33 @@ function applyIdentityFromProfile(newProfile: any, targetFile: string, bindSessi
|
|
|
2286
2300
|
activeProfileFile = targetFile;
|
|
2287
2301
|
anonymousMode = false;
|
|
2288
2302
|
|
|
2303
|
+
const targetProfName = profileNameFromPath(targetFile);
|
|
2289
2304
|
if (bindSessionId && bindSessionId.trim()) {
|
|
2305
|
+
const cleanSid = bindSessionId.trim();
|
|
2306
|
+
const isAgyEnv =
|
|
2307
|
+
process.env.__CFBundleIdentifier === "com.google.antigravity" ||
|
|
2308
|
+
Boolean(process.env.AGY_BROWSER_WS_URL) ||
|
|
2309
|
+
Boolean(discoverAntigravityHost());
|
|
2290
2310
|
runtimeSession = {
|
|
2291
|
-
sessionId:
|
|
2292
|
-
runtime: runtimeSession?.runtime ?? "custom",
|
|
2311
|
+
sessionId: cleanSid,
|
|
2312
|
+
runtime: runtimeSession?.runtime ?? (isAgyEnv && /^[0-9a-f-]{36}$/i.test(cleanSid) ? "antigravity" : "custom"),
|
|
2293
2313
|
...(runtimeSession?.workspacePath ? { workspacePath: runtimeSession.workspacePath } : {}),
|
|
2294
2314
|
};
|
|
2295
|
-
} else
|
|
2296
|
-
const
|
|
2297
|
-
if (
|
|
2298
|
-
runtimeSession = {
|
|
2315
|
+
} else {
|
|
2316
|
+
const existingBoundSid = findBoundSessionForProfile(configDir, targetProfName);
|
|
2317
|
+
if (existingBoundSid) {
|
|
2318
|
+
runtimeSession = {
|
|
2319
|
+
sessionId: existingBoundSid,
|
|
2320
|
+
runtime:
|
|
2321
|
+
runtimeSession?.runtime ??
|
|
2322
|
+
(/^[0-9a-f-]{36}$/i.test(existingBoundSid) ? "antigravity" : existingBoundSid.startsWith("sess_") ? "zcode" : "custom"),
|
|
2323
|
+
...(runtimeSession?.workspacePath ? { workspacePath: runtimeSession.workspacePath } : {}),
|
|
2324
|
+
};
|
|
2325
|
+
} else if (!runtimeSession?.sessionId) {
|
|
2326
|
+
const agyHost = discoverAntigravityHost();
|
|
2327
|
+
if (agyHost && agyHost.openConversations.length === 1) {
|
|
2328
|
+
runtimeSession = { sessionId: agyHost.openConversations[0]!, runtime: "antigravity" };
|
|
2329
|
+
}
|
|
2299
2330
|
}
|
|
2300
2331
|
}
|
|
2301
2332
|
|
|
@@ -2609,9 +2640,19 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
2609
2640
|
// error returns below carry isError:true individually.
|
|
2610
2641
|
try {
|
|
2611
2642
|
// Capture session metadata injected by hosts on tools/call (e.g. ZCode's
|
|
2612
|
-
// _meta.session_id and _meta.workspace_path).
|
|
2613
|
-
//
|
|
2614
|
-
|
|
2643
|
+
// _meta.session_id and _meta.workspace_path). Never allow Antigravity's
|
|
2644
|
+
// currently-focused window heuristic (`discoverAntigravityHost`) to overwrite
|
|
2645
|
+
// an already-bound `runtimeSession` when another tab calls a tool.
|
|
2646
|
+
const rawMeta = (request.params as any)?._meta;
|
|
2647
|
+
const hasExplicitMetaSession = Boolean(
|
|
2648
|
+
(typeof rawMeta?.session_id === "string" && rawMeta.session_id.trim()) ||
|
|
2649
|
+
(typeof rawMeta?.["com.zcode/request-context"]?.session_id === "string" &&
|
|
2650
|
+
rawMeta["com.zcode/request-context"].session_id.trim()),
|
|
2651
|
+
);
|
|
2652
|
+
const metaSession =
|
|
2653
|
+
hasExplicitMetaSession || !runtimeSession
|
|
2654
|
+
? detectRuntimeSession(process.env, rawMeta)
|
|
2655
|
+
: null;
|
|
2615
2656
|
if (metaSession && (!runtimeSession || runtimeSession.sessionId !== metaSession.sessionId || (!runtimeSession.workspacePath && metaSession.workspacePath))) {
|
|
2616
2657
|
runtimeSession = metaSession;
|
|
2617
2658
|
if (anonymousMode && name !== "connect_profile" && name !== "switch_profile" && name !== "disconnect_profile") {
|
|
@@ -2642,7 +2683,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
2642
2683
|
runtime: metaSession.runtime,
|
|
2643
2684
|
});
|
|
2644
2685
|
const pName = profileNameFromPath(activeProfileFile);
|
|
2645
|
-
if (pName
|
|
2686
|
+
if (pName && (hasExplicitMetaSession || !findBoundSessionForProfile(configDir, pName))) {
|
|
2687
|
+
saveSessionBind(configDir, metaSession.sessionId, pName);
|
|
2688
|
+
}
|
|
2646
2689
|
}
|
|
2647
2690
|
}
|
|
2648
2691
|
|
|
@@ -4774,7 +4817,7 @@ function connectWS() {
|
|
|
4774
4817
|
})) ?? "";
|
|
4775
4818
|
}
|
|
4776
4819
|
if (agentId) {
|
|
4777
|
-
void fireGrokWake(data, { gatewayConfigPath: gwPath, agentId });
|
|
4820
|
+
void fireGrokWake(data, { gatewayConfigPath: gwPath, agentId, contextPrefix });
|
|
4778
4821
|
}
|
|
4779
4822
|
} catch (e) {
|
|
4780
4823
|
process.stderr.write(`[agentchat] grok wake resolve failed: ${e}\n`);
|
|
@@ -4797,6 +4840,7 @@ function connectWS() {
|
|
|
4797
4840
|
workspacePath: runtimeSession?.workspacePath,
|
|
4798
4841
|
profileName: activeProfName ?? undefined,
|
|
4799
4842
|
lockOwnerPid: process.pid,
|
|
4843
|
+
contextPrefix,
|
|
4800
4844
|
logger: (m) => process.stderr.write(`${m}\n`),
|
|
4801
4845
|
});
|
|
4802
4846
|
}
|
|
@@ -4811,15 +4855,8 @@ function connectWS() {
|
|
|
4811
4855
|
const activeProfName = profileNameFromPath(activeProfileFile);
|
|
4812
4856
|
const allBinds = loadSessionBinds(configDir);
|
|
4813
4857
|
let targetCid =
|
|
4814
|
-
(runtimeSession?.runtime === "antigravity" ? runtimeSession.sessionId : "") ||
|
|
4815
|
-
findBoundSessionForProfile(
|
|
4816
|
-
configDir,
|
|
4817
|
-
activeProfName,
|
|
4818
|
-
(sid) =>
|
|
4819
|
-
/^[0-9a-f-]{36}$/i.test(sid) &&
|
|
4820
|
-
(!agyHost || agyHost.openConversations.length === 0 || agyHost.openConversations.includes(sid)),
|
|
4821
|
-
) ||
|
|
4822
4858
|
findBoundSessionForProfile(configDir, activeProfName, (sid) => /^[0-9a-f-]{36}$/i.test(sid)) ||
|
|
4859
|
+
(runtimeSession?.runtime === "antigravity" ? runtimeSession.sessionId : "") ||
|
|
4823
4860
|
"";
|
|
4824
4861
|
if (!targetCid && agyHost) {
|
|
4825
4862
|
if (agyHost.openConversations.length === 1) {
|
|
@@ -4837,6 +4874,7 @@ function connectWS() {
|
|
|
4837
4874
|
csrfToken,
|
|
4838
4875
|
lsAddress: lsAddress || undefined,
|
|
4839
4876
|
ports: agyHost?.ports,
|
|
4877
|
+
contextPrefix,
|
|
4840
4878
|
logger: (m) => process.stderr.write(`${m}\n`),
|
|
4841
4879
|
});
|
|
4842
4880
|
}
|
package/src/session-bind.ts
CHANGED
|
@@ -204,9 +204,32 @@ export function saveSessionBind(configDir: string, sessionId: string, profileNam
|
|
|
204
204
|
if (existsSync(path)) {
|
|
205
205
|
try { current = parseSessionBinds(JSON.parse(readFileSync(path, "utf8"))); } catch {}
|
|
206
206
|
}
|
|
207
|
+
// Enforce 1:1 profileName <-> sessionId mapping so re-binding a profile to a
|
|
208
|
+
// conversation replaces any stale conversation bound to the same profile.
|
|
209
|
+
for (const [existingSid, existingProf] of Object.entries(current)) {
|
|
210
|
+
if (existingProf === prof && existingSid !== sid) {
|
|
211
|
+
delete current[existingSid];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
delete current[sid];
|
|
207
215
|
current[sid] = prof;
|
|
208
216
|
mkdirSync(configDir, { recursive: true });
|
|
209
217
|
safeWriteProfile(path, current);
|
|
218
|
+
|
|
219
|
+
const legacyPath = join(configDir, LEGACY_AGY_BINDS_FILENAME);
|
|
220
|
+
if (existsSync(legacyPath)) {
|
|
221
|
+
try {
|
|
222
|
+
const legacy = parseSessionBinds(JSON.parse(readFileSync(legacyPath, "utf8")));
|
|
223
|
+
let changed = false;
|
|
224
|
+
for (const [existingSid, existingProf] of Object.entries(legacy)) {
|
|
225
|
+
if (existingProf === prof && existingSid !== sid) {
|
|
226
|
+
delete legacy[existingSid];
|
|
227
|
+
changed = true;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (changed) safeWriteProfile(legacyPath, legacy);
|
|
231
|
+
} catch {}
|
|
232
|
+
}
|
|
210
233
|
}
|
|
211
234
|
|
|
212
235
|
export function removeSessionBind(configDir: string, sessionId: string): boolean {
|