@masons/agent-network 0.5.23 → 0.5.24
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-setup.d.ts +1 -0
- package/dist/channel-setup.d.ts.map +1 -1
- package/dist/channel-setup.js +2 -1
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +11 -1
- package/dist/config-schema.d.ts +2 -2
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -1
- package/dist/owner-session-state.d.ts +3 -0
- package/dist/owner-session-state.d.ts.map +1 -1
- package/dist/owner-session-state.js +10 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +6 -4
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +56 -24
- package/dist/turn-context.d.ts +3 -0
- package/dist/turn-context.d.ts.map +1 -1
- package/dist/turn-context.js +7 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/channel-setup.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-setup.d.ts","sourceRoot":"","sources":["../src/channel-setup.ts"],"names":[],"mappings":"AAeA,UAAU,wBAAwB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"channel-setup.d.ts","sourceRoot":"","sources":["../src/channel-setup.ts"],"names":[],"mappings":"AAeA,UAAU,wBAAwB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IAMnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAuBD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,wBAAgB,6BAA6B,IAAI,wBAAwB,CAMxE;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CA+B7B;AAED,wBAAgB,qBAAqB,IAAI,kBAAkB,GAAG,IAAI,CAejE;AAED,wBAAgB,yBAAyB,IAAI,kBAAkB,GAAG,IAAI,CAMrE;AAmED,wBAAgB,4BAA4B,IAAI,IAAI,CAGnD;AAED,eAAO,MAAM,oBAAoB,QAAqB,CAAC"}
|
package/dist/channel-setup.js
CHANGED
|
@@ -29,6 +29,7 @@ export async function startOrGetChannelSetup(options) {
|
|
|
29
29
|
apiHost: options.apiHost,
|
|
30
30
|
connectorUrl: options.connectorUrl,
|
|
31
31
|
idpBaseUrl: options.idpBaseUrl,
|
|
32
|
+
invitedBy: options.invitedBy,
|
|
32
33
|
};
|
|
33
34
|
pendingSetup = record;
|
|
34
35
|
void completePendingSetup(record);
|
|
@@ -85,7 +86,7 @@ async function completePendingSetup(record) {
|
|
|
85
86
|
connectorUrl: existingConnectorUrl ?? record.connectorUrl,
|
|
86
87
|
token: handoff.token,
|
|
87
88
|
};
|
|
88
|
-
await writeCredentials(creds, record.apiHost, record.idpBaseUrl);
|
|
89
|
+
await writeCredentials(creds, record.apiHost, record.idpBaseUrl, record.invitedBy);
|
|
89
90
|
lastSetupStatus = {
|
|
90
91
|
status: "completed",
|
|
91
92
|
agentHandle: handoff.agent.handle,
|
package/dist/channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"channel.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AAY,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC9C,QAAQ,CAAC,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACzE;AAED,UAAU,qBAAqB,CAAC,CAAC,GAAG,OAAO;IACzC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;CAC1B;AA2DD,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;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;AAyYD,eAAO,MAAM,mBAAmB,EAAE,yBAyNjC,CAAC"}
|
package/dist/channel.js
CHANGED
|
@@ -5,7 +5,7 @@ import { ConnectorClient } from "./connector-client.js";
|
|
|
5
5
|
import { ConversationManager } from "./conversation-manager.js";
|
|
6
6
|
import { clearEnvironmentContext } from "./environment-context.js";
|
|
7
7
|
import { extractHandleFromAddress } from "./handle-utils.js";
|
|
8
|
-
import { clearOwnerState, isOwnerAddress, markOwnerAddress, setCurrentTurnIsOwner, } from "./owner-session-state.js";
|
|
8
|
+
import { clearOwnerState, isOwnerAddress, markOwnerAddress, setCurrentTurnIsOwner, setCurrentTurnOwnerSignal, } from "./owner-session-state.js";
|
|
9
9
|
import { setCurrentTurnSender } from "./turn-context.js";
|
|
10
10
|
import { checkForUpdate } from "./update-check.js";
|
|
11
11
|
const dbg = createDebug("agent-network:channel");
|
|
@@ -128,6 +128,7 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
128
128
|
const nodeRef = tryProjectNodeRef(event.metadata);
|
|
129
129
|
if (nodeRef) {
|
|
130
130
|
setCurrentTurnIsOwner(false);
|
|
131
|
+
setCurrentTurnOwnerSignal(null);
|
|
131
132
|
dbg("Full Node sender: kind=%s mstpAddress=%s handle=%s", nodeRef.kind, nodeRef.mstpAddress, nodeRef.handle ?? "(absent)");
|
|
132
133
|
}
|
|
133
134
|
else {
|
|
@@ -146,6 +147,15 @@ async function handleAddressedMessage(event, conversationManager, client, ctx) {
|
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
setCurrentTurnIsOwner(isOwnerAddress(fromAddress));
|
|
150
|
+
if (event.metadata?.is_owner === true) {
|
|
151
|
+
setCurrentTurnOwnerSignal("owner");
|
|
152
|
+
}
|
|
153
|
+
else if (event.metadata?.is_owner === false) {
|
|
154
|
+
setCurrentTurnOwnerSignal("non-owner");
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
setCurrentTurnOwnerSignal(null);
|
|
158
|
+
}
|
|
149
159
|
}
|
|
150
160
|
const contact = nodeRef
|
|
151
161
|
? deriveNodeName(nodeRef, fromAddress)
|
package/dist/config-schema.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Static } from "@sinclair/typebox";
|
|
2
2
|
export declare const AgentNetworkAccountSchema: import("@sinclair/typebox").TObject<{
|
|
3
|
-
connectorUrl: import("@sinclair/typebox").TString
|
|
4
|
-
token: import("@sinclair/typebox").TString
|
|
3
|
+
connectorUrl: import("@sinclair/typebox").TString<string>;
|
|
4
|
+
token: import("@sinclair/typebox").TString<string>;
|
|
5
5
|
}>;
|
|
6
6
|
export type AgentNetworkAccount = Static<typeof AgentNetworkAccountSchema>;
|
|
7
7
|
//# sourceMappingURL=config-schema.d.ts.map
|
package/dist/config.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface NetworkCredentials {
|
|
|
26
26
|
token: string;
|
|
27
27
|
}
|
|
28
28
|
export declare function readExistingConnectorUrl(): Promise<string | undefined>;
|
|
29
|
-
export declare function writeCredentials(creds: NetworkCredentials, apiHost?: string, idpBaseUrl?: string): Promise<void>;
|
|
29
|
+
export declare function writeCredentials(creds: NetworkCredentials, apiHost?: string, idpBaseUrl?: string, pendingTarget?: string): Promise<void>;
|
|
30
30
|
export declare function writeTargetHandle(handle: string): Promise<void>;
|
|
31
31
|
export declare function clearTargetHandle(): Promise<void>;
|
|
32
32
|
export declare function markProfileNeeded(): Promise<void>;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAoCjD,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD;AAsBD,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GA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AK,EAAE,MAAM,CAAC;CACf;AAQD,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAW5E;AAmBD,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,kBAAkB,EACzB,OAAO,CAAC,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAUD,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMrE;AASD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CASvD;AAYD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAOvD;AAUD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAOzD;AAwCD,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAAC,CAsBf;AAQD,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4B1E;AAOD,MAAM,WAAW,YAAY;IAE3B,cAAc,EAAE,OAAO,CAAC;IAExB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B,YAAY,EAAE,OAAO,CAAC;CACvB;AASD,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,YAAY,CAAC,CA2BhE;AAOD,wBAAgB,gBAAgB,IAAI,IAAI,CAWvC"}
|
package/dist/config.js
CHANGED
|
@@ -141,7 +141,7 @@ export async function readExistingConnectorUrl() {
|
|
|
141
141
|
? connectorUrl
|
|
142
142
|
: undefined;
|
|
143
143
|
}
|
|
144
|
-
export async function writeCredentials(creds, apiHost, idpBaseUrl) {
|
|
144
|
+
export async function writeCredentials(creds, apiHost, idpBaseUrl, pendingTarget) {
|
|
145
145
|
const config = await readConfig();
|
|
146
146
|
const section = ensureNetworkSection(config);
|
|
147
147
|
section.enabled = true;
|
|
@@ -160,8 +160,14 @@ export async function writeCredentials(creds, apiHost, idpBaseUrl) {
|
|
|
160
160
|
if (idpBaseUrl) {
|
|
161
161
|
section.idpBaseUrl = idpBaseUrl;
|
|
162
162
|
}
|
|
163
|
+
if (pendingTarget) {
|
|
164
|
+
section.pendingTarget = pendingTarget;
|
|
165
|
+
}
|
|
163
166
|
await persistConfig(config);
|
|
164
167
|
storedApiKey = creds.token;
|
|
168
|
+
if (pendingTarget) {
|
|
169
|
+
storedPendingTarget = pendingTarget;
|
|
170
|
+
}
|
|
165
171
|
stateCacheGeneration++;
|
|
166
172
|
}
|
|
167
173
|
export async function writeTargetHandle(handle) {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
export type OwnerSignal = "owner" | "non-owner" | null;
|
|
1
2
|
export declare function markOwnerAddress(address: string): void;
|
|
2
3
|
export declare function isOwnerAddress(address: string): boolean;
|
|
3
4
|
export declare function clearOwnerState(): void;
|
|
4
5
|
export declare function setCurrentTurnIsOwner(value: boolean): void;
|
|
6
|
+
export declare function setCurrentTurnOwnerSignal(signal: OwnerSignal): void;
|
|
5
7
|
export declare function consumeCurrentTurnIsOwner(): boolean;
|
|
8
|
+
export declare function consumeCurrentTurnOwnerSignal(): OwnerSignal;
|
|
6
9
|
//# sourceMappingURL=owner-session-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owner-session-state.d.ts","sourceRoot":"","sources":["../src/owner-session-state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"owner-session-state.d.ts","sourceRoot":"","sources":["../src/owner-session-state.ts"],"names":[],"mappings":"AAmDA,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,WAAW,GAAG,IAAI,CAAC;AAQvD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEtD;AAGD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAGD,wBAAgB,eAAe,IAAI,IAAI,CAItC;AAMD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE1D;AAYD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAEnE;AAUD,wBAAgB,yBAAyB,IAAI,OAAO,CAInD;AASD,wBAAgB,6BAA6B,IAAI,WAAW,CAI3D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const ownerAddresses = new Set();
|
|
2
2
|
let currentTurnIsOwner = false;
|
|
3
|
+
let currentTurnOwnerSignal = null;
|
|
3
4
|
export function markOwnerAddress(address) {
|
|
4
5
|
ownerAddresses.add(address);
|
|
5
6
|
}
|
|
@@ -9,12 +10,21 @@ export function isOwnerAddress(address) {
|
|
|
9
10
|
export function clearOwnerState() {
|
|
10
11
|
ownerAddresses.clear();
|
|
11
12
|
currentTurnIsOwner = false;
|
|
13
|
+
currentTurnOwnerSignal = null;
|
|
12
14
|
}
|
|
13
15
|
export function setCurrentTurnIsOwner(value) {
|
|
14
16
|
currentTurnIsOwner = value;
|
|
15
17
|
}
|
|
18
|
+
export function setCurrentTurnOwnerSignal(signal) {
|
|
19
|
+
currentTurnOwnerSignal = signal;
|
|
20
|
+
}
|
|
16
21
|
export function consumeCurrentTurnIsOwner() {
|
|
17
22
|
const value = currentTurnIsOwner;
|
|
18
23
|
currentTurnIsOwner = false;
|
|
19
24
|
return value;
|
|
20
25
|
}
|
|
26
|
+
export function consumeCurrentTurnOwnerSignal() {
|
|
27
|
+
const value = currentTurnOwnerSignal;
|
|
28
|
+
currentTurnOwnerSignal = null;
|
|
29
|
+
return value;
|
|
30
|
+
}
|
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":"AAqJA,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;CA+XhC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -4,10 +4,10 @@ import { login } from "./cli-setup.js";
|
|
|
4
4
|
import { detectPendingState, getConversationManager, getDmScope, getStateCacheGeneration, initPluginRuntime, } from "./config.js";
|
|
5
5
|
import { getAgentIdentity } from "./environment-context.js";
|
|
6
6
|
import { ownerNotesQueue } from "./owner-notes.js";
|
|
7
|
-
import { consumeCurrentTurnIsOwner } from "./owner-session-state.js";
|
|
7
|
+
import { consumeCurrentTurnIsOwner, consumeCurrentTurnOwnerSignal, } from "./owner-session-state.js";
|
|
8
8
|
import { sentMessageBuffer } from "./sent-message-buffer.js";
|
|
9
9
|
import { registerTools } from "./tools.js";
|
|
10
|
-
import { consumeCurrentTurnSender, setCurrentTurnChannelId, setCurrentTurnIsOwnerForTools, } from "./turn-context.js";
|
|
10
|
+
import { consumeCurrentTurnSender, setCurrentTurnChannelId, setCurrentTurnIsOwnerForTools, setCurrentTurnOwnerSignalForTools, } from "./turn-context.js";
|
|
11
11
|
import { getUpdateInfo } from "./update-check.js";
|
|
12
12
|
import { PLUGIN_VERSION } from "./version.js";
|
|
13
13
|
function formatTimeAgo(timestamp) {
|
|
@@ -126,16 +126,18 @@ const plugin = {
|
|
|
126
126
|
"After responding on the network, check: " +
|
|
127
127
|
"should you report to your owner via masons_note_for_owner? " +
|
|
128
128
|
"Should you follow up with another agent via masons_send_message? " +
|
|
129
|
-
"When the interaction is complete, call masons_end_conversation as your FINAL
|
|
130
|
-
"
|
|
129
|
+
"When the interaction is complete, call masons_end_conversation as your FINAL action — " +
|
|
130
|
+
"do not generate any text reply after ending. " +
|
|
131
131
|
"";
|
|
132
132
|
api.on("before_prompt_build", async (_event, ctx) => {
|
|
133
133
|
const hookCtx = ctx;
|
|
134
134
|
const channelId = hookCtx?.channelId;
|
|
135
135
|
const turnIsOwner = consumeCurrentTurnIsOwner();
|
|
136
|
+
const turnOwnerSignal = consumeCurrentTurnOwnerSignal();
|
|
136
137
|
const turnSender = consumeCurrentTurnSender();
|
|
137
138
|
setCurrentTurnChannelId(channelId ?? null);
|
|
138
139
|
setCurrentTurnIsOwnerForTools(turnIsOwner);
|
|
140
|
+
setCurrentTurnOwnerSignalForTools(turnOwnerSignal);
|
|
139
141
|
const currentGeneration = getStateCacheGeneration();
|
|
140
142
|
if (!cachedState || cachedGeneration !== currentGeneration) {
|
|
141
143
|
try {
|
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":"AAqEA,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;AAmCD,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C;AAqRD,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CA80BhD"}
|
package/dist/tools.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getOwnerHandle } from "./environment-context.js";
|
|
|
6
6
|
import { ownerNotesQueue } from "./owner-notes.js";
|
|
7
7
|
import { acceptRequest, declineRequest, listConnections, listRequests, PlatformApiError, requestConnection, updateProfile, } from "./platform-client.js";
|
|
8
8
|
import { sentMessageBuffer } from "./sent-message-buffer.js";
|
|
9
|
-
import { getCurrentTurnChannelId, getCurrentTurnIsOwnerNonConsuming, } from "./turn-context.js";
|
|
9
|
+
import { getCurrentTurnChannelId, getCurrentTurnIsOwnerNonConsuming, getCurrentTurnOwnerSignal, } from "./turn-context.js";
|
|
10
10
|
import { getLatestPublishedVersion, getPluginVersion, getUpdateInfo, } from "./update-check.js";
|
|
11
11
|
const PROFILE_FIELDS = new Set(["name", "scope", "about", "audience"]);
|
|
12
12
|
const UPGRADE_CMD = "openclaw plugins update agent-network";
|
|
@@ -56,12 +56,17 @@ function formatConnectionResult(requestIds, status) {
|
|
|
56
56
|
}
|
|
57
57
|
return `Connection request sent. Status: ${status}. The other agent's owner will be notified.`;
|
|
58
58
|
}
|
|
59
|
-
function resolveSetupAuthority(
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
function resolveSetupAuthority() {
|
|
60
|
+
const channelId = getCurrentTurnChannelId();
|
|
61
|
+
if (channelId !== "agent-network") {
|
|
62
|
+
return { allowed: true };
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
+
const signal = getCurrentTurnOwnerSignal();
|
|
65
|
+
if (signal === "owner")
|
|
64
66
|
return { allowed: true };
|
|
67
|
+
if (signal === "non-owner") {
|
|
68
|
+
return { allowed: false, reason: "known-non-owner" };
|
|
69
|
+
}
|
|
65
70
|
return { allowed: false, reason: "ambiguous" };
|
|
66
71
|
}
|
|
67
72
|
function getSetupOptionsFromToolContext(ctx) {
|
|
@@ -116,20 +121,25 @@ function terminalSetupInstructions() {
|
|
|
116
121
|
"its own runtime key. Re-running login here updates this OpenClaw install's credentials.",
|
|
117
122
|
].join("\n");
|
|
118
123
|
}
|
|
119
|
-
function
|
|
124
|
+
function ownerRefusalText(reason) {
|
|
120
125
|
if (reason === "known-non-owner") {
|
|
121
126
|
return [
|
|
122
|
-
"
|
|
123
|
-
"",
|
|
124
|
-
|
|
127
|
+
"Setup is owner-only. You are reaching this agent through the MASONS",
|
|
128
|
+
"network as a visitor or as a peer agent. Setup re-binds the OpenClaw",
|
|
129
|
+
"runtime to a specific agent identity, so it must be initiated by the",
|
|
130
|
+
"agent's runtime owner from a channel their OpenClaw is configured for.",
|
|
125
131
|
].join("\n");
|
|
126
132
|
}
|
|
127
133
|
return [
|
|
128
|
-
"
|
|
134
|
+
"Setup is owner-only on the MASONS network channel. I could not verify",
|
|
135
|
+
"that you are this agent's owner from the message received.",
|
|
129
136
|
"",
|
|
130
|
-
"
|
|
137
|
+
"If you are the agent's runtime owner, please initiate setup from a",
|
|
138
|
+
"channel your OpenClaw runtime is configured for (e.g., Lark, Telegram,",
|
|
139
|
+
"desktop). The terminal command works as a last resort if no other channel",
|
|
140
|
+
"is reachable:",
|
|
131
141
|
"",
|
|
132
|
-
|
|
142
|
+
" openclaw channels login --channel agent-network",
|
|
133
143
|
].join("\n");
|
|
134
144
|
}
|
|
135
145
|
function formatChannelSetupResult(result) {
|
|
@@ -175,24 +185,46 @@ export function registerTools(api) {
|
|
|
175
185
|
description: [
|
|
176
186
|
"Start or inspect Agent Network setup.",
|
|
177
187
|
"Use when the user asks to set up Agent Network, when other Agent",
|
|
178
|
-
"Network tools fail with a 'no credentials'
|
|
179
|
-
"
|
|
188
|
+
"Network tools fail with a 'no credentials' error, or when the runtime",
|
|
189
|
+
"owner wants to switch which MASONS agent OpenClaw is driving.",
|
|
180
190
|
"",
|
|
181
|
-
"
|
|
182
|
-
"
|
|
183
|
-
"
|
|
184
|
-
"
|
|
191
|
+
"Pass `invitedBy` if the user came from another agent's profile page",
|
|
192
|
+
"(handle extracted from the URL); the plugin will record it and propose",
|
|
193
|
+
"a connection request after setup completes.",
|
|
194
|
+
"",
|
|
195
|
+
"This tool returns a browser handoff URL on the channel where you are",
|
|
196
|
+
"running. The user opens it, signs in, picks an agent, and the encrypted",
|
|
197
|
+
"handoff completes in the background. After completion, restart the",
|
|
198
|
+
"gateway to activate realtime messaging.",
|
|
199
|
+
"",
|
|
200
|
+
"If the user is reaching this agent through the MASONS network as a",
|
|
201
|
+
"visitor (not the agent's owner), this tool refuses with an explanation",
|
|
202
|
+
"— setup is owner-only because it re-binds the OpenClaw runtime to a",
|
|
203
|
+
"specific agent identity.",
|
|
185
204
|
].join("\n"),
|
|
186
|
-
parameters: Type.Object({
|
|
187
|
-
|
|
188
|
-
|
|
205
|
+
parameters: Type.Object({
|
|
206
|
+
invitedBy: Type.Optional(Type.String({
|
|
207
|
+
description: "Handle of the agent whose profile page the user came from " +
|
|
208
|
+
"(e.g., 'alice' from 'masons.ai/alice'). When setup completes, " +
|
|
209
|
+
"the plugin records this as a pending connection target so the " +
|
|
210
|
+
"agent can propose a connection request automatically.",
|
|
211
|
+
})),
|
|
212
|
+
}),
|
|
213
|
+
execute: async (_id, params) => {
|
|
214
|
+
const authority = resolveSetupAuthority();
|
|
189
215
|
if (!authority.allowed) {
|
|
190
|
-
return textResult(
|
|
216
|
+
return textResult(ownerRefusalText(authority.reason ?? "ambiguous"));
|
|
191
217
|
}
|
|
218
|
+
const invitedBy = typeof params.invitedBy === "string" && params.invitedBy.length > 0
|
|
219
|
+
? params.invitedBy
|
|
220
|
+
: undefined;
|
|
192
221
|
const existing = consumeChannelSetupStatus();
|
|
193
222
|
const result = existing
|
|
194
223
|
? existing
|
|
195
|
-
: await startOrGetChannelSetup(
|
|
224
|
+
: await startOrGetChannelSetup({
|
|
225
|
+
...getSetupOptionsFromToolContext(ctx),
|
|
226
|
+
invitedBy,
|
|
227
|
+
});
|
|
196
228
|
return textResult(formatChannelSetupResult(result));
|
|
197
229
|
},
|
|
198
230
|
}), { name: "masons_setup" });
|
|
@@ -529,7 +561,7 @@ export function registerTools(api) {
|
|
|
529
561
|
});
|
|
530
562
|
api.registerTool({
|
|
531
563
|
name: "masons_end_conversation",
|
|
532
|
-
description: "End the
|
|
564
|
+
description: "End the conversation with a connected agent. This immediately closes the session — do not send any text reply after calling this tool.",
|
|
533
565
|
parameters: Type.Object({
|
|
534
566
|
contact: Type.String({
|
|
535
567
|
description: "Handle (e.g. alice) or address of the agent to end the conversation with",
|
package/dist/turn-context.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { OwnerSignal } from "./owner-session-state.js";
|
|
1
2
|
export declare function setCurrentTurnSender(contact: string | null): void;
|
|
2
3
|
export declare function setCurrentTurnChannelId(channelId: string | null): void;
|
|
3
4
|
export declare function setCurrentTurnIsOwnerForTools(value: boolean): void;
|
|
5
|
+
export declare function setCurrentTurnOwnerSignalForTools(signal: OwnerSignal): void;
|
|
4
6
|
export declare function consumeCurrentTurnSender(): string | null;
|
|
5
7
|
export declare function getCurrentTurnChannelId(): string | null;
|
|
6
8
|
export declare function getCurrentTurnIsOwnerNonConsuming(): boolean;
|
|
9
|
+
export declare function getCurrentTurnOwnerSignal(): OwnerSignal;
|
|
7
10
|
//# sourceMappingURL=turn-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn-context.d.ts","sourceRoot":"","sources":["../src/turn-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"turn-context.d.ts","sourceRoot":"","sources":["../src/turn-context.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAwC5D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAEjE;AAOD,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAEtE;AAOD,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAElE;AAUD,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAE3E;AAUD,wBAAgB,wBAAwB,IAAI,MAAM,GAAG,IAAI,CAIxD;AAMD,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAEvD;AAMD,wBAAgB,iCAAiC,IAAI,OAAO,CAE3D;AAOD,wBAAgB,yBAAyB,IAAI,WAAW,CAEvD"}
|
package/dist/turn-context.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
let currentTurnSender = null;
|
|
2
2
|
let currentTurnChannelId = null;
|
|
3
3
|
let currentTurnIsOwner = false;
|
|
4
|
+
let currentTurnOwnerSignalForTools = null;
|
|
4
5
|
export function setCurrentTurnSender(contact) {
|
|
5
6
|
currentTurnSender = contact;
|
|
6
7
|
}
|
|
@@ -10,6 +11,9 @@ export function setCurrentTurnChannelId(channelId) {
|
|
|
10
11
|
export function setCurrentTurnIsOwnerForTools(value) {
|
|
11
12
|
currentTurnIsOwner = value;
|
|
12
13
|
}
|
|
14
|
+
export function setCurrentTurnOwnerSignalForTools(signal) {
|
|
15
|
+
currentTurnOwnerSignalForTools = signal;
|
|
16
|
+
}
|
|
13
17
|
export function consumeCurrentTurnSender() {
|
|
14
18
|
const value = currentTurnSender;
|
|
15
19
|
currentTurnSender = null;
|
|
@@ -21,3 +25,6 @@ export function getCurrentTurnChannelId() {
|
|
|
21
25
|
export function getCurrentTurnIsOwnerNonConsuming() {
|
|
22
26
|
return currentTurnIsOwner;
|
|
23
27
|
}
|
|
28
|
+
export function getCurrentTurnOwnerSignal() {
|
|
29
|
+
return currentTurnOwnerSignalForTools;
|
|
30
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PLUGIN_VERSION = "0.5.
|
|
1
|
+
export declare const PLUGIN_VERSION = "0.5.24";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PLUGIN_VERSION = "0.5.
|
|
1
|
+
export const PLUGIN_VERSION = "0.5.24";
|
package/package.json
CHANGED