@masons/agent-network 0.5.30 → 0.5.31
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/broker/entry.d.ts +8 -0
- package/dist/broker/entry.d.ts.map +1 -1
- package/dist/broker/entry.js +67 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/broker/entry.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { type BrokerLogger } from "./logger.js";
|
|
2
2
|
import type { RuntimeEndpointPort } from "./runtime-endpoint-port.js";
|
|
3
|
+
interface ResolvedCredentials {
|
|
4
|
+
accountId: string;
|
|
5
|
+
connectorUrl: string;
|
|
6
|
+
token: string;
|
|
7
|
+
apiHost: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function resolveCredentialsFromFile(filePath: string, accountId: string, envApiHost: string | undefined): Promise<ResolvedCredentials>;
|
|
3
10
|
export declare function buildApiPort(apiHost: string, runtimeKey: string, logger: BrokerLogger): RuntimeEndpointPort;
|
|
4
11
|
export declare function main(): Promise<void>;
|
|
12
|
+
export {};
|
|
5
13
|
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/broker/entry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/broker/entry.ts"],"names":[],"mappings":"AA0EA,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,aAAa,CAAC;AAEpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAItE,UAAU,mBAAmB;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAUD,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CA8F9B;AAyDD,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,YAAY,GACnB,mBAAmB,CAkErB;AAYD,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAgD1C"}
|
package/dist/broker/entry.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
1
2
|
import { pathToFileURL } from "node:url";
|
|
2
3
|
import { readConfig } from "../config-fs.js";
|
|
3
4
|
import { DEFAULT_API_HOST } from "../platform-client.js";
|
|
@@ -7,7 +8,63 @@ import { ConnectorWS } from "./connector-ws.js";
|
|
|
7
8
|
import { createBrokerLogger } from "./logger.js";
|
|
8
9
|
import { resolveBrokerPaths } from "./paths.js";
|
|
9
10
|
const DEFAULT_ACCOUNT_ID = "default";
|
|
10
|
-
async function
|
|
11
|
+
export async function resolveCredentialsFromFile(filePath, accountId, envApiHost) {
|
|
12
|
+
let raw;
|
|
13
|
+
try {
|
|
14
|
+
raw = await readFile(filePath, "utf8");
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
const code = err.code;
|
|
18
|
+
if (code === "ENOENT") {
|
|
19
|
+
throw new Error(`MASONS_BROKER_CREDENTIALS_FILE points to non-existent path: ${filePath}`);
|
|
20
|
+
}
|
|
21
|
+
throw new Error(`failed to read MASONS_BROKER_CREDENTIALS_FILE at ${filePath}: ` +
|
|
22
|
+
(err instanceof Error ? err.message : String(err)));
|
|
23
|
+
}
|
|
24
|
+
let parsed;
|
|
25
|
+
try {
|
|
26
|
+
parsed = JSON.parse(raw);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw new Error(`MASONS_BROKER_CREDENTIALS_FILE at ${filePath} is not valid JSON: ` +
|
|
30
|
+
(err instanceof Error ? err.message : String(err)));
|
|
31
|
+
}
|
|
32
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
33
|
+
throw new Error(`MASONS_BROKER_CREDENTIALS_FILE at ${filePath}: top-level must be an object`);
|
|
34
|
+
}
|
|
35
|
+
const accounts = parsed.accounts;
|
|
36
|
+
if (typeof accounts !== "object" ||
|
|
37
|
+
accounts === null ||
|
|
38
|
+
Array.isArray(accounts)) {
|
|
39
|
+
throw new Error(`MASONS_BROKER_CREDENTIALS_FILE at ${filePath}: missing or invalid "accounts" object`);
|
|
40
|
+
}
|
|
41
|
+
const accountRaw = accounts[accountId];
|
|
42
|
+
if (typeof accountRaw !== "object" ||
|
|
43
|
+
accountRaw === null ||
|
|
44
|
+
Array.isArray(accountRaw)) {
|
|
45
|
+
const available = Object.keys(accounts).join(", ") || "<none>";
|
|
46
|
+
throw new Error(`MASONS_BROKER_CREDENTIALS_FILE at ${filePath}: account "${accountId}" not found (available: ${available})`);
|
|
47
|
+
}
|
|
48
|
+
const acct = accountRaw;
|
|
49
|
+
const connectorUrl = typeof acct.connectorUrl === "string" ? acct.connectorUrl : null;
|
|
50
|
+
const token = typeof acct.token === "string" ? acct.token : null;
|
|
51
|
+
if (!connectorUrl) {
|
|
52
|
+
throw new Error(`MASONS_BROKER_CREDENTIALS_FILE at ${filePath}: account "${accountId}" missing required field "connectorUrl"`);
|
|
53
|
+
}
|
|
54
|
+
if (!token) {
|
|
55
|
+
throw new Error(`MASONS_BROKER_CREDENTIALS_FILE at ${filePath}: account "${accountId}" missing required field "token"`);
|
|
56
|
+
}
|
|
57
|
+
if (acct.apiHost !== undefined && typeof acct.apiHost !== "string") {
|
|
58
|
+
throw new Error(`MASONS_BROKER_CREDENTIALS_FILE at ${filePath}: account "${accountId}" optional field "apiHost" must be a string when present`);
|
|
59
|
+
}
|
|
60
|
+
if (acct.handle !== undefined && typeof acct.handle !== "string") {
|
|
61
|
+
throw new Error(`MASONS_BROKER_CREDENTIALS_FILE at ${filePath}: account "${accountId}" optional field "handle" must be a string when present`);
|
|
62
|
+
}
|
|
63
|
+
const apiHost = envApiHost ??
|
|
64
|
+
(typeof acct.apiHost === "string" ? acct.apiHost : DEFAULT_API_HOST);
|
|
65
|
+
return { accountId, connectorUrl, token, apiHost };
|
|
66
|
+
}
|
|
67
|
+
async function resolveCredentialsFromOpenClawConfig(accountId, envApiHost) {
|
|
11
68
|
const config = await readConfig();
|
|
12
69
|
const channels = config.channels;
|
|
13
70
|
const network = channels?.["agent-network"];
|
|
@@ -19,10 +76,18 @@ async function resolveCredentials(accountId, envApiHost) {
|
|
|
19
76
|
const token = typeof account?.token === "string" ? account.token : null;
|
|
20
77
|
if (!connectorUrl || !token) {
|
|
21
78
|
throw new Error(`agent-network credentials missing for account "${accountId}"; ` +
|
|
22
|
-
"run setup before lazy-spawning the broker"
|
|
79
|
+
"run setup before lazy-spawning the broker " +
|
|
80
|
+
"(or set MASONS_BROKER_CREDENTIALS_FILE for Plugin hosts)");
|
|
23
81
|
}
|
|
24
82
|
return { accountId, connectorUrl, token, apiHost };
|
|
25
83
|
}
|
|
84
|
+
async function resolveCredentials(accountId, envApiHost) {
|
|
85
|
+
const credentialsFile = process.env.MASONS_BROKER_CREDENTIALS_FILE;
|
|
86
|
+
if (credentialsFile) {
|
|
87
|
+
return resolveCredentialsFromFile(credentialsFile, accountId, envApiHost);
|
|
88
|
+
}
|
|
89
|
+
return resolveCredentialsFromOpenClawConfig(accountId, envApiHost);
|
|
90
|
+
}
|
|
26
91
|
export function buildApiPort(apiHost, runtimeKey, logger) {
|
|
27
92
|
return {
|
|
28
93
|
async register(params) {
|
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.31";
|
|
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.31";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masons/agent-network",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.31",
|
|
4
4
|
"description": "MASONS Agent Network — connects agent runtimes to the Agent Network over MSTP. Ships an OpenClaw channel plugin (root export) and subpath exports consumed by the Claude Code plugin today (planned: Codex and future hosts).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "MASONS.ai <hello@masons.ai> (https://masons.ai)",
|