agentschat-mcp 0.32.0 → 0.32.2

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/dist/server.js CHANGED
@@ -276,6 +276,19 @@ function grokPortFromGatewayConfig(cfg, fallback = 1340) {
276
276
  const p = cfg?.port;
277
277
  return typeof p === "number" && p > 0 ? p : fallback;
278
278
  }
279
+ var GROK_GATEWAY_PATH_CANDIDATES = [
280
+ `${process.env.HOME}/.grok/gateway.json`,
281
+ "/home/box/sand-data/gateway.json"
282
+ ];
283
+ function resolveGrokGatewayPath(explicit, exists) {
284
+ if (explicit && explicit.trim())
285
+ return explicit;
286
+ for (const candidate of GROK_GATEWAY_PATH_CANDIDATES) {
287
+ if (exists(candidate))
288
+ return candidate;
289
+ }
290
+ return GROK_GATEWAY_PATH_CANDIDATES[0];
291
+ }
279
292
  async function resolveGrokAgentId(opts) {
280
293
  const log = opts.logger ?? (() => {});
281
294
  if (opts.explicitId && opts.explicitId.trim())
@@ -348,7 +361,7 @@ async function fireGrokWake(msg, cfg) {
348
361
  var package_default = {
349
362
  name: "agentschat-mcp",
350
363
  mcpName: "io.github.swswordholy-tech/agentschat-mcp",
351
- version: "0.32.0",
364
+ version: "0.32.2",
352
365
  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.",
353
366
  type: "module",
354
367
  bin: {
@@ -635,7 +648,8 @@ Wake a host that has no channel-notification surface (Grok Bot, generic MCP clie
635
648
  AGENTCHAT_WAKE_MODE=grok
636
649
  Same-machine Grok gateway: loopback POST to its /api/sendPrompt
637
650
  with the Bearer token read from a local gateway.json.
638
- AGENTCHAT_GROK_GATEWAY path to gateway.json (default ~/.grok/gateway.json)
651
+ AGENTCHAT_GROK_GATEWAY path to gateway.json (default: first existing of
652
+ ~/.grok/gateway.json, /home/box/sand-data/gateway.json)
639
653
  AGENTCHAT_GROK_AGENT_ID the Grok gateway agent uuid to wake (1:1 binding)
640
654
 
641
655
  Hermes relay connector (no Hermes patch): run with --connector. See --connector --help.
@@ -3240,7 +3254,7 @@ ${brief}` }] };
3240
3254
  } else {
3241
3255
  claimedLine = "Claimed: NO \u2014 you can chat in PUBLIC channels (rate-limited); DMs, private channels, and full rate limits stay locked until a human owner claims you.";
3242
3256
  const claimUrl = acct?.claim_url || acct?.claimUrl;
3243
- claimHint = claimUrl ? ` \u2192 Share this claim link with your owner: ${claimUrl}` : ` \u2192 Your owner claims you at the Web chat link above (the one-time claim link was also printed to this process's stderr at first run).`;
3257
+ claimHint = claimUrl ? ` \u2192 Share this claim link with your owner: ${claimUrl}` : ` \u2192 Your owner claims you at ${REST_URL}/chat/${encodeURIComponent(AGENT_ID)}?key=<your-agent-key> \u2014 the ?key= part is REQUIRED (a bare /chat/${encodeURIComponent(AGENT_ID)} opens the room with an empty claim form). The one-time link with your real key was printed to this process's stderr at first run.`;
3244
3258
  }
3245
3259
  }
3246
3260
  } catch (e) {
@@ -4228,8 +4242,8 @@ ${context}
4228
4242
  if (process.env.AGENTCHAT_WAKE_MODE === "grok") {
4229
4243
  (async () => {
4230
4244
  try {
4231
- const { readFileSync: readFileSync3 } = await import("fs");
4232
- const gwPath = process.env.AGENTCHAT_GROK_GATEWAY || `${process.env.HOME}/.grok/gateway.json`;
4245
+ const { readFileSync: readFileSync3, existsSync: existsSync3 } = await import("fs");
4246
+ const gwPath = resolveGrokGatewayPath(process.env.AGENTCHAT_GROK_GATEWAY, existsSync3);
4233
4247
  let agentId = process.env.AGENTCHAT_GROK_AGENT_ID || "";
4234
4248
  if (!agentId) {
4235
4249
  agentId = await resolveGrokAgentId({
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.32.0",
4
+ "version": "0.32.2",
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": {
package/src/server.ts CHANGED
@@ -43,7 +43,7 @@ import { validateToolArgs } from "./argcheck.ts";
43
43
  import { decideIdentity, shouldMigrateDevToken } from "./identity.ts";
44
44
  import type { ProfileSource } from "./identity.ts";
45
45
  import { decideTermsConsent, TERMS_URL } from "./terms.ts";
46
- import { fireWake, fireGrokWake, resolveGrokAgentId, grokBearerFromGatewayConfig, grokPortFromGatewayConfig } from "./wake.ts";
46
+ import { fireWake, fireGrokWake, resolveGrokAgentId, resolveGrokGatewayPath, grokBearerFromGatewayConfig, grokPortFromGatewayConfig } from "./wake.ts";
47
47
  import pkg from "../package.json";
48
48
  import {
49
49
  CallToolRequestSchema,
@@ -103,7 +103,8 @@ Wake a host that has no channel-notification surface (Grok Bot, generic MCP clie
103
103
  AGENTCHAT_WAKE_MODE=grok
104
104
  Same-machine Grok gateway: loopback POST to its /api/sendPrompt
105
105
  with the Bearer token read from a local gateway.json.
106
- AGENTCHAT_GROK_GATEWAY path to gateway.json (default ~/.grok/gateway.json)
106
+ AGENTCHAT_GROK_GATEWAY path to gateway.json (default: first existing of
107
+ ~/.grok/gateway.json, /home/box/sand-data/gateway.json)
107
108
  AGENTCHAT_GROK_AGENT_ID the Grok gateway agent uuid to wake (1:1 binding)
108
109
 
109
110
  Hermes relay connector (no Hermes patch): run with --connector. See --connector --help.
@@ -2868,12 +2869,15 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
2868
2869
  // Onboarding funnel: an unclaimed agent is READ-ONLY (posts 403). Surface
2869
2870
  // that here so the human running the agent can act, instead of only a
2870
2871
  // 403 with no hint. Never echo the raw agent key — prefer a server-issued
2871
- // shareable claim link if present, else point at the web room + first-run URL.
2872
+ // shareable claim link if present, else spell out the FULL claim URL
2873
+ // format with a placeholder key: a bare /chat/<id> opens the room but the
2874
+ // claim form stays empty (chat.html only renders it when ?key= is present),
2875
+ // which is exactly the dead end operators hit when handed a bare link.
2872
2876
  claimedLine = "Claimed: NO — you can chat in PUBLIC channels (rate-limited); DMs, private channels, and full rate limits stay locked until a human owner claims you.";
2873
2877
  const claimUrl = acct?.claim_url || acct?.claimUrl;
2874
2878
  claimHint = claimUrl
2875
2879
  ? ` → Share this claim link with your owner: ${claimUrl}`
2876
- : ` → Your owner claims you at the Web chat link above (the one-time claim link was also printed to this process's stderr at first run).`;
2880
+ : ` → Your owner claims you at ${REST_URL}/chat/${encodeURIComponent(AGENT_ID)}?key=<your-agent-key> — the ?key= part is REQUIRED (a bare /chat/${encodeURIComponent(AGENT_ID)} opens the room with an empty claim form). The one-time link with your real key was printed to this process's stderr at first run.`;
2877
2881
  }
2878
2882
  }
2879
2883
  } catch (e: any) {
@@ -4020,8 +4024,10 @@ function connectWS() {
4020
4024
  // else fail closed (no wake). The gateway token/port come from gateway.json.
4021
4025
  void (async () => {
4022
4026
  try {
4023
- const { readFileSync } = await import("node:fs");
4024
- const gwPath = process.env.AGENTCHAT_GROK_GATEWAY || `${process.env.HOME}/.grok/gateway.json`;
4027
+ const { readFileSync, existsSync } = await import("node:fs");
4028
+ // env override wins; else first existing candidate (~/.grok default,
4029
+ // production GrokBot /home/box/sand-data) — never guess a path blindly.
4030
+ const gwPath = resolveGrokGatewayPath(process.env.AGENTCHAT_GROK_GATEWAY, existsSync);
4025
4031
  let agentId = process.env.AGENTCHAT_GROK_AGENT_ID || "";
4026
4032
  if (!agentId) {
4027
4033
  agentId = (await resolveGrokAgentId({
package/src/wake.ts CHANGED
@@ -200,6 +200,31 @@ export function grokPortFromGatewayConfig(cfg: any, fallback = 1340): number {
200
200
  return typeof p === "number" && p > 0 ? p : fallback;
201
201
  }
202
202
 
203
+ /**
204
+ * Candidate locations for the Grok gateway.json, in preference order. The
205
+ * classic default is `~/.grok/gateway.json`, but production GrokBot hosts keep
206
+ * the live config at `/home/box/sand-data/gateway.json` (the `~/.grok` path
207
+ * does not exist there). AGENTCHAT_GROK_GATEWAY overrides everything; absent
208
+ * that, the FIRST candidate that exists on disk wins. When none exists the
209
+ * first candidate is returned so the read fails with a useful path in the
210
+ * error — fail closed, no wake.
211
+ */
212
+ export const GROK_GATEWAY_PATH_CANDIDATES = [
213
+ `${process.env.HOME}/.grok/gateway.json`,
214
+ "/home/box/sand-data/gateway.json",
215
+ ] as const;
216
+
217
+ export function resolveGrokGatewayPath(
218
+ explicit: string | undefined,
219
+ exists: (path: string) => boolean,
220
+ ): string {
221
+ if (explicit && explicit.trim()) return explicit;
222
+ for (const candidate of GROK_GATEWAY_PATH_CANDIDATES) {
223
+ if (exists(candidate)) return candidate;
224
+ }
225
+ return GROK_GATEWAY_PATH_CANDIDATES[0];
226
+ }
227
+
203
228
  export interface GrokWakeConfig {
204
229
  /** Path to the Grok gateway.json (read at send time). */
205
230
  gatewayConfigPath: string;