@masons/agent-network 0.6.10 → 0.6.12
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 +26 -9
- package/dist/conversation-manager.d.ts +9 -0
- package/dist/conversation-manager.d.ts.map +1 -1
- package/dist/conversation-manager.js +41 -8
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +4 -2
- package/dist/trace-metadata.d.ts +6 -1
- package/dist/trace-metadata.d.ts.map +1 -1
- package/dist/trace-metadata.js +6 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +13 -12
- package/skills/agent-network/SKILL.md +2 -0
package/dist/channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EAEd,MAAM,kCAAkC,CAAC;AAa1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAyC9D,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAEvD;AAOD,wBAAgB,2BAA2B,IAAI,OAAO,CAIrD;AAGD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE/D;AAaD,iBAAS,iCAAiC,CACxC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6BzB;AAED,eAAO,MAAM,4CAA4C,0CACtB,CAAC;
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EAEd,MAAM,kCAAkC,CAAC;AAa1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAyC9D,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAEvD;AAOD,wBAAgB,2BAA2B,IAAI,OAAO,CAIrD;AAGD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE/D;AAaD,iBAAS,iCAAiC,CACxC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6BzB;AAED,eAAO,MAAM,4CAA4C,0CACtB,CAAC;AAodpC,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,mBAAmB,CAqOlE,CAAC"}
|
package/dist/channel.js
CHANGED
|
@@ -129,7 +129,7 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
129
129
|
const inboundCorrelationId = typeof metadata.correlation_id === "string"
|
|
130
130
|
? metadata.correlation_id
|
|
131
131
|
: undefined;
|
|
132
|
-
const inboundMessageId = typeof
|
|
132
|
+
const inboundMessageId = typeof event.messageId === "string" ? event.messageId : undefined;
|
|
133
133
|
const nodeRef = tryProjectNodeRef(metadata);
|
|
134
134
|
if (nodeRef) {
|
|
135
135
|
setCurrentTurnIsOwner(false);
|
|
@@ -183,6 +183,13 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
183
183
|
}
|
|
184
184
|
const senderId = fromAddress;
|
|
185
185
|
const senderName = contact;
|
|
186
|
+
conversationManager.recordInboundEnvelope(fromAddress, {
|
|
187
|
+
traceparent: typeof metadata.traceparent === "string"
|
|
188
|
+
? metadata.traceparent
|
|
189
|
+
: undefined,
|
|
190
|
+
correlationId: inboundCorrelationId,
|
|
191
|
+
messageId: inboundMessageId,
|
|
192
|
+
});
|
|
186
193
|
try {
|
|
187
194
|
const route = await runtime.channel.routing.resolveAgentRoute({
|
|
188
195
|
cfg: ctx.cfg,
|
|
@@ -224,6 +231,8 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
224
231
|
},
|
|
225
232
|
});
|
|
226
233
|
client.sendTyping(fromAddress, true);
|
|
234
|
+
let replyDelivered = false;
|
|
235
|
+
let suppressedBlocks = 0;
|
|
227
236
|
try {
|
|
228
237
|
await runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
229
238
|
ctx: msgCtx,
|
|
@@ -234,18 +243,20 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
234
243
|
if (!text)
|
|
235
244
|
return;
|
|
236
245
|
if (!conversationManager.hasConversation(senderId)) {
|
|
237
|
-
|
|
246
|
+
suppressedBlocks++;
|
|
238
247
|
return;
|
|
239
248
|
}
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
249
|
+
const replyTrace = createReplyTraceMetadata(metadata, {
|
|
250
|
+
correlationId: inboundCorrelationId,
|
|
251
|
+
messageId: inboundMessageId,
|
|
252
|
+
});
|
|
253
|
+
const deliverResult = await conversationManager.send(senderId, text, replyTrace.metadata);
|
|
254
|
+
if (deliverResult.status === "sent") {
|
|
255
|
+
replyDelivered = true;
|
|
243
256
|
}
|
|
244
|
-
|
|
245
|
-
|
|
257
|
+
else {
|
|
258
|
+
console.warn(`[agent-network:${ctx.accountId}] reply send FAILED to=${senderId} code=${deliverResult.errorCode ?? "(none)"} error=${deliverResult.error ?? "(none)"}`);
|
|
246
259
|
}
|
|
247
|
-
const replyTrace = createReplyTraceMetadata(metadata, replyMetadata);
|
|
248
|
-
const deliverResult = await conversationManager.send(senderId, text, replyTrace.metadata);
|
|
249
260
|
dbg("deliver reply senderId=%s status=%s contentLength=%d traceId=%s originalTraceId=%s spanName=send", senderId, deliverResult.status, text.length, replyTrace.traceId, replyTrace.originalTraceId ?? "(absent)");
|
|
250
261
|
},
|
|
251
262
|
onError: (err) => {
|
|
@@ -253,6 +264,12 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
253
264
|
},
|
|
254
265
|
},
|
|
255
266
|
});
|
|
267
|
+
if (suppressedBlocks > 0) {
|
|
268
|
+
console.warn(`[agent-network:${ctx.accountId}] reply suppressed (conversation ended) from=${senderId} blocks=${suppressedBlocks}`);
|
|
269
|
+
}
|
|
270
|
+
else if (!replyDelivered) {
|
|
271
|
+
console.log(`[agent-network:${ctx.accountId}] dispatch completed without in-turn reply text from=${senderId} (tool-path reply or silence)`);
|
|
272
|
+
}
|
|
256
273
|
}
|
|
257
274
|
finally {
|
|
258
275
|
client.sendTyping(fromAddress, false);
|
|
@@ -10,6 +10,7 @@ export interface ConversationEntry {
|
|
|
10
10
|
lastMessageAt: number;
|
|
11
11
|
initiatedBy: "local" | "remote";
|
|
12
12
|
ended?: boolean;
|
|
13
|
+
inboundEnvelope?: InboundEnvelope;
|
|
13
14
|
}
|
|
14
15
|
export interface ConversationSummary {
|
|
15
16
|
contact: string;
|
|
@@ -18,6 +19,13 @@ export interface ConversationSummary {
|
|
|
18
19
|
lastMessageAt: number;
|
|
19
20
|
initiatedBy: "local" | "remote";
|
|
20
21
|
}
|
|
22
|
+
export interface InboundEnvelope {
|
|
23
|
+
traceparent?: string;
|
|
24
|
+
correlationId?: string;
|
|
25
|
+
messageId?: string;
|
|
26
|
+
receivedAt: number;
|
|
27
|
+
}
|
|
28
|
+
export declare const REPLY_CORRELATION_MAX_AGE_MS: number;
|
|
21
29
|
export declare class ConversationManager {
|
|
22
30
|
private readonly client;
|
|
23
31
|
private readonly mstpAuthority;
|
|
@@ -25,6 +33,7 @@ export declare class ConversationManager {
|
|
|
25
33
|
constructor(client: ConnectorClient, mstpAuthority: string);
|
|
26
34
|
send(contact: string, content: string, metadata?: Record<string, unknown>): Promise<SendResult>;
|
|
27
35
|
registerInbound(contact: string, address: string): void;
|
|
36
|
+
recordInboundEnvelope(address: string, envelope: Omit<InboundEnvelope, "receivedAt">): void;
|
|
28
37
|
getContactByAddress(address: string): string | undefined;
|
|
29
38
|
listConversations(): ConversationSummary[];
|
|
30
39
|
hasConversation(contact: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-manager.d.ts","sourceRoot":"","sources":["../src/conversation-manager.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"conversation-manager.d.ts","sourceRoot":"","sources":["../src/conversation-manager.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,uBAAuB,CAAC;AAa7E,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,GAAG,QAAQ,CAAC;IAchC,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,GAAG,QAAQ,CAAC;CACjC;AAuBD,MAAM,WAAW,eAAe;IAE9B,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AASD,eAAO,MAAM,4BAA4B,QAAc,CAAC;AA4BxD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAGvC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAwC;gBAE1D,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM;IAuBpD,IAAI,CACR,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,UAAU,CAAC;IAmGtB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAYvD,qBAAqB,CACnB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,GAC5C,IAAI;IAmBP,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAkBxD,iBAAiB,IAAI,mBAAmB,EAAE;IAwB1C,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAiBzC,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAyBzC,wBAAwB,IAAI,IAAI;IAkChC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAyBvC,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAQtC,OAAO,CAAC,uBAAuB;IA0B/B,gBAAgB,IAAI,IAAI;CAGzB"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import createDebug from "debug";
|
|
2
2
|
import { ConnectorError } from "./connector-client.js";
|
|
3
3
|
import { extractHandleFromAddress } from "./handle-utils.js";
|
|
4
|
-
import { ensureTraceMetadata } from "./trace-metadata.js";
|
|
4
|
+
import { createReplyTraceMetadata, ensureTraceMetadata, } from "./trace-metadata.js";
|
|
5
5
|
const dbg = createDebug("agent-network:conversation-manager");
|
|
6
|
+
export const REPLY_CORRELATION_MAX_AGE_MS = 10 * 60_000;
|
|
6
7
|
const ERROR_MESSAGES = {
|
|
7
8
|
ADDRESS_NOT_FOUND: "Cannot find agent '{to}'. Check the handle.",
|
|
8
9
|
ACCESS_DENIED: "No connection to '{to}'. Send a connection request first.",
|
|
@@ -27,17 +28,40 @@ export class ConversationManager {
|
|
|
27
28
|
}
|
|
28
29
|
async send(contact, content, metadata) {
|
|
29
30
|
const address = this.resolveAddress(contact);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
let wireMetadata;
|
|
32
|
+
let sendTraceId;
|
|
33
|
+
let envelope = metadata === undefined
|
|
34
|
+
? this.conversations.get(address)?.inboundEnvelope
|
|
35
|
+
: undefined;
|
|
36
|
+
if (envelope &&
|
|
37
|
+
Date.now() - envelope.receivedAt > REPLY_CORRELATION_MAX_AGE_MS) {
|
|
38
|
+
dbg("inbound envelope stale, sending uncorrelated contact=%s ageMs=%d", contact, Date.now() - envelope.receivedAt);
|
|
39
|
+
envelope = undefined;
|
|
40
|
+
}
|
|
41
|
+
if (envelope) {
|
|
42
|
+
const replyTrace = createReplyTraceMetadata(envelope, {
|
|
43
|
+
correlationId: envelope.correlationId,
|
|
44
|
+
messageId: envelope.messageId,
|
|
45
|
+
});
|
|
46
|
+
wireMetadata = replyTrace.metadata;
|
|
47
|
+
sendTraceId = replyTrace.traceId;
|
|
48
|
+
dbg("auto reply-correlation contact=%s in_reply_to=%s correlation_id=%s originalTraceId=%s spanName=send", contact, envelope.messageId ?? "(absent)", envelope.correlationId ?? "(absent)", replyTrace.originalTraceId ?? "(absent)");
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const trace = ensureTraceMetadata(metadata);
|
|
52
|
+
if (trace.degraded) {
|
|
53
|
+
dbg("trace context degraded contact=%s traceId=%s reason=%s spanName=send", contact, trace.traceId, trace.reason);
|
|
54
|
+
if (trace.reason === "invalid") {
|
|
55
|
+
console.warn(`[agent-network:conversation-manager] invalid traceparent contact=${contact} traceId=${trace.traceId} spanName=send`);
|
|
56
|
+
}
|
|
35
57
|
}
|
|
58
|
+
wireMetadata = trace.metadata;
|
|
59
|
+
sendTraceId = trace.traceId;
|
|
36
60
|
}
|
|
37
61
|
try {
|
|
38
|
-
const ack = await this.client.send(address, content, "text",
|
|
62
|
+
const ack = await this.client.send(address, content, "text", wireMetadata);
|
|
39
63
|
this.ensureConversationEntry(this.extractHandle(address), address, "local");
|
|
40
|
-
dbg("send contact=%s address=%s status=%s traceId=%s spanName=send", contact, address, ack.status,
|
|
64
|
+
dbg("send contact=%s address=%s status=%s traceId=%s spanName=send", contact, address, ack.status, sendTraceId);
|
|
41
65
|
return { status: "sent" };
|
|
42
66
|
}
|
|
43
67
|
catch (err) {
|
|
@@ -55,6 +79,15 @@ export class ConversationManager {
|
|
|
55
79
|
this.ensureConversationEntry(contact, address, "remote");
|
|
56
80
|
dbg("registerInbound contact=%s address=%s", contact, address);
|
|
57
81
|
}
|
|
82
|
+
recordInboundEnvelope(address, envelope) {
|
|
83
|
+
const entry = this.conversations.get(address);
|
|
84
|
+
if (!entry) {
|
|
85
|
+
dbg("recordInboundEnvelope no entry, skipped address=%s", address);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
entry.inboundEnvelope = { ...envelope, receivedAt: Date.now() };
|
|
89
|
+
dbg("recordInboundEnvelope address=%s messageId=%s correlationId=%s", address, envelope.messageId ?? "(absent)", envelope.correlationId ?? "(absent)");
|
|
90
|
+
}
|
|
58
91
|
getContactByAddress(address) {
|
|
59
92
|
const entry = this.conversations.get(address);
|
|
60
93
|
if (entry)
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAuEA,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,WAAW;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,KAAK,WAAW,GAAG,CAAC,GAAG,EAAE,WAAW,KAAK,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;AAE3E,UAAU,OAAO;IACf,YAAY,CACV,IAAI,EAAE,cAAc,GAAG,WAAW,EAWlC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAC7D,IAAI,CAAC;CACT;AAoDD,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C;AAwSD,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAuEA,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,WAAW;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,KAAK,WAAW,GAAG,CAAC,GAAG,EAAE,WAAW,KAAK,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;AAE3E,UAAU,OAAO;IACf,YAAY,CACV,IAAI,EAAE,cAAc,GAAG,WAAW,EAWlC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAC7D,IAAI,CAAC;CACT;AAoDD,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C;AAwSD,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAs2BhD"}
|
package/dist/tools.js
CHANGED
|
@@ -566,7 +566,8 @@ export function registerTools(api) {
|
|
|
566
566
|
const displayName = node.displayName || node.handle || "(unnamed)";
|
|
567
567
|
const address = node.mstpAddress;
|
|
568
568
|
const kindLabel = formatKindLabel(node?.kind);
|
|
569
|
-
|
|
569
|
+
const handlePart = node.handle ? `@${node.handle} — ` : "";
|
|
570
|
+
return `${i + 1}. ${kindLabel}${displayName} (${handlePart}${address})`;
|
|
570
571
|
});
|
|
571
572
|
return textResult(`${result.total} connection(s):\n\n${lines.join("\n")}\n\nUse masons_send_message with a handle or address to send a message.`);
|
|
572
573
|
}),
|
|
@@ -576,7 +577,7 @@ export function registerTools(api) {
|
|
|
576
577
|
description: "Send a message to a remote agent on the agent network. This is agent-to-agent communication — separate from your owner's conversation. Sessions are managed automatically — just provide the contact handle or address.",
|
|
577
578
|
parameters: Type.Object({
|
|
578
579
|
to: Type.String({
|
|
579
|
-
description: "Handle
|
|
580
|
+
description: "Handle of the agent to message, e.g. alice — resolved against your connection list, which is the reliable path. A full network address is accepted only when copied verbatim from masons_list_connections; do not assemble one from a handle yourself.",
|
|
580
581
|
}),
|
|
581
582
|
content: Type.String({
|
|
582
583
|
description: "Message content to send",
|
|
@@ -592,6 +593,7 @@ export function registerTools(api) {
|
|
|
592
593
|
sentMessageBuffer.record(handle, content);
|
|
593
594
|
return textResult("Message sent.");
|
|
594
595
|
}
|
|
596
|
+
console.warn(`[agent-network:tools] masons_send_message FAILED to=${to} code=${result.errorCode ?? "(none)"} error=${result.error ?? "(none)"}`);
|
|
595
597
|
return textResult(result.error ??
|
|
596
598
|
"Failed to send message. The network connection may be temporarily unavailable. Try again in a moment.");
|
|
597
599
|
}),
|
package/dist/trace-metadata.d.ts
CHANGED
|
@@ -11,5 +11,10 @@ export interface ReplyTraceMetadataResult {
|
|
|
11
11
|
traceId: string;
|
|
12
12
|
originalTraceId?: string;
|
|
13
13
|
}
|
|
14
|
-
export declare function createReplyTraceMetadata(
|
|
14
|
+
export declare function createReplyTraceMetadata(inbound: {
|
|
15
|
+
traceparent?: unknown;
|
|
16
|
+
}, reply?: {
|
|
17
|
+
correlationId?: string;
|
|
18
|
+
messageId?: string;
|
|
19
|
+
}): ReplyTraceMetadataResult;
|
|
15
20
|
//# sourceMappingURL=trace-metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace-metadata.d.ts","sourceRoot":"","sources":["../src/trace-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAUD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC5C,mBAAmB,CAWrB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"trace-metadata.d.ts","sourceRoot":"","sources":["../src/trace-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAUD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC5C,mBAAmB,CAWrB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AASD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,EAClC,KAAK,GAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACzD,wBAAwB,CAqB1B"}
|
package/dist/trace-metadata.js
CHANGED
|
@@ -16,17 +16,19 @@ export function ensureTraceMetadata(metadata) {
|
|
|
16
16
|
reason: ensured.reason,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
export function createReplyTraceMetadata(
|
|
19
|
+
export function createReplyTraceMetadata(inbound, reply = {}) {
|
|
20
20
|
const traceparent = mintTraceparent();
|
|
21
21
|
const traceId = extractTraceId(traceparent);
|
|
22
22
|
if (traceId === null) {
|
|
23
23
|
throw new Error("mintTraceparent returned an invalid traceparent");
|
|
24
24
|
}
|
|
25
|
-
const originalTraceId = extractTraceId(
|
|
26
|
-
const { originalTraceId: _ignoredOriginalTraceId, ...safeReplyMetadata } = replyMetadata;
|
|
25
|
+
const originalTraceId = extractTraceId(typeof inbound.traceparent === "string" ? inbound.traceparent : undefined);
|
|
27
26
|
return {
|
|
28
27
|
metadata: {
|
|
29
|
-
...
|
|
28
|
+
...(reply.correlationId !== undefined && {
|
|
29
|
+
correlation_id: reply.correlationId,
|
|
30
|
+
}),
|
|
31
|
+
...(reply.messageId !== undefined && { in_reply_to: reply.messageId }),
|
|
30
32
|
traceparent,
|
|
31
33
|
...(originalTraceId !== null && { originalTraceId }),
|
|
32
34
|
},
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PLUGIN_VERSION = "0.6.
|
|
1
|
+
export declare const PLUGIN_VERSION = "0.6.12";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PLUGIN_VERSION = "0.6.
|
|
1
|
+
export const PLUGIN_VERSION = "0.6.12";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masons/agent-network",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12",
|
|
4
4
|
"description": "MASONS Agent Network — OpenClaw channel plugin for connecting agent runtimes to the Agent Network over MSTP.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "MASONS.ai <hello@masons.ai> (https://masons.ai)",
|
|
@@ -21,6 +21,16 @@
|
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"dev": "tsc --watch",
|
|
27
|
+
"test": "node ../../scripts/sync-vendored-trace-context.mjs && tsc -p test/tsconfig.json && node --test --loader ts-node/esm 'test/**/*.test.ts'",
|
|
28
|
+
"biome:check": "biome check .",
|
|
29
|
+
"biome:fix": "biome check . --write",
|
|
30
|
+
"biome:ci": "biome ci .",
|
|
31
|
+
"prepublishOnly": "node ../../scripts/sync-vendored-trace-context.mjs && bash scripts/check-version.sh && npm run build && npm run test",
|
|
32
|
+
"release": "pnpm publish --access public"
|
|
33
|
+
},
|
|
24
34
|
"files": [
|
|
25
35
|
"dist/",
|
|
26
36
|
"openclaw.plugin.json",
|
|
@@ -86,15 +96,6 @@
|
|
|
86
96
|
"@types/ws": "^8",
|
|
87
97
|
"openclaw": "2026.6.11",
|
|
88
98
|
"ts-node": "^10",
|
|
89
|
-
"typescript": "
|
|
90
|
-
},
|
|
91
|
-
"scripts": {
|
|
92
|
-
"build": "tsc",
|
|
93
|
-
"dev": "tsc --watch",
|
|
94
|
-
"test": "node ../../scripts/sync-vendored-trace-context.mjs && tsc -p test/tsconfig.json && node --test --loader ts-node/esm 'test/**/*.test.ts'",
|
|
95
|
-
"biome:check": "biome check .",
|
|
96
|
-
"biome:fix": "biome check . --write",
|
|
97
|
-
"biome:ci": "biome ci .",
|
|
98
|
-
"release": "pnpm publish --access public"
|
|
99
|
+
"typescript": "catalog:"
|
|
99
100
|
}
|
|
100
|
-
}
|
|
101
|
+
}
|
|
@@ -294,6 +294,8 @@ Your context will show your **active interactions** — who you're interacting w
|
|
|
294
294
|
- To report to your owner: `masons_note_for_owner(content, from?)`
|
|
295
295
|
- To mark an explicitly stopped interaction closed for this turn: `masons_end_conversation(contact)` (rare compatibility tool)
|
|
296
296
|
|
|
297
|
+
**Addressing rule:** pass the bare handle (as listed by `masons_list_connections`), or an address copied verbatim from your connections or from the incoming message. **Never assemble an `mstps://` address yourself** — a handle does not tell you which host the agent lives on, so a hand-built address can be well-formed and still name the wrong host. Handles resolve through your own connection list, which knows the real address.
|
|
298
|
+
|
|
297
299
|
`masons_end_conversation` is not routine cleanup. The Connector owns endpoint lifecycle. Use the tool at most once for a direct stop/close instruction, and never call it in response to tail acknowledgements such as "Done", "Goodbye", "OK", or "收到".
|
|
298
300
|
|
|
299
301
|
### When you contact another agent (you initiate)
|