@masons/agent-network 0.6.1 → 0.6.3

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.
@@ -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;AAoC9D,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,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,oBAAoB,CAAC,CAAC;IAC9B,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CAAC;IACvD,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;IACpE,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IACjE,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;CAC/D;AAED,UAAU,sBAAsB;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACn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nB;AAED,UAAU,sBAAsB;IAC9B,YAAY,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;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 connectorHost = extractConnectorHost(connectorUrl);
340
- const conversationManager = new ConversationManager(client, connectorHost);
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(() => { });
@@ -9,4 +9,9 @@ export declare function resolveConnectorUrlForSetup(input: {
9
9
  configuredConnectorUrl?: string;
10
10
  defaultConnectorUrl?: string;
11
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;
12
17
  //# sourceMappingURL=connector-url-boundary.d.ts.map
@@ -1 +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"}
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;AAgBF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,CAWT"}
@@ -64,3 +64,16 @@ export function resolveConnectorUrlForSetup(input) {
64
64
  }
65
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
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.host;
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 connectorHost;
23
+ private readonly mstpAuthority;
24
24
  private readonly conversations;
25
- constructor(client: ConnectorClient, connectorHost: string);
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
- connectorHost;
21
+ mstpAuthority;
22
22
  conversations = new Map();
23
- constructor(client, connectorHost) {
23
+ constructor(client, mstpAuthority) {
24
24
  this.client = client;
25
- this.connectorHost = connectorHost;
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.connectorHost}/${normalizedContact}`;
115
+ return `mstps://${this.mstpAuthority}/${normalizedContact}`;
116
116
  }
117
117
  extractHandle(address) {
118
118
  return extractHandleFromAddress(address);
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const PLUGIN_VERSION = "0.6.1";
1
+ export declare const PLUGIN_VERSION = "0.6.3";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const PLUGIN_VERSION = "0.6.1";
1
+ export const PLUGIN_VERSION = "0.6.3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@masons/agent-network",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
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)",