@masons/agent-network 0.6.18 → 0.6.19
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 +6 -1
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +48 -8
- package/dist/plugin.d.ts +6 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +6 -0
- package/dist/services-retained-tool-policy.d.ts +11 -0
- package/dist/services-retained-tool-policy.d.ts.map +1 -0
- package/dist/services-retained-tool-policy.js +30 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/openclaw.plugin.json +1 -0
- package/package.json +2 -2
package/dist/channel.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import type { ChannelPlugin } from "openclaw/plugin-sdk/channel-core";
|
|
1
|
+
import type { ChannelPlugin, PluginRuntime } from "openclaw/plugin-sdk/channel-core";
|
|
2
2
|
import type { AgentNetworkAccount } from "./config-schema.js";
|
|
3
3
|
export declare function getOwnerPassportAddress(): string | null;
|
|
4
4
|
export declare function consumeIdentityLinkingNudge(): boolean;
|
|
5
5
|
export declare function _setNudgePendingForTesting(value: boolean): void;
|
|
6
|
+
export declare function buildServicesRetainedRuntimeSessionKey(buildAgentSessionKey: PluginRuntime["channel"]["routing"]["buildAgentSessionKey"], params: {
|
|
7
|
+
agentId: string;
|
|
8
|
+
accountId: string;
|
|
9
|
+
messageRef: string;
|
|
10
|
+
}): string;
|
|
6
11
|
declare function withAgentNetworkSilentReplyPolicy(cfg: Record<string, unknown>, servicesRetained?: boolean): Record<string, unknown>;
|
|
7
12
|
export declare const _withAgentNetworkSilentReplyPolicyForTesting: typeof withAgentNetworkSilentReplyPolicy;
|
|
8
13
|
export declare const agentNetworkChannel: ChannelPlugin<AgentNetworkAccount>;
|
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,
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACd,MAAM,kCAAkC,CAAC;AAa1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAuD9D,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAEvD;AAOD,wBAAgB,2BAA2B,IAAI,OAAO,CAIrD;AAGD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE/D;AAeD,wBAAgB,sCAAsC,CACpD,oBAAoB,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,sBAAsB,CAAC,EACjF,MAAM,EAAE;IACN,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,GACA,MAAM,CAiBR;AAED,iBAAS,iCAAiC,CACxC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,gBAAgB,UAAQ,GACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA8CzB;AAED,eAAO,MAAM,4CAA4C,0CACtB,CAAC;AAokBpC,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,mBAAmB,CAuRlE,CAAC"}
|
package/dist/channel.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import createDebug from "debug";
|
|
3
3
|
import { clearConnectorClient, clearConversationManager, extractNetworkConfig, getDmScope, initConnectorClient, initConversationManager, initToolConfig, isIdentityLinksConfigured, requirePlatformConfig, requirePluginRuntime, } from "./config.js";
|
|
4
4
|
import { ConnectorClient } from "./connector-client.js";
|
|
@@ -8,6 +8,7 @@ import { extractHandleFromAddress } from "./handle-utils.js";
|
|
|
8
8
|
import { clearOwnerState, isOwnerAddress, markOwnerAddress, setCurrentTurnIsOwner, setCurrentTurnOwnerSignal, } from "./owner-session-state.js";
|
|
9
9
|
import { ServicesRetainedRecipientConsumer, } from "./services-retained-recipient.js";
|
|
10
10
|
import { isServicesRetainedReplyContext, runWithServicesRetainedReplyContext, } from "./services-retained-reply-context.js";
|
|
11
|
+
import { runWithServicesRetainedToolPolicy } from "./services-retained-tool-policy.js";
|
|
11
12
|
import { createReplyTraceMetadata, ensureTraceMetadata, } from "./trace-metadata.js";
|
|
12
13
|
import { setCurrentTurnSender, setCurrentTurnSenderAddress, } from "./turn-context.js";
|
|
13
14
|
import { checkForUpdate } from "./update-check.js";
|
|
@@ -31,6 +32,22 @@ export function _setNudgePendingForTesting(value) {
|
|
|
31
32
|
function isRecord(value) {
|
|
32
33
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
33
34
|
}
|
|
35
|
+
const SERVICES_RETAINED_TOOL_ALLOW = ["masons_note_for_owner"];
|
|
36
|
+
export function buildServicesRetainedRuntimeSessionKey(buildAgentSessionKey, params) {
|
|
37
|
+
const messageRefDigest = createHash("sha256")
|
|
38
|
+
.update(params.messageRef, "utf8")
|
|
39
|
+
.digest("hex");
|
|
40
|
+
return buildAgentSessionKey({
|
|
41
|
+
agentId: params.agentId,
|
|
42
|
+
channel: "agent-network",
|
|
43
|
+
accountId: params.accountId,
|
|
44
|
+
peer: {
|
|
45
|
+
kind: "direct",
|
|
46
|
+
id: `services-retained-${messageRefDigest}`,
|
|
47
|
+
},
|
|
48
|
+
dmScope: "per-account-channel-peer",
|
|
49
|
+
});
|
|
50
|
+
}
|
|
34
51
|
function withAgentNetworkSilentReplyPolicy(cfg, servicesRetained = false) {
|
|
35
52
|
const surfaces = isRecord(cfg.surfaces) ? cfg.surfaces : {};
|
|
36
53
|
const existingSurface = isRecord(surfaces["agent-network"])
|
|
@@ -43,9 +60,7 @@ function withAgentNetworkSilentReplyPolicy(cfg, servicesRetained = false) {
|
|
|
43
60
|
? existingSurface.silentReplyRewrite
|
|
44
61
|
: {};
|
|
45
62
|
const tools = isRecord(cfg.tools) ? cfg.tools : {};
|
|
46
|
-
const
|
|
47
|
-
? tools.deny.filter((value) => typeof value === "string")
|
|
48
|
-
: [];
|
|
63
|
+
const messages = isRecord(cfg.messages) ? cfg.messages : {};
|
|
49
64
|
return {
|
|
50
65
|
...cfg,
|
|
51
66
|
surfaces: {
|
|
@@ -63,9 +78,15 @@ function withAgentNetworkSilentReplyPolicy(cfg, servicesRetained = false) {
|
|
|
63
78
|
},
|
|
64
79
|
},
|
|
65
80
|
...(servicesRetained && {
|
|
81
|
+
messages: {
|
|
82
|
+
...messages,
|
|
83
|
+
visibleReplies: "automatic",
|
|
84
|
+
},
|
|
66
85
|
tools: {
|
|
67
86
|
...tools,
|
|
68
|
-
|
|
87
|
+
allow: [...SERVICES_RETAINED_TOOL_ALLOW],
|
|
88
|
+
alsoAllow: [],
|
|
89
|
+
toolSearch: false,
|
|
69
90
|
},
|
|
70
91
|
}),
|
|
71
92
|
};
|
|
@@ -218,13 +239,23 @@ async function handleAddressedMessage(event, conversationManager, client, ctx, o
|
|
|
218
239
|
accountId: ctx.accountId,
|
|
219
240
|
peer: { kind: "direct", id: senderId },
|
|
220
241
|
});
|
|
242
|
+
const runtimeSessionKey = options.servicesRetained
|
|
243
|
+
? buildServicesRetainedRuntimeSessionKey(runtime.channel.routing.buildAgentSessionKey, {
|
|
244
|
+
agentId: route.agentId,
|
|
245
|
+
accountId: ctx.accountId,
|
|
246
|
+
messageRef: options.servicesRetained.messageRef,
|
|
247
|
+
})
|
|
248
|
+
: route.sessionKey;
|
|
221
249
|
const msgCtx = runtime.channel.reply.finalizeInboundContext({
|
|
222
250
|
Body: event.content,
|
|
223
251
|
RawBody: event.content,
|
|
224
252
|
CommandBody: event.content,
|
|
225
253
|
From: senderId,
|
|
226
254
|
To: senderId,
|
|
227
|
-
SessionKey:
|
|
255
|
+
SessionKey: runtimeSessionKey,
|
|
256
|
+
...(options.servicesRetained && {
|
|
257
|
+
RuntimePolicySessionKey: runtimeSessionKey,
|
|
258
|
+
}),
|
|
228
259
|
AccountId: ctx.accountId,
|
|
229
260
|
ChatType: "direct",
|
|
230
261
|
SenderName: senderName,
|
|
@@ -262,8 +293,14 @@ async function handleAddressedMessage(event, conversationManager, client, ctx, o
|
|
|
262
293
|
const dispatch = () => runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
263
294
|
ctx: msgCtx,
|
|
264
295
|
cfg: withAgentNetworkSilentReplyPolicy(ctx.cfg, options.servicesRetained !== undefined),
|
|
296
|
+
toolsAllow: options.servicesRetained
|
|
297
|
+
? SERVICES_RETAINED_TOOL_ALLOW
|
|
298
|
+
: undefined,
|
|
265
299
|
dispatcherOptions: {
|
|
266
300
|
deliver: async (payload) => {
|
|
301
|
+
if (options.servicesRetained && payload.isError) {
|
|
302
|
+
throw new Error("services_retained_runtime_policy_unavailable");
|
|
303
|
+
}
|
|
267
304
|
const text = payload.text;
|
|
268
305
|
if (!text)
|
|
269
306
|
return;
|
|
@@ -299,7 +336,7 @@ async function handleAddressedMessage(event, conversationManager, client, ctx, o
|
|
|
299
336
|
},
|
|
300
337
|
});
|
|
301
338
|
if (options.servicesRetained) {
|
|
302
|
-
await runWithServicesRetainedReplyContext(dispatch);
|
|
339
|
+
await runWithServicesRetainedToolPolicy(runtimeSessionKey, () => runWithServicesRetainedReplyContext(dispatch));
|
|
303
340
|
}
|
|
304
341
|
else {
|
|
305
342
|
await dispatch();
|
|
@@ -450,7 +487,10 @@ export const agentNetworkChannel = {
|
|
|
450
487
|
runtimePeerId: SERVICES_RETAINED_INBOX_PEER,
|
|
451
488
|
senderName: servicesRetainedSenderName(message),
|
|
452
489
|
messageSid: `an:${message.envelope.message_ref}`,
|
|
453
|
-
servicesRetained: {
|
|
490
|
+
servicesRetained: {
|
|
491
|
+
messageRef: message.envelope.message_ref,
|
|
492
|
+
reply: message.reply,
|
|
493
|
+
},
|
|
454
494
|
}),
|
|
455
495
|
});
|
|
456
496
|
const state = {
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { evaluateServicesRetainedToolPolicy } from "./services-retained-tool-policy.js";
|
|
1
2
|
export declare function buildInteractionContext(channelId: string | undefined, turnSender: string | null, turnSenderAddress: string | null, servicesRetained?: boolean): string | undefined;
|
|
2
3
|
interface OpenClawPluginApi {
|
|
3
4
|
runtime: unknown;
|
|
@@ -8,6 +9,11 @@ interface OpenClawPluginApi {
|
|
|
8
9
|
optional?: boolean;
|
|
9
10
|
name?: string;
|
|
10
11
|
}): void;
|
|
12
|
+
registerTrustedToolPolicy(policy: {
|
|
13
|
+
id: string;
|
|
14
|
+
description: string;
|
|
15
|
+
evaluate: typeof evaluateServicesRetainedToolPolicy;
|
|
16
|
+
}): void;
|
|
11
17
|
on(event: string, handler: (...args: unknown[]) => unknown): void;
|
|
12
18
|
}
|
|
13
19
|
declare const plugin: {
|
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":"AAuBA,OAAO,EACL,kCAAkC,EAEnC,MAAM,oCAAoC,CAAC;AAgE5C,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,iBAAiB,EAAE,MAAM,GAAG,IAAI,EAChC,gBAAgB,UAAQ,GACvB,MAAM,GAAG,SAAS,CA+EpB;AAKD,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,yBAAyB,CAAC,MAAM,EAAE;QAChC,EAAE,EAAE,MAAM,CAAC;QACX,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,OAAO,kCAAkC,CAAC;KACrD,GAAG,IAAI,CAAC;IACT,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;CAiZhC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -7,6 +7,7 @@ import { ownerNotesQueue } from "./owner-notes.js";
|
|
|
7
7
|
import { consumeCurrentTurnIsOwner, consumeCurrentTurnOwnerSignal, } from "./owner-session-state.js";
|
|
8
8
|
import { sentMessageBuffer } from "./sent-message-buffer.js";
|
|
9
9
|
import { isServicesRetainedReplyContext } from "./services-retained-reply-context.js";
|
|
10
|
+
import { evaluateServicesRetainedToolPolicy, SERVICES_RETAINED_TOOL_POLICY_ID, } from "./services-retained-tool-policy.js";
|
|
10
11
|
import { registerTools } from "./tools.js";
|
|
11
12
|
import { consumeCurrentTurnSender, consumeCurrentTurnSenderAddress, setCurrentTurnChannelId, setCurrentTurnIsOwnerForTools, setCurrentTurnOwnerSignalForTools, } from "./turn-context.js";
|
|
12
13
|
import { getUpdateInfo } from "./update-check.js";
|
|
@@ -95,6 +96,11 @@ const plugin = {
|
|
|
95
96
|
configSchema: pluginManifest.configSchema,
|
|
96
97
|
register(api) {
|
|
97
98
|
initPluginRuntime(api.runtime);
|
|
99
|
+
api.registerTrustedToolPolicy({
|
|
100
|
+
id: SERVICES_RETAINED_TOOL_POLICY_ID,
|
|
101
|
+
description: "Deny every tool except the owner note during Services-retained recipient turns.",
|
|
102
|
+
evaluate: evaluateServicesRetainedToolPolicy,
|
|
103
|
+
});
|
|
98
104
|
registerTools(api);
|
|
99
105
|
try {
|
|
100
106
|
api.registerChannel({
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const SERVICES_RETAINED_TOOL_POLICY_ID = "agent-network-services-retained-turn-v1";
|
|
2
|
+
export declare function runWithServicesRetainedToolPolicy<T>(sessionKey: string, callback: () => Promise<T> | T): Promise<T>;
|
|
3
|
+
export declare function evaluateServicesRetainedToolPolicy(event: {
|
|
4
|
+
toolName: string;
|
|
5
|
+
}, ctx: {
|
|
6
|
+
sessionKey?: string;
|
|
7
|
+
}): {
|
|
8
|
+
allow: false;
|
|
9
|
+
reason: string;
|
|
10
|
+
} | undefined;
|
|
11
|
+
//# sourceMappingURL=services-retained-tool-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services-retained-tool-policy.d.ts","sourceRoot":"","sources":["../src/services-retained-tool-policy.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gCAAgC,4CACF,CAAC;AAE5C,wBAAsB,iCAAiC,CAAC,CAAC,EACvD,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAC7B,OAAO,CAAC,CAAC,CAAC,CAeZ;AAED,wBAAgB,kCAAkC,CAChD,KAAK,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC3B,GAAG,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3B;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAY9C"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const SERVICES_RETAINED_OWNER_NOTE_TOOL = "masons_note_for_owner";
|
|
2
|
+
const activeSessionRefCounts = new Map();
|
|
3
|
+
export const SERVICES_RETAINED_TOOL_POLICY_ID = "agent-network-services-retained-turn-v1";
|
|
4
|
+
export async function runWithServicesRetainedToolPolicy(sessionKey, callback) {
|
|
5
|
+
activeSessionRefCounts.set(sessionKey, (activeSessionRefCounts.get(sessionKey) ?? 0) + 1);
|
|
6
|
+
try {
|
|
7
|
+
return await callback();
|
|
8
|
+
}
|
|
9
|
+
finally {
|
|
10
|
+
const remaining = (activeSessionRefCounts.get(sessionKey) ?? 1) - 1;
|
|
11
|
+
if (remaining > 0) {
|
|
12
|
+
activeSessionRefCounts.set(sessionKey, remaining);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
activeSessionRefCounts.delete(sessionKey);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function evaluateServicesRetainedToolPolicy(event, ctx) {
|
|
20
|
+
if (!ctx.sessionKey || !activeSessionRefCounts.has(ctx.sessionKey)) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
if (event.toolName === SERVICES_RETAINED_OWNER_NOTE_TOOL) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
allow: false,
|
|
28
|
+
reason: "Services-retained recipient turns permit only the owner-note capability.",
|
|
29
|
+
};
|
|
30
|
+
}
|
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.19";
|
|
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.19";
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masons/agent-network",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.19",
|
|
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)",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"openclaw": {
|
|
40
40
|
"compat": {
|
|
41
|
-
"pluginApi": ">=2026.
|
|
41
|
+
"pluginApi": ">=2026.6.11"
|
|
42
42
|
},
|
|
43
43
|
"extensions": [
|
|
44
44
|
"./dist/plugin.js"
|