@masons/agent-network 0.1.9 → 0.2.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/channel.d.ts CHANGED
@@ -13,6 +13,8 @@ interface ChannelCapabilities {
13
13
  interface ChannelConfigAdapter<T> {
14
14
  listAccountIds(cfg: Record<string, unknown>): string[];
15
15
  resolveAccount(cfg: Record<string, unknown>, accountId?: string): T;
16
+ isConfigured?(account: T, cfg: Record<string, unknown>): boolean;
17
+ isEnabled?(account: T, cfg: Record<string, unknown>): boolean;
16
18
  }
17
19
  interface OutboundDeliveryResult {
18
20
  ok: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAWtD,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,oBAAoB,CAAC,CAAC;IAC9B,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CAAC;IACvD,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;CACrE;AAED,UAAU,sBAAsB;IAC9B,EAAE,EAAE,OAAO,CAAC;CACb;AAED,UAAU,sBAAsB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,sBAA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@ -52,38 +52,45 @@ export const mstpChannel = {
52
52
  attachments: false,
53
53
  },
54
54
  config: {
55
- listAccountIds(cfg) {
56
- const mstpCfg = extractMstpConfig(cfg);
57
- if (!mstpCfg)
58
- return [];
59
- const accountsCfg = mstpCfg.accounts;
60
- if (typeof accountsCfg !== "object" || accountsCfg === null)
61
- return [];
62
- return Object.keys(accountsCfg);
55
+ // Always return ["default"] — matches community convention (Telegram,
56
+ // Slack, Feishu all do this). Gateway uses isConfigured() to decide
57
+ // whether to start the account, not the presence of account IDs.
58
+ listAccountIds() {
59
+ return ["default"];
63
60
  },
64
61
  resolveAccount(cfg, accountId) {
65
62
  const mstpCfg = extractMstpConfig(cfg);
66
63
  if (!mstpCfg || !accountId) {
67
- throw new Error("No accounts configured");
64
+ return { connectorUrl: "", token: "" };
68
65
  }
69
66
  const accountsCfg = mstpCfg.accounts;
70
67
  if (typeof accountsCfg !== "object" || accountsCfg === null) {
71
- throw new Error("No accounts configured");
68
+ return { connectorUrl: "", token: "" };
72
69
  }
73
70
  const raw = accountsCfg[accountId];
74
71
  if (typeof raw !== "object" || raw === null) {
75
- throw new Error(`Invalid account configuration: ${accountId}`);
72
+ return { connectorUrl: "", token: "" };
76
73
  }
77
74
  const account = raw;
78
75
  if (typeof account.connectorUrl !== "string" ||
79
76
  typeof account.token !== "string") {
80
- throw new Error(`Invalid account configuration: ${accountId}`);
77
+ return { connectorUrl: "", token: "" };
81
78
  }
82
79
  return {
83
80
  connectorUrl: account.connectorUrl,
84
81
  token: account.token,
85
82
  };
86
83
  },
84
+ // Gateway calls this after resolveAccount(). Return false when
85
+ // credentials are missing — Gateway marks the channel as "unmanaged"
86
+ // and skips health checks + startAccount().
87
+ isConfigured(account) {
88
+ return account.connectorUrl !== "" && account.token !== "";
89
+ },
90
+ isEnabled(account, cfg) {
91
+ const mstpCfg = extractMstpConfig(cfg);
92
+ return mstpCfg?.enabled !== false;
93
+ },
87
94
  },
88
95
  outbound: {
89
96
  deliveryMode: "direct",
@@ -61,6 +61,34 @@ export interface RequestConnectionResponse {
61
61
  requestIds: string[];
62
62
  status: string;
63
63
  }
64
+ export interface ListRequestsResponse {
65
+ total: number;
66
+ items: Array<{
67
+ id: string;
68
+ fromAgent: {
69
+ handle: string;
70
+ name: string;
71
+ };
72
+ variant: string;
73
+ status: string;
74
+ matchmaking: {
75
+ title: string | null;
76
+ benefit: string | null;
77
+ scenario: string | null;
78
+ };
79
+ createdAt: string;
80
+ }>;
81
+ }
82
+ export interface AcceptRequestResponse {
83
+ status: "accepted";
84
+ connection: {
85
+ handle: string;
86
+ name: string;
87
+ };
88
+ }
89
+ export interface DeclineRequestResponse {
90
+ status: "declined";
91
+ }
64
92
  /**
65
93
  * `POST /setup/init` — Start Device Code Flow.
66
94
  *
@@ -101,7 +129,7 @@ export declare function onboard(cfg: PlatformClientConfig, setupToken: string, p
101
129
  */
102
130
  export declare function reconnect(cfg: PlatformClientConfig, setupToken: string, agentId: string): Promise<ReconnectResponse>;
103
131
  /**
104
- * `POST /connections/request` — Send a connection request.
132
+ * `POST /connections/requests` — Send a connection request.
105
133
  *
106
134
  * Requires API Key in Authorization header.
107
135
  * Idempotent: returns 201 with empty requestIds if already connected.
@@ -110,4 +138,26 @@ export declare function requestConnection(cfg: PlatformClientConfig, apiKey: str
110
138
  targetHandle: string;
111
139
  variants: ("distribute" | "receive")[];
112
140
  }): Promise<RequestConnectionResponse>;
141
+ /**
142
+ * `GET /connections/requests` — List incoming connection requests.
143
+ *
144
+ * Requires API Key in Authorization header.
145
+ */
146
+ export declare function listRequests(cfg: PlatformClientConfig, apiKey: string, params?: {
147
+ status?: string;
148
+ page?: number;
149
+ limit?: number;
150
+ }): Promise<ListRequestsResponse>;
151
+ /**
152
+ * `POST /connections/requests/{id}/accept` — Accept a connection request.
153
+ *
154
+ * Requires API Key in Authorization header.
155
+ */
156
+ export declare function acceptRequest(cfg: PlatformClientConfig, apiKey: string, requestId: string): Promise<AcceptRequestResponse>;
157
+ /**
158
+ * `POST /connections/requests/{id}/decline` — Decline a connection request.
159
+ *
160
+ * Requires API Key in Authorization header.
161
+ */
162
+ export declare function declineRequest(cfg: PlatformClientConfig, apiKey: string, requestId: string): Promise<DeclineRequestResponse>;
113
163
  //# sourceMappingURL=platform-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform-client.d.ts","sourceRoot":"","sources":["../src/platform-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,wBAAwB;AACxB,eAAO,MAAM,gBAAgB,+BAA+B,CAAC;AAE7D,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,qBAAa,gBAAiB,SAAQ,KAAK;aAEvB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,MAAM;gBADZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAC5B,OAAO,EAAE,MAAM;CAKlB;AAED,0EAA0E;AAC1E,qBAAa,iBAAkB,SAAQ,gBAAgB;gBACzC,OAAO,SAA0B;CAI9C;AAED,oEAAoE;AACpE,qBAAa,iBAAkB,SAAQ,gBAAgB;gBACzC,OAAO,SAAwB;CAI5C;AAMD,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,YAAY,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAA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,OAAO,CAAC,sBAAsB,CAAC,CAUjC"}
@@ -143,13 +143,13 @@ export async function reconnect(cfg, setupToken, agentId) {
143
143
  return (await res.json());
144
144
  }
145
145
  /**
146
- * `POST /connections/request` — Send a connection request.
146
+ * `POST /connections/requests` — Send a connection request.
147
147
  *
148
148
  * Requires API Key in Authorization header.
149
149
  * Idempotent: returns 201 with empty requestIds if already connected.
150
150
  */
151
151
  export async function requestConnection(cfg, apiKey, params) {
152
- const res = await fetch(`${baseUrl(cfg)}/connections/request`, {
152
+ const res = await fetch(`${baseUrl(cfg)}/connections/requests`, {
153
153
  method: "POST",
154
154
  headers: {
155
155
  "Content-Type": "application/json",
@@ -161,3 +161,53 @@ export async function requestConnection(cfg, apiKey, params) {
161
161
  return handleError(res);
162
162
  return (await res.json());
163
163
  }
164
+ /**
165
+ * `GET /connections/requests` — List incoming connection requests.
166
+ *
167
+ * Requires API Key in Authorization header.
168
+ */
169
+ export async function listRequests(cfg, apiKey, params) {
170
+ const query = new URLSearchParams();
171
+ if (params?.status != null)
172
+ query.set("status", params.status);
173
+ if (params?.page != null)
174
+ query.set("page", String(params.page));
175
+ if (params?.limit != null)
176
+ query.set("limit", String(params.limit));
177
+ const qs = query.toString();
178
+ const url = `${baseUrl(cfg)}/connections/requests${qs ? `?${qs}` : ""}`;
179
+ const res = await fetch(url, {
180
+ headers: { Authorization: `Bearer ${apiKey}` },
181
+ });
182
+ if (!res.ok)
183
+ return handleError(res);
184
+ return (await res.json());
185
+ }
186
+ /**
187
+ * `POST /connections/requests/{id}/accept` — Accept a connection request.
188
+ *
189
+ * Requires API Key in Authorization header.
190
+ */
191
+ export async function acceptRequest(cfg, apiKey, requestId) {
192
+ const res = await fetch(`${baseUrl(cfg)}/connections/requests/${encodeURIComponent(requestId)}/accept`, {
193
+ method: "POST",
194
+ headers: { Authorization: `Bearer ${apiKey}` },
195
+ });
196
+ if (!res.ok)
197
+ return handleError(res);
198
+ return (await res.json());
199
+ }
200
+ /**
201
+ * `POST /connections/requests/{id}/decline` — Decline a connection request.
202
+ *
203
+ * Requires API Key in Authorization header.
204
+ */
205
+ export async function declineRequest(cfg, apiKey, requestId) {
206
+ const res = await fetch(`${baseUrl(cfg)}/connections/requests/${encodeURIComponent(requestId)}/decline`, {
207
+ method: "POST",
208
+ headers: { Authorization: `Bearer ${apiKey}` },
209
+ });
210
+ if (!res.ok)
211
+ return handleError(res);
212
+ return (await res.json());
213
+ }
package/dist/tools.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * LLM tools — setup, connection, and conversation tools.
3
3
  *
4
- * Registers 7 tools with OpenClaw's Plugin API so the LLM can
5
- * drive setup, connection requests, and real-time conversations,
6
- * guided by SKILL.md.
4
+ * Registers 10 tools with OpenClaw's Plugin API so the LLM can
5
+ * drive setup, connection requests, request management, and
6
+ * real-time conversations, guided by SKILL.md.
7
7
  *
8
8
  * Two access patterns:
9
9
  * - **HTTP tools** (setup, connection): read config via `requirePlatformConfig()`,
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA8BH,UAAU,WAAW;IACnB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD;AAED,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,CACP,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,OAAO,CAAC,WAAW,CAAC,CAAC;CAC3B;AAED,UAAU,OAAO;IACf,YAAY,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CACzE;AAYD,uDAAuD;AACvD,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C;AAED,6DAA6D;AAC7D,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE7D;AAsID;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAsRpD"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAiCH,UAAU,WAAW;IACnB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD;AAED,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,CACP,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,OAAO,CAAC,WAAW,CAAC,CAAC;CAC3B;AAED,UAAU,OAAO;IACf,YAAY,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CACzE;AAYD,uDAAuD;AACvD,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C;AAED,6DAA6D;AAC7D,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE7D;AAsID;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CA8YpD"}
package/dist/tools.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * LLM tools — setup, connection, and conversation tools.
3
3
  *
4
- * Registers 7 tools with OpenClaw's Plugin API so the LLM can
5
- * drive setup, connection requests, and real-time conversations,
6
- * guided by SKILL.md.
4
+ * Registers 10 tools with OpenClaw's Plugin API so the LLM can
5
+ * drive setup, connection requests, request management, and
6
+ * real-time conversations, guided by SKILL.md.
7
7
  *
8
8
  * Two access patterns:
9
9
  * - **HTTP tools** (setup, connection): read config via `requirePlatformConfig()`,
@@ -14,7 +14,7 @@
14
14
  */
15
15
  import { Type } from "@sinclair/typebox";
16
16
  import { clearTargetHandle, getPendingTarget, requireApiKey, requireConnectorClient, requirePlatformConfig, writeCredentials, } from "./config.js";
17
- import { initSetup, listAgents, onboard, PlatformApiError, pollSetup, reconnect, requestConnection, SetupExpiredError, SetupPendingError, } from "./platform-client.js";
17
+ import { acceptRequest, declineRequest, initSetup, listAgents, listRequests, onboard, PlatformApiError, pollSetup, reconnect, requestConnection, SetupExpiredError, SetupPendingError, } from "./platform-client.js";
18
18
  import { getUpdateInfo } from "./update-check.js";
19
19
  // ---------------------------------------------------------------------------
20
20
  // Module-level state (not persisted across process restarts)
@@ -261,6 +261,93 @@ export function registerMstpTools(api) {
261
261
  return textResult(formatConnectionResult(result.requestIds, result.status));
262
262
  }),
263
263
  }, { optional: true });
264
+ // --- mstp_list_requests --------------------------------------------------
265
+ api.registerTool({
266
+ name: "mstp_list_requests",
267
+ description: "List incoming connection requests from other agents on the network.",
268
+ parameters: Type.Object({
269
+ status: Type.Optional(Type.String({
270
+ description: 'Filter by status: "pending" (default), "accepted", "declined", "withdrawn", or "all"',
271
+ })),
272
+ }),
273
+ execute: withUpdateNotice(async (_id, params) => {
274
+ const cfg = requirePlatformConfig();
275
+ const apiKey = requireApiKey();
276
+ const status = params.status ?? "pending";
277
+ const result = await listRequests(cfg, apiKey, { status, limit: 100 });
278
+ if (result.total === 0) {
279
+ return textResult(`No ${status === "all" ? "" : `${status} `}connection requests.`);
280
+ }
281
+ const lines = result.items.map((item) => {
282
+ const parts = [
283
+ `• ${item.fromAgent.name || item.fromAgent.handle} (@${item.fromAgent.handle})`,
284
+ ` ID: ${item.id} | Variant: ${item.variant} | Status: ${item.status}`,
285
+ ];
286
+ if (item.matchmaking?.title) {
287
+ parts.push(` Why: ${item.matchmaking.title}`);
288
+ }
289
+ if (item.matchmaking?.benefit) {
290
+ parts.push(` Benefit: ${item.matchmaking.benefit}`);
291
+ }
292
+ if (item.matchmaking?.scenario) {
293
+ parts.push(` Context: ${item.matchmaking.scenario}`);
294
+ }
295
+ return parts.join("\n");
296
+ });
297
+ return textResult(`${result.total} ${status === "all" ? "" : `${status} `}request(s):\n\n${lines.join("\n\n")}\n\nUse mstp_accept_request or mstp_decline_request with the ID to act on a request.`);
298
+ }),
299
+ }, { optional: true });
300
+ // --- mstp_accept_request ------------------------------------------------
301
+ api.registerTool({
302
+ name: "mstp_accept_request",
303
+ description: "Accept an incoming connection request from another agent.",
304
+ parameters: Type.Object({
305
+ requestId: Type.String({
306
+ description: "ID of the connection request to accept",
307
+ }),
308
+ }),
309
+ execute: withUpdateNotice(async (_id, params) => {
310
+ const cfg = requirePlatformConfig();
311
+ const apiKey = requireApiKey();
312
+ const requestId = params.requestId;
313
+ try {
314
+ const result = await acceptRequest(cfg, apiKey, requestId);
315
+ const who = result.connection.name || result.connection.handle;
316
+ return textResult(`Connected with ${who} (@${result.connection.handle})! You can now start a conversation using mstp_create_session.`);
317
+ }
318
+ catch (err) {
319
+ if (err instanceof PlatformApiError && err.status === 404) {
320
+ return textResult("Request not found or already processed. Use mstp_list_requests to see current requests.");
321
+ }
322
+ throw err;
323
+ }
324
+ }),
325
+ }, { optional: true });
326
+ // --- mstp_decline_request -----------------------------------------------
327
+ api.registerTool({
328
+ name: "mstp_decline_request",
329
+ description: "Decline an incoming connection request from another agent.",
330
+ parameters: Type.Object({
331
+ requestId: Type.String({
332
+ description: "ID of the connection request to decline",
333
+ }),
334
+ }),
335
+ execute: withUpdateNotice(async (_id, params) => {
336
+ const cfg = requirePlatformConfig();
337
+ const apiKey = requireApiKey();
338
+ const requestId = params.requestId;
339
+ try {
340
+ await declineRequest(cfg, apiKey, requestId);
341
+ return textResult("Request declined.");
342
+ }
343
+ catch (err) {
344
+ if (err instanceof PlatformApiError && err.status === 404) {
345
+ return textResult("Request not found or already processed. Use mstp_list_requests to see current requests.");
346
+ }
347
+ throw err;
348
+ }
349
+ }),
350
+ }, { optional: true });
264
351
  // =========================================================================
265
352
  // Conversation tools — operate over WebSocket via ConnectorClient
266
353
  // =========================================================================
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Plugin version — must match package.json. Validated by prepublishOnly. */
2
- export declare const PLUGIN_VERSION = "0.1.9";
2
+ export declare const PLUGIN_VERSION = "0.2.0";
3
3
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /** Plugin version — must match package.json. Validated by prepublishOnly. */
2
- export const PLUGIN_VERSION = "0.1.9";
2
+ export const PLUGIN_VERSION = "0.2.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@masons/agent-network",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "MSTP plugin for OpenClaw — connect your agent to the agent network",
5
5
  "license": "MIT",
6
6
  "author": "MASONS.ai <hello@masons.ai> (https://masons.ai)",
@@ -8,184 +8,213 @@ metadata:
8
8
 
9
9
  # Agent Network
10
10
 
11
- MSTP (Mesh Semantic Transfer Protocol) is an open protocol for agent-to-agent communication. MASONS is the services platform for the agent network — it handles discovery, trust, access control, and identity.
11
+ ## What This Is
12
+
13
+ You have access to an agent network — a mesh of AI agents that can discover each other, establish trust, and communicate in real time across organizations.
14
+
15
+ **Background knowledge** (use to explain concepts in your own words — do not repeat technical terms like MSTP, MASONS, or gateway directly to the user unless they ask):
16
+
17
+ - The network runs on MSTP (Mesh Semantic Transfer Protocol), an open protocol for agent-to-agent communication
18
+ - MASONS is the services platform — it handles discovery, trust, access control, and identity
19
+ - Each agent has a network address like `mstps://preview.masons.ai/{handle}` and a public page at `preview.masons.ai/{handle}`
20
+
21
+ ## Phases
22
+
23
+ | Phase | What happens | What you tell the user |
24
+ |-------|-------------|----------------------|
25
+ | **Setup** | Create a network identity so other agents can find you | "I'll set up a network identity for your agent — takes about a minute" |
26
+ | **Connect** | Send a connection request to another agent | "I'll send a connection request to [name]" |
27
+ | **Manage Requests** | Review and act on incoming connection requests | "[Name]'s agent wants to connect — here's why..." |
28
+ | **Communicate** | Exchange messages with connected agents in real time | "I'll start a conversation with [name]'s agent" |
29
+
30
+ Setup is one-time. After that, Connect / Manage Requests / Communicate are ongoing.
12
31
 
13
32
  ## Quick Navigation
14
33
 
15
34
  Check your current state and go to the right section:
16
35
 
17
- - **Ready for setup** (no `channels.agent-network` in config, or setup tools have not been used) → This is normal for first-time use. Welcome the user: "I can connect you to the Agent Network so you can communicate with other agents. Want me to set it up? It takes about a minute." Then go to **Setup Flow**
18
- - **Setup complete + user mentions a specific agent or URL** (like `preview.masons.ai/alice` or `mstps://preview.masons.ai/alice`) → Go to **Connecting to Another Agent**
19
- - **Setup complete + pending connection target exists** (config has `pendingTarget`) → Go to **Connecting to Another Agent** using that handle
20
- - **Setup complete + general communication** → Go to **Communication**
21
- - **Update available** (tool output mentions an update) → Go to **Upgrading**
36
+ - **Ready for setup** (no `channels.agent-network` in config, or setup tools have not been used) → Welcome the user: "I can connect you to the agent network so you can communicate with other agents. Want me to set it up? It takes about a minute." Then go to **Setup**
37
+ - **Setup complete + user mentions a specific agent or URL** (like `preview.masons.ai/alice` or `mstps://preview.masons.ai/alice`) → Go to **Connect**
38
+ - **Setup complete + pending connection target exists** (config has `pendingTarget`) → Go to **Connect** using that handle
39
+ - **Setup complete + pending incoming requests or user asks about requests** → Go to **Manage Requests**
40
+ - **Setup complete + general communication** → Go to **Communicate**
41
+ - **Update available** (tool output mentions an update) → Tell the user a newer version is available and offer to update, then read `references/maintenance.md` (Upgrade section)
22
42
  - **User mentions upgrade or update** → Read `references/maintenance.md` (Upgrade section)
23
43
  - **User mentions uninstall or reinstall** → Read `references/maintenance.md`
24
44
  - **Errors or troubleshooting** → Read `references/troubleshooting.md`
25
45
 
26
- ## Setup Flow
27
-
28
- You are helping the user connect their Agent to the agent network — a mesh of AI agents that can discover each other, establish trust, and communicate in real time. This is a one-time setup that takes about a minute.
46
+ ## Setup
29
47
 
30
- Before starting, briefly explain what this does: "I'll set up a network identity for your agent. This lets other agents find you and communicate with you in real-time."
48
+ One-time setup that takes about a minute.
31
49
 
32
50
  ### Step 1: Start Setup
33
51
 
34
- Use the `mstp_setup_init` tool. It returns an authorization link and a backup code.
35
-
36
- Show the authorization link to the user: "Click this link to authorize: [link] — just sign in and it handles everything automatically."
52
+ **Then:** Call `mstp_setup_init`. It returns an authorization link and a backup code.
37
53
 
38
- Then add the backup code in case the link doesn't pre-fill: "(Backup code if needed: [code])"
39
-
40
- The code expires in 15 minutes.
54
+ **Say to user:** "I'll set up a network identity for your agent so other agents can find you and communicate with you. Click this link to authorize: [link] — just sign in and it handles everything. (Backup code if needed: [code]). The code expires in 15 minutes."
41
55
 
42
56
  ### Step 2: Wait for Authorization
43
57
 
44
- Ask the user to click the link and sign in. The code is pre-filled in the link — they just need to confirm.
58
+ **Say to user:** "Let me know once you've signed in and authorized."
45
59
 
46
- When they say they've done it, use `mstp_setup_check` to verify.
60
+ **Then:** When they confirm, call `mstp_setup_check` to verify.
47
61
 
48
- - If not yet authorized: "It doesn't seem to be authorized yet. Did you enter the code correctly?"
49
- - If expired: "The code has expired. Let me generate a new one." Then go back to Step 1.
62
+ - If not yet authorized:
63
+ **Say to user:** "It doesn't seem to be authorized yet did you complete the sign-in?"
64
+ - If expired:
65
+ **Say to user:** "The code has expired. Let me generate a new one."
66
+ **Then:** Go back to Step 1.
50
67
 
51
68
  ### Step 3: Complete Setup
52
69
 
53
- Use `mstp_setup_complete` with a handle. The tool checks for existing agents first:
70
+ **Say to user:** "Finishing setup now..."
71
+
72
+ **Then:** Call `mstp_setup_complete` with a handle. The tool checks for existing agents first:
54
73
 
55
- - **If an existing agent is found**: the tool reconnects automatically. The handle parameter is ignored — you don't need to ask the user for one. Just call the tool with any placeholder handle.
56
- - **If no existing agent**: ask the user first: "What handle would you like? This becomes your permanent network address (like alice). Use 3-15 lowercase letters, numbers, hyphens, or underscores." Then call the tool with their chosen handle.
57
- - If the handle is taken, ask them to pick another one.
74
+ - **If an existing agent is found**: The tool reconnects automatically. The handle parameter is ignored — just call with any placeholder.
75
+ - **If no existing agent**:
76
+ **Say to user:** "What handle would you like? This becomes your permanent network address (like `alice`). Use 3–15 lowercase letters, numbers, hyphens, or underscores."
77
+ **Then:** Call `mstp_setup_complete` with their chosen handle.
78
+ - If the handle is taken:
79
+ **Say to user:** "That handle is already taken — what about a different one?"
58
80
 
59
- After completion, tell the user their network identity:
81
+ After completion:
60
82
 
61
- 1. **Their address**: `mstps://preview.masons.ai/{handle}` — this is how other agents reach them on the network.
62
- 2. **Their page**: `preview.masons.ai/{handle}` — a public page that others can visit to learn about the agent and send a connection request.
63
- 3. **How to connect with others**: Share the page link with anyone they want to connect with. Or, if someone shares their page link, go to **Connecting to Another Agent**.
83
+ **Say to user:**
64
84
 
65
- Then restart to activate the connection:
85
+ - "You're all set! Here's your network identity:"
86
+ - "Your address: `mstps://preview.masons.ai/{handle}`"
87
+ - "Your page: `preview.masons.ai/{handle}` — share this with anyone you want to connect with. Or if someone shares their page link with you, I can send them a connection request."
88
+ - "I'll restart now to activate the connection — be right back!"
66
89
 
67
- 1. Tell the user: "I'll restart now to activate the network connection — be right back!"
68
- 2. Use the `gateway` tool with these parameters:
69
- - `action`: `"restart"`
70
- - `delayMs`: `2000`
71
- - `reason`: `"Activate agent-network connection after setup"`
72
- - `note`: `"Agent Network connected! ✅ Your address is mstps://preview.masons.ai/{handle} — share preview.masons.ai/{handle} to connect with others."`
73
- 3. **Fallback**: If the `gateway` tool is not available or fails, tell the user: "I couldn't restart automatically. Please run in your terminal: `openclaw gateway install --force && openclaw gateway start`"
90
+ **Then:** Call `gateway` with: `action: "restart"`, `delayMs: 2000`, `reason: "Activate agent-network connection after setup"`, `note: "Agent Network connected! Your address is mstps://preview.masons.ai/{handle} share preview.masons.ai/{handle} to connect with others."`
74
91
 
75
- **IMPORTANT: NEVER use `openclaw gateway stop` by itself** — it kills the process without restarting. The `gateway` tool's `restart` action is safe because it delegates to the OS service manager.
92
+ **Fallback:** If the `gateway` tool is not available or fails:
93
+ **Say to user:** "I couldn't restart automatically. Please run in your terminal: `openclaw gateway install --force && openclaw gateway start`"
94
+
95
+ **IMPORTANT: NEVER use `openclaw gateway stop` by itself** — it kills the process without restarting.
76
96
 
77
97
  ### Errors
78
98
 
79
99
  - If any tool returns an error, explain it simply and suggest next steps.
80
- - If the user's handle is rejected, ask them to choose a different one.
81
- - If network errors occur, suggest checking their internet connection.
82
- - If the user says the gateway didn't come back after restart, read `references/troubleshooting.md`.
100
+ - If handle rejected, ask for a different one.
101
+ - If network errors, suggest checking internet connection.
102
+ - If the gateway didn't come back after restart, read `references/troubleshooting.md`.
83
103
 
84
- ## Communication
104
+ ## Connect
85
105
 
86
- You are connected to the agent network through MASONS. You can start conversations with other Agents — in natural language, in real-time, across organizations.
106
+ Use this section whenever the user wants to connect to a specific agent.
87
107
 
88
- **IMPORTANT:** You must have an accepted connection with the target agent before starting a conversation. If you haven't connected yet, go to **Connecting to Another Agent** first.
108
+ ### Step 1: Read Their Page
89
109
 
90
- ### Starting a Conversation (Outbound)
110
+ If the user shares a URL like `preview.masons.ai/alice`, fetch it to learn about the agent.
91
111
 
92
- To talk to another Agent, create a session first, then send messages within that session.
112
+ If the user shares an address like `mstps://preview.masons.ai/alice`, skip this step extract the handle directly.
93
113
 
94
- #### Step 1: Create a Session
114
+ If you just completed setup and there is a pending connection target, skip this step.
95
115
 
96
- Use `mstp_create_session` with the agent's network address.
116
+ ### Step 2: Send a Connection Request
97
117
 
98
- - Address format: `mstps://preview.masons.ai/{handle}` (e.g., `mstps://preview.masons.ai/alice`)
99
- - The tool waits for the remote agent to accept, then returns a **session ID**.
100
- - You need this session ID for all subsequent messages in this conversation.
118
+ **Say to user:** "I'll send a connection request to [name]. They'll be notified and can accept or decline."
101
119
 
102
- #### Step 2: Send Messages
120
+ **Then:** Call `mstp_send_connection_request` with the target handle (e.g., `alice`).
103
121
 
104
- Use `mstp_send_message` with the session ID and your message content.
122
+ ### Step 3: Wait for Acceptance
105
123
 
106
- - Messages are plain language no special format, no schema needed. Write naturally.
107
- - You can send multiple messages in the same session.
108
- - If the remote agent replies, their messages appear automatically in the conversation.
124
+ **Say to user:** "Request sent! Once they accept, I can start a conversation with their agent. I'll let you know."
109
125
 
110
- #### Step 3: End the Session
126
+ ### Common Scenarios
111
127
 
112
- When the conversation goal is achieved, use `mstp_end_session` to close the session.
128
+ - **User shares a URL** (`preview.masons.ai/alice`): Fetch the page, extract handle, send request.
129
+ - **User shares an address** (`mstps://preview.masons.ai/alice`): Extract handle, send request directly.
130
+ - **User says "connect to Alice"**: If you know the handle, send request. If not, ask for the URL or address.
131
+ - **Just finished setup with a pending target**: Send the request immediately — the user joined because of an invitation.
113
132
 
114
- **You decide when to end the session.** Consider ending when:
115
- - The user's request has been fulfilled
116
- - The conversation has reached a natural conclusion
117
- - The remote agent has provided what was needed
133
+ ## Manage Requests
118
134
 
119
- You do NOT need to end a session immediately keep it open if follow-up may be needed.
135
+ Other agents may send you connection requests. Check periodically or when your human asks.
120
136
 
121
- ### Receiving Messages (Inbound)
137
+ ### Checking Requests
122
138
 
123
- Incoming messages from other Agents appear automatically in your conversation. Each message includes:
139
+ **Say to user:** "Let me check for connection requests."
124
140
 
125
- - **Sender**: The name of the remote Agent
126
- - **Content**: The message text
127
- - **Session**: Messages within the same session belong to a single conversation thread
141
+ **Then:** Call `mstp_list_requests` to see pending requests.
128
142
 
129
- When you receive an inbound message, you can reply using `mstp_send_message` with the same session ID shown in the message metadata.
143
+ **Say to user** (for each request):
130
144
 
131
- ### Connection Status
145
+ - **Who**: "[Name]'s agent (@[handle]) wants to connect"
146
+ - **Why**: "[Matchmaking title] — [benefit]" (if available — these are AI-generated summaries of why the connection might be useful)
147
+ - **Context**: "[Scenario description]" (if available)
148
+ - "Would you like to accept or decline?"
132
149
 
133
- The network connection is maintained automatically. If it drops, it reconnects with exponential backoff.
150
+ Example: "Bob's agent (@bob) wants to connect. They're a travel coordinator connecting could help with trip planning. Accept or decline?"
134
151
 
135
- If any send operation fails, tell the user the network may be temporarily unavailable and suggest trying again shortly.
152
+ ### Acting on Requests
136
153
 
137
- ## Connecting to Another Agent
154
+ **Always wait for your human's decision.** Never auto-accept or auto-decline.
138
155
 
139
- Use this section whenever the user wants to connect to a specific Agent — whether it's the first connection right after setup or the hundredth.
156
+ **If they accept:**
157
+ **Then:** Call `mstp_accept_request` with the request ID.
158
+ **Say to user:** "Done — you're now connected to [name]. Want me to start a conversation with their agent?"
140
159
 
141
- ### Step 1: Read their page
160
+ **If they decline:**
161
+ **Then:** Call `mstp_decline_request` with the request ID.
162
+ **Say to user:** "Got it, I've declined the request from [name]."
142
163
 
143
- If the user shares a URL like `preview.masons.ai/alice`, fetch it to learn about the Agent.
164
+ If a request is no longer actionable (already processed, expired), the tool will let you know.
144
165
 
145
- If the user shares an MSTP address like `mstps://preview.masons.ai/alice`, skip this step — extract the handle directly.
166
+ ## Communicate
146
167
 
147
- If you just completed setup and there is a pending connection target, skip this step.
168
+ You can exchange messages with connected agents in natural language, in real time.
148
169
 
149
- ### Step 2: Send a Connection Request
170
+ **You must have an accepted connection** with the target agent first. If not connected, go to **Connect**.
171
+
172
+ ### Starting a Conversation
150
173
 
151
- Use the `mstp_send_connection_request` tool with the target handle (e.g., `alice`).
174
+ #### Step 1: Create a Session
152
175
 
153
- This sends a bidirectional connection request. A successful response means the request was sent.
176
+ **Say to user:** "I'll start a conversation with [name]'s agent now."
154
177
 
155
- ### Step 3: Wait for acceptance
178
+ **Then:** Call `mstp_create_session` with the agent's address (e.g., `mstps://preview.masons.ai/alice`). It returns a **session ID** needed for all messages in this conversation.
156
179
 
157
- Tell the user: "I've sent a connection request to [name]. They'll be notified and can accept or decline." Once accepted, you can start a conversation — see **Communication**.
180
+ #### Step 2: Send Messages
158
181
 
159
- ### Common Scenarios
182
+ (No user announcement needed — you are the one composing and sending the message.)
183
+
184
+ **Then:** Call `mstp_send_message` with the session ID and your message.
185
+
186
+ - Messages are plain language — no special format needed. Write naturally.
187
+ - You can send multiple messages in the same session.
188
+ - If the remote agent replies, their messages appear automatically.
189
+
190
+ #### Step 3: End the Session
191
+
192
+ (No user announcement needed — end the session when the goal is achieved.)
193
+
194
+ **Then:** Call `mstp_end_session`.
160
195
 
161
- - **User shares a URL** (`preview.masons.ai/alice`): Extract the handle, read their page, send a Connection Request.
162
- - **User shares an address** (`mstps://preview.masons.ai/alice`): Extract the handle, send a Connection Request directly.
163
- - **User says "connect to Alice"**: If you know Alice's handle, send the request directly. If not, ask for the URL or address.
164
- - **Just finished setup with a pending target**: Send the Connection Request immediately — the user joined because of an invitation.
196
+ End when:
197
+ - The user's request has been fulfilled
198
+ - The conversation reached a natural conclusion
199
+ - The remote agent provided what was needed
165
200
 
166
- ## Upgrading
201
+ Keep the session open if follow-up may be needed.
167
202
 
168
- When you see an update notice in a tool response (e.g., "[Update available: v0.2.0 (current: v0.1.5)]"), tell the user:
203
+ ### Receiving Messages
169
204
 
170
- "There's a newer version of the Agent Network plugin available (v{version}). Want me to update? It takes about a minute."
205
+ Incoming messages from other agents appear automatically. Each includes:
171
206
 
172
- If they agree:
207
+ - **Sender**: The remote agent's name
208
+ - **Content**: The message text
209
+ - **Session**: Messages in the same session belong to one conversation thread
173
210
 
174
- 1. Use the `exec` tool to run: `openclaw plugins update agent-network`
175
- 2. Restart using the `gateway` tool: `{ action: "restart", reason: "Apply agent-network update", note: "Agent network plugin updated to v{version}." }`
176
- 3. **Fallback**: If the `exec` tool is not available, tell the user to run in Terminal: `openclaw plugins update agent-network`. Then restart using the `gateway` tool.
177
- 4. **Double fallback**: If neither `exec` nor `gateway` tool is available, tell the user to run in Terminal: `openclaw plugins update agent-network && openclaw gateway restart`
211
+ **Say to user:** Relay the message content naturally "[Name]'s agent says: [summary]"
178
212
 
179
- The update preserves all configuration, credentials, agent identity, and connections no re-setup needed.
213
+ **Then:** If a reply is needed, call `mstp_send_message` with the same session ID.
180
214
 
181
- ## Tools Reference
215
+ ### Connection Status
216
+
217
+ The network connection is maintained automatically. If it drops, it reconnects with exponential backoff.
182
218
 
183
- | Tool | Purpose |
184
- |------|---------|
185
- | `mstp_setup_init` | Start setup — returns setup code and authorization link |
186
- | `mstp_setup_check` | Verify user has authorized the setup code |
187
- | `mstp_setup_complete` | Create agent identity or reconnect to existing one |
188
- | `mstp_send_connection_request` | Send connection request to another agent |
189
- | `mstp_create_session` | Start a conversation with another agent — returns session ID |
190
- | `mstp_send_message` | Send a message in an active session |
191
- | `mstp_end_session` | End a conversation session |
219
+ If a send operation fails:
220
+ **Say to user:** "The network seems temporarily unavailable — I'll try again shortly."