@masons/agent-network 0.3.2 → 0.3.4
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.map +1 -1
- package/dist/channel.js +10 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -0
- package/dist/connector-client.d.ts.map +1 -1
- package/dist/connector-client.js +21 -2
- package/dist/platform-client.d.ts +26 -16
- package/dist/platform-client.d.ts.map +1 -1
- package/dist/platform-client.js +4 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +32 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -1
- package/skills/agent-network/SKILL.md +11 -3
package/dist/channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAa9D,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;IACpE,YAAY,CAAC,CAAC,OAAO,EA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,qBAAqB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/D,WAAW,CAAC,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D;AAED,UAAU,yBAAyB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,YAAY,EAAE,mBAAmB,CAAC;IAClC,MAAM,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,CAAC;IAClD,QAAQ,EAAE,sBAAsB,CAAC;IACjC,OAAO,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;CACrD;AAwDD,eAAO,MAAM,mBAAmB,EAAE,yBA2MjC,CAAC"}
|
package/dist/channel.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
+
import createDebug from "debug";
|
|
2
3
|
import { clearConnectorClient, extractNetworkConfig, initConnectorClient, initToolConfig, } from "./config.js";
|
|
3
4
|
import { ConnectorClient } from "./connector-client.js";
|
|
4
5
|
import { checkForUpdate } from "./update-check.js";
|
|
6
|
+
const dbg = createDebug("agent-network:channel");
|
|
5
7
|
// --- Sender identity ---
|
|
6
8
|
/**
|
|
7
9
|
* Use sessionId as the sender identifier for OpenClaw routing.
|
|
@@ -103,11 +105,13 @@ export const agentNetworkChannel = {
|
|
|
103
105
|
const sent = state.client.sendMessage(ctx.recipient, ctx.text, {
|
|
104
106
|
contentType: "text",
|
|
105
107
|
});
|
|
108
|
+
dbg("sendText sessionId=%s contentLength=%d sent=%s", ctx.recipient, ctx.text.length, sent);
|
|
106
109
|
return { ok: sent };
|
|
107
110
|
},
|
|
108
111
|
},
|
|
109
112
|
gateway: {
|
|
110
113
|
async startAccount(ctx) {
|
|
114
|
+
dbg("starting account %s", ctx.accountId);
|
|
111
115
|
const { connectorUrl, token } = ctx.account;
|
|
112
116
|
const client = new ConnectorClient(connectorUrl, token);
|
|
113
117
|
const state = {
|
|
@@ -117,6 +121,7 @@ export const agentNetworkChannel = {
|
|
|
117
121
|
accounts.set(ctx.accountId, state);
|
|
118
122
|
// --- Inbound message routing ---
|
|
119
123
|
client.on("message_received", (event) => {
|
|
124
|
+
dbg("routing inbound message sessionId=%s contentLength=%d", event.sessionId, event.content.length);
|
|
120
125
|
const senderId = deriveSenderId(event);
|
|
121
126
|
const envelope = {
|
|
122
127
|
channelId: "agent-network",
|
|
@@ -135,12 +140,14 @@ export const agentNetworkChannel = {
|
|
|
135
140
|
});
|
|
136
141
|
// --- Session lifecycle ---
|
|
137
142
|
client.on("session_created", (event) => {
|
|
143
|
+
dbg("session created sessionId=%s direction=%s", event.sessionId, event.direction);
|
|
138
144
|
const from = event.metadata?.from;
|
|
139
145
|
state.sessions.set(event.sessionId, {
|
|
140
146
|
remoteAddress: typeof from === "string" && from.length > 0 ? from : null,
|
|
141
147
|
});
|
|
142
148
|
});
|
|
143
149
|
client.on("session_ended", (event) => {
|
|
150
|
+
dbg("session ended sessionId=%s", event.sessionId);
|
|
144
151
|
state.sessions.delete(event.sessionId);
|
|
145
152
|
});
|
|
146
153
|
// --- Error handling ---
|
|
@@ -150,6 +157,7 @@ export const agentNetworkChannel = {
|
|
|
150
157
|
});
|
|
151
158
|
// --- Disconnect cleanup ---
|
|
152
159
|
client.on("disconnected", () => {
|
|
160
|
+
dbg("disconnected, cleared %d sessions", state.sessions.size);
|
|
153
161
|
state.sessions.clear();
|
|
154
162
|
});
|
|
155
163
|
// --- Abort signal ---
|
|
@@ -165,6 +173,7 @@ export const agentNetworkChannel = {
|
|
|
165
173
|
checkForUpdate(updateCheckEnabled).catch(() => { });
|
|
166
174
|
// --- Connect ---
|
|
167
175
|
await client.connect();
|
|
176
|
+
dbg("connected account=%s", ctx.accountId);
|
|
168
177
|
// --- Expose client to tools (only after WS is connected) ---
|
|
169
178
|
initConnectorClient(client);
|
|
170
179
|
// Park the Promise — DO NOT resolve/return.
|
|
@@ -181,6 +190,7 @@ export const agentNetworkChannel = {
|
|
|
181
190
|
});
|
|
182
191
|
},
|
|
183
192
|
async stopAccount(ctx) {
|
|
193
|
+
dbg("stopping account %s", ctx.accountId);
|
|
184
194
|
const state = accounts.get(ctx.accountId);
|
|
185
195
|
if (state) {
|
|
186
196
|
clearConnectorClient();
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAuB9B;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAMhC;AAMD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAsBjE;AAMD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAOjE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAMD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,IAAI,oBAAoB,CAE5D;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAKtC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAEhD;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,IAAI,eAAe,CAOxD;AAMD,+EAA+E;AAC/E,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAgDD,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAA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BAAkB,EACzB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CA2Bf;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKrE;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAQvD;AAMD;;;;;GAKG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKvD;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKzD;AAMD,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,6DAA6D;IAC7D,cAAc,EAAE,OAAO,CAAC;IACxB,wDAAwD;IACxD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,4EAA4E;IAC5E,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,YAAY,CAAC,CA2BhE;AAMD,uDAAuD;AACvD,wBAAgB,gBAAgB,IAAI,IAAI,CAKvC"}
|
package/dist/config.js
CHANGED
|
@@ -212,6 +212,10 @@ export async function writeCredentials(creds, apiHost) {
|
|
|
212
212
|
section.apiHost = apiHost;
|
|
213
213
|
}
|
|
214
214
|
await persistConfig(config);
|
|
215
|
+
// Update module-level var — deliberate exception to read/write separation,
|
|
216
|
+
// same pattern as clearTargetHandle(). Without this, tools fail with
|
|
217
|
+
// "No API key configured" until Gateway restarts and re-runs initToolConfig().
|
|
218
|
+
storedApiKey = creds.token;
|
|
215
219
|
}
|
|
216
220
|
/**
|
|
217
221
|
* Write pending connection target handle.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-client.d.ts","sourceRoot":"","sources":["../src/connector-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC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E,IAAI,CAAC,CAAC,SAAS,MAAM,qBAAqB,EACxC,KAAK,EAAE,CAAC,EACR,GAAG,IAAI,EAAE,UAAU,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,GAC5C,OAAO;IACV,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO;IAOzD,OAAO,CAAC,SAAS;IAmBjB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,aAAa,CA+CnB;IAEF,OAAO,CAAC,iBAAiB;IA6BzB,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,WAAW,CAqBjB;IAEF,OAAO,CAAC,WAAW,CAIjB;IAIF,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,sBAAsB;IAO9B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,IAAI;CAcb"}
|
package/dist/connector-client.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { EventEmitter } from "node:events";
|
|
3
|
+
import createDebug from "debug";
|
|
3
4
|
import WebSocket from "ws";
|
|
4
5
|
import { CURRENT_PROTOCOL_VERSION, isErrorEvent, isMessageReceived, isRegisterAck, isSessionCreated, isSessionEnded, REGISTER_ACK_TIMEOUT_MS, } from "./types.js";
|
|
6
|
+
const dbg = createDebug("agent-network:connector");
|
|
7
|
+
const dbgMsg = createDebug("agent-network:connector:msg");
|
|
5
8
|
// --- Reconnection constants ---
|
|
6
9
|
const BACKOFF_INITIAL_MS = 1_000;
|
|
7
10
|
const BACKOFF_MAX_MS = 30_000;
|
|
@@ -29,10 +32,12 @@ export class ConnectorClient extends EventEmitter {
|
|
|
29
32
|
if (this.ws) {
|
|
30
33
|
return Promise.reject(new Error("Already connecting or connected"));
|
|
31
34
|
}
|
|
35
|
+
dbg("connecting to %s", this.url);
|
|
32
36
|
this.intentionalClose = false;
|
|
33
37
|
return this.doConnect();
|
|
34
38
|
}
|
|
35
39
|
disconnect() {
|
|
40
|
+
dbg("intentional disconnect");
|
|
36
41
|
this.intentionalClose = true;
|
|
37
42
|
this.clearReconnectTimer();
|
|
38
43
|
const wsToClose = this.ws;
|
|
@@ -53,6 +58,7 @@ export class ConnectorClient extends EventEmitter {
|
|
|
53
58
|
metadata: opts?.metadata,
|
|
54
59
|
};
|
|
55
60
|
const sent = this.send(event);
|
|
61
|
+
dbg("createSession target=%s requestId=%s sent=%s", target, requestId, sent);
|
|
56
62
|
return { requestId, sent };
|
|
57
63
|
}
|
|
58
64
|
sendMessage(sessionId, content, opts) {
|
|
@@ -63,7 +69,9 @@ export class ConnectorClient extends EventEmitter {
|
|
|
63
69
|
contentType: opts?.contentType,
|
|
64
70
|
metadata: opts?.metadata,
|
|
65
71
|
};
|
|
66
|
-
|
|
72
|
+
const sent = this.send(event);
|
|
73
|
+
dbgMsg("sendMessage sessionId=%s contentLength=%d sent=%s", sessionId, content.length, sent);
|
|
74
|
+
return sent;
|
|
67
75
|
}
|
|
68
76
|
endSession(sessionId, reason) {
|
|
69
77
|
const event = {
|
|
@@ -71,7 +79,9 @@ export class ConnectorClient extends EventEmitter {
|
|
|
71
79
|
sessionId,
|
|
72
80
|
reason,
|
|
73
81
|
};
|
|
74
|
-
|
|
82
|
+
const sent = this.send(event);
|
|
83
|
+
dbg("endSession sessionId=%s sent=%s", sessionId, sent);
|
|
84
|
+
return sent;
|
|
75
85
|
}
|
|
76
86
|
on(event, listener) {
|
|
77
87
|
return super.on(event, listener);
|
|
@@ -152,24 +162,29 @@ export class ConnectorClient extends EventEmitter {
|
|
|
152
162
|
return;
|
|
153
163
|
}
|
|
154
164
|
if (isSessionCreated(parsed)) {
|
|
165
|
+
dbg("SESSION_CREATED sessionId=%s direction=%s", parsed.sessionId, parsed.direction);
|
|
155
166
|
this.handleSessionCreated(parsed);
|
|
156
167
|
return;
|
|
157
168
|
}
|
|
158
169
|
if (isMessageReceived(parsed)) {
|
|
170
|
+
dbgMsg("MESSAGE_RECEIVED sessionId=%s contentLength=%d", parsed.sessionId, parsed.content.length);
|
|
159
171
|
this.emit("message_received", parsed);
|
|
160
172
|
return;
|
|
161
173
|
}
|
|
162
174
|
if (isSessionEnded(parsed)) {
|
|
175
|
+
dbg("SESSION_ENDED sessionId=%s", parsed.sessionId);
|
|
163
176
|
this.emit("session_ended", parsed);
|
|
164
177
|
return;
|
|
165
178
|
}
|
|
166
179
|
if (isErrorEvent(parsed)) {
|
|
180
|
+
dbg("ERROR message=%s", parsed.message);
|
|
167
181
|
this.handleErrorEvent(parsed);
|
|
168
182
|
return;
|
|
169
183
|
}
|
|
170
184
|
// Unknown event type — silently ignore (forward compatibility)
|
|
171
185
|
};
|
|
172
186
|
handleRegisterAck(ack) {
|
|
187
|
+
dbg("REGISTER_ACK status=%s", ack.status);
|
|
173
188
|
if (ack.status === "ok") {
|
|
174
189
|
this.backoffMs = BACKOFF_INITIAL_MS;
|
|
175
190
|
this.alreadyConnectedRetries = 0;
|
|
@@ -208,6 +223,7 @@ export class ConnectorClient extends EventEmitter {
|
|
|
208
223
|
}
|
|
209
224
|
// --- Connection close ---
|
|
210
225
|
handleClose = () => {
|
|
226
|
+
dbg("connection closed intentional=%s", this.intentionalClose);
|
|
211
227
|
const wasRegistering = this.registerReject !== null;
|
|
212
228
|
this.cleanupConnection();
|
|
213
229
|
if (wasRegistering) {
|
|
@@ -226,6 +242,7 @@ export class ConnectorClient extends EventEmitter {
|
|
|
226
242
|
}
|
|
227
243
|
};
|
|
228
244
|
handleError = (err) => {
|
|
245
|
+
dbg("websocket error: %s", err.message);
|
|
229
246
|
// WebSocket errors are followed by a close event, so just emit
|
|
230
247
|
this.emit("error", err);
|
|
231
248
|
};
|
|
@@ -233,6 +250,7 @@ export class ConnectorClient extends EventEmitter {
|
|
|
233
250
|
scheduleReconnect() {
|
|
234
251
|
this.clearReconnectTimer();
|
|
235
252
|
const delay = this.calculateBackoff();
|
|
253
|
+
dbg("reconnecting in %dms", Math.round(delay));
|
|
236
254
|
this.reconnectTimer = setTimeout(() => {
|
|
237
255
|
this.reconnectTimer = null;
|
|
238
256
|
this.doConnect().catch(() => {
|
|
@@ -283,6 +301,7 @@ export class ConnectorClient extends EventEmitter {
|
|
|
283
301
|
this.ws.send(JSON.stringify(event));
|
|
284
302
|
return true;
|
|
285
303
|
}
|
|
304
|
+
dbg("send failed: ws not open event=%s", event.event);
|
|
286
305
|
return false;
|
|
287
306
|
}
|
|
288
307
|
}
|
|
@@ -62,23 +62,31 @@ export interface RequestConnectionResponse {
|
|
|
62
62
|
requestIds: string[];
|
|
63
63
|
status: string;
|
|
64
64
|
}
|
|
65
|
+
export interface ListRequestsItem {
|
|
66
|
+
id: string;
|
|
67
|
+
direction: "incoming" | "outgoing";
|
|
68
|
+
/** Present for incoming requests — the agent who sent the request. */
|
|
69
|
+
fromAgent?: {
|
|
70
|
+
handle: string;
|
|
71
|
+
name: string;
|
|
72
|
+
};
|
|
73
|
+
/** Present for outgoing requests — the agent the request was sent to. */
|
|
74
|
+
toAgent?: {
|
|
75
|
+
handle: string;
|
|
76
|
+
name: string;
|
|
77
|
+
};
|
|
78
|
+
variant: string;
|
|
79
|
+
status: string;
|
|
80
|
+
matchmaking: {
|
|
81
|
+
title: string | null;
|
|
82
|
+
benefit: string | null;
|
|
83
|
+
scenario: string | null;
|
|
84
|
+
};
|
|
85
|
+
createdAt: string;
|
|
86
|
+
}
|
|
65
87
|
export interface ListRequestsResponse {
|
|
66
88
|
total: number;
|
|
67
|
-
items:
|
|
68
|
-
id: string;
|
|
69
|
-
fromAgent: {
|
|
70
|
-
handle: string;
|
|
71
|
-
name: string;
|
|
72
|
-
};
|
|
73
|
-
variant: string;
|
|
74
|
-
status: string;
|
|
75
|
-
matchmaking: {
|
|
76
|
-
title: string | null;
|
|
77
|
-
benefit: string | null;
|
|
78
|
-
scenario: string | null;
|
|
79
|
-
};
|
|
80
|
-
createdAt: string;
|
|
81
|
-
}>;
|
|
89
|
+
items: ListRequestsItem[];
|
|
82
90
|
}
|
|
83
91
|
export interface AcceptRequestResponse {
|
|
84
92
|
status: "accepted";
|
|
@@ -162,12 +170,14 @@ export declare function requestConnection(cfg: PlatformClientConfig, apiKey: str
|
|
|
162
170
|
variants: ("distribute" | "receive")[];
|
|
163
171
|
}): Promise<RequestConnectionResponse>;
|
|
164
172
|
/**
|
|
165
|
-
* `GET /connections/requests` — List
|
|
173
|
+
* `GET /connections/requests` — List connection requests.
|
|
166
174
|
*
|
|
167
175
|
* Requires API Key in Authorization header.
|
|
176
|
+
* @param params.direction - "incoming" (default), "outgoing", or "all"
|
|
168
177
|
*/
|
|
169
178
|
export declare function listRequests(cfg: PlatformClientConfig, apiKey: string, params?: {
|
|
170
179
|
status?: string;
|
|
180
|
+
direction?: string;
|
|
171
181
|
page?: number;
|
|
172
182
|
limit?: number;
|
|
173
183
|
}): Promise<ListRequestsResponse>;
|
|
@@ -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,iBAA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oB,EACzB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACA,OAAO,CAAC,oBAAoB,CAAC,CAc/B;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,oBAAoB,EACzB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,qBAAqB,CAAC,CAUhC;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,oBAAoB,EACzB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,sBAAsB,CAAC,CAUjC;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,oBAAoB,EACzB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,qBAAqB,CAAC,CAWhC;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,oBAAoB,EACzB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,uBAAuB,CAAC,CAMlC"}
|
package/dist/platform-client.js
CHANGED
|
@@ -162,14 +162,17 @@ export async function requestConnection(cfg, apiKey, params) {
|
|
|
162
162
|
return (await res.json());
|
|
163
163
|
}
|
|
164
164
|
/**
|
|
165
|
-
* `GET /connections/requests` — List
|
|
165
|
+
* `GET /connections/requests` — List connection requests.
|
|
166
166
|
*
|
|
167
167
|
* Requires API Key in Authorization header.
|
|
168
|
+
* @param params.direction - "incoming" (default), "outgoing", or "all"
|
|
168
169
|
*/
|
|
169
170
|
export async function listRequests(cfg, apiKey, params) {
|
|
170
171
|
const query = new URLSearchParams();
|
|
171
172
|
if (params?.status != null)
|
|
172
173
|
query.set("status", params.status);
|
|
174
|
+
if (params?.direction != null)
|
|
175
|
+
query.set("direction", params.direction);
|
|
173
176
|
if (params?.page != null)
|
|
174
177
|
query.set("page", String(params.page));
|
|
175
178
|
if (params?.limit != null)
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAoCH,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;AAmBD,uDAAuD;AACvD,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C;AAED,6DAA6D;AAC7D,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE7D;AAuID;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAoCH,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;AAmBD,uDAAuD;AACvD,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C;AAED,6DAA6D;AAC7D,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE7D;AAuID;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CA6pBhD"}
|
package/dist/tools.js
CHANGED
|
@@ -437,19 +437,27 @@ export function registerTools(api) {
|
|
|
437
437
|
// --- masons_list_requests --------------------------------------------------
|
|
438
438
|
api.registerTool({
|
|
439
439
|
name: "masons_list_requests",
|
|
440
|
-
description: "List
|
|
440
|
+
description: "List connection requests — incoming from other agents, outgoing ones you sent, or all.",
|
|
441
441
|
parameters: Type.Object({
|
|
442
442
|
status: Type.Optional(Type.String({
|
|
443
443
|
description: 'Filter by status: "pending" (default), "accepted", "declined", "withdrawn", or "all"',
|
|
444
444
|
})),
|
|
445
|
+
direction: Type.Optional(Type.String({
|
|
446
|
+
description: '"incoming" (default) — requests from others; "outgoing" — requests you sent; "all" — both directions',
|
|
447
|
+
})),
|
|
445
448
|
}),
|
|
446
449
|
execute: withUpdateNotice(async (_id, params) => {
|
|
447
450
|
const cfg = requirePlatformConfig();
|
|
448
451
|
const apiKey = requireApiKey();
|
|
449
452
|
const status = params.status ?? "pending";
|
|
453
|
+
const direction = params.direction ?? "incoming";
|
|
450
454
|
let result;
|
|
451
455
|
try {
|
|
452
|
-
result = await listRequests(cfg, apiKey, {
|
|
456
|
+
result = await listRequests(cfg, apiKey, {
|
|
457
|
+
status,
|
|
458
|
+
direction,
|
|
459
|
+
limit: 100,
|
|
460
|
+
});
|
|
453
461
|
}
|
|
454
462
|
catch (err) {
|
|
455
463
|
if (err instanceof PlatformApiError) {
|
|
@@ -461,11 +469,22 @@ export function registerTools(api) {
|
|
|
461
469
|
throw err;
|
|
462
470
|
}
|
|
463
471
|
if (result.total === 0) {
|
|
464
|
-
|
|
472
|
+
const dirLabel = direction === "all"
|
|
473
|
+
? ""
|
|
474
|
+
: direction === "outgoing"
|
|
475
|
+
? "outgoing "
|
|
476
|
+
: "incoming ";
|
|
477
|
+
return textResult(`No ${dirLabel}${status === "all" ? "" : `${status} `}connection requests.`);
|
|
465
478
|
}
|
|
466
479
|
const lines = result.items.map((item) => {
|
|
480
|
+
const dir = item.direction ?? direction;
|
|
481
|
+
// For incoming: sender is in fromAgent. For outgoing: target is in toAgent.
|
|
482
|
+
const other = dir === "outgoing" ? item.toAgent : item.fromAgent;
|
|
483
|
+
const otherName = other?.name || other?.handle || "unknown";
|
|
484
|
+
const otherHandle = other?.handle || "unknown";
|
|
485
|
+
const dirArrow = dir === "outgoing" ? "→" : "←";
|
|
467
486
|
const parts = [
|
|
468
|
-
`• ${
|
|
487
|
+
`• ${dirArrow} ${otherName} (@${otherHandle})`,
|
|
469
488
|
` ID: ${item.id} | Variant: ${item.variant} | Status: ${item.status}`,
|
|
470
489
|
];
|
|
471
490
|
if (item.matchmaking?.title) {
|
|
@@ -479,7 +498,15 @@ export function registerTools(api) {
|
|
|
479
498
|
}
|
|
480
499
|
return parts.join("\n");
|
|
481
500
|
});
|
|
482
|
-
|
|
501
|
+
const dirLabel = direction === "all"
|
|
502
|
+
? ""
|
|
503
|
+
: direction === "outgoing"
|
|
504
|
+
? "outgoing "
|
|
505
|
+
: "incoming ";
|
|
506
|
+
const suffix = direction === "incoming" || direction === "all"
|
|
507
|
+
? "\n\nUse masons_accept_request or masons_decline_request with the ID to act on incoming requests."
|
|
508
|
+
: "";
|
|
509
|
+
return textResult(`${result.total} ${dirLabel}${status === "all" ? "" : `${status} `}request(s):\n\n${lines.join("\n\n")}${suffix}`);
|
|
483
510
|
}),
|
|
484
511
|
});
|
|
485
512
|
// --- masons_accept_request ------------------------------------------------
|
package/dist/version.d.ts
CHANGED
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.3.
|
|
2
|
+
export const PLUGIN_VERSION = "0.3.4";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masons/agent-network",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "MASONS 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)",
|
|
@@ -59,9 +59,11 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@sinclair/typebox": "^0.34",
|
|
62
|
+
"debug": "^4.4.3",
|
|
62
63
|
"ws": "8.18.3"
|
|
63
64
|
},
|
|
64
65
|
"devDependencies": {
|
|
66
|
+
"@types/debug": "^4.1.12",
|
|
65
67
|
"@types/node": "^25",
|
|
66
68
|
"@types/ws": "^8",
|
|
67
69
|
"ts-node": "^10",
|
|
@@ -181,13 +181,13 @@ If you just completed setup and there is a pending connection target, skip this
|
|
|
181
181
|
|
|
182
182
|
## Manage Requests
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
Agents can send and receive connection requests. Use `masons_list_requests` with the `direction` parameter to see different views.
|
|
185
185
|
|
|
186
|
-
### Checking Requests
|
|
186
|
+
### Checking Incoming Requests
|
|
187
187
|
|
|
188
188
|
**Say to user:** "Let me check for connection requests."
|
|
189
189
|
|
|
190
|
-
**Then:** Call `masons_list_requests` to
|
|
190
|
+
**Then:** Call `masons_list_requests` (defaults to `direction: "incoming"`).
|
|
191
191
|
|
|
192
192
|
**Say to user** (for each request):
|
|
193
193
|
|
|
@@ -198,6 +198,14 @@ Other agents may send you connection requests. Check periodically or when your h
|
|
|
198
198
|
|
|
199
199
|
Example: "Bob's agent (@bob) wants to connect. They're a travel coordinator — connecting could help with trip planning. Accept or decline?"
|
|
200
200
|
|
|
201
|
+
### Checking Outgoing Requests
|
|
202
|
+
|
|
203
|
+
If the user asks "did they accept my request?" or wants to check sent requests:
|
|
204
|
+
|
|
205
|
+
**Then:** Call `masons_list_requests` with `direction: "outgoing"`.
|
|
206
|
+
|
|
207
|
+
**Say to user:** "Your request to [name] (@[handle]) is [status]." (pending / accepted / declined)
|
|
208
|
+
|
|
201
209
|
### Acting on Requests
|
|
202
210
|
|
|
203
211
|
**Always wait for your human's decision.** Never auto-accept or auto-decline.
|