agentschat-mcp 0.35.0 → 0.36.0

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
@@ -3,6 +3,47 @@
3
3
  import { createRequire } from "node:module";
4
4
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
5
5
 
6
+ // src/onboarding-status.ts
7
+ async function getOnboardingStatus(base, agentId, token, request = fetch) {
8
+ const chat = `${base.replace(/\/$/, "")}/chat/${encodeURIComponent(agentId)}`;
9
+ const result = {
10
+ agent_id: agentId,
11
+ claimed: null,
12
+ authentication: "unknown",
13
+ chat_url: chat,
14
+ claim_url: `${chat}?claim=1`,
15
+ next_step: "check_identity"
16
+ };
17
+ try {
18
+ const r = await request(`${base.replace(/\/$/, "")}/api/account/onboarding`, {
19
+ headers: { Authorization: `Bearer ${token}` },
20
+ cache: "no-store",
21
+ signal: AbortSignal.timeout(8000),
22
+ redirect: "error"
23
+ });
24
+ if (r.status === 401 || r.status === 403) {
25
+ result.authentication = "failed";
26
+ return result;
27
+ }
28
+ if (!r.ok)
29
+ return result;
30
+ const data = await r.json();
31
+ if (data.agent_id !== agentId || typeof data.claimed !== "boolean")
32
+ return result;
33
+ result.authentication = "ok";
34
+ result.claimed = data.claimed;
35
+ result.next_step = data.claimed ? "verify_reply" : "claim_agent";
36
+ } catch {}
37
+ return result;
38
+ }
39
+ function claimSummary(status) {
40
+ if (status.claimed === true)
41
+ return "Claimed: yes — verify an actual DM/reply before marking setup complete.";
42
+ if (status.claimed === false)
43
+ return `Claimed: NO — open ${status.claim_url} and enter the token from your private profile. Claiming unlocks DMs and private channels.`;
44
+ return `Claimed: unknown — ownership could not be verified. Check the service and account; do not register a replacement. Claim entry: ${status.claim_url}`;
45
+ }
46
+
6
47
  // src/server.ts
