@masons/agent-network 0.1.5
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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/channel.d.ts +63 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.js +182 -0
- package/dist/cli-setup.d.ts +39 -0
- package/dist/cli-setup.d.ts.map +1 -0
- package/dist/cli-setup.js +146 -0
- package/dist/config-schema.d.ts +7 -0
- package/dist/config-schema.d.ts.map +1 -0
- package/dist/config-schema.js +9 -0
- package/dist/config.d.ts +105 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +245 -0
- package/dist/connector-client.d.ts +65 -0
- package/dist/connector-client.d.ts.map +1 -0
- package/dist/connector-client.js +288 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +5 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/platform-client.d.ts +113 -0
- package/dist/platform-client.d.ts.map +1 -0
- package/dist/platform-client.js +163 -0
- package/dist/plugin.d.ts +27 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +46 -0
- package/dist/tools.d.ts +46 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +301 -0
- package/dist/types.d.ts +66 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +32 -0
- package/openclaw.plugin.json +16 -0
- package/package.json +78 -0
- package/skills/agent-network/SKILL.md +162 -0
- package/skills/agent-network/references/maintenance.md +61 -0
- package/skills/agent-network/references/troubleshooting.md +34 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MASONS Platform API client.
|
|
3
|
+
*
|
|
4
|
+
* Pure HTTP functions wrapping the setup and connection API endpoints.
|
|
5
|
+
* Zero platform dependencies — only global fetch.
|
|
6
|
+
*
|
|
7
|
+
* Used by:
|
|
8
|
+
* - cli-setup.ts (CLI path: configureInteractive)
|
|
9
|
+
* - tools.ts (LLM path: tool execute functions)
|
|
10
|
+
*/
|
|
11
|
+
/** Default API host. */
|
|
12
|
+
export declare const DEFAULT_API_HOST = "preview-platform.masons.ai";
|
|
13
|
+
export interface PlatformClientConfig {
|
|
14
|
+
apiHost: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class PlatformApiError extends Error {
|
|
17
|
+
readonly status: number;
|
|
18
|
+
readonly code: string;
|
|
19
|
+
constructor(status: number, code: string, message: string);
|
|
20
|
+
}
|
|
21
|
+
/** HTTP 428 — user hasn't authorized the setup code yet. Keep polling. */
|
|
22
|
+
export declare class SetupPendingError extends PlatformApiError {
|
|
23
|
+
constructor(message?: string);
|
|
24
|
+
}
|
|
25
|
+
/** HTTP 410 — setup token expired or not found. Must start over. */
|
|
26
|
+
export declare class SetupExpiredError extends PlatformApiError {
|
|
27
|
+
constructor(message?: string);
|
|
28
|
+
}
|
|
29
|
+
export interface InitSetupResponse {
|
|
30
|
+
setup_code: string;
|
|
31
|
+
setup_token: string;
|
|
32
|
+
verification_uri: string;
|
|
33
|
+
expires_in: number;
|
|
34
|
+
interval: number;
|
|
35
|
+
}
|
|
36
|
+
export interface PollSetupResponse {
|
|
37
|
+
status: "authorized";
|
|
38
|
+
setup_token: string;
|
|
39
|
+
expires_in: number;
|
|
40
|
+
}
|
|
41
|
+
export interface AgentInfo {
|
|
42
|
+
id: string;
|
|
43
|
+
handle: string;
|
|
44
|
+
address: string;
|
|
45
|
+
deliveryMode: string;
|
|
46
|
+
createdAt: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ListAgentsResponse {
|
|
49
|
+
agents: AgentInfo[];
|
|
50
|
+
}
|
|
51
|
+
export interface OnboardResponse {
|
|
52
|
+
agentId: string;
|
|
53
|
+
handle: string;
|
|
54
|
+
address: string;
|
|
55
|
+
connectorUrl: string;
|
|
56
|
+
token: string;
|
|
57
|
+
}
|
|
58
|
+
/** Same shape as OnboardResponse. */
|
|
59
|
+
export type ReconnectResponse = OnboardResponse;
|
|
60
|
+
export interface RequestConnectionResponse {
|
|
61
|
+
requestIds: string[];
|
|
62
|
+
status: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* `POST /setup/init` — Start Device Code Flow.
|
|
66
|
+
*
|
|
67
|
+
* Public endpoint (no auth). Returns a setup code for the user to enter
|
|
68
|
+
* in their browser, plus a setup token for subsequent API calls.
|
|
69
|
+
*/
|
|
70
|
+
export declare function initSetup(cfg: PlatformClientConfig): Promise<InitSetupResponse>;
|
|
71
|
+
/**
|
|
72
|
+
* `POST /setup/poll` — Poll for user authorization.
|
|
73
|
+
*
|
|
74
|
+
* Public endpoint. The setup token is sent in the request body (not header).
|
|
75
|
+
*
|
|
76
|
+
* @throws {SetupPendingError} 428 — user hasn't authorized yet
|
|
77
|
+
* @throws {SetupExpiredError} 410 — token expired, start over
|
|
78
|
+
*/
|
|
79
|
+
export declare function pollSetup(cfg: PlatformClientConfig, setupToken: string): Promise<PollSetupResponse>;
|
|
80
|
+
/**
|
|
81
|
+
* `GET /me/agents` — List authenticated user's agents.
|
|
82
|
+
*
|
|
83
|
+
* Requires Setup Token in Authorization header.
|
|
84
|
+
*/
|
|
85
|
+
export declare function listAgents(cfg: PlatformClientConfig, setupToken: string): Promise<ListAgentsResponse>;
|
|
86
|
+
/**
|
|
87
|
+
* `POST /onboard` — Create a new agent identity.
|
|
88
|
+
*
|
|
89
|
+
* Requires Setup Token in Authorization header.
|
|
90
|
+
* Returns credentials for Gateway connection and API access.
|
|
91
|
+
*/
|
|
92
|
+
export declare function onboard(cfg: PlatformClientConfig, setupToken: string, params: {
|
|
93
|
+
handle: string;
|
|
94
|
+
name?: string;
|
|
95
|
+
}): Promise<OnboardResponse>;
|
|
96
|
+
/**
|
|
97
|
+
* `POST /agents/{id}/reconnect` — Rotate API key for an existing agent.
|
|
98
|
+
*
|
|
99
|
+
* Requires Setup Token in Authorization header.
|
|
100
|
+
* Returns fresh credentials (same shape as onboard).
|
|
101
|
+
*/
|
|
102
|
+
export declare function reconnect(cfg: PlatformClientConfig, setupToken: string, agentId: string): Promise<ReconnectResponse>;
|
|
103
|
+
/**
|
|
104
|
+
* `POST /connections/request` — Send a connection request.
|
|
105
|
+
*
|
|
106
|
+
* Requires API Key in Authorization header.
|
|
107
|
+
* Idempotent: returns 201 with empty requestIds if already connected.
|
|
108
|
+
*/
|
|
109
|
+
export declare function requestConnection(cfg: PlatformClientConfig, apiKey: string, params: {
|
|
110
|
+
targetHandle: string;
|
|
111
|
+
variants: ("distribute" | "receive")[];
|
|
112
|
+
}): Promise<RequestConnectionResponse>;
|
|
113
|
+
//# sourceMappingURL=platform-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-client.d.ts","sourceRoot":"","sources":["../src/platform-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,wBAAwB;AACxB,eAAO,MAAM,gBAAgB,+BAA+B,CAAC;AAE7D,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;AAED,0EAA0E;AAC1E,qBAAa,iBAAkB,SAAQ,gBAAgB;gBACzC,OAAO,SAA0B;CAI9C;AAED,oEAAoE;AACpE,qBAAa,iBAAkB,SAAQ,gBAAgB;gBACzC,OAAO,SAAwB;CAI5C;AAMD,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,YAAY,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qCAAqC;AACrC,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEhD,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AA0BD;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,GAAG,EAAE,oBAAoB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAO5B;AAED;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAC7B,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,CAAC,CAQ5B;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,kBAAkB,CAAC,CAM7B;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAC3B,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC,OAAO,CAAC,eAAe,CAAC,CAW1B;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,GAAG,EAAE,oBAAoB,EACzB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,CAa5B;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,oBAAoB,EACzB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,CAAC,YAAY,GAAG,SAAS,CAAC,EAAE,CAAA;CAAE,GACvE,OAAO,CAAC,yBAAyB,CAAC,CAWpC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MASONS Platform API client.
|
|
3
|
+
*
|
|
4
|
+
* Pure HTTP functions wrapping the setup and connection API endpoints.
|
|
5
|
+
* Zero platform dependencies — only global fetch.
|
|
6
|
+
*
|
|
7
|
+
* Used by:
|
|
8
|
+
* - cli-setup.ts (CLI path: configureInteractive)
|
|
9
|
+
* - tools.ts (LLM path: tool execute functions)
|
|
10
|
+
*/
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Config
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
/** Default API host. */
|
|
15
|
+
export const DEFAULT_API_HOST = "preview-platform.masons.ai";
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Error classes
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
export class PlatformApiError extends Error {
|
|
20
|
+
status;
|
|
21
|
+
code;
|
|
22
|
+
constructor(status, code, message) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.status = status;
|
|
25
|
+
this.code = code;
|
|
26
|
+
this.name = "PlatformApiError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** HTTP 428 — user hasn't authorized the setup code yet. Keep polling. */
|
|
30
|
+
export class SetupPendingError extends PlatformApiError {
|
|
31
|
+
constructor(message = "Authorization pending") {
|
|
32
|
+
super(428, "authorization_pending", message);
|
|
33
|
+
this.name = "SetupPendingError";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** HTTP 410 — setup token expired or not found. Must start over. */
|
|
37
|
+
export class SetupExpiredError extends PlatformApiError {
|
|
38
|
+
constructor(message = "Setup token expired") {
|
|
39
|
+
super(410, "expired_token", message);
|
|
40
|
+
this.name = "SetupExpiredError";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// Internal helpers
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
function baseUrl(cfg) {
|
|
47
|
+
return `https://${cfg.apiHost}/openclaw/v1`;
|
|
48
|
+
}
|
|
49
|
+
async function handleError(res) {
|
|
50
|
+
const body = (await res.json().catch(() => ({})));
|
|
51
|
+
const code = typeof body.error === "string" ? body.error : "unknown";
|
|
52
|
+
const message = typeof body.message === "string" ? body.message : res.statusText;
|
|
53
|
+
if (res.status === 428)
|
|
54
|
+
throw new SetupPendingError(message);
|
|
55
|
+
if (res.status === 410)
|
|
56
|
+
throw new SetupExpiredError(message);
|
|
57
|
+
throw new PlatformApiError(res.status, code, message);
|
|
58
|
+
}
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// API functions
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
/**
|
|
63
|
+
* `POST /setup/init` — Start Device Code Flow.
|
|
64
|
+
*
|
|
65
|
+
* Public endpoint (no auth). Returns a setup code for the user to enter
|
|
66
|
+
* in their browser, plus a setup token for subsequent API calls.
|
|
67
|
+
*/
|
|
68
|
+
export async function initSetup(cfg) {
|
|
69
|
+
const res = await fetch(`${baseUrl(cfg)}/setup/init`, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: { "Content-Type": "application/json" },
|
|
72
|
+
});
|
|
73
|
+
if (!res.ok)
|
|
74
|
+
return handleError(res);
|
|
75
|
+
return (await res.json());
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* `POST /setup/poll` — Poll for user authorization.
|
|
79
|
+
*
|
|
80
|
+
* Public endpoint. The setup token is sent in the request body (not header).
|
|
81
|
+
*
|
|
82
|
+
* @throws {SetupPendingError} 428 — user hasn't authorized yet
|
|
83
|
+
* @throws {SetupExpiredError} 410 — token expired, start over
|
|
84
|
+
*/
|
|
85
|
+
export async function pollSetup(cfg, setupToken) {
|
|
86
|
+
const res = await fetch(`${baseUrl(cfg)}/setup/poll`, {
|
|
87
|
+
method: "POST",
|
|
88
|
+
headers: { "Content-Type": "application/json" },
|
|
89
|
+
body: JSON.stringify({ setup_token: setupToken }),
|
|
90
|
+
});
|
|
91
|
+
if (!res.ok)
|
|
92
|
+
return handleError(res);
|
|
93
|
+
return (await res.json());
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* `GET /me/agents` — List authenticated user's agents.
|
|
97
|
+
*
|
|
98
|
+
* Requires Setup Token in Authorization header.
|
|
99
|
+
*/
|
|
100
|
+
export async function listAgents(cfg, setupToken) {
|
|
101
|
+
const res = await fetch(`${baseUrl(cfg)}/me/agents`, {
|
|
102
|
+
headers: { Authorization: `Bearer ${setupToken}` },
|
|
103
|
+
});
|
|
104
|
+
if (!res.ok)
|
|
105
|
+
return handleError(res);
|
|
106
|
+
return (await res.json());
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* `POST /onboard` — Create a new agent identity.
|
|
110
|
+
*
|
|
111
|
+
* Requires Setup Token in Authorization header.
|
|
112
|
+
* Returns credentials for Gateway connection and API access.
|
|
113
|
+
*/
|
|
114
|
+
export async function onboard(cfg, setupToken, params) {
|
|
115
|
+
const res = await fetch(`${baseUrl(cfg)}/onboard`, {
|
|
116
|
+
method: "POST",
|
|
117
|
+
headers: {
|
|
118
|
+
"Content-Type": "application/json",
|
|
119
|
+
Authorization: `Bearer ${setupToken}`,
|
|
120
|
+
},
|
|
121
|
+
body: JSON.stringify(params),
|
|
122
|
+
});
|
|
123
|
+
if (!res.ok)
|
|
124
|
+
return handleError(res);
|
|
125
|
+
return (await res.json());
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* `POST /agents/{id}/reconnect` — Rotate API key for an existing agent.
|
|
129
|
+
*
|
|
130
|
+
* Requires Setup Token in Authorization header.
|
|
131
|
+
* Returns fresh credentials (same shape as onboard).
|
|
132
|
+
*/
|
|
133
|
+
export async function reconnect(cfg, setupToken, agentId) {
|
|
134
|
+
const res = await fetch(`${baseUrl(cfg)}/agents/${encodeURIComponent(agentId)}/reconnect`, {
|
|
135
|
+
method: "POST",
|
|
136
|
+
headers: {
|
|
137
|
+
"Content-Type": "application/json",
|
|
138
|
+
Authorization: `Bearer ${setupToken}`,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
if (!res.ok)
|
|
142
|
+
return handleError(res);
|
|
143
|
+
return (await res.json());
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* `POST /connections/request` — Send a connection request.
|
|
147
|
+
*
|
|
148
|
+
* Requires API Key in Authorization header.
|
|
149
|
+
* Idempotent: returns 201 with empty requestIds if already connected.
|
|
150
|
+
*/
|
|
151
|
+
export async function requestConnection(cfg, apiKey, params) {
|
|
152
|
+
const res = await fetch(`${baseUrl(cfg)}/connections/request`, {
|
|
153
|
+
method: "POST",
|
|
154
|
+
headers: {
|
|
155
|
+
"Content-Type": "application/json",
|
|
156
|
+
Authorization: `Bearer ${apiKey}`,
|
|
157
|
+
},
|
|
158
|
+
body: JSON.stringify(params),
|
|
159
|
+
});
|
|
160
|
+
if (!res.ok)
|
|
161
|
+
return handleError(res);
|
|
162
|
+
return (await res.json());
|
|
163
|
+
}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface OpenClawPluginApi {
|
|
2
|
+
registerChannel(opts: {
|
|
3
|
+
plugin: unknown;
|
|
4
|
+
}): void;
|
|
5
|
+
registerTool(tool: unknown, opts?: {
|
|
6
|
+
optional?: boolean;
|
|
7
|
+
}): void;
|
|
8
|
+
}
|
|
9
|
+
declare const plugin: {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
configSchema: {
|
|
14
|
+
type: "object";
|
|
15
|
+
additionalProperties: boolean;
|
|
16
|
+
properties: {
|
|
17
|
+
apiHost: {
|
|
18
|
+
type: "string";
|
|
19
|
+
description: string;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
register(api: OpenClawPluginApi): void;
|
|
25
|
+
};
|
|
26
|
+
export default plugin;
|
|
27
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AASA,UAAU,iBAAiB;IACzB,eAAe,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CAClE;AAED,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;kBAsBI,iBAAiB;CAmBhC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// OpenClaw Plugin entry point.
|
|
2
|
+
// Loaded by OpenClaw Gateway via the "openclaw.extensions" field in package.json.
|
|
3
|
+
// NOT imported by index.ts to avoid pulling ws/typebox into Next.js app bundles.
|
|
4
|
+
import { mstpChannel } from "./channel.js";
|
|
5
|
+
import { configureInteractive } from "./cli-setup.js";
|
|
6
|
+
import { registerMstpTools } from "./tools.js";
|
|
7
|
+
const plugin = {
|
|
8
|
+
id: "agent-network",
|
|
9
|
+
name: "MSTP",
|
|
10
|
+
description: "Connect your Agent to the agent network for real-time communication",
|
|
11
|
+
// configSchema MUST be on the plugin export object (not just openclaw.plugin.json).
|
|
12
|
+
// Gateway validates user config via AJV against this schema BEFORE calling register().
|
|
13
|
+
// Missing configSchema → register() is never called (silent skip, no error logged).
|
|
14
|
+
// Keep in sync with openclaw.plugin.json.
|
|
15
|
+
configSchema: {
|
|
16
|
+
type: "object",
|
|
17
|
+
additionalProperties: false,
|
|
18
|
+
properties: {
|
|
19
|
+
apiHost: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "MASONS Platform API host",
|
|
22
|
+
default: "preview-platform.masons.ai",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
register(api) {
|
|
27
|
+
// Register tools FIRST — they must be available even when the channel
|
|
28
|
+
// has no credentials yet (setup flow needs these tools to GET credentials).
|
|
29
|
+
registerMstpTools(api);
|
|
30
|
+
// Channel registration may fail if no credentials are configured yet.
|
|
31
|
+
// This is expected on first run — the user will use the setup tools above
|
|
32
|
+
// to obtain credentials, then restart to activate the channel.
|
|
33
|
+
try {
|
|
34
|
+
api.registerChannel({
|
|
35
|
+
plugin: {
|
|
36
|
+
...mstpChannel,
|
|
37
|
+
setup: { configureInteractive },
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// Silently ignore — channel will be registered after setup + restart.
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
export default plugin;
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM tools — setup, connection, and conversation tools.
|
|
3
|
+
*
|
|
4
|
+
* Registers 7 tools with OpenClaw's Plugin API so the LLM can
|
|
5
|
+
* drive setup, connection requests, and real-time conversations,
|
|
6
|
+
* guided by SKILL.md.
|
|
7
|
+
*
|
|
8
|
+
* Two access patterns:
|
|
9
|
+
* - **HTTP tools** (setup, connection): read config via `requirePlatformConfig()`,
|
|
10
|
+
* call Platform API via `platform-client.ts`.
|
|
11
|
+
* - **WebSocket tools** (conversation): read runtime client via
|
|
12
|
+
* `requireConnectorClient()`, send/receive over the live connection.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
interface ToolContent {
|
|
16
|
+
content: Array<{
|
|
17
|
+
type: "text";
|
|
18
|
+
text: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
interface ToolDefinition {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
parameters: unknown;
|
|
25
|
+
execute: (id: string, params: Record<string, unknown>) => Promise<ToolContent>;
|
|
26
|
+
}
|
|
27
|
+
interface ToolApi {
|
|
28
|
+
registerTool(tool: ToolDefinition, opts?: {
|
|
29
|
+
optional?: boolean;
|
|
30
|
+
}): void;
|
|
31
|
+
}
|
|
32
|
+
/** @internal Reset module state for test isolation. */
|
|
33
|
+
export declare function _resetToolsForTesting(): void;
|
|
34
|
+
/** @internal Override session creation timeout for tests. */
|
|
35
|
+
export declare function _setSessionTimeoutForTesting(ms: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Register MSTP setup and connection tools with the OpenClaw Plugin API.
|
|
38
|
+
*
|
|
39
|
+
* Called from `plugin.ts` during plugin registration. Tools become available
|
|
40
|
+
* to the LLM after the plugin loads. Tools that require config will fail-fast
|
|
41
|
+
* with a clear error if `initToolConfig()` hasn't been called yet (i.e.,
|
|
42
|
+
* `startAccount()` hasn't run).
|
|
43
|
+
*/
|
|
44
|
+
export declare function registerMstpTools(api: ToolApi): void;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA6BH,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,OAAO;IACf,YAAY,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CACzE;AAYD,uDAAuD;AACvD,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C;AAED,6DAA6D;AAC7D,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE7D;AAmGD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAsRpD"}
|