@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/types.d.ts CHANGED
@@ -2,7 +2,6 @@
2
2
  * Centrifugo channel layout:
3
3
  * agent:<agentId> — system commands from backend (deploy, config, backup, etc.)
4
4
  * chat:<agentId> — chat commands (list sessions, history, send)
5
- * board:<workspaceId> — board events (card:entered, card:moved, etc.)
6
5
  * heartbeat:<agentId> — heartbeat publications from agent
7
6
  */
8
7
  export type CommandType = 'diagnostics' | 'restart' | 'deploy' | 'pair' | 'stop' | 'backup' | 'chat_list_sessions' | 'chat_history' | 'chat_send' | 'chat_delete_session' | 'package_install' | 'file_write' | 'file_delete' | 'onboarding_complete' | 'knowledge_sync' | 'self_update' | 'plugin_update' | 'agent_update' | 'telegram_webhook' | 'update_skills' | 'update_config' | 'memory_create_entities' | 'memory_create_relations' | 'memory_add_observations' | 'memory_delete_entities' | 'memory_delete_observations' | 'memory_delete_relations' | 'memory_read_graph' | 'memory_search_nodes' | 'memory_open_nodes';
@@ -23,93 +22,25 @@ export interface GatewayStatus {
23
22
  rpcOk: boolean;
24
23
  pid?: number;
25
24
  }
25
+ export interface InstalledVersions {
26
+ agentController: string;
27
+ agentRuntime?: string;
28
+ plugins?: Array<{
29
+ id: string;
30
+ version: string;
31
+ }>;
32
+ }
26
33
  export interface HeartbeatPayload {
27
34
  type: 'heartbeat';
28
35
  agentId: string;
29
36
  ts: number;
30
37
  version: string;
38
+ versions?: InstalledVersions;
31
39
  metrics: {
32
40
  cpu: number;
33
41
  mem: number;
34
42
  uptime: number;
35
43
  };
36
- boardStatus?: BoardState;
37
44
  gatewayStatus?: GatewayStatus;
38
45
  lastMessageAt?: string | null;
39
46
  }
40
- export interface BoardState {
41
- state: 'idle' | 'claiming' | 'working';
42
- cardId: string | null;
43
- }
44
- export interface BoardEvent {
45
- event: 'card:entered' | 'card:claimed' | 'card:moved' | 'card:commented';
46
- cardId: string;
47
- columnId?: string;
48
- columnName?: string;
49
- title?: string;
50
- description?: string;
51
- priority?: string;
52
- agentId?: string;
53
- fromColumnId?: string;
54
- toColumnId?: string;
55
- authorType?: string;
56
- authorId?: string;
57
- content?: string;
58
- }
59
- /**
60
- * Shape returned by GET /api/agent/board — flat, not wrapped in `{ board: ... }`.
61
- * The endpoint serializes the board object spread with `myColumnIds` at the
62
- * top level (see backend/src/modules/gateway/api/agent/board/get.method.ts).
63
- */
64
- export interface BoardInfo {
65
- id: string;
66
- workspaceId: string;
67
- columns: Array<{
68
- id: string;
69
- name: string;
70
- type: string;
71
- position: number;
72
- cards: Array<{
73
- id: string;
74
- title: string;
75
- description?: string;
76
- priority?: string;
77
- assignedAgentId?: string | null;
78
- createdAt?: string;
79
- }>;
80
- }>;
81
- myColumnIds: string[];
82
- /**
83
- * The card this agent currently has claimed (if any). Used to seed
84
- * `BoardState` on startup BEFORE the first heartbeat fires — without
85
- * this seed the controller would heartbeat `idle` while a CP is still
86
- * active in the DB, and the backend would overwrite the DB to idle.
87
- */
88
- myClaim?: {
89
- cardId: string;
90
- columnId: string | null;
91
- cardProcessingId: string | null;
92
- } | null;
93
- }
94
- export interface CardDetail {
95
- card: {
96
- id: string;
97
- title: string;
98
- description?: string;
99
- priority?: string;
100
- columnId: string;
101
- columnName?: string;
102
- assignedAgentId?: string | null;
103
- };
104
- }
105
- export interface MockAction {
106
- type: 'wait' | 'artifact' | 'comment' | 'result' | 'move';
107
- ms?: number;
108
- body?: Record<string, unknown>;
109
- }
110
- export interface TaskInfo {
111
- cardProcessingId: string;
112
- prompt: string;
113
- workflowSteps: Array<Record<string, unknown>>;
114
- mockActions?: MockAction[];
115
- }
package/dist/types.js CHANGED
@@ -2,7 +2,6 @@
2
2
  * Centrifugo channel layout:
