@masons/agent-network 0.6.0 → 0.6.2
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 -1
- package/dist/channel-setup.d.ts.map +1 -1
- package/dist/channel-setup.js +10 -5
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +8 -13
- package/dist/cli-setup.d.ts.map +1 -1
- package/dist/cli-setup.js +17 -1
- package/dist/connector-url-boundary.d.ts +17 -0
- package/dist/connector-url-boundary.d.ts.map +1 -0
- package/dist/connector-url-boundary.js +79 -0
- package/dist/conversation-manager.d.ts +2 -2
- package/dist/conversation-manager.js +4 -4
- package/dist/platform-client.d.ts.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +18 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +15 -10
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":"
|
|
1
|
+
{"version":3,"file":"channel-setup.d.ts","sourceRoot":"","sources":["../src/channel-setup.ts"],"names":[],"mappings":"AAgBA,UAAU,wBAAwB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,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,CAKxE;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAsC7B;AAED,wBAAgB,qBAAqB,IAAI,kBAAkB,GAAG,IAAI,CAejE;AAED,wBAAgB,yBAAyB,IAAI,kBAAkB,GAAG,IAAI,CAMrE;AAkED,wBAAgB,4BAA4B,IAAI,IAAI,CAGnD;AAED,eAAO,MAAM,oBAAoB,QAAqB,CAAC"}
|
package/dist/channel-setup.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { readExistingConnectorUrl, writeCredentials, } from "./config.js";
|
|
2
|
+
import { resolveConnectorUrlForSetup } from "./connector-url-boundary.js";
|
|
2
3
|
import { beginBridgeHandoff, completeBridgeHandoff, DEFAULT_IDP_BASE_URL, HANDOFF_TIMEOUT_MS, SetupFlowError, } from "./handoff.js";
|
|
3
|
-
import { DEFAULT_API_HOST
|
|
4
|
+
import { DEFAULT_API_HOST } from "./platform-client.js";
|
|
4
5
|
let pendingSetup = null;
|
|
5
6
|
let lastSetupStatus = null;
|
|
6
7
|
export function getDefaultChannelSetupOptions() {
|
|
7
8
|
return {
|
|
8
9
|
apiHost: DEFAULT_API_HOST,
|
|
9
|
-
connectorUrl: DEFAULT_CONNECTOR_URL,
|
|
10
10
|
idpBaseUrl: DEFAULT_IDP_BASE_URL,
|
|
11
11
|
};
|
|
12
12
|
}
|
|
@@ -20,6 +20,12 @@ export async function startOrGetChannelSetup(options) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
lastSetupStatus = null;
|
|
23
|
+
const existingConnectorUrl = await readExistingConnectorUrl();
|
|
24
|
+
const connectorUrl = resolveConnectorUrlForSetup({
|
|
25
|
+
apiHost: options.apiHost,
|
|
26
|
+
existingConnectorUrl,
|
|
27
|
+
configuredConnectorUrl: options.connectorUrl,
|
|
28
|
+
});
|
|
23
29
|
const session = await beginBridgeHandoff({
|
|
24
30
|
apiHost: options.apiHost,
|
|
25
31
|
idpBaseUrl: options.idpBaseUrl,
|
|
@@ -28,7 +34,7 @@ export async function startOrGetChannelSetup(options) {
|
|
|
28
34
|
const record = {
|
|
29
35
|
session,
|
|
30
36
|
apiHost: options.apiHost,
|
|
31
|
-
connectorUrl
|
|
37
|
+
connectorUrl,
|
|
32
38
|
idpBaseUrl: options.idpBaseUrl,
|
|
33
39
|
invitedBy: options.invitedBy,
|
|
34
40
|
};
|
|
@@ -82,9 +88,8 @@ async function completePendingSetup(record) {
|
|
|
82
88
|
const handoff = await completeBridgeHandoff(record.session);
|
|
83
89
|
if (pendingSetup !== record)
|
|
84
90
|
return;
|
|
85
|
-
const existingConnectorUrl = await readExistingConnectorUrl();
|
|
86
91
|
const creds = {
|
|
87
|
-
connectorUrl:
|
|
92
|
+
connectorUrl: record.connectorUrl,
|
|
88
93
|
token: handoff.token,
|
|
89
94
|
};
|
|
90
95
|
await writeCredentials(creds, record.apiHost, record.idpBaseUrl, record.invitedBy);
|
package/dist/channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAqC9D,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,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW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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;AAqZD,eAAO,MAAM,mBAAmB,EAAE,yBA+NjC,CAAC"}
|
package/dist/channel.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import createDebug from "debug";
|
|
3
|
-
import { clearConnectorClient, clearConversationManager, extractNetworkConfig, getDmScope, initConnectorClient, initConversationManager, initToolConfig, isIdentityLinksConfigured, requirePluginRuntime, } from "./config.js";
|
|
3
|
+
import { clearConnectorClient, clearConversationManager, extractNetworkConfig, getDmScope, initConnectorClient, initConversationManager, initToolConfig, isIdentityLinksConfigured, requirePlatformConfig, requirePluginRuntime, } from "./config.js";
|
|
4
4
|
import { ConnectorClient } from "./connector-client.js";
|
|
5
|
+
import { resolveMstpAuthority } from "./connector-url-boundary.js";
|
|
5
6
|
import { ConversationManager } from "./conversation-manager.js";
|
|
6
7
|
import { clearEnvironmentContext } from "./environment-context.js";
|
|
7
8
|
import { extractHandleFromAddress } from "./handle-utils.js";
|
|
@@ -89,15 +90,6 @@ function deriveNodeName(nodeRef, fromAddress) {
|
|
|
89
90
|
return nodeRef.handle;
|
|
90
91
|
return extractHandleFromAddress(fromAddress);
|
|
91
92
|
}
|
|
92
|
-
function extractConnectorHost(connectorUrl) {
|
|
93
|
-
try {
|
|
94
|
-
const url = new URL(connectorUrl);
|
|
95
|
-
return url.hostname;
|
|
96
|
-
}
|
|
97
|
-
catch {
|
|
98
|
-
return connectorUrl.replace(/^wss?:\/\//, "").replace(/\/.*$/, "");
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
93
|
const DEDUP_WINDOW_MS = 60_000;
|
|
102
94
|
const recentMessages = new Map();
|
|
103
95
|
function isDuplicate(from, content, sentAt) {
|
|
@@ -334,10 +326,14 @@ export const agentNetworkChannel = {
|
|
|
334
326
|
storedOwnerPassportAddress = null;
|
|
335
327
|
clearConversationManager();
|
|
336
328
|
clearConnectorClient();
|
|
329
|
+
initToolConfig(ctx.cfg);
|
|
337
330
|
const { connectorUrl, token } = ctx.account;
|
|
338
331
|
const client = new ConnectorClient(connectorUrl, token);
|
|
339
|
-
const
|
|
340
|
-
|
|
332
|
+
const mstpAuthority = resolveMstpAuthority({
|
|
333
|
+
apiHost: requirePlatformConfig().apiHost,
|
|
334
|
+
connectorUrl,
|
|
335
|
+
});
|
|
336
|
+
const conversationManager = new ConversationManager(client, mstpAuthority);
|
|
341
337
|
const state = {
|
|
342
338
|
client,
|
|
343
339
|
conversationManager,
|
|
@@ -361,7 +357,6 @@ export const agentNetworkChannel = {
|
|
|
361
357
|
ctx.abortSignal.addEventListener("abort", () => {
|
|
362
358
|
client.disconnect();
|
|
363
359
|
}, { once: true });
|
|
364
|
-
initToolConfig(ctx.cfg);
|
|
365
360
|
const networkCfg = extractNetworkConfig(ctx.cfg);
|
|
366
361
|
const updateCheckEnabled = networkCfg?.updateCheck !== false;
|
|
367
362
|
checkForUpdate(updateCheckEnabled).catch(() => { });
|
package/dist/cli-setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-setup.d.ts","sourceRoot":"","sources":["../src/cli-setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-setup.d.ts","sourceRoot":"","sources":["../src/cli-setup.ts"],"names":[],"mappings":"AAyFA,UAAU,eAAe;IACvB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAOD,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAiFD,wBAAsB,KAAK,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmEhE"}
|
package/dist/cli-setup.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readExistingConnectorUrl, writeCredentials } from "./config.js";
|
|
2
|
+
import { ConnectorUrlConfigurationError, resolveConnectorUrlForSetup, } from "./connector-url-boundary.js";
|
|
2
3
|
import { beginBridgeHandoff, completeBridgeHandoff, DEFAULT_IDP_BASE_URL, SetupFlowError, } from "./handoff.js";
|
|
3
4
|
import { DEFAULT_API_HOST, DEFAULT_CONNECTOR_URL, PlatformApiError, } from "./platform-client.js";
|
|
4
5
|
async function serverBridgeHandoffFlow(apiHost, idpBaseUrl, runtime, channelInput) {
|
|
@@ -40,7 +41,22 @@ export async function login(ctx) {
|
|
|
40
41
|
}
|
|
41
42
|
const existingConnectorUrl = await readExistingConnectorUrl();
|
|
42
43
|
const configuredConnectorUrl = typeof ctx.cfg.connectorUrl === "string" ? ctx.cfg.connectorUrl : undefined;
|
|
43
|
-
|
|
44
|
+
let connectorUrl;
|
|
45
|
+
try {
|
|
46
|
+
connectorUrl = resolveConnectorUrlForSetup({
|
|
47
|
+
apiHost,
|
|
48
|
+
existingConnectorUrl,
|
|
49
|
+
configuredConnectorUrl,
|
|
50
|
+
defaultConnectorUrl: DEFAULT_CONNECTOR_URL,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
if (err instanceof ConnectorUrlConfigurationError) {
|
|
55
|
+
ctx.runtime.error(err.message);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
44
60
|
await writeCredentials({ connectorUrl, token: handoff.token }, apiHost, idpBaseUrl);
|
|
45
61
|
ctx.runtime.log(`✓ Connected as @${handoff.agent.handle}`);
|
|
46
62
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const MASONS_CLOUD_TRANSPORT_BY_API_HOST: Record<string, string>;
|
|
2
|
+
export declare const MASONS_CLOUD_IDENTITY_AUTHORITY_HOSTS: Set<string>;
|
|
3
|
+
export declare class ConnectorUrlConfigurationError extends Error {
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function resolveConnectorUrlForSetup(input: {
|
|
7
|
+
apiHost: string;
|
|
8
|
+
existingConnectorUrl?: string;
|
|
9
|
+
configuredConnectorUrl?: string;
|
|
10
|
+
defaultConnectorUrl?: string;
|
|
11
|
+
}): string;
|
|
12
|
+
export declare const MASONS_CLOUD_IDENTITY_AUTHORITY_BY_API_HOST: Record<string, string>;
|
|
13
|
+
export declare function resolveMstpAuthority(input: {
|
|
14
|
+
apiHost: string;
|
|
15
|
+
connectorUrl: string;
|
|
16
|
+
}): string;
|
|
17
|
+
//# sourceMappingURL=connector-url-boundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector-url-boundary.d.ts","sourceRoot":"","sources":["../src/connector-url-boundary.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kCAAkC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGrE,CAAC;AAEF,eAAO,MAAM,qCAAqC,aAGhD,CAAC;AAEH,qBAAa,8BAA+B,SAAQ,KAAK;IAC9C,IAAI,SAAoC;CAClD;AA+CD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,GAAG,MAAM,CA4BT;AAKD,eAAO,MAAM,2CAA2C,EAAE,MAAM,CAC9D,MAAM,EACN,MAAM,CAIP,CAAC;AAaF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,CAOT"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { DEFAULT_CONNECTOR_URL } from "./platform-client.js";
|
|
2
|
+
export const MASONS_CLOUD_TRANSPORT_BY_API_HOST = {
|
|
3
|
+
"api.masons.ai": "connectorapi.masons.ai",
|
|
4
|
+
"preview-api.masons.ai": "preview-connectorapi.masons.ai",
|
|
5
|
+
};
|
|
6
|
+
export const MASONS_CLOUD_IDENTITY_AUTHORITY_HOSTS = new Set([
|
|
7
|
+
"masons.ai",
|
|
8
|
+
"preview.masons.ai",
|
|
9
|
+
]);
|
|
10
|
+
export class ConnectorUrlConfigurationError extends Error {
|
|
11
|
+
name = "ConnectorUrlConfigurationError";
|
|
12
|
+
}
|
|
13
|
+
function normalizeHost(value) {
|
|
14
|
+
const trimmed = value.trim().replace(/\/+$/, "");
|
|
15
|
+
const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed)
|
|
16
|
+
? trimmed
|
|
17
|
+
: `https://${trimmed}`;
|
|
18
|
+
try {
|
|
19
|
+
return new URL(withScheme).hostname.toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return trimmed.toLowerCase();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function parseUrl(value) {
|
|
26
|
+
try {
|
|
27
|
+
return new URL(value);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function defaultMasonsCloudConnectorUrl(apiHost) {
|
|
34
|
+
const transportHost = MASONS_CLOUD_TRANSPORT_BY_API_HOST[normalizeHost(apiHost)];
|
|
35
|
+
return transportHost ? `wss://${transportHost}/gateway` : undefined;
|
|
36
|
+
}
|
|
37
|
+
function healKnownStaleMasonsCloudConnectorUrl(connectorUrl, apiHost) {
|
|
38
|
+
if (!connectorUrl)
|
|
39
|
+
return undefined;
|
|
40
|
+
const transportDefault = defaultMasonsCloudConnectorUrl(apiHost);
|
|
41
|
+
if (!transportDefault)
|
|
42
|
+
return connectorUrl;
|
|
43
|
+
const parsed = parseUrl(connectorUrl);
|
|
44
|
+
if (!parsed)
|
|
45
|
+
return connectorUrl;
|
|
46
|
+
if (!MASONS_CLOUD_IDENTITY_AUTHORITY_HOSTS.has(parsed.hostname.toLowerCase())) {
|
|
47
|
+
return connectorUrl;
|
|
48
|
+
}
|
|
49
|
+
return transportDefault;
|
|
50
|
+
}
|
|
51
|
+
export function resolveConnectorUrlForSetup(input) {
|
|
52
|
+
const cloudDefault = defaultMasonsCloudConnectorUrl(input.apiHost);
|
|
53
|
+
const existingConnectorUrl = healKnownStaleMasonsCloudConnectorUrl(input.existingConnectorUrl, input.apiHost);
|
|
54
|
+
if (existingConnectorUrl)
|
|
55
|
+
return existingConnectorUrl;
|
|
56
|
+
const configuredConnectorUrl = healKnownStaleMasonsCloudConnectorUrl(input.configuredConnectorUrl, input.apiHost);
|
|
57
|
+
if (configuredConnectorUrl)
|
|
58
|
+
return configuredConnectorUrl;
|
|
59
|
+
if (cloudDefault)
|
|
60
|
+
return cloudDefault;
|
|
61
|
+
if (input.defaultConnectorUrl &&
|
|
62
|
+
input.defaultConnectorUrl !== DEFAULT_CONNECTOR_URL) {
|
|
63
|
+
return input.defaultConnectorUrl;
|
|
64
|
+
}
|
|
65
|
+
throw new ConnectorUrlConfigurationError(`connectorUrl is required for self-hosted apiHost "${normalizeHost(input.apiHost)}". Configure the Connector transport URL explicitly; the MASONS preview Connector default is only used for MASONS Cloud accounts.`);
|
|
66
|
+
}
|
|
67
|
+
export const MASONS_CLOUD_IDENTITY_AUTHORITY_BY_API_HOST = {
|
|
68
|
+
"api.masons.ai": "masons.ai",
|
|
69
|
+
"preview-api.masons.ai": "preview.masons.ai",
|
|
70
|
+
};
|
|
71
|
+
export function resolveMstpAuthority(input) {
|
|
72
|
+
const cloudAuthority = MASONS_CLOUD_IDENTITY_AUTHORITY_BY_API_HOST[normalizeHost(input.apiHost)];
|
|
73
|
+
if (cloudAuthority)
|
|
74
|
+
return cloudAuthority;
|
|
75
|
+
const parsed = parseUrl(input.connectorUrl);
|
|
76
|
+
if (parsed)
|
|
77
|
+
return parsed.hostname;
|
|
78
|
+
return input.connectorUrl.replace(/^wss?:\/\//, "").replace(/\/.*$/, "");
|
|
79
|
+
}
|
|
@@ -20,9 +20,9 @@ export interface ConversationSummary {
|
|
|
20
20
|
}
|
|
21
21
|
export declare class ConversationManager {
|
|
22
22
|
private readonly client;
|
|
23
|
-
private readonly
|
|
23
|
+
private readonly mstpAuthority;
|
|
24
24
|
private readonly conversations;
|
|
25
|
-
constructor(client: ConnectorClient,
|
|
25
|
+
constructor(client: ConnectorClient, mstpAuthority: string);
|
|
26
26
|
send(contact: string, content: string, metadata?: Record<string, unknown>): Promise<SendResult>;
|
|
27
27
|
registerInbound(contact: string, address: string): void;
|
|
28
28
|
getContactByAddress(address: string): string | undefined;
|
|
@@ -18,11 +18,11 @@ function normalizeHandleContact(contact) {
|
|
|
18
18
|
}
|
|
19
19
|
export class ConversationManager {
|
|
20
20
|
client;
|
|
21
|
-
|
|
21
|
+
mstpAuthority;
|
|
22
22
|
conversations = new Map();
|
|
23
|
-
constructor(client,
|
|
23
|
+
constructor(client, mstpAuthority) {
|
|
24
24
|
this.client = client;
|
|
25
|
-
this.
|
|
25
|
+
this.mstpAuthority = mstpAuthority;
|
|
26
26
|
}
|
|
27
27
|
async send(contact, content, metadata) {
|
|
28
28
|
const address = this.resolveAddress(contact);
|
|
@@ -112,7 +112,7 @@ export class ConversationManager {
|
|
|
112
112
|
if (entry.contact === normalizedContact)
|
|
113
113
|
return addr;
|
|
114
114
|
}
|
|
115
|
-
return `mstps://${this.
|
|
115
|
+
return `mstps://${this.mstpAuthority}/${normalizedContact}`;
|
|
116
116
|
}
|
|
117
117
|
extractHandle(address) {
|
|
118
118
|
return extractHandleFromAddress(address);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-client.d.ts","sourceRoot":"","sources":["../src/platform-client.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,gBAAgB,0BAA0B,CAAC;
|
|
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;AAMD,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAA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AAC,qBAAqB,CAAC,CAWhC;AAQD,wBAAsB,eAAe,CACnC,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,uBAAuB,CAAC,CAMlC"}
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;AAoDD,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C;AAqRD,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,
|
|
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;AAoDD,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C;AAqRD,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAw0BhD"}
|
package/dist/tools.js
CHANGED
|
@@ -71,7 +71,7 @@ function getSetupOptionsFromToolContext(ctx) {
|
|
|
71
71
|
const cfg = extractSetupConfig(ctx);
|
|
72
72
|
return {
|
|
73
73
|
apiHost: stringValue(cfg.apiHost) ?? defaults.apiHost,
|
|
74
|
-
connectorUrl: stringValue(cfg.connectorUrl)
|
|
74
|
+
connectorUrl: stringValue(cfg.connectorUrl),
|
|
75
75
|
idpBaseUrl: stringValue(cfg.idpBaseUrl) ?? defaults.idpBaseUrl,
|
|
76
76
|
};
|
|
77
77
|
}
|
|
@@ -216,12 +216,23 @@ export function registerTools(api) {
|
|
|
216
216
|
? params.invitedBy
|
|
217
217
|
: undefined;
|
|
218
218
|
const existing = consumeChannelSetupStatus();
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
219
|
+
let result;
|
|
220
|
+
try {
|
|
221
|
+
result = existing
|
|
222
|
+
? existing
|
|
223
|
+
: await startOrGetChannelSetup({
|
|
224
|
+
...getSetupOptionsFromToolContext(ctx),
|
|
225
|
+
invitedBy,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
catch (err) {
|
|
229
|
+
result = {
|
|
230
|
+
status: "failed",
|
|
231
|
+
message: err instanceof Error
|
|
232
|
+
? err.message
|
|
233
|
+
: "Agent Network setup failed.",
|
|
234
|
+
};
|
|
235
|
+
}
|
|
225
236
|
return textResult(formatChannelSetupResult(result));
|
|
226
237
|
},
|
|
227
238
|
}), { name: "masons_setup" });
|
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.2";
|
|
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.2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masons/agent-network",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
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,15 @@
|
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"dev": "tsc --watch",
|
|
27
|
+
"test": "tsc -p test/tsconfig.json && node --test --loader ts-node/esm 'test/**/*.test.ts'",
|
|
28
|
+
"lint": "biome check",
|
|
29
|
+
"format": "biome format --write",
|
|
30
|
+
"prepublishOnly": "bash scripts/check-version.sh && npm run build && npm run test",
|
|
31
|
+
"release": "pnpm publish --access public"
|
|
32
|
+
},
|
|
24
33
|
"files": [
|
|
25
34
|
"dist/",
|
|
26
35
|
"openclaw.plugin.json",
|
|
@@ -65,6 +74,10 @@
|
|
|
65
74
|
"./handoff": {
|
|
66
75
|
"types": "./dist/handoff.d.ts",
|
|
67
76
|
"default": "./dist/handoff.js"
|
|
77
|
+
},
|
|
78
|
+
"./connector-url-boundary": {
|
|
79
|
+
"types": "./dist/connector-url-boundary.d.ts",
|
|
80
|
+
"default": "./dist/connector-url-boundary.js"
|
|
68
81
|
}
|
|
69
82
|
},
|
|
70
83
|
"dependencies": {
|
|
@@ -79,13 +92,5 @@
|
|
|
79
92
|
"@types/ws": "^8",
|
|
80
93
|
"ts-node": "^10",
|
|
81
94
|
"typescript": "^5"
|
|
82
|
-
},
|
|
83
|
-
"scripts": {
|
|
84
|
-
"build": "tsc",
|
|
85
|
-
"dev": "tsc --watch",
|
|
86
|
-
"test": "tsc -p test/tsconfig.json && node --test --loader ts-node/esm 'test/**/*.test.ts'",
|
|
87
|
-
"lint": "biome check",
|
|
88
|
-
"format": "biome format --write",
|
|
89
|
-
"release": "pnpm publish --access public"
|
|
90
95
|
}
|
|
91
|
-
}
|
|
96
|
+
}
|