@masons/agent-network 0.6.5 → 0.6.7
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 +7 -0
- package/dist/handoff.d.ts.map +1 -1
- package/dist/handoff.js +14 -6
- package/dist/message-log.d.ts +18 -0
- package/dist/message-log.d.ts.map +1 -0
- package/dist/message-log.js +52 -0
- package/dist/platform-client.d.ts +1 -0
- package/dist/platform-client.d.ts.map +1 -1
- package/dist/platform-client.js +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +3 -1
- package/dist/runtime-endpoint-client.d.ts.map +1 -1
- package/dist/runtime-endpoint-client.js +9 -9
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +56 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
- 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":"AAcA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AA0C9D,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAEvD;AAOD,wBAAgB,2BAA2B,IAAI,OAAO,CAIrD;AAGD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE/D;AAUD,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,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O,CAAC,GAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6BzB;AAED,eAAO,MAAM,4CAA4C,0CACtB,CAAC;AAEpC,UAAU,qBAAqB,CAAC,CAAC,GAAG,OAAO;IACzC,YAAY,CAAC,CAAC,GAAG,EAAE,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;AAscD,eAAO,MAAM,mBAAmB,EAAE,yBA+NjC,CAAC"}
|
package/dist/channel.js
CHANGED
|
@@ -6,6 +6,7 @@ import { resolveMstpAuthority } from "./connector-url-boundary.js";
|
|
|
6
6
|
import { ConversationManager } from "./conversation-manager.js";
|
|
7
7
|
import { clearEnvironmentContext } from "./environment-context.js";
|
|
8
8
|
import { extractHandleFromAddress } from "./handle-utils.js";
|
|
9
|
+
import { messageLog } from "./message-log.js";
|
|
9
10
|
import { clearOwnerState, isOwnerAddress, markOwnerAddress, setCurrentTurnIsOwner, setCurrentTurnOwnerSignal, } from "./owner-session-state.js";
|
|
10
11
|
import { createReplyTraceMetadata, ensureTraceMetadata, } from "./trace-metadata.js";
|
|
11
12
|
import { setCurrentTurnSender } from "./turn-context.js";
|
|
@@ -209,6 +210,9 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
209
210
|
OriginatingChannel: "agent-network",
|
|
210
211
|
OriginatingTo: senderId,
|
|
211
212
|
});
|
|
213
|
+
if (metadata.is_owner !== true) {
|
|
214
|
+
messageLog.record(extractHandleFromAddress(fromAddress), "inbound", event.content);
|
|
215
|
+
}
|
|
212
216
|
const storePath = runtime.channel.session.resolveStorePath(undefined, {
|
|
213
217
|
agentId: route.agentId,
|
|
214
218
|
});
|
|
@@ -246,6 +250,9 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
246
250
|
}
|
|
247
251
|
const replyTrace = createReplyTraceMetadata(metadata, replyMetadata);
|
|
248
252
|
const deliverResult = await conversationManager.send(senderId, text, replyTrace.metadata);
|
|
253
|
+
if (deliverResult.status === "sent" && metadata.is_owner !== true) {
|
|
254
|
+
messageLog.record(extractHandleFromAddress(fromAddress), "outbound", text);
|
|
255
|
+
}
|
|
249
256
|
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
257
|
},
|
|
251
258
|
onError: (err) => {
|
package/dist/handoff.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AAerB,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAiBhE,eAAO,MAAM,kBAAkB,QAAgB,CAAC;AAKhD,qBAAa,cAAe,SAAQ,KAAK;CAAG;AAY5C,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG,eAAe,CAAC;AAEtE,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1D;AAQD,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAOhB,UAAU,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,oBAAoB,CAAC;CACxC;AAMD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,oBAAoB,CAAC,CAyD/B;AAKD,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CAmC9B"}
|
package/dist/handoff.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createDecipheriv, constants as cryptoConstants, generateKeyPairSync, privateDecrypt, } from "node:crypto";
|
|
2
|
+
import { apiFetch, PlatformNetworkError } from "./platform-client.js";
|
|
2
3
|
export const DEFAULT_IDP_BASE_URL = "https://preview.masons.ai";
|
|
3
4
|
const HANDLE_REGEX = /^[a-z][a-z0-9_-]{2,14}$/;
|
|
4
5
|
export const HANDOFF_TIMEOUT_MS = 5 * 60 * 1000;
|
|
@@ -15,7 +16,7 @@ export async function beginBridgeHandoff(options) {
|
|
|
15
16
|
const apiBase = normalizeHttpBase(options.apiHost);
|
|
16
17
|
let sessionId;
|
|
17
18
|
try {
|
|
18
|
-
const initRes = await
|
|
19
|
+
const initRes = await apiFetch(`${apiBase}/v1/cli-handoff/init`, {
|
|
19
20
|
method: "POST",
|
|
20
21
|
headers: { "content-type": "application/json" },
|
|
21
22
|
body: JSON.stringify({
|
|
@@ -83,14 +84,19 @@ export async function completeBridgeHandoff(session) {
|
|
|
83
84
|
}
|
|
84
85
|
async function pollForCompletion(apiBase, sessionId) {
|
|
85
86
|
const start = Date.now();
|
|
87
|
+
let lastNetworkError;
|
|
86
88
|
while (Date.now() - start < HANDOFF_TIMEOUT_MS) {
|
|
87
89
|
let res;
|
|
88
90
|
try {
|
|
89
|
-
res = await
|
|
91
|
+
res = await apiFetch(`${apiBase}/v1/cli-handoff/${encodeURIComponent(sessionId)}/poll`, { method: "GET" });
|
|
90
92
|
}
|
|
91
|
-
catch (
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
catch (err) {
|
|
94
|
+
if (err instanceof PlatformNetworkError) {
|
|
95
|
+
lastNetworkError = err;
|
|
96
|
+
await sleep(HANDOFF_POLL_INTERVAL_MS);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
throw err;
|
|
94
100
|
}
|
|
95
101
|
if (res.status === 404) {
|
|
96
102
|
throw new SetupFlowError("Handoff session expired before the runtime key was delivered. Re-run setup.");
|
|
@@ -105,7 +111,9 @@ async function pollForCompletion(apiBase, sessionId) {
|
|
|
105
111
|
}
|
|
106
112
|
await sleep(HANDOFF_POLL_INTERVAL_MS);
|
|
107
113
|
}
|
|
108
|
-
throw new SetupFlowError(
|
|
114
|
+
throw new SetupFlowError(lastNetworkError
|
|
115
|
+
? `Handoff timed out before the runtime key was delivered; the last poll could not reach ${apiBase} (${lastNetworkError.message}). Re-run setup; if you're behind a proxy that blocks long-running fetches, retry on a different network.`
|
|
116
|
+
: "Handoff timed out before the runtime key was delivered. Re-run setup; if you're behind a proxy that blocks long-running fetches, retry on a different network.");
|
|
109
117
|
}
|
|
110
118
|
function decryptBridgeEnvelope(privateKey, envelope) {
|
|
111
119
|
const wrappedKey = Buffer.from(envelope.wrapped_key, "base64url");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type MessageLogDirection = "inbound" | "outbound";
|
|
2
|
+
export interface MessageLogEntry {
|
|
3
|
+
direction: MessageLogDirection;
|
|
4
|
+
content: string;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class MessageLog {
|
|
8
|
+
private entries;
|
|
9
|
+
static readonly MAX_PER_CONTACT = 30;
|
|
10
|
+
static readonly TTL_MS: number;
|
|
11
|
+
static readonly MAX_CONTENT_LENGTH = 2000;
|
|
12
|
+
record(contact: string, direction: MessageLogDirection, content: string): void;
|
|
13
|
+
getRecent(contact: string, limit?: number): MessageLogEntry[];
|
|
14
|
+
contacts(): string[];
|
|
15
|
+
clear(): void;
|
|
16
|
+
}
|
|
17
|
+
export declare const messageLog: MessageLog;
|
|
18
|
+
//# sourceMappingURL=message-log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-log.d.ts","sourceRoot":"","sources":["../src/message-log.ts"],"names":[],"mappings":"AAuCA,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,eAAe;IAE9B,SAAS,EAAE,mBAAmB,CAAC;IAE/B,OAAO,EAAE,MAAM,CAAC;IAEhB,SAAS,EAAE,MAAM,CAAC;CACnB;AAMD,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAwC;IAGvD,MAAM,CAAC,QAAQ,CAAC,eAAe,MAAM;IAErC,MAAM,CAAC,QAAQ,CAAC,MAAM,SAA2B;IAEjD,MAAM,CAAC,QAAQ,CAAC,kBAAkB,QAAQ;IAM1C,MAAM,CACJ,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,mBAAmB,EAC9B,OAAO,EAAE,MAAM,GACd,IAAI;IA+BP,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,EAAE;IAuB7D,QAAQ,IAAI,MAAM,EAAE;IAKpB,KAAK,IAAI,IAAI;CAGd;AAMD,eAAO,MAAM,UAAU,YAAmB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export class MessageLog {
|
|
2
|
+
entries = new Map();
|
|
3
|
+
static MAX_PER_CONTACT = 30;
|
|
4
|
+
static TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
5
|
+
static MAX_CONTENT_LENGTH = 2000;
|
|
6
|
+
record(contact, direction, content) {
|
|
7
|
+
const now = Date.now();
|
|
8
|
+
const key = contact.toLowerCase();
|
|
9
|
+
let list = this.entries.get(key);
|
|
10
|
+
if (!list) {
|
|
11
|
+
list = [];
|
|
12
|
+
this.entries.set(key, list);
|
|
13
|
+
}
|
|
14
|
+
const cutoff = now - MessageLog.TTL_MS;
|
|
15
|
+
const fresh = list.filter((m) => m.timestamp > cutoff);
|
|
16
|
+
if (fresh.length >= MessageLog.MAX_PER_CONTACT) {
|
|
17
|
+
fresh.shift();
|
|
18
|
+
}
|
|
19
|
+
const stored = content.length > MessageLog.MAX_CONTENT_LENGTH
|
|
20
|
+
? `${content.slice(0, MessageLog.MAX_CONTENT_LENGTH)}...`
|
|
21
|
+
: content;
|
|
22
|
+
fresh.push({ direction, content: stored, timestamp: now });
|
|
23
|
+
this.entries.set(key, fresh);
|
|
24
|
+
}
|
|
25
|
+
getRecent(contact, limit) {
|
|
26
|
+
const key = contact.toLowerCase();
|
|
27
|
+
const list = this.entries.get(key);
|
|
28
|
+
if (!list)
|
|
29
|
+
return [];
|
|
30
|
+
const cutoff = Date.now() - MessageLog.TTL_MS;
|
|
31
|
+
const fresh = list.filter((m) => m.timestamp > cutoff);
|
|
32
|
+
if (fresh.length !== list.length) {
|
|
33
|
+
if (fresh.length === 0) {
|
|
34
|
+
this.entries.delete(key);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.entries.set(key, fresh);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (limit !== undefined && limit > 0 && fresh.length > limit) {
|
|
41
|
+
return fresh.slice(fresh.length - limit);
|
|
42
|
+
}
|
|
43
|
+
return fresh;
|
|
44
|
+
}
|
|
45
|
+
contacts() {
|
|
46
|
+
return [...this.entries.keys()];
|
|
47
|
+
}
|
|
48
|
+
clear() {
|
|
49
|
+
this.entries.clear();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export const messageLog = new MessageLog();
|
|
@@ -72,6 +72,7 @@ export interface ListConnectionsResponse {
|
|
|
72
72
|
createdAt: string | null;
|
|
73
73
|
}>;
|
|
74
74
|
}
|
|
75
|
+
export declare function apiFetch(url: string, init?: RequestInit): Promise<Response>;
|
|
75
76
|
export declare function requestConnection(cfg: PlatformClientConfig, runtimeKey: string, params: {
|
|
76
77
|
targetHandle: string;
|
|
77
78
|
variants: ("distribute" | "receive")[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-client.d.ts","sourceRoot":"","sources":["../src/platform-client.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,gBAAgB,0BAA0B,CAAC;AASxD,eAAO,MAAM,qBAAqB,iDACc,CAAC;AAEjD,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;AAiBD,qBAAa,oBAAqB,SAAQ,KAAK;aAE3B,IAAI,EAAE,SAAS,GAAG,SAAS;aAE3B,MAAM,EAAE,MAAM;gBAFd,IAAI,EAAE,SAAS,GAAG,SAAS,EAE3B,MAAM,EAAE,MAAM;CAKjC;AAMD,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAQD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC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,CAAC,QAAQ,CAAC,CAanB;AAYD,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,CAAC,YAAY,GAAG,SAAS,CAAC,EAAE,CAAA;CAAE,GACvE,OAAO,CAAC,yBAAyB,CAAC,CAWpC;AAQD,wBAAsB,YAAY,CAChC,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,EAClB,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;AAOD,wBAAsB,aAAa,CACjC,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,qBAAqB,CAAC,CAUhC;AAOD,wBAAsB,cAAc,CAClC,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,sBAAsB,CAAC,CAUjC;AAQD,wBAAsB,aAAa,CACjC,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,qBAAqB,CAAC,CAWhC;AAQD,wBAAsB,eAAe,CACnC,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,uBAAuB,CAAC,CAMlC"}
|
package/dist/platform-client.js
CHANGED
|
@@ -60,7 +60,7 @@ function toNetworkError(err) {
|
|
|
60
60
|
}
|
|
61
61
|
return err;
|
|
62
62
|
}
|
|
63
|
-
async function apiFetch(url, init = {}) {
|
|
63
|
+
export async function apiFetch(url, init = {}) {
|
|
64
64
|
const controller = new AbortController();
|
|
65
65
|
const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
66
66
|
try {
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAyJA,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD,YAAY,CACV,IAAI,EAAE,OAAO,EACb,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3C,IAAI,CAAC;IACR,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,IAAI,CAAC;CACnE;AAED,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAaI,iBAAiB;CAiYhC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -77,7 +77,9 @@ function buildInteractionContext(channelId, turnSender) {
|
|
|
77
77
|
const ownerHeader = truncated
|
|
78
78
|
? `[Active interactions on the network (showing ${sorted.length} of ${conversations.length})]`
|
|
79
79
|
: "[Active interactions on the network]";
|
|
80
|
-
return `${ownerHeader}\n${lines.join("\n")}
|
|
80
|
+
return (`${ownerHeader}\n${lines.join("\n")}\n` +
|
|
81
|
+
"To read what was actually said in any exchange (including autonomous " +
|
|
82
|
+
"background replies), use masons_read_conversation with the contact handle.");
|
|
81
83
|
}
|
|
82
84
|
const plugin = {
|
|
83
85
|
id: "agent-network",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-endpoint-client.d.ts","sourceRoot":"","sources":["../src/runtime-endpoint-client.ts"],"names":[],"mappings":"AAuBA,OAAO,
|
|
1
|
+
{"version":3,"file":"runtime-endpoint-client.d.ts","sourceRoot":"","sources":["../src/runtime-endpoint-client.ts"],"names":[],"mappings":"AAuBA,OAAO,EAEL,gBAAgB,EAChB,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EAAE,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,CAAC;AAmBvD,MAAM,MAAM,WAAW,GACnB,aAAa,GACb,UAAU,GACV,OAAO,GACP,UAAU,GACV,QAAQ,GACR,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,MAAM,yBAAyB,GACjC,iBAAiB,GACjB,wBAAwB,GACxB,uBAAuB,GACvB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,MAAM,wBAAwB,GAChC,gBAAgB,GAChB,UAAU,GACV,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,MAAM,8BAA8B,GACtC,mBAAmB,GACnB,sBAAsB,GACtB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,MAAM,oBAAoB,GAC5B;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,wBAAwB,EAAE,mBAAmB,CAAC;CAC/C,GACD;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wBAAwB,EAAE,sBAAsB,CAAC;CAClD,CAAC;AAaN,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MA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"./platform-client.js";
|
|
1
|
+
import { apiFetch, PlatformApiError, } from "./platform-client.js";
|
|
2
2
|
export { PlatformApiError };
|
|
3
3
|
function baseUrl(cfg) {
|
|
4
4
|
const trimmed = cfg.apiHost.replace(/\/+$/, "");
|
|
@@ -21,7 +21,7 @@ function jsonHeaders(runtimeKey) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
export async function registerRuntimeEndpoint(cfg, runtimeKey, params) {
|
|
24
|
-
const res = await
|
|
24
|
+
const res = await apiFetch(`${baseUrl(cfg)}/runtime-endpoints`, {
|
|
25
25
|
method: "POST",
|
|
26
26
|
headers: jsonHeaders(runtimeKey),
|
|
27
27
|
body: JSON.stringify(params),
|
|
@@ -31,7 +31,7 @@ export async function registerRuntimeEndpoint(cfg, runtimeKey, params) {
|
|
|
31
31
|
return (await res.json());
|
|
32
32
|
}
|
|
33
33
|
export async function heartbeatRuntimeEndpoint(cfg, runtimeKey, endpointId) {
|
|
34
|
-
const res = await
|
|
34
|
+
const res = await apiFetch(`${baseUrl(cfg)}/runtime-endpoints/${encodeURIComponent(endpointId)}/heartbeat`, {
|
|
35
35
|
method: "POST",
|
|
36
36
|
headers: authHeaders(runtimeKey),
|
|
37
37
|
});
|
|
@@ -41,7 +41,7 @@ export async function heartbeatRuntimeEndpoint(cfg, runtimeKey, endpointId) {
|
|
|
41
41
|
{});
|
|
42
42
|
}
|
|
43
43
|
export async function transitionRuntimeEndpointState(cfg, runtimeKey, endpointId, params) {
|
|
44
|
-
const res = await
|
|
44
|
+
const res = await apiFetch(`${baseUrl(cfg)}/runtime-endpoints/${encodeURIComponent(endpointId)}/state`, {
|
|
45
45
|
method: "POST",
|
|
46
46
|
headers: jsonHeaders(runtimeKey),
|
|
47
47
|
body: JSON.stringify(params),
|
|
@@ -55,7 +55,7 @@ export async function unregisterRuntimeEndpoint(cfg, runtimeKey, endpointId, asN
|
|
|
55
55
|
const query = asNodeId
|
|
56
56
|
? `?${new URLSearchParams({ as: asNodeId }).toString()}`
|
|
57
57
|
: "";
|
|
58
|
-
const res = await
|
|
58
|
+
const res = await apiFetch(`${baseUrl(cfg)}/runtime-endpoints/${encodeURIComponent(endpointId)}${query}`, {
|
|
59
59
|
method: "DELETE",
|
|
60
60
|
headers: authHeaders(runtimeKey),
|
|
61
61
|
});
|
|
@@ -66,7 +66,7 @@ export async function unregisterRuntimeEndpoint(cfg, runtimeKey, endpointId, asN
|
|
|
66
66
|
}
|
|
67
67
|
export async function listOwnedRuntimeEndpoints(cfg, runtimeKey, asNodeId) {
|
|
68
68
|
const query = new URLSearchParams({ as: asNodeId }).toString();
|
|
69
|
-
const res = await
|
|
69
|
+
const res = await apiFetch(`${baseUrl(cfg)}/runtime-endpoints?${query}`, {
|
|
70
70
|
headers: authHeaders(runtimeKey),
|
|
71
71
|
});
|
|
72
72
|
if (!res.ok)
|
|
@@ -75,7 +75,7 @@ export async function listOwnedRuntimeEndpoints(cfg, runtimeKey, asNodeId) {
|
|
|
75
75
|
}
|
|
76
76
|
export async function getOwnedRuntimeEndpoint(cfg, runtimeKey, endpointId, asNodeId) {
|
|
77
77
|
const query = new URLSearchParams({ as: asNodeId }).toString();
|
|
78
|
-
const res = await
|
|
78
|
+
const res = await apiFetch(`${baseUrl(cfg)}/runtime-endpoints/${encodeURIComponent(endpointId)}?${query}`, {
|
|
79
79
|
headers: authHeaders(runtimeKey),
|
|
80
80
|
});
|
|
81
81
|
if (!res.ok)
|
|
@@ -85,7 +85,7 @@ export async function getOwnedRuntimeEndpoint(cfg, runtimeKey, endpointId, asNod
|
|
|
85
85
|
export async function emitRuntimeUndispatchedChanged(cfg, runtimeKey, event) {
|
|
86
86
|
let res;
|
|
87
87
|
try {
|
|
88
|
-
res = await
|
|
88
|
+
res = await apiFetch(`${baseUrl(cfg)}/runtime/undispatched-changed`, {
|
|
89
89
|
method: "POST",
|
|
90
90
|
headers: jsonHeaders(runtimeKey),
|
|
91
91
|
body: JSON.stringify(event),
|
|
@@ -118,7 +118,7 @@ export async function emitRuntimeUndispatchedChanged(cfg, runtimeKey, event) {
|
|
|
118
118
|
export async function emitRuntimeNetworkPresenceChanged(cfg, runtimeKey, event) {
|
|
119
119
|
let res;
|
|
120
120
|
try {
|
|
121
|
-
res = await
|
|
121
|
+
res = await apiFetch(`${baseUrl(cfg)}/runtime/network-presence-changed`, {
|
|
122
122
|
method: "POST",
|
|
123
123
|
headers: jsonHeaders(runtimeKey),
|
|
124
124
|
body: JSON.stringify(event),
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAwEA,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,EAClC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3C,IAAI,CAAC;CACT;AAoDD,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C;AAuTD,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAw5BhD"}
|
package/dist/tools.js
CHANGED
|
@@ -3,6 +3,8 @@ import { getOwnerPassportAddress } from "./channel.js";
|
|
|
3
3
|
import { _resetChannelSetupForTesting, consumeChannelSetupStatus, getDefaultChannelSetupOptions, startOrGetChannelSetup, } from "./channel-setup.js";
|
|
4
4
|
import { clearTargetHandle, extractNetworkConfig, getDmScope, getPendingTarget, isProfileNeeded, markProfileComplete, removeIdentityLinks, requireApiKey, requireConversationManager, requirePlatformConfig, writeIdentityLinks, } from "./config.js";
|
|
5
5
|
import { getOwnerHandle } from "./environment-context.js";
|
|
6
|
+
import { extractHandleFromAddress } from "./handle-utils.js";
|
|
7
|
+
import { messageLog } from "./message-log.js";
|
|
6
8
|
import { ownerNotesQueue } from "./owner-notes.js";
|
|
7
9
|
import { acceptRequest, declineRequest, listConnections, listRequests, PlatformApiError, PlatformNetworkError, requestConnection, updateProfile, } from "./platform-client.js";
|
|
8
10
|
import { sentMessageBuffer } from "./sent-message-buffer.js";
|
|
@@ -55,6 +57,19 @@ function formatKindLabel(kind) {
|
|
|
55
57
|
return "[Agent Node] ";
|
|
56
58
|
return `[Node:${kind}] `;
|
|
57
59
|
}
|
|
60
|
+
function formatLogTimeAgo(timestamp) {
|
|
61
|
+
const deltaMs = Date.now() - timestamp;
|
|
62
|
+
if (deltaMs < 60_000)
|
|
63
|
+
return "just now";
|
|
64
|
+
const minutes = Math.floor(deltaMs / 60_000);
|
|
65
|
+
if (minutes < 60)
|
|
66
|
+
return `${minutes}m ago`;
|
|
67
|
+
const hours = Math.floor(minutes / 60);
|
|
68
|
+
if (hours < 24)
|
|
69
|
+
return `${hours}h ago`;
|
|
70
|
+
const days = Math.floor(hours / 24);
|
|
71
|
+
return `${days}d ago`;
|
|
72
|
+
}
|
|
58
73
|
function formatConnectionResult(requestIds, status) {
|
|
59
74
|
if (requestIds.length === 0) {
|
|
60
75
|
return "Already connected or request already pending — no new request needed.";
|
|
@@ -581,12 +596,11 @@ export function registerTools(api) {
|
|
|
581
596
|
const cm = requireConversationManager();
|
|
582
597
|
const to = params.to;
|
|
583
598
|
const content = params.content;
|
|
584
|
-
const handle =
|
|
585
|
-
? to.replace(/^mstps?:\/\/[^/]+\//, "").replace(/\/+$/, "")
|
|
586
|
-
: to;
|
|
599
|
+
const handle = extractHandleFromAddress(to);
|
|
587
600
|
const result = await cm.send(to, content);
|
|
588
601
|
if (result.status === "sent") {
|
|
589
602
|
sentMessageBuffer.record(handle, content);
|
|
603
|
+
messageLog.record(handle, "outbound", content);
|
|
590
604
|
return textResult("Message sent.");
|
|
591
605
|
}
|
|
592
606
|
return textResult(result.error ??
|
|
@@ -612,6 +626,45 @@ export function registerTools(api) {
|
|
|
612
626
|
: "No active conversation to close.");
|
|
613
627
|
}),
|
|
614
628
|
});
|
|
629
|
+
api.registerTool({
|
|
630
|
+
name: "masons_read_conversation",
|
|
631
|
+
description: "Read the recent message exchange with an agent-network contact — both " +
|
|
632
|
+
"what they sent and what was replied (including autonomous replies " +
|
|
633
|
+
"composed in background network turns). Use this when your owner asks " +
|
|
634
|
+
"what a contact said, whether they replied, or what was discussed.",
|
|
635
|
+
parameters: Type.Object({
|
|
636
|
+
contact: Type.String({
|
|
637
|
+
description: "Handle (e.g. alice) or network address (e.g. mstps://masons.ai/alice) of the contact",
|
|
638
|
+
}),
|
|
639
|
+
limit: Type.Optional(Type.Number({
|
|
640
|
+
description: "Max messages to return (most recent first cap; default all retained)",
|
|
641
|
+
})),
|
|
642
|
+
}),
|
|
643
|
+
execute: withUpdateNotice(async (_id, params) => {
|
|
644
|
+
const contact = params.contact;
|
|
645
|
+
const limit = typeof params.limit === "number" &&
|
|
646
|
+
Number.isFinite(params.limit) &&
|
|
647
|
+
params.limit > 0
|
|
648
|
+
? Math.floor(params.limit)
|
|
649
|
+
: 10;
|
|
650
|
+
const handle = extractHandleFromAddress(contact);
|
|
651
|
+
const entries = messageLog.getRecent(handle, limit);
|
|
652
|
+
if (entries.length === 0) {
|
|
653
|
+
const known = messageLog.contacts();
|
|
654
|
+
const hint = known.length > 0
|
|
655
|
+
? ` Contacts with recorded exchanges: ${known.map((c) => `@${c}`).join(", ")}.`
|
|
656
|
+
: "";
|
|
657
|
+
return textResult(`No recorded exchanges with @${handle}. The log holds recent messages ` +
|
|
658
|
+
`only (since the Gateway started, up to 7 days).${hint}`);
|
|
659
|
+
}
|
|
660
|
+
const lines = entries.map((entry) => {
|
|
661
|
+
const arrow = entry.direction === "inbound" ? `@${handle} →` : `→ @${handle}`;
|
|
662
|
+
const when = formatLogTimeAgo(entry.timestamp);
|
|
663
|
+
return `[${when}] ${arrow}\n${entry.content}`;
|
|
664
|
+
});
|
|
665
|
+
return textResult(`Recent exchange with @${handle} (${entries.length} message(s), oldest first):\n\n${lines.join("\n\n")}`);
|
|
666
|
+
}),
|
|
667
|
+
});
|
|
615
668
|
api.registerTool({
|
|
616
669
|
name: "masons_note_for_owner",
|
|
617
670
|
description: "Save a note for your owner (Principal). The note will be delivered " +
|
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.7";
|
|
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.7";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masons/agent-network",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
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)",
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
"build": "tsc",
|
|
26
26
|
"dev": "tsc --watch",
|
|
27
27
|
"test": "node ../../scripts/sync-vendored-trace-context.mjs && tsc -p test/tsconfig.json && node --test --loader ts-node/esm 'test/**/*.test.ts'",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"biome:check": "biome check .",
|
|
29
|
+
"biome:fix": "biome check . --write",
|
|
30
|
+
"biome:ci": "biome ci .",
|
|
30
31
|
"prepublishOnly": "node ../../scripts/sync-vendored-trace-context.mjs && bash scripts/check-version.sh && npm run build && npm run test",
|
|
31
32
|
"release": "pnpm publish --access public"
|
|
32
33
|
},
|
|
@@ -54,6 +54,7 @@ Check your current state and go to the right section:
|
|
|
54
54
|
- **Setup complete + pending connection target exists** (config has `pendingTarget`) → Go to **Connect** using that handle
|
|
55
55
|
- **Setup complete + pending incoming requests or user asks about requests** → Go to **Manage Requests**
|
|
56
56
|
- **Setup complete + user asks "who am I connected to" or wants to see connections** → Call `masons_list_connections` and show the results
|
|
57
|
+
- **Owner asks what a contact said, whether they replied, or what was discussed** → Call `masons_read_conversation` with the contact handle and relay the message bodies (it includes autonomous replies composed in background network turns)
|
|
57
58
|
- **Connected + message from the network** → Go to **Network Behavior**
|
|
58
59
|
- **Setup complete + general communication** → Go to **Network Behavior**
|
|
59
60
|
- **User asks about cross-channel identity or why they appear as different people on different channels** → Go to **Cross-Channel Identity**
|
|
@@ -286,6 +287,7 @@ Your context will show your **active interactions** — who you're interacting w
|
|
|
286
287
|
|
|
287
288
|
- To send to an agent: `masons_send_message(to, content)`
|
|
288
289
|
- To report to your owner: `masons_note_for_owner(content, from?)`
|
|
290
|
+
- To read the recent exchange with a contact (both directions, including autonomous background replies): `masons_read_conversation(contact, limit?)`
|
|
289
291
|
- To mark an explicitly stopped interaction closed for this turn: `masons_end_conversation(contact)` (rare compatibility tool)
|
|
290
292
|
|
|
291
293
|
`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 "收到".
|