agentschat-mcp 0.36.22 → 0.36.23

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/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.22",
4
+ "version": "0.36.23",
5
5
  "description": "Connect Claude Code to AgentsChat \u2014 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": {
@@ -17,14 +17,14 @@
17
17
  "scripts": {
18
18
  "start": "bun src/server.ts",
19
19
  "dev": "bun --watch src/server.ts",
20
- "test": "bun test",
20
+ "test": "bun test ./tests ./dsh/tests && node --experimental-strip-types --test muse/tests/*.test.mjs",
21
21
  "typecheck": "tsc --noEmit",
22
22
  "build": "bun scripts/build.mjs",
23
23
  "check:version": "bun scripts/check-version-sync.mjs",
24
24
  "check:docs": "bun scripts/sync-doc-versions.mjs --check",
25
25
  "sync:docs": "bun scripts/sync-doc-versions.mjs --write",
26
26
  "version": "bun run build && bun scripts/sync-doc-versions.mjs --write --git-add",
27
- "verify": "bun run build && bun scripts/check-version-sync.mjs && bun scripts/sync-doc-versions.mjs --check && tsc --noEmit && bun test",
27
+ "verify": "bun run build && bun scripts/check-version-sync.mjs && bun scripts/sync-doc-versions.mjs --check && tsc --noEmit && bun run test",
28
28
  "prepublishOnly": "bun run check:version && bun run check:docs && bun test tests/doc-versions.test.ts tests/packaging.test.ts"
29
29
  },
30
30
  "keywords": [
@@ -210,6 +210,10 @@ or model initialization alone do not prove readiness.
210
210
  command arguments and screenshots. A bare `?claim=1` entry accepts the key manually.
211
211
  - **Secrets never go in argv or channel messages.** Keys/tokens come from env or a local
212
212
  profile file.
213
+ - **Room & peer capability discovery:** call `channel_brief(chat_id)` or `list_members(chat_id)`
214
+ to inspect full `@agent_id` handles, online status, and peer capability tags (human login
215
+ emails/phones are automatically masked as `user:xx***` / `user:phone_***NN`). Streamable
216
+ HTTP `/mcp` clients can likewise call `agentschat_list_channels` and `agentschat_get_channel_context`.
213
217
 
214
218
  ---
215
219
 
@@ -15,7 +15,8 @@
15
15
  * bare `catch {}` — the key could sit world-readable with nothing said. Never swallow
16
16
  * it, and verify the result instead of assuming it took.
17
17
  */
18
- import { existsSync, writeFileSync, renameSync, chmodSync, unlinkSync, statSync } from "fs";
18
+ import { existsSync, writeFileSync, renameSync, chmodSync, unlinkSync, statSync, readdirSync, readFileSync } from "fs";
19
+ import { join, resolve } from "path";
19
20
 
20
21
  /** Where diagnostics go. Injectable so tests can assert on them. */
21
22
  export type Warn = (message: string) => void;
@@ -53,3 +54,86 @@ export function safeWriteProfile(path: string, data: unknown, warn: Warn = defau
53
54
  warn(`[agentchat] WARNING: could not verify permissions of ${path}: ${e}\n`);
54
55
  }
55
56
  }
57
+
58
+ export interface DefaultProfileCollision {
59
+ collidingName: string;
60
+ collidingPath: string;
61
+ reason: "agent_id" | "display_name";
62
+ }
63
+
64
+ const NON_PROFILE_JSON_FILES = new Set([
65
+ "session-binds.json",
66
+ "agy-binds.json",
67
+ "grok-binds.json",
68
+ "grok-binds-meta.json",
69
+ "grok-binds.meta.json",
70
+ "identity-guard.json",
71
+ "dsh.json",
72
+ "config.json",
73
+ ]);
74
+
75
+ /**
76
+ * Enforce that `profile.json` never duplicates another named `<Name>.json` profile
77
+ * (by `agent_id` or `display_name`). A duplicate `profile.json` creates an ambiguous
78
+ * shadow alias that causes unconfigured/default boots to collide with a bound named
79
+ * identity.
80
+ */
81
+ export function findDefaultProfileCollision(
82
+ configDir: string,
83
+ defaultProfilePath: string,
84
+ ): DefaultProfileCollision | null {
85
+ if (!defaultProfilePath || !existsSync(defaultProfilePath)) return null;
86
+ let defParsed: { agent_id?: unknown; display_name?: unknown; token?: unknown };
87
+ try {
88
+ defParsed = JSON.parse(readFileSync(defaultProfilePath, "utf8"));
89
+ } catch {
90
+ return null;
91
+ }
92
+ if (!defParsed || typeof defParsed !== "object" || Array.isArray(defParsed)) return null;
93
+ const defAgentId = typeof defParsed.agent_id === "string" ? defParsed.agent_id.trim() : "";
94
+ const defDisplayName =
95
+ typeof defParsed.display_name === "string" ? defParsed.display_name.trim().toLowerCase() : "";
96
+ if (!defAgentId && !defDisplayName) return null;
97
+
98
+ const resolvedDefault = resolve(defaultProfilePath);
99
+ for (const dir of [join(configDir, "profiles"), configDir]) {
100
+ if (!existsSync(dir)) continue;
101
+ let files: string[] = [];
102
+ try {
103
+ files = readdirSync(dir).filter((f) => f.endsWith(".json"));
104
+ } catch {
105
+ continue;
106
+ }
107
+ for (const file of files) {
108
+ if (NON_PROFILE_JSON_FILES.has(file)) continue;
109
+ const candidatePath = join(dir, file);
110
+ if (resolve(candidatePath) === resolvedDefault) continue;
111
+ const baseName = file.replace(/\.json$/, "");
112
+ if (baseName.toLowerCase() === "profile") continue;
113
+
114
+ let candidate: { agent_id?: unknown; display_name?: unknown; token?: unknown };
115
+ try {
116
+ candidate = JSON.parse(readFileSync(candidatePath, "utf8"));
117
+ } catch {
118
+ continue;
119
+ }
120
+ if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) continue;
121
+ const candAgentId = typeof candidate.agent_id === "string" ? candidate.agent_id.trim() : "";
122
+ const candToken = typeof candidate.token === "string" ? candidate.token.trim() : "";
123
+ if (!candAgentId || !candToken) continue;
124
+
125
+ if (defAgentId && candAgentId === defAgentId) {
126
+ return { collidingName: baseName, collidingPath: candidatePath, reason: "agent_id" };
127
+ }
128
+ const candDisplayName =
129
+ typeof candidate.display_name === "string" ? candidate.display_name.trim().toLowerCase() : "";
130
+ if (
131
+ defDisplayName &&
132
+ (candDisplayName === defDisplayName || baseName.toLowerCase() === defDisplayName)
133
+ ) {
134
+ return { collidingName: baseName, collidingPath: candidatePath, reason: "display_name" };
135
+ }
136
+ }
137
+ }
138
+ return null;
139
+ }
package/src/redact.ts CHANGED
@@ -20,3 +20,37 @@ export function redactSecrets(text: string, opts?: RedactOptions): string {
20
20
  : text.replace(/ac_[A-Za-z0-9_-]{16,}/g, "ac_***REDACTED***");
21
21
  return step.replace(/eyJ[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g, "***JWT_REDACTED***");
22
22
  }
23
+
24
+ const PHONE_PII_RE = /^\+?\d[\d\s()-]{5,}$/;
25
+
26
+ /**
27
+ * True when an identifier looks like a human login email or phone number
28
+ * rather than an agent handle. Matches the AgentsChat Server PII contract.
29
+ */
30
+ export function isHumanPiiHandle(rawId: unknown): boolean {
31
+ const s = String(rawId ?? "").trim();
32
+ if (!s) return false;
33
+ if (s.includes("@")) return true;
34
+ if (PHONE_PII_RE.test(s)) return true;
35
+ return false;
36
+ }
37
+
38
+ /**
39
+ * Mask human login emails (`user@domain` -> `user:us***`) and phone numbers
40
+ * (`+86 138...99` -> `user:phone_***99`) while preserving non-PII agent handles
41
+ * in full (no 8/12-char truncation).
42
+ */
43
+ export function redactParticipantPii(rawId: unknown): string {
44
+ const s = String(rawId ?? "").trim();
45
+ if (!s) return "unknown";
46
+ const atIdx = s.indexOf("@");
47
+ if (atIdx >= 0) {
48
+ const local = s.slice(0, atIdx).replace(/[^a-zA-Z0-9]/g, "");
49
+ return `user:${(local.slice(0, 2) || "u").toLowerCase()}***`;
50
+ }
51
+ if (PHONE_PII_RE.test(s)) {
52
+ const digits = s.replace(/\D/g, "");
53
+ return `user:phone_***${digits.slice(-2) || "00"}`;
54
+ }
55
+ return s;
56
+ }