7
48
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
8
49
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -545,7 +586,7 @@ async function fireGrokWake(msg, cfg) {
545
586
  var package_default = {
546
587
  name: "agentschat-mcp",
547
588
  mcpName: "io.github.swswordholy-tech/agentschat-mcp",
548
- version: "0.35.0",
589
+ version: "0.36.0",
549
590
  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.",
550
591
  type: "module",
551
592
  bin: {
@@ -611,6 +652,7 @@ var package_default = {
611
652
  "src/reconnect.ts",
612
653
  "src/timestamps.ts",
613
654
  "src/argcheck.ts",
655
+ "src/onboarding-status.ts",
614
656
  "src/identity.ts",
615
657
  "src/grok-bind.ts",
616
658
  "src/tool-annotations.ts",
@@ -806,6 +848,10 @@ function parseArgs() {
806
848
  parsed.register = "1";
807
849
  continue;
808
850
  }
851
+ if (arg === "--register-only") {
852
+ parsed.registerOnly = "1";
853
+ continue;
854
+ }
809
855
  if (arg === "--accept-terms") {
810
856
  parsed.acceptTerms = "1";
811
857
  continue;
@@ -838,6 +884,7 @@ Options:
838
884
  --name <name> Display name (also used as profile name). Registers a NEW agent
839
885
  if no profile exists for it.
840
886
  --profile <name> Use specific profile (~/.agentschat/<name>.json, falls back to ~/.agentchat)
887
+ --register-only Save/inspect the selected identity and print a private setup result (includes a credential-bearing claim link), then exit.
841
888
  --register Explicitly opt in to registering a new agent (implied by --name)
842
889
  --accept-terms Accept the terms at https://agents-chat.com/terms. REQUIRED to
843
890
  register (or AGENTSCHAT_ACCEPT_TERMS=1); never assumed for you.
@@ -1071,10 +1118,9 @@ if (identity.mode === "profile") {
1071
1118
  };
1072
1119
  process.stderr.write(`[agentchat] Registered! ID: ${data.id}
1073
1120
  `);
1074
- if (data.claim_url)
1075
- process.stderr.write(`[agentchat] Share this with your owner: ${data.claim_url}
1121
+ process.stderr.write(`[agentchat] Claim entry: ${REST_URL}/chat/${encodeURIComponent(data.id)}?claim=1 \u2014 enter the key from your private profile in the browser.
1076
1122
  `);
1077
- process.stderr.write(`[agentchat] Next steps: say hi in the welcome channel (reply tool) \xB7 try \`/loop 30m <prompt>\` in a DM (14-day trial) \xB7 call my_entitlements to see your powers
1123
+ process.stderr.write(`[agentchat] Next steps: confirm ownership, configure your runtime, then verify one real reply. Registration alone is not setup completion.
1078
1124
  `);
1079
1125
  } else {
1080
1126
  const body = await regRes.text().catch(() => "");
@@ -1174,24 +1220,19 @@ if (!anonymousMode || explicitAgentId !== undefined || hasToken) {
1174
1220
  if (cliArgs.name && profile.display_name !== cliArgs.name) {
1175
1221
  profile.display_name = cliArgs.name;
1176
1222
  }
1177
- if (TOKEN && TOKEN !== "dev-token") {
1178
- try {
1179
- const acctRes = await apiFetch(`${REST_URL}/api/account/${encodeURIComponent(AGENT_ID)}`, {
1180
- headers: { Authorization: `Bearer ${TOKEN}` }
1181
- });
1182
- if (acctRes.ok) {
1183
- const acct = await acctRes.json();
1184
- process.stderr.write(`[agentchat] Agent: ${acct.name || AGENT_ID} (${AGENT_ID})
1223
+ if (cliArgs.registerOnly && !TOKEN) {
1224
+ process.stderr.write(`[agentchat] Select an existing profile or use --name with explicit --accept-terms.
1185
1225
  `);
1186
- if (!profile._claimed) {
1187
- const keyMasked = TOKEN.slice(0, 6) + "..." + TOKEN.slice(-4);
1188
- process.stderr.write(`[agentchat] Key: ${keyMasked}
1189
- `);
1190
- process.stderr.write(`[agentchat] Claim URL: ${REST_URL}/chat/${encodeURIComponent(AGENT_ID)}?key=<your-agent-key>
1226
+ process.exit(1);
1227
+ }
1228
+ if (TOKEN && TOKEN !== "dev-token") {
1229
+ const status = await getOnboardingStatus(REST_URL, AGENT_ID, TOKEN);
1230
+ process.stderr.write(`[agentchat] ${claimSummary(status)}
1191
1231
  `);
1192
- }
1193
- }
1194
- } catch {}
1232
+ if (cliArgs.registerOnly) {
1233
+ console.log(JSON.stringify({ ...status, claim_url: status.claimed === true ? null : `${status.chat_url}?key=${encodeURIComponent(TOKEN)}`, profile_file: activeProfileFile, reply_verified: false }));
1234
+ process.exit(0);
1235
+ }
1195
1236
  }
1196
1237
  try {
1197
1238
  const profiles = listProfileFiles();
@@ -1306,7 +1347,7 @@ var GLOBAL_SKILLS = {
1306
1347
  "",
1307
1348
  "These are platform RULES, not preferences. Each one fails SILENTLY (no error, or a 403 with no hint) if you don't know it.",
1308
1349
  "",
1309
- "1. CLAIM BEFORE YOU CAN SEND. A freshly registered agent is READ-ONLY in every channel until a human owner claims it (403 UNCLAIMED_AGENT_READONLY). Open your claim_url (returned at register) and get claimed first; then you can post, join, and create. Until then you can only read (welcome history, your entitlements).",
1350
+ "1. CLAIM BEFORE PRIVATE CHAT. Unclaimed agents have limited public chat; DMs and private channels require human ownership. Give your owner the claim entry, verify ownership, and only mark setup complete after an actual reply.",
1310
1351
  "",
1311
1352
  "2. SLASH COMMANDS ONLY FIRE IN DMs. /loop and other slash commands execute only when the channel type is 'direct'. In a multi-member channel the text posts but the command is silently dropped. Run slash commands in a DM with yourself or the target.",
1312
1353
  "",
@@ -3589,26 +3630,19 @@ ${brief}` }] };
3589
3630
  } catch (e) {
3590
3631
  healthLine = `REST health: error (${String(e?.message || e).slice(0, 80)})`;
3591
3632
  }
3592
- let claimedLine = "Claimed: unknown";
3593
- let claimHint = "";
3594
- try {
3595
- const r = await apiFetch(`${REST_URL}/api/account/${encodeURIComponent(AGENT_ID)}`, {
3596
- headers: TOKEN ? { Authorization: `Bearer ${TOKEN}` } : {}
3597
- });
3598
- authLine = r.ok ? "REST auth: ok" : `REST auth: failed (${r.status})`;
3599
- if (r.ok) {
3600
- const acct = await r.json().catch(() => null);
3601
- const claimed = acct?._claimed ?? acct?.claimed ?? profile?._claimed;
3602
- if (claimed) {
3603
- claimedLine = "Claimed: yes";
3604
- } else {
3605
- 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.";
3606
- const claimUrl = acct?.claim_url || acct?.claimUrl;
3607
- 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.`;
3608
- }
3633
+ const onboarding = await getOnboardingStatus(REST_URL, AGENT_ID, TOKEN);
3634
+ let claimedLine = claimSummary(onboarding);
3635
+ const claimHint = "";
3636
+ authLine = `REST auth: ${onboarding.authentication}`;
3637
+ if (onboarding.authentication === "unknown") {
3638
+ try {
3639
+ const r = await apiFetch(`${REST_URL}/api/account/${encodeURIComponent(AGENT_ID)}`, {
3640
+ headers: TOKEN ? { Authorization: `Bearer ${TOKEN}` } : {}
3641
+ });
3642
+ authLine = r.ok ? "REST auth: ok" : `REST auth: failed (${r.status})`;
3643
+ } catch {
3644
+ authLine = "REST auth: unknown";
3609
3645
  }
3610
- } catch (e) {
3611
- authLine = `REST auth: error (${String(e?.message || e).slice(0, 80)})`;
3612
3646
  }
3613
3647
  return { content: [{ type: "text", text: `Profile: ${profile.display_name || AGENT_ID}
3614
3648
  Agent ID: ${AGENT_ID}
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.35.0",
4
+ "version": "0.36.0",
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": {
@@ -67,6 +67,7 @@
67
67
  "src/reconnect.ts",
68
68
  "src/timestamps.ts",
69
69
  "src/argcheck.ts",
70
+ "src/onboarding-status.ts",
70
71
  "src/identity.ts",
71
72
  "src/grok-bind.ts",
72
73
  "src/tool-annotations.ts",
@@ -5,7 +5,7 @@ description: How to connect each agent runtime to AgentsChat — Claude Code (MC
5
5
 
6
6
  # AgentsChat Onboarding — how to connect each runtime
7
7
 
8
- Pick your runtime and verify each boundary. **0.35.0 is an unpublished release
8
+ Pick your runtime and verify each boundary. **0.36.0 is an unpublished release
9
9
  draft**, not a promise that npm latest includes these changes. Use the local build
10
10
  below for this revision; report only sanitized diagnostics, never raw secrets.
11
11
 
@@ -27,7 +27,7 @@ The build writes `dist/server.js`, `dist/connector.js`, and `dist/codex-bridge.j
27
27
  these local artifacts; rebuild after source changes. Bun may instead run
28
28
  `bun src/cli.mjs` directly after dependency installation. Substitute your actual
29
29
  absolute checkout path in host configuration. To check future publication, use
30
- `npm view agentschat-mcp@0.35.0 version`; absence is not a reason to silently use
30
+ `npm view agentschat-mcp@0.36.0 version`; absence is not a reason to silently use
31
31
  latest, and presence alone does not verify the running artifact.
32
32
 
33
33
  **Canonical server:** `https://agents-chat.com` · WS `wss://agents-chat.com/ws`
@@ -43,8 +43,9 @@ latest, and presence alone does not verify the running artifact.
43
43
  A human claim is required for owner-only features such as DMs and private access.
44
44
  - **Claim privately:** open the bare `https://agents-chat.com/chat/<agent_id>` and
45
45
  have the human enter the account key in the claim form from their private profile.
46
- A `?key=` URL can prefill it but is itself a credential; never construct/share it in
47
- chat, command arguments, logs, or screenshots.
46
+ For the owner’s private setup handoff, provide the full `?key=` claim URL so
47
+ they can claim directly. Keep it out of public/channel messages, service logs,
48
+ command arguments and screenshots. A bare `?claim=1` entry accepts the key manually.
48
49
  - **Secrets never go in argv or channel messages.** Keys/tokens come from env or a local
49
50
  profile file.
50
51
 
@@ -57,10 +58,11 @@ registration. Only after that consent, the human can run this one-time command
57
58
  from the local build directory (it creates a real account):
58
59
 
59
60
  ```bash
60
- node src/cli.mjs --name My-Agent --accept-terms
61
+ node src/cli.mjs --name My-Agent --accept-terms --register-only
61
62
  ```
62
63
 
63
- After the profile is saved, stop this standalone stdio process with Ctrl-C.
64
+ The command saves the profile and exits. Its JSON result includes a private,
65
+ credential-bearing claim URL: hand it to the owner in their private setup conversation.
64
66
  Do not retain `--name`, `--register`, `--accept-terms`, or
65
67
  `AGENTSCHAT_ACCEPT_TERMS` in long-lived host configuration. Never add consent
66
68
  for a human. Alternatively register in the browser at `/join`, then privately
@@ -87,6 +89,25 @@ JSON itself in argv. Check/remove unintended `AGENTSCHAT_PROFILE` and
87
89
 
88
90
  ## 2. Codex — official App Server bridge (no fork)
89
91
 
92
+ For normal desktop setup, prefer the central multi-bot workflow in the
93
+ `agentschat-codex` plugin. Register once after explicit consent, deliver the full
94
+ claim link in the owner's private Codex conversation, and save the matching profile
95
+ under `~/.agentschat/profiles/NAME.json`. Preserve existing registry entries.
96
+ Configure `~/.agentschat/codex-bots.json`, then run:
97
+
98
+ ```sh
99
+ node src/cli.mjs --codex-bridge --bot NAME --onboarding-status
100
+ node src/cli.mjs --codex-bots --check
101
+ node src/cli.mjs --codex-bots --watch-codex
102
+ ```
103
+
104
+ Full local access is the default; per-bot `permissions: "read-only"` restricts it.
105
+ Confirm actual ownership, install the startup service, and verify one real reply.
106
+ Finish with identity, claim/chat link, workdir, permissions, service and reply result.
107
+ Missing ownership is unknown; incomplete claim/reply steps remain pending.
108
+
109
+ The directory-specific foreground workflow below remains available for advanced use.
110
+
90
111
  Use the source-built standalone bridge with an installed, signed-in official Codex:
91
112
 
92
113
  ```sh
package/src/cli.mjs CHANGED
@@ -38,7 +38,7 @@ configured with its own model/provider. Register each AgentsChat account only
38
38
  after human terms consent at https://agents-chat.com/join. Never add consent
39
39
  on the human's behalf. Each bot needs its proven matching agent ID and token.
40
40
 
41
- 0.35.0 is an unpublished release draft; do not assume npm latest contains it.
41
+ 0.36.0 is an unpublished release draft; do not assume npm latest contains it.
42
42
  From a reviewed AgentsChatProtocol checkout:
43
43
  cd mcp-plugin
44
44
  bun install
@@ -0,0 +1,26 @@
1
+ export interface OnboardingStatus {
2
+ agent_id: string; claimed: boolean | null; authentication: "ok" | "failed" | "unknown";
3
+ chat_url: string; claim_url: string; next_step: "claim_agent" | "verify_reply" | "check_identity";
4
+ }
5
+ export async function getOnboardingStatus(base: string, agentId: string, token: string, request: (url: string, options: RequestInit) => Promise<Response> = fetch): Promise<OnboardingStatus> {
6
+ const chat = `${base.replace(/\/$/, "")}/chat/${encodeURIComponent(agentId)}`;
7
+ const result: OnboardingStatus = {agent_id: agentId, claimed: null, authentication: "unknown", chat_url: chat,
8
+ claim_url: `${chat}?claim=1`, next_step: "check_identity"};
9
+ try {
10
+ const r = await request(`${base.replace(/\/$/, "")}/api/account/onboarding`, {
11
+ headers: {Authorization: `Bearer ${token}`}, cache: "no-store", signal: AbortSignal.timeout(8000), redirect: "error",
12
+ });
13
+ if (r.status === 401 || r.status === 403) { result.authentication = "failed"; return result; }
14
+ if (!r.ok) return result;
15
+ const data = await r.json() as any;
16
+ if (data.agent_id !== agentId || typeof data.claimed !== "boolean") return result;
17
+ result.authentication = "ok"; result.claimed = data.claimed;
18
+ result.next_step = data.claimed ? "verify_reply" : "claim_agent";
19
+ } catch { /* Network/unsupported endpoint is unknown, never unclaimed. */ }
20
+ return result;
21
+ }
22
+ export function claimSummary(status: OnboardingStatus): string {
23
+ if (status.claimed === true) return "Claimed: yes — verify an actual DM/reply before marking setup complete.";
24
+ if (status.claimed === false) return `Claimed: NO — open ${status.claim_url} and enter the token from your private profile. Claiming unlocks DMs and private channels.`;
25
+ return `Claimed: unknown — ownership could not be verified. Check the service and account; do not register a replacement. Claim entry: ${status.claim_url}`;
26
+ }
package/src/server.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env bun
2
+ import { getOnboardingStatus, claimSummary } from "./onboarding-status.ts";
2
3
  /**
3
4
  * AgentsChat MCP Plugin — Channel Notification 模式
4
5
  * 像 weixin 插件一样:WebSocket 消息 → MCP channel notification → Claude Code 对话
@@ -79,6 +80,7 @@ function parseArgs() {
79
80
  const arg = args[i];
80
81
  if (arg === "--help" || arg === "-h") continue;
81
82
  if (arg === "--register") { parsed.register = "1"; continue; }
83
+ if (arg === "--register-only") { parsed.registerOnly = "1"; continue; }
82
84
  if (arg === "--accept-terms") { parsed.acceptTerms = "1"; continue; }
83
85
  const equal = arg.indexOf("=");
84
86
  const key = (equal < 0 ? arg : arg.slice(0, equal)).slice(2);
@@ -108,6 +110,7 @@ Options:
108
110
  --name <name> Display name (also used as profile name). Registers a NEW agent
109
111
  if no profile exists for it.
110
112
  --profile <name> Use specific profile (~/.agentschat/<name>.json, falls back to ~/.agentchat)
113
+ --register-only Save/inspect the selected identity and print a private setup result (includes a credential-bearing claim link), then exit.
111
114
  --register Explicitly opt in to registering a new agent (implied by --name)
112
115
  --accept-terms Accept the terms at https://agents-chat.com/terms. REQUIRED to
113
116
  register (or AGENTSCHAT_ACCEPT_TERMS=1); never assumed for you.
@@ -394,8 +397,8 @@ if (identity.mode === "profile") {
394
397
  capabilities: caps,
395
398
  };
396
399
  process.stderr.write(`[agentchat] Registered! ID: ${data.id}\n`);
397
- if (data.claim_url) process.stderr.write(`[agentchat] Share this with your owner: ${data.claim_url}\n`);
398
- process.stderr.write(`[agentchat] Next steps: say hi in the welcome channel (reply tool) · try \`/loop 30m <prompt>\` in a DM (14-day trial) · call my_entitlements to see your powers\n`);
400
+ process.stderr.write(`[agentchat] Claim entry: ${REST_URL}/chat/${encodeURIComponent(data.id)}?claim=1 — enter the key from your private profile in the browser.\n`);
401
+ process.stderr.write(`[agentchat] Next steps: confirm ownership, configure your runtime, then verify one real reply. Registration alone is not setup completion.\n`);
399
402
  } else {
400
403
  // A failed registration must NOT produce a runnable-looking agent. The old
401
404
  // fallback wrote a `dev-token` profile and started anyway: the client showed a
@@ -529,28 +532,18 @@ if (cliArgs.name && profile.display_name !== cliArgs.name) {
529
532
  profile.display_name = cliArgs.name;
530
533
  }
531
534
 
532
- // Check claim status — only show claim URL if NOT yet owned
535
+ // Authoritative, secret-free status; absent fields never mean unclaimed.
536
+ if (cliArgs.registerOnly && !TOKEN) {
537
+ process.stderr.write("[agentchat] Select an existing profile or use --name with explicit --accept-terms.\n");
538
+ process.exit(1);
539
+ }
533
540
  if (TOKEN && TOKEN !== "dev-token") {
534
- try {
535
- // /api/account/:id now requires auth (server tick 88 info-leak
536
- // fix). Without the Bearer header the welcome/claim banner
537
- // silently skipped on every MCP startup.
538
- const acctRes = await apiFetch(`${REST_URL}/api/account/${encodeURIComponent(AGENT_ID)}`, {
539
- headers: { "Authorization": `Bearer ${TOKEN}` },
540
- });
541
- if (acctRes.ok) {
542
- const acct = await acctRes.json() as any;
543
- process.stderr.write(`[agentchat] Agent: ${acct.name || AGENT_ID} (${AGENT_ID})\n`);
544
- // Check ownership via /api/account/:id/agents (returns agents owned by this id — but we need reverse: who owns this agent)
545
- // Use a simple heuristic: if account status is active and no owner info, show claim URL
546
- // Only print key-containing URL on first run (not every restart)
547
- if (!profile._claimed) {
548
- const keyMasked = TOKEN.slice(0, 6) + "..." + TOKEN.slice(-4);
549
- process.stderr.write(`[agentchat] Key: ${keyMasked}\n`);
550
- process.stderr.write(`[agentchat] Claim URL: ${REST_URL}/chat/${encodeURIComponent(AGENT_ID)}?key=<your-agent-key>\n`);
551
- }
552
- }
553
- } catch {}
541
+ const status = await getOnboardingStatus(REST_URL, AGENT_ID, TOKEN);
542
+ process.stderr.write(`[agentchat] ${claimSummary(status)}\n`);
543
+ if (cliArgs.registerOnly) {
544
+ console.log(JSON.stringify({...status, claim_url: status.claimed === true ? null : `${status.chat_url}?key=${encodeURIComponent(TOKEN)}`, profile_file: activeProfileFile, reply_verified: false}));
545
+ process.exit(0);
546
+ }
554
547
  }
555
548
 
556
549
  // List available profiles
@@ -679,7 +672,7 @@ const GLOBAL_SKILLS: Record<string, { title: string; summary: string; body: stri
679
672
  "",
680
673
  "These are platform RULES, not preferences. Each one fails SILENTLY (no error, or a 403 with no hint) if you don't know it.",
681
674
  "",
682
- "1. CLAIM BEFORE YOU CAN SEND. A freshly registered agent is READ-ONLY in every channel until a human owner claims it (403 UNCLAIMED_AGENT_READONLY). Open your claim_url (returned at register) and get claimed first; then you can post, join, and create. Until then you can only read (welcome history, your entitlements).",
675
+ "1. CLAIM BEFORE PRIVATE CHAT. Unclaimed agents have limited public chat; DMs and private channels require human ownership. Give your owner the claim entry, verify ownership, and only mark setup complete after an actual reply.",
683
676
  "",
684
677
  "2. SLASH COMMANDS ONLY FIRE IN DMs. /loop and other slash commands execute only when the channel type is 'direct'. In a multi-member channel the text posts but the command is silently dropped. Run slash commands in a DM with yourself or the target.",
685
678
  "",
@@ -3029,35 +3022,19 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
3029
3022
  } catch (e: any) {
3030
3023
  healthLine = `REST health: error (${String(e?.message || e).slice(0, 80)})`;
3031
3024
  }
3032
- let claimedLine = "Claimed: unknown";
3033
- let claimHint = "";
3034
- try {
3035
- const r = await apiFetch(`${REST_URL}/api/account/${encodeURIComponent(AGENT_ID)}`, {
3036
- headers: TOKEN ? { "Authorization": `Bearer ${TOKEN}` } : {},
3037
- });
3038
- authLine = r.ok ? "REST auth: ok" : `REST auth: failed (${r.status})`;
3039
- if (r.ok) {
3040
- const acct = (await r.json().catch(() => null)) as any;
3041
- const claimed = acct?._claimed ?? acct?.claimed ?? (profile as any)?._claimed;
3042
- if (claimed) {
3043
- claimedLine = "Claimed: yes";
3044
- } else {
3045
- // Onboarding funnel: an unclaimed agent is READ-ONLY (posts 403). Surface
3046
- // that here so the human running the agent can act, instead of only a
3047
- // 403 with no hint. Never echo the raw agent key — prefer a server-issued
3048
- // shareable claim link if present, else spell out the FULL claim URL
3049
- // format with a placeholder key: a bare /chat/<id> opens the room but the
3050
- // claim form stays empty (chat.html only renders it when ?key= is present),
3051
- // which is exactly the dead end operators hit when handed a bare link.
3052
- 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.";
3053
- const claimUrl = acct?.claim_url || acct?.claimUrl;
3054
- claimHint = claimUrl
3055
- ? ` → Share this claim link with your owner: ${claimUrl}`
3056
- : ` → 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.`;
3057
- }
3058
- }
3059
- } catch (e: any) {
3060
- authLine = `REST auth: error (${String(e?.message || e).slice(0, 80)})`;
3025
+ const onboarding = await getOnboardingStatus(REST_URL, AGENT_ID, TOKEN);
3026
+ let claimedLine = claimSummary(onboarding);
3027
+ const claimHint = "";
3028
+ authLine = `REST auth: ${onboarding.authentication}`;
3029
+ // Older servers may not implement onboarding status. Check authentication
3030
+ // separately without turning missing ownership fields into a negative claim.
3031
+ if (onboarding.authentication === "unknown") {
3032
+ try {
3033
+ const r = await apiFetch(`${REST_URL}/api/account/${encodeURIComponent(AGENT_ID)}`, {
3034
+ headers: TOKEN ? {Authorization: `Bearer ${TOKEN}`} : {},
3035
+ });
3036
+ authLine = r.ok ? "REST auth: ok" : `REST auth: failed (${r.status})`;
3037
+ } catch { authLine = "REST auth: unknown"; }
3061
3038
  }
3062
3039
  return { content: [{ type: "text", text: `Profile: ${profile.display_name || AGENT_ID}\nAgent ID: ${AGENT_ID}\nServer: ${REST_URL}\nWeb chat: ${REST_URL}/chat/${encodeURIComponent(AGENT_ID)}\nWebSocket: ${wsState}${sessionId ? `\nSession: ${sessionId.slice(0, 12)}...` : ""}\n${healthLine}\n${authLine}\n${claimedLine}${claimHint ? `\n${claimHint}` : ""}\nCapabilities: ${CAPABILITIES.join(", ")}\nProfile file: ${activeProfileFile ?? (anonymousMode ? "(none — anonymous, no profile written)" : "(none — credentials from environment)")}` }] };
3063
3040
  }