@sleep2agi/commhub-server 0.9.0-preview.13 → 0.9.0-preview.14

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/tools.ts +23 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleep2agi/commhub-server",
3
- "version": "0.9.0-preview.13",
3
+ "version": "0.9.0-preview.14",
4
4
  "description": "CommHub Server — AI Agent communication hub with MCP protocol, multi-network isolation, user auth, and 17 MCP tools.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/tools.ts CHANGED
@@ -365,6 +365,29 @@ export function registerTools(server: McpServer, clientIP?: string, enforceNetwo
365
365
  };
366
366
  }
367
367
  }
368
+ // #203 identity guard — network tokens must not silently rebind their
369
+ // own name via report_status. Without this, a runtime whose ALIAS
370
+ // drifted (env leak / wrong --alias / CurrentAliasResolver seeded from
371
+ // the wrong node_id) could rewrite api_tokens.name and cause every
372
+ // subsequent send_task from this token to be attributed to the drifted
373
+ // alias — the observed #203 symptom (grokB's send arriving as
374
+ // from=grokA). Only the legit rename path (rename.ts) may cross the
375
+ // token→alias binding. Symmetric to fromIdentityMismatchReply on the
376
+ // send side (test198).
377
+ if (callerTokenIsNetwork && callerAlias && !canonical.renamed && effectiveAlias !== callerAlias) {
378
+ return {
379
+ content: [{
380
+ type: "text" as const,
381
+ text: JSON.stringify({
382
+ ok: false,
383
+ error: "alias_identity_mismatch",
384
+ message: "report_status alias does not match the token-bound node alias; use anet node rename to change identity",
385
+ token_alias: callerAlias,
386
+ reported_alias: effectiveAlias,
387
+ }),
388
+ }],
389
+ };
390
+ }
368
391
  console.log(`[${ts()}] ${effectiveAlias} (${resume_id.slice(0, 8)}) → report_status: ${status}${task ? " | " + task.slice(0, 60) : ""}${effectiveNetId ? " [net]" : ""}${canonical.renamed ? ` [renamed from ${alias}]` : ""}`);
369
392
  if (callerTokenIsNetwork && callerTokenId) {
370
393
  try {