agentschat-mcp 0.32.0 → 0.32.1

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.1",
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.
@@ -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.1",
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.
@@ -4020,8 +4021,10 @@ function connectWS() {
4020
4021
  // else fail closed (no wake). The gateway token/port come from gateway.json.
4021
4022
  void (async () => {
4022
4023
  try {
4023
- const { readFileSync } = await import("node:fs");
4024
- const gwPath = process.env.AGENTCHAT_GROK_GATEWAY || `${process.env.HOME}/.grok/gateway.json`;
4024
+ const { readFileSync, existsSync } = await import("node:fs");
4025
+ // env override wins; else first existing candidate (~/.grok default,
4026
+ // production GrokBot /home/box/sand-data) — never guess a path blindly.
4027
+ const gwPath = resolveGrokGatewayPath(process.env.AGENTCHAT_GROK_GATEWAY, existsSync);
4025
4028
  let agentId = process.env.AGENTCHAT_GROK_AGENT_ID || "";
4026
4029
  if (!agentId) {
4027
4030
  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;