3
3
  * agent:<agentId> — system commands from backend (deploy, config, backup, etc.)
4
4
  * chat:<agentId> — chat commands (list sessions, history, send)
5
- * board:<workspaceId> — board events (card:entered, card:moved, etc.)
6
5
  * heartbeat:<agentId> — heartbeat publications from agent
7
6
  */
8
7
  export {};
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw-cloud/agent-controller",
3
- "version": "2.5.0",
3
+ "version": "3.0.0-beta.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -1,43 +0,0 @@
1
- import type { AgentApi } from '../api.js';
2
- import type { McpBoardClient } from '../mcp-client.js';
3
- import type { BoardState, BoardEvent, BoardInfo } from '../types.js';
4
- export declare class BoardHandler {
5
- private boardState;
6
- private myColumnIds;
7
- private boardId;
8
- private workspaceId;
9
- private currentCardProcessingId;
10
- private api;
11
- private mcpClient;
12
- private mcpToolNames;
13
- private useMcp;
14
- constructor(api: AgentApi, mcpClient?: McpBoardClient);
15
- initialize(): Promise<string | null>;
16
- /**
17
- * Find an MCP tool name matching a path pattern.
18
- * Tool names are generated from method + path: e.g. get__api_agent_board
19
- */
20
- private findTool;
21
- /**
22
- * Try an MCP tool call first; fall back to HTTP if MCP is unavailable or tool not found.
23
- */
24
- private mcpOrHttp;
25
- private getBoard;
26
- private claimCard;
27
- private getTask;
28
- private postResult;
29
- private postArtifact;
30
- private postComment;
31
- private postMove;
32
- onBoardEvent(event: BoardEvent): Promise<void>;
33
- tryClaimCard(cardId: string): Promise<void>;
34
- startTask(cardId: string): Promise<void>;
35
- private executeMockActions;
36
- completeTask(cardId: string): Promise<void>;
37
- private reportResult;
38
- checkQueue(existingData?: BoardInfo): Promise<void>;
39
- getBoardStatus(): BoardState;
40
- getBoardId(): string | null;
41
- /** Whether this handler is using MCP tools (vs HTTP fallback). */
42
- isUsingMcp(): boolean;
43
- }
@@ -1,377 +0,0 @@
1
- import { getProvider } from '../providers/index.js';
2
- import { ClaudeCodeProvider } from '../providers/claude-code/index.js';
3
- import { toErrorMessage } from '../utils/response.js';
4
- import { logCollector } from '../connection.js';
5
- /**
6
- * Try to parse JSON response from MCP tool result.
7
- * Returns the parsed object or throws on error.
8
- */
9
- function parseMcpResult(result, toolName) {
10
- if (result.isError) {
11
- const errText = result.content[0]?.text ?? 'Unknown MCP error';
12
- throw new Error(`MCP tool ${toolName} failed: ${errText}`);
13
- }
14
- const text = result.content[0]?.text;
15
- if (!text)
16
- throw new Error(`MCP tool ${toolName} returned empty result`);
17
- return JSON.parse(text);
18
- }
19
- export class BoardHandler {
20
- boardState = { state: 'idle', cardId: null };
21
- myColumnIds = [];
22
- boardId = null;
23
- workspaceId = null;
24
- currentCardProcessingId = null;
25
- api;
26
- mcpClient = null;
27
- mcpToolNames = [];
28
- useMcp = false;
29
- constructor(api, mcpClient) {
30
- this.api = api;
31
- this.mcpClient = mcpClient ?? null;
32
- }
33
- async initialize() {
34
- try {
35
- // Try to connect MCP client first
36
- if (this.mcpClient) {
37
- try {
38
- await this.mcpClient.connect();
39
- this.mcpToolNames = await this.mcpClient.listTools();
40
- logCollector?.push('board_mcp_tools', 'info', `MCP tools available: ${this.mcpToolNames.join(', ')}`);
41
- this.useMcp = true;
42
- // Set up MCP event handler for board notifications
43
- this.mcpClient.setEventHandler((event) => {
44
- this.onBoardEvent({
45
- event: (event.type ?? event.event),
46
- cardId: event.cardId,
47
- columnId: event.columnId,
48
- }).catch((err) => {
49
- logCollector?.push('board_mcp_event_error', 'error', `MCP event handler error: ${toErrorMessage(err)}`);
50
- });
51
- });
52
- }
53
- catch (err) {
54
- logCollector?.push('board_mcp_fallback', 'error', `MCP connection failed, falling back to HTTP: ${toErrorMessage(err)}`);
55
- this.useMcp = false;
56
- }
57
- }
58
- const data = await this.getBoard();
59
- this.boardId = data.id;
60
- this.workspaceId = data.workspaceId;
61
- this.myColumnIds = data.myColumnIds;
62
- // Seed boardState from any existing claim BEFORE the heartbeat loop
63
- // can read it. Without this, BoardHandler is constructed with
64
- // `boardState={state:'idle'}` and the heartbeat loop (which starts
65
- // synchronously alongside this async initialize()) can fire a
66
- // heartbeat that says `idle` even when the backend already has a
67
- // claim+CP for this agent. The backend then overwrites the DB to
68
- // idle and orphans the card.
69
- if (data.myClaim) {
70
- this.boardState = { state: 'working', cardId: data.myClaim.cardId };
71
- this.currentCardProcessingId = data.myClaim.cardProcessingId;
72
- logCollector?.push('board_state_seeded', 'info', `Board state seeded from existing claim: card=${data.myClaim.cardId}, cp=${data.myClaim.cardProcessingId ?? 'null'}`, { cardId: data.myClaim.cardId, cardProcessingId: data.myClaim.cardProcessingId });
73
- }
74
- logCollector?.push('board_initialized', 'info', `Board initialized: ${this.boardId} (workspace: ${this.workspaceId}), watching ${this.myColumnIds.length} column(s)`);
75
- // Backfill: check for existing unassigned cards in my columns —
76
- // skip when we already have a claim so we don't accidentally try to
77
- // claim a second card while the existing one is still live.
78
- if (!data.myClaim) {
79
- await this.checkQueue(data);
80
- }
81
- // Return workspaceId for channel subscription (board:<workspaceId>)
82
- return this.workspaceId;
83
- }
84
- catch (err) {
85
- logCollector?.push('board_init_error', 'warn', `Board initialization failed: ${toErrorMessage(err)}`);
86
- return null;
87
- }
88
- }
89
- // ─── MCP-aware API methods ──────────────────────────────────────────────
90
- /**
91
- * Find an MCP tool name matching a path pattern.
92
- * Tool names are generated from method + path: e.g. get__api_agent_board
93
- */
94
- findTool(method, pathFragment) {
95
- const prefix = method.toLowerCase() + '_';
96
- return (this.mcpToolNames.find((t) => t.startsWith(prefix) && t.includes(pathFragment.replace(/[^a-zA-Z0-9]/g, '_'))) ?? null);
97
- }
98
- /**
99
- * Try an MCP tool call first; fall back to HTTP if MCP is unavailable or tool not found.
100
- */
101
- async mcpOrHttp(toolName, mcpCall, httpFallback) {
102
- if (this.useMcp && this.mcpClient && toolName) {
103
- return mcpCall(this.mcpClient, toolName);
104
- }
105
- return httpFallback();
106
- }
107
- async getBoard() {
108
- const rawTool = this.findTool('get', 'api_agent_board');
109
- const toolName = rawTool && !rawTool.includes('cards') ? rawTool : null;
110
- return this.mcpOrHttp(toolName, async (client, tool) => parseMcpResult(await client.callTool(tool), tool), () => this.api.get('/api/agent/board'));
111
- }
112
- async claimCard(cardId) {
113
- return this.mcpOrHttp(this.findTool('post', 'agent_board_cards__cardId__claim'), async (client, tool) => {
114
- const result = await client.callTool(tool, { cardId });
115
- // Convert MCP result to Response-like for compatibility
116
- if (result.isError) {
117
- const text = result.content[0]?.text ?? '';
118
- const status = text.includes('409') ? 409 : 500;
119
- return { ok: false, status, text: () => Promise.resolve(text) };
120
- }
121
- return {
122
- ok: true,
123
- status: 200,
124
- text: () => Promise.resolve(result.content[0]?.text ?? ''),
125
- };
126
- }, () => this.api.post(`/api/agent/board/cards/${cardId}/claim`));
127
- }
128
- async getTask(cardId) {
129
- return this.mcpOrHttp(this.findTool('get', 'agent_board_cards__cardId__task'), async (client, tool) => parseMcpResult(await client.callTool(tool, { cardId }), tool), () => this.api.get(`/api/agent/board/cards/${cardId}/task`));
130
- }
131
- async postResult(cardId, body) {
132
- return this.mcpOrHttp(this.findTool('post', 'agent_board_cards__cardId__result'), async (client, tool) => {
133
- const result = await client.callTool(tool, { cardId, body });
134
- if (result.isError) {
135
- throw new Error(`MCP tool ${tool} failed: ${result.content[0]?.text}`);
136
- }
137
- }, async () => {
138
- await this.api.post(`/api/agent/board/cards/${cardId}/result`, body);
139
- });
140
- }
141
- async postArtifact(cardId, body) {
142
- return this.mcpOrHttp(this.findTool('post', 'agent_board_cards__cardId__artifacts'), async (client, tool) => {
143
- await client.callTool(tool, { cardId, body });
144
- }, async () => {
145
- await this.api.post(`/api/agent/board/cards/${cardId}/artifacts`, body);
146
- });
147
- }
148
- async postComment(cardId, body) {
149
- return this.mcpOrHttp(this.findTool('post', 'agent_board_cards__cardId__comments'), async (client, tool) => {
150
- await client.callTool(tool, { cardId, body });
151
- }, async () => {
152
- await this.api.post(`/api/agent/board/cards/${cardId}/comments`, body);
153
- });
154
- }
155
- async postMove(cardId) {
156
- return this.mcpOrHttp(this.findTool('post', 'agent_board_cards__cardId__move'), async (client, tool) => {
157
- await client.callTool(tool, { cardId });
158
- }, async () => {
159
- await this.api.post(`/api/agent/board/cards/${cardId}/move`);
160
- });
161
- }
162
- // ─── Board event handling ────────────────────────────────────────────────
163
- async onBoardEvent(event) {
164
- switch (event.event) {
165
- case 'card:entered':
166
- if (!event.columnId || !this.myColumnIds.includes(event.columnId))
167
- return;
168
- if (this.boardState.state !== 'idle')
169
- return;
170
- // RACE-2: lock state synchronously before any await so concurrent events are rejected
171
- this.boardState = { state: 'claiming', cardId: event.cardId };
172
- await this.tryClaimCard(event.cardId);
173
- break;
174
- case 'card:claimed':
175
- case 'card:moved':
176
- case 'card:commented':
177
- // Info only, ignore
178
- break;
179
- }
180
- }
181
- async tryClaimCard(cardId) {
182
- try {
183
- const res = await this.claimCard(cardId);
184
- if (res.ok) {
185
- this.boardState = { state: 'working', cardId };
186
- logCollector?.push('card_claimed', 'info', `Claimed card: ${cardId}`, { cardId });
187
- await this.startTask(cardId);
188
- }
189
- else if (res.status === 409) {
190
- this.boardState = { state: 'idle', cardId: null };
191
- logCollector?.push('card_claim_skipped', 'info', `Card ${cardId} already claimed or agent busy, skipping`, { cardId });
192
- }
193
- else {
194
- this.boardState = { state: 'idle', cardId: null };
195
- const body = await res.text().catch(() => '');
196
- logCollector?.push('card_claim_error', 'error', `Claim card ${cardId} failed (HTTP ${res.status}): ${body}`, { cardId, status: res.status });
197
- }
198
- }
199
- catch (err) {
200
- this.boardState = { state: 'idle', cardId: null };
201
- logCollector?.push('card_claim_error', 'error', `tryClaimCard error: ${toErrorMessage(err)}`, { cardId });
202
- }
203
- }
204
- async startTask(cardId) {
205
- try {
206
- // Fetch task prompt from backend (includes rendered workflow prompt)
207
- const taskData = await this.getTask(cardId);
208
- this.currentCardProcessingId = taskData.cardProcessingId;
209
- process.env.BOARD_CARD_ID = cardId;
210
- if (taskData.mockActions) {
211
- // Mock path: execute actions directly via board API (no LLM needed)
212
- await this.executeMockActions(cardId, taskData.mockActions);
213
- }
214
- else {
215
- // Real path: send prompt to agent via provider
216
- const provider = getProvider();
217
- if (!provider)
218
- throw new Error('No agent provider configured');
219
- // claude-code: board tasks flow through the channel as plain chat
220
- // notifications — Claude replies asynchronously via the MCP `reply`
221
- // tool, we don't block on onDone here.
222
- if (provider instanceof ClaudeCodeProvider) {
223
- provider.pushToChannel(`New task (card ${cardId}):\n\n${taskData.prompt}`, {
224
- chat_id: 'board',
225
- source: 'board',
226
- message_id: cardId,
227
- });
228
- // BOARD-CC-COMPLETION: Claude drives card completion itself by
229
- // calling the agent-board MCP tools (POST /api/agent/board/cards/:id/
230
- // result | artifacts | comments | move) exposed via the backend MCP
231
- // server. We intentionally do NOT call completeTask() here — that
232
- // would mark the card `completed` before Claude has done any work.
233
- //
234
- // Trade-off: we reset local state to `idle` so the agent can claim
235
- // additional cards while Claude works, but the card itself stays
236
- // `claimed/in-progress` on the backend until Claude posts a result.
237
- // If Claude never finishes (crash, exit) the card appears stuck
238
- // until a backend reaper times it out.
239
- //
240
- // TODO: detect Claude's own result-call (via a `board:done` marker
241
- // in reply meta, or by wiring a second MCP notification back to
242
- // this handler) so we can log completion in agent-controller too.
243
- logCollector?.push('card_task_handed_off', 'info', `Card ${cardId} handed to claude-code channel; completion driven by agent via MCP`, { cardId, provider: 'claude-code' });
244
- delete process.env.BOARD_CARD_ID;
245
- this.currentCardProcessingId = null;
246
- this.boardState = { state: 'idle', cardId: null };
247
- this.checkQueue().catch((err) => {
248
- logCollector?.push('board_queue_check_error', 'error', `checkQueue after claude-code handoff error: ${toErrorMessage(err)}`, { cardId });
249
- });
250
- return;
251
- }
252
- else {
253
- await new Promise((resolve, reject) => {
254
- const timeoutId = setTimeout(() => reject(new Error('Provider timeout')), 300_000);
255
- provider
256
- .sendMessage({
257
- sessionKey: 'board-task',
258
- text: taskData.prompt,
259
- idempotencyKey: `board-${cardId}-${Date.now()}`,
260
- onDone: () => {
261
- clearTimeout(timeoutId);
262
- resolve();
263
- },
264
- onError: (error) => {
265
- clearTimeout(timeoutId);
266
- reject(new Error(error));
267
- },
268
- })
269
- .catch((err) => {
270
- clearTimeout(timeoutId);
271
- reject(err);
272
- });
273
- });
274
- }
275
- }
276
- // STRUCT-2: reset state after task is sent so new cards can be claimed
277
- await this.completeTask(cardId);
278
- }
279
- catch (err) {
280
- logCollector?.push('card_task_error', 'error', `startTask(${cardId}) error: ${toErrorMessage(err)}`, { cardId });
281
- // Report failure to backend
282
- await this.reportResult(cardId, 'failed', toErrorMessage(err));
283
- this.boardState = { state: 'idle', cardId: null };
284
- }
285
- }
286
- async executeMockActions(cardId, actions) {
287
- for (const action of actions) {
288
- switch (action.type) {
289
- case 'wait':
290
- await new Promise((r) => setTimeout(r, action.ms ?? 1000));
291
- break;
292
- case 'artifact':
293
- await this.postArtifact(cardId, action.body ?? {});
294
- break;
295
- case 'comment':
296
- await this.postComment(cardId, action.body ?? {});
297
- break;
298
- case 'result':
299
- await this.postResult(cardId, (action.body ?? {}));
300
- break;
301
- case 'move':
302
- await this.postMove(cardId);
303
- break;
304
- }
305
- logCollector?.push('board_mock_action', 'info', `Mock action executed: ${action.type}`, {
306
- cardId,
307
- actionType: action.type,
308
- });
309
- }
310
- }
311
- async completeTask(cardId) {
312
- logCollector?.push('card_task_completed', 'info', `Task completed: ${cardId}`, { cardId });
313
- delete process.env.BOARD_CARD_ID;
314
- // Report completion to backend
315
- await this.reportResult(cardId, 'completed');
316
- this.currentCardProcessingId = null;
317
- this.boardState = { state: 'idle', cardId: null };
318
- this.checkQueue().catch((err) => {
319
- logCollector?.push('board_queue_check_error', 'error', `checkQueue after completeTask error: ${toErrorMessage(err)}`, { cardId });
320
- });
321
- }
322
- async reportResult(cardId, status, error) {
323
- try {
324
- const body = { status };
325
- if (error)
326
- body.error = error;
327
- await this.postResult(cardId, body);
328
- logCollector?.push('card_result_reported', 'info', `Reported result for card ${cardId}: ${status}`, { cardId, status });
329
- }
330
- catch (err) {
331
- logCollector?.push('card_result_error', 'error', `reportResult(${cardId}) error: ${toErrorMessage(err)}`, { cardId });
332
- // Don't throw — result reporting failure shouldn't break the flow
333
- }
334
- }
335
- async checkQueue(existingData) {
336
- try {
337
- const data = existingData ?? (await this.getBoard());
338
- const candidates = [];
339
- for (const col of data.columns) {
340
- if (!this.myColumnIds.includes(col.id))
341
- continue;
342
- for (const card of col.cards) {
343
- if (!card.assignedAgentId) {
344
- candidates.push(card);
345
- }
346
- }
347
- }
348
- if (candidates.length === 0)
349
- return;
350
- // Sort by priority (critical > high > medium > low) then by creation date (oldest first)
351
- const priorityOrder = { critical: 0, high: 1, medium: 2, low: 3 };
352
- candidates.sort((a, b) => {
353
- const pa = priorityOrder[a.priority ?? 'medium'] ?? 2;
354
- const pb = priorityOrder[b.priority ?? 'medium'] ?? 2;
355
- if (pa !== pb)
356
- return pa - pb;
357
- return (a.createdAt ?? '').localeCompare(b.createdAt ?? '');
358
- });
359
- logCollector?.push('board_queue_check', 'info', `Queue: ${candidates.length} unassigned card(s) in my columns, trying first`, { count: candidates.length });
360
- await this.tryClaimCard(candidates[0].id);
361
- }
362
- catch (err) {
363
- logCollector?.push('board_queue_check_error', 'error', `checkQueue error: ${toErrorMessage(err)}`);
364
- }
365
- }
366
- getBoardStatus() {
367
- return this.boardState;
368
- }
369
- getBoardId() {
370
- return this.boardId;
371
- }
372
- /** Whether this handler is using MCP tools (vs HTTP fallback). */
373
- isUsingMcp() {
374
- return this.useMcp;
375
- }
376
- }
377
- //# sourceMappingURL=board-handler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"board-handler.js","sourceRoot":"","sources":["../../src/handlers/board-handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAA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E,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;YAC1F,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;gBACvB,MAAM,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACtD,MAAM,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACtD,IAAI,EAAE,KAAK,EAAE;oBAAE,OAAO,EAAE,GAAG,EAAE,CAAC;gBAC9B,OAAO,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;YAC9D,CAAC,CAAC,CAAC;YAEH,YAAY,EAAE,IAAI,CAChB,mBAAmB,EACnB,MAAM,EACN,UAAU,UAAU,CAAC,MAAM,iDAAiD,EAC5E,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,EAAE,CAC7B,CAAC;YACF,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,YAAY,EAAE,IAAI,CAChB,yBAAyB,EACzB,OAAO,EACP,qBAAqB,cAAc,CAAC,GAAG,CAAC,EAAE,CAC3C,CAAC;QACJ,CAAC;IACH,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,kEAAkE;IAClE,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}
@@ -1,64 +0,0 @@
1
- export interface McpToolResult {
2
- content: Array<{
3
- type: string;
4
- text?: string;
5
- }>;
6
- isError?: boolean;
7
- }
8
- export interface McpBoardClientOptions {
9
- url: string;
10
- token: string;
11
- }
12
- /**
13
- * MCP client for communicating with the openclaw-cloud MCP server.
14
- * Used by BoardHandler to call board tools and receive board event notifications.
15
- *
16
- * The backend stores MCP sessions in Redis with a TTL that is refreshed on each
17
- * request and on SSE keepalives. If the session disappears server-side (Redis
18
- * flush during deploy, TTL expiry during long idle, transient network drop where
19
- * the GET SSE channel never recovered) every subsequent callTool returns
20
- * `-32001 Session not found`. Without recovery, the agent-controller is stuck
21
- * with a dead client until process restart.
22
- *
23
- * `callTool` and `listTools` transparently re-establish the session on
24
- * `Session not found` and retry exactly once. A mutex prevents concurrent
25
- * reconnects when many calls fail at the same moment. Persistent failure
26
- * bubbles up and is handled by the restart-loop.
27
- */
28
- export declare class McpBoardClient {
29
- private client;
30
- private connected;
31
- private onBoardEvent?;
32
- private url;
33
- private token;
34
- private reconnectInFlight;
35
- constructor(options: McpBoardClientOptions);
36
- setEventHandler(handler: (event: Record<string, unknown>) => void): void;
37
- connect(): Promise<void>;
38
- disconnect(): Promise<void>;
39
- callTool(name: string, args?: Record<string, unknown>): Promise<McpToolResult>;
40
- listTools(): Promise<string[]>;
41
- isConnected(): boolean;
42
- /**
43
- * Match either an `McpError` carrying `code: -32001` or a generic Error whose
44
- * message contains the JSON-RPC text / HTTP 404 status from the SDK transport.
45
- */
46
- private isSessionLost;
47
- private handleSessionLost;
48
- /**
49
- * Mutex-guarded reconnect. Concurrent callers all await the same in-flight
50
- * promise so a burst of failed callTool invocations triggers exactly one
51
- * fresh transport+session, not N. Capped at a single retry per failure —
52
- * if the retry also fails, the error propagates and the supervising
53
- * restart-loop takes over.
54
- */
55
- private reconnect;
56
- private performReconnect;
57
- /**
58
- * Notification handler is registered on the Client instance, so we must
59
- * re-install it every time we replace that instance during reconnect.
60
- * Listens for `board/event` notifications dispatched by the backend's
61
- * McpSessionManager.
62
- */
63
- private installNotificationHandler;
64
- }