@openclaw-cloud/agent-controller 2.5.0 → 3.0.0-beta.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/config-file.js +0 -1
- package/dist/config-file.js.map +1 -1
- package/dist/config.d.ts +0 -7
- package/dist/config.js +2 -11
- package/dist/config.js.map +1 -1
- package/dist/handlers/chat.js +1 -3
- package/dist/handlers/chat.js.map +1 -1
- package/dist/heartbeat.d.ts +1 -2
- package/dist/heartbeat.js +26 -1
- package/dist/heartbeat.js.map +1 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.js +1 -137
- package/dist/index.js.map +1 -1
- package/dist/providers/claude-code/index.d.ts +1 -1
- package/dist/providers/claude-code/index.js +1 -1
- package/dist/providers/claude-code/index.js.map +1 -1
- package/dist/types.d.ts +9 -78
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/handlers/board-handler.d.ts +0 -43
- package/dist/handlers/board-handler.js +0 -377
- package/dist/handlers/board-handler.js.map +0 -1
- package/dist/mcp-client.d.ts +0 -64
- package/dist/mcp-client.js +0 -179
- package/dist/mcp-client.js.map +0 -1
- package/dist/skills/index.d.ts +0 -1
- package/dist/skills/index.js +0 -2
- package/dist/skills/index.js.map +0 -1
package/dist/mcp-client.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
-
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import { logCollector } from './connection.js';
|
|
5
|
-
// Notification schema is shared across the initial connect() and every reconnect()
|
|
6
|
-
// so we install the same handler each time the underlying Client is replaced.
|
|
7
|
-
const BoardEventNotification = z.object({
|
|
8
|
-
method: z.literal('board/event'),
|
|
9
|
-
params: z.object({}).passthrough().optional(),
|
|
10
|
-
});
|
|
11
|
-
/**
|
|
12
|
-
* MCP client for communicating with the openclaw-cloud MCP server.
|
|
13
|
-
* Used by BoardHandler to call board tools and receive board event notifications.
|
|
14
|
-
*
|
|
15
|
-
* The backend stores MCP sessions in Redis with a TTL that is refreshed on each
|
|
16
|
-
* request and on SSE keepalives. If the session disappears server-side (Redis
|
|
17
|
-
* flush during deploy, TTL expiry during long idle, transient network drop where
|
|
18
|
-
* the GET SSE channel never recovered) every subsequent callTool returns
|
|
19
|
-
* `-32001 Session not found`. Without recovery, the agent-controller is stuck
|
|
20
|
-
* with a dead client until process restart.
|
|
21
|
-
*
|
|
22
|
-
* `callTool` and `listTools` transparently re-establish the session on
|
|
23
|
-
* `Session not found` and retry exactly once. A mutex prevents concurrent
|
|
24
|
-
* reconnects when many calls fail at the same moment. Persistent failure
|
|
25
|
-
* bubbles up and is handled by the restart-loop.
|
|
26
|
-
*/
|
|
27
|
-
export class McpBoardClient {
|
|
28
|
-
client;
|
|
29
|
-
connected = false;
|
|
30
|
-
onBoardEvent;
|
|
31
|
-
url;
|
|
32
|
-
token;
|
|
33
|
-
reconnectInFlight = null;
|
|
34
|
-
constructor(options) {
|
|
35
|
-
this.url = options.url;
|
|
36
|
-
this.token = options.token;
|
|
37
|
-
this.client = new Client({ name: 'agent-controller', version: '1.0.0' }, { capabilities: {} });
|
|
38
|
-
}
|
|
39
|
-
setEventHandler(handler) {
|
|
40
|
-
this.onBoardEvent = handler;
|
|
41
|
-
}
|
|
42
|
-
async connect() {
|
|
43
|
-
const transport = new StreamableHTTPClientTransport(new URL(this.url), {
|
|
44
|
-
requestInit: {
|
|
45
|
-
headers: { Authorization: `Bearer ${this.token}` },
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
await this.client.connect(transport);
|
|
49
|
-
this.connected = true;
|
|
50
|
-
this.installNotificationHandler();
|
|
51
|
-
console.log('[mcp] Client connected to', this.url);
|
|
52
|
-
}
|
|
53
|
-
async disconnect() {
|
|
54
|
-
if (this.connected) {
|
|
55
|
-
try {
|
|
56
|
-
await this.client.close();
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
// Ignore close errors
|
|
60
|
-
}
|
|
61
|
-
this.connected = false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
async callTool(name, args = {}) {
|
|
65
|
-
if (!this.connected)
|
|
66
|
-
throw new Error('MCP client not connected');
|
|
67
|
-
try {
|
|
68
|
-
return (await this.client.callTool({ name, arguments: args }));
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
if (!this.isSessionLost(err))
|
|
72
|
-
throw err;
|
|
73
|
-
await this.handleSessionLost(err, { tool: name });
|
|
74
|
-
return (await this.client.callTool({ name, arguments: args }));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
async listTools() {
|
|
78
|
-
if (!this.connected)
|
|
79
|
-
throw new Error('MCP client not connected');
|
|
80
|
-
try {
|
|
81
|
-
const result = await this.client.listTools();
|
|
82
|
-
return result.tools.map((t) => t.name);
|
|
83
|
-
}
|
|
84
|
-
catch (err) {
|
|
85
|
-
if (!this.isSessionLost(err))
|
|
86
|
-
throw err;
|
|
87
|
-
await this.handleSessionLost(err, { tool: 'listTools' });
|
|
88
|
-
const result = await this.client.listTools();
|
|
89
|
-
return result.tools.map((t) => t.name);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
isConnected() {
|
|
93
|
-
return this.connected;
|
|
94
|
-
}
|
|
95
|
-
// ---------------------------------------------------------------------------
|
|
96
|
-
// Reconnect / recovery internals
|
|
97
|
-
// ---------------------------------------------------------------------------
|
|
98
|
-
/**
|
|
99
|
-
* Match either an `McpError` carrying `code: -32001` or a generic Error whose
|
|
100
|
-
* message contains the JSON-RPC text / HTTP 404 status from the SDK transport.
|
|
101
|
-
*/
|
|
102
|
-
isSessionLost(err) {
|
|
103
|
-
if (err &&
|
|
104
|
-
typeof err === 'object' &&
|
|
105
|
-
'code' in err &&
|
|
106
|
-
err.code === -32001) {
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
110
|
-
return /-32001|Session not found|HTTP 404/i.test(msg);
|
|
111
|
-
}
|
|
112
|
-
async handleSessionLost(err, ctx) {
|
|
113
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
114
|
-
logCollector?.push('mcp_session_lost', 'warn', `Reconnecting after: ${message}`, ctx);
|
|
115
|
-
await this.reconnect();
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Mutex-guarded reconnect. Concurrent callers all await the same in-flight
|
|
119
|
-
* promise so a burst of failed callTool invocations triggers exactly one
|
|
120
|
-
* fresh transport+session, not N. Capped at a single retry per failure —
|
|
121
|
-
* if the retry also fails, the error propagates and the supervising
|
|
122
|
-
* restart-loop takes over.
|
|
123
|
-
*/
|
|
124
|
-
async reconnect() {
|
|
125
|
-
if (this.reconnectInFlight) {
|
|
126
|
-
return this.reconnectInFlight;
|
|
127
|
-
}
|
|
128
|
-
this.reconnectInFlight = this.performReconnect().finally(() => {
|
|
129
|
-
this.reconnectInFlight = null;
|
|
130
|
-
});
|
|
131
|
-
return this.reconnectInFlight;
|
|
132
|
-
}
|
|
133
|
-
async performReconnect() {
|
|
134
|
-
// Best-effort close — transport may already be dead.
|
|
135
|
-
try {
|
|
136
|
-
await this.client.close();
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
// ignored
|
|
140
|
-
}
|
|
141
|
-
// The SDK transport caches sessionId per instance; we must replace both
|
|
142
|
-
// the Client and the StreamableHTTPClientTransport, not reuse them.
|
|
143
|
-
this.client = new Client({ name: 'agent-controller', version: '1.0.0' }, { capabilities: {} });
|
|
144
|
-
const transport = new StreamableHTTPClientTransport(new URL(this.url), {
|
|
145
|
-
requestInit: {
|
|
146
|
-
headers: { Authorization: `Bearer ${this.token}` },
|
|
147
|
-
},
|
|
148
|
-
});
|
|
149
|
-
await this.client.connect(transport);
|
|
150
|
-
this.connected = true;
|
|
151
|
-
this.installNotificationHandler();
|
|
152
|
-
let toolCount;
|
|
153
|
-
try {
|
|
154
|
-
const result = await this.client.listTools();
|
|
155
|
-
toolCount = result.tools.length;
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
// Tool count is informational only — don't fail the reconnect over it.
|
|
159
|
-
}
|
|
160
|
-
logCollector?.push('mcp_reconnected', 'info', 'MCP session re-established', {
|
|
161
|
-
url: this.url,
|
|
162
|
-
tools: toolCount,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Notification handler is registered on the Client instance, so we must
|
|
167
|
-
* re-install it every time we replace that instance during reconnect.
|
|
168
|
-
* Listens for `board/event` notifications dispatched by the backend's
|
|
169
|
-
* McpSessionManager.
|
|
170
|
-
*/
|
|
171
|
-
installNotificationHandler() {
|
|
172
|
-
this.client.setNotificationHandler(BoardEventNotification, (notification) => {
|
|
173
|
-
if (this.onBoardEvent && notification.params) {
|
|
174
|
-
this.onBoardEvent(notification.params);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
//# sourceMappingURL=mcp-client.js.map
|
package/dist/mcp-client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-client.js","sourceRoot":"","sources":["../src/mcp-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAY/C,mFAAmF;AACnF,8EAA8E;AAC9E,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,WAAW,EAA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AAC;IACL,CAAC;IAED;;;;;OAKG;IACK,0BAA0B;QAChC,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,sBAAsB,EAAE,CAAC,YAAY,EAAE,EAAE;YAC1E,IAAI,IAAI,CAAC,YAAY,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;gBAC7C,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,MAAiC,CAAC,CAAC;YACpE,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/skills/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/skills/index.js
DELETED
package/dist/skills/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":""}
|