@masons/agent-network 0.6.13 → 0.6.14
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.
|
@@ -40,6 +40,7 @@ export declare class ConversationManager {
|
|
|
40
40
|
endConversation(contact: string): boolean;
|
|
41
41
|
commitEndedConversations(): void;
|
|
42
42
|
resolveAddress(contact: string): string;
|
|
43
|
+
private resolveContactForSend;
|
|
43
44
|
extractHandle(address: string): string;
|
|
44
45
|
private ensureConversationEntry;
|
|
45
46
|
_resetForTesting(): void;
|
|
@@ -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;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,UA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|
+
const resolution = this.resolveContactForSend(contact);
|
|
31
|
+
if (resolution.ambiguous) {
|
|
32
|
+
const message = `'${contact}' matches more than one of your connections. Use the full address from masons_list_connections instead of the bare handle.`;
|
|
33
|
+
dbg("send refused: ambiguous contact=%s", contact);
|
|
34
|
+
return {
|
|
35
|
+
status: "failed",
|
|
36
|
+
error: message,
|
|
37
|
+
errorCode: "AMBIGUOUS_CONTACT",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const address = resolution.address;
|
|
31
41
|
let wireMetadata;
|
|
32
42
|
let sendTraceId;
|
|
33
43
|
let envelope = metadata === undefined
|
|
@@ -116,7 +126,12 @@ export class ConversationManager {
|
|
|
116
126
|
return this.conversations.has(address);
|
|
117
127
|
}
|
|
118
128
|
endConversation(contact) {
|
|
119
|
-
const
|
|
129
|
+
const resolution = this.resolveContactForSend(contact);
|
|
130
|
+
if (resolution.ambiguous) {
|
|
131
|
+
dbg("endConversation refused: ambiguous contact=%s", contact);
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
const address = resolution.address;
|
|
120
135
|
const entry = this.conversations.get(address);
|
|
121
136
|
if (entry && !entry.ended) {
|
|
122
137
|
entry.ended = true;
|
|
@@ -139,21 +154,39 @@ export class ConversationManager {
|
|
|
139
154
|
}
|
|
140
155
|
}
|
|
141
156
|
resolveAddress(contact) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (contact.startsWith("
|
|
146
|
-
|
|
157
|
+
return this.resolveContactForSend(contact).address;
|
|
158
|
+
}
|
|
159
|
+
resolveContactForSend(contact) {
|
|
160
|
+
if (contact.startsWith("mstps://") ||
|
|
161
|
+
contact.startsWith("mstp://") ||
|
|
162
|
+
contact.startsWith("passport:")) {
|
|
163
|
+
return { address: contact, ambiguous: false };
|
|
147
164
|
}
|
|
148
165
|
const normalizedContact = normalizeHandleContact(contact);
|
|
149
166
|
if (this.conversations.has(normalizedContact)) {
|
|
150
|
-
return normalizedContact;
|
|
167
|
+
return { address: normalizedContact, ambiguous: false };
|
|
151
168
|
}
|
|
169
|
+
let first;
|
|
170
|
+
let ambiguous = false;
|
|
152
171
|
for (const [addr, entry] of this.conversations) {
|
|
153
|
-
if (entry.contact
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
172
|
+
if (entry.contact !== normalizedContact &&
|
|
173
|
+
extractHandleFromAddress(addr).toLowerCase() !==
|
|
174
|
+
normalizedContact.toLowerCase()) {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (first === undefined) {
|
|
178
|
+
first = addr;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
ambiguous = true;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
if (first !== undefined)
|
|
185
|
+
return { address: first, ambiguous };
|
|
186
|
+
return {
|
|
187
|
+
address: `mstps://${this.mstpAuthority}/${normalizedContact}`,
|
|
188
|
+
ambiguous: false,
|
|
189
|
+
};
|
|
157
190
|
}
|
|
158
191
|
extractHandle(address) {
|
|
159
192
|
return extractHandleFromAddress(address);
|
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.14";
|
|
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.14";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masons/agent-network",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.14",
|
|
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)",
|