gopherhole_openclaw_a2a 0.4.5 → 0.4.7
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/src/channel.js +40 -8
- package/dist/src/gateway-client.d.ts +2 -1
- package/dist/src/gateway-client.js +8 -4
- package/openclaw.plugin.json +114 -0
- package/package.json +2 -2
package/dist/src/channel.js
CHANGED
|
@@ -227,9 +227,19 @@ export const a2aPlugin = {
|
|
|
227
227
|
const config = account.config;
|
|
228
228
|
ctx.log?.info(`[a2a] Starting A2A channel`);
|
|
229
229
|
ctx.setStatus({ accountId: account.accountId });
|
|
230
|
-
|
|
230
|
+
const localConnection = new A2AConnectionManager(config);
|
|
231
|
+
// Defensive: prior plugin versions leaked a connection on every
|
|
232
|
+
// supervisor auto-restart. If a stale manager is still around, stop it
|
|
233
|
+
// before overwriting the module-level singleton.
|
|
234
|
+
if (connectionManager && connectionManager !== localConnection) {
|
|
235
|
+
try {
|
|
236
|
+
await connectionManager.stop();
|
|
237
|
+
}
|
|
238
|
+
catch { /* ignore */ }
|
|
239
|
+
}
|
|
240
|
+
connectionManager = localConnection;
|
|
231
241
|
// Set up message handler for incoming messages
|
|
232
|
-
|
|
242
|
+
localConnection.setMessageHandler(async (agentId, message) => {
|
|
233
243
|
if (message.type === 'message' && message.from) {
|
|
234
244
|
const text = message.content?.parts
|
|
235
245
|
?.filter((p) => p.kind === 'text')
|
|
@@ -276,24 +286,46 @@ export const a2aPlugin = {
|
|
|
276
286
|
}
|
|
277
287
|
}
|
|
278
288
|
});
|
|
279
|
-
await
|
|
289
|
+
await localConnection.start();
|
|
280
290
|
ctx.setStatus({
|
|
281
291
|
accountId: account.accountId,
|
|
282
292
|
running: true,
|
|
283
293
|
lastStartAt: Date.now(),
|
|
284
294
|
});
|
|
285
295
|
ctx.log?.info(`[a2a] A2A channel started`);
|
|
286
|
-
//
|
|
287
|
-
|
|
296
|
+
// OpenClaw's channel supervisor treats resolution of this promise as
|
|
297
|
+
// "channel exited" and immediately schedules an auto-restart. Hold the
|
|
298
|
+
// channel open for its lifetime by blocking on the abort signal — the
|
|
299
|
+
// supervisor aborts it only when it actually wants us to stop.
|
|
300
|
+
try {
|
|
301
|
+
await new Promise((resolve) => {
|
|
302
|
+
const signal = ctx.abortSignal;
|
|
303
|
+
if (!signal)
|
|
304
|
+
return; // no signal provided: never resolve
|
|
305
|
+
if (signal.aborted) {
|
|
306
|
+
resolve();
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
signal.addEventListener('abort', () => resolve(), { once: true });
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
finally {
|
|
288
313
|
ctx.log?.info(`[a2a] Stopping A2A channel`);
|
|
289
|
-
|
|
290
|
-
|
|
314
|
+
try {
|
|
315
|
+
await localConnection.stop();
|
|
316
|
+
}
|
|
317
|
+
catch (err) {
|
|
318
|
+
ctx.log?.error?.(`[a2a] Error during stop: ${err.message}`);
|
|
319
|
+
}
|
|
320
|
+
if (connectionManager === localConnection) {
|
|
321
|
+
connectionManager = null;
|
|
322
|
+
}
|
|
291
323
|
ctx.setStatus({
|
|
292
324
|
accountId: account.accountId,
|
|
293
325
|
running: false,
|
|
294
326
|
lastStopAt: Date.now(),
|
|
295
327
|
});
|
|
296
|
-
}
|
|
328
|
+
}
|
|
297
329
|
},
|
|
298
330
|
},
|
|
299
331
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Gateway WebSocket Client
|
|
3
|
-
* Sends messages to the
|
|
3
|
+
* Sends messages to the OpenClaw gateway via its WebSocket protocol
|
|
4
4
|
*
|
|
5
5
|
* chat.send is non-blocking - it returns a runId immediately and
|
|
6
6
|
* streams the response via chat events. We accumulate deltas and
|
|
7
7
|
* resolve when we get state: "final".
|
|
8
8
|
*/
|
|
9
|
+
export declare const GATEWAY_PROTOCOL_VERSION = 4;
|
|
9
10
|
export declare function connectToGateway(port?: number): Promise<void>;
|
|
10
11
|
export declare function callGateway(method: string, params: Record<string, unknown>, timeoutMs?: number): Promise<unknown>;
|
|
11
12
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Gateway WebSocket Client
|
|
3
|
-
* Sends messages to the
|
|
3
|
+
* Sends messages to the OpenClaw gateway via its WebSocket protocol
|
|
4
4
|
*
|
|
5
5
|
* chat.send is non-blocking - it returns a runId immediately and
|
|
6
6
|
* streams the response via chat events. We accumulate deltas and
|
|
@@ -16,6 +16,10 @@ let pendingRequests = new Map();
|
|
|
16
16
|
let pendingChats = new Map(); // keyed by runId
|
|
17
17
|
let connected = false;
|
|
18
18
|
let handshakeComplete = false;
|
|
19
|
+
// OpenClaw 2026.7+ requires gateway protocol v4. Keep this explicit so a
|
|
20
|
+
// protocol bump fails a focused compatibility test instead of silently
|
|
21
|
+
// breaking inbound A2A replies at runtime.
|
|
22
|
+
export const GATEWAY_PROTOCOL_VERSION = 4;
|
|
19
23
|
function getGatewayToken() {
|
|
20
24
|
// Try the current OpenClaw config location first, then the legacy
|
|
21
25
|
// Clawdbot path as a fallback for users still on older installs.
|
|
@@ -56,12 +60,12 @@ export async function connectToGateway(port = 18789) {
|
|
|
56
60
|
id: connectId,
|
|
57
61
|
method: 'connect',
|
|
58
62
|
params: {
|
|
59
|
-
minProtocol:
|
|
60
|
-
maxProtocol:
|
|
63
|
+
minProtocol: GATEWAY_PROTOCOL_VERSION,
|
|
64
|
+
maxProtocol: GATEWAY_PROTOCOL_VERSION,
|
|
61
65
|
client: {
|
|
62
66
|
id: 'gateway-client',
|
|
63
67
|
displayName: 'A2A Channel Plugin',
|
|
64
|
-
version: '0.
|
|
68
|
+
version: '0.4.7',
|
|
65
69
|
platform: process.platform,
|
|
66
70
|
mode: 'backend',
|
|
67
71
|
},
|
package/openclaw.plugin.json
CHANGED
|
@@ -10,5 +10,119 @@
|
|
|
10
10
|
"description": "Enable the plugin"
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
},
|
|
14
|
+
"channelConfigs": {
|
|
15
|
+
"a2a": {
|
|
16
|
+
"label": "A2A (GopherHole)",
|
|
17
|
+
"description": "Agent-to-agent communication over the GopherHole hub. Lets other AI agents discover and message this OpenClaw instance.",
|
|
18
|
+
"schema": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"additionalProperties": false,
|
|
21
|
+
"properties": {
|
|
22
|
+
"enabled": {
|
|
23
|
+
"type": "boolean",
|
|
24
|
+
"default": false,
|
|
25
|
+
"description": "Enable the A2A channel"
|
|
26
|
+
},
|
|
27
|
+
"apiKey": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "GopherHole API key (starts with gph_)"
|
|
30
|
+
},
|
|
31
|
+
"bridgeUrl": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"format": "uri",
|
|
34
|
+
"default": "wss://hub.gopherhole.ai/ws",
|
|
35
|
+
"description": "WebSocket URL for the GopherHole hub"
|
|
36
|
+
},
|
|
37
|
+
"agentId": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "Canonical hub-side agent ID (e.g. agent-9a2fb7a8). Assigned by the hub; look it up via the GopherHole admin dashboard."
|
|
40
|
+
},
|
|
41
|
+
"agentName": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "Display name for this agent; used to build the default agent card when agentCard is not provided."
|
|
44
|
+
},
|
|
45
|
+
"agentCard": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"description": "Override the default agent card sent to the hub on connect.",
|
|
48
|
+
"properties": {
|
|
49
|
+
"name": { "type": "string" },
|
|
50
|
+
"description": { "type": "string" },
|
|
51
|
+
"url": { "type": "string", "format": "uri" },
|
|
52
|
+
"version": { "type": "string" },
|
|
53
|
+
"skills": {
|
|
54
|
+
"type": "array",
|
|
55
|
+
"items": {
|
|
56
|
+
"type": "object",
|
|
57
|
+
"properties": {
|
|
58
|
+
"id": { "type": "string" },
|
|
59
|
+
"name": { "type": "string" },
|
|
60
|
+
"description": { "type": "string" },
|
|
61
|
+
"tags": { "type": "array", "items": { "type": "string" } },
|
|
62
|
+
"examples": { "type": "array", "items": { "type": "string" } },
|
|
63
|
+
"inputModes": { "type": "array", "items": { "type": "string" } },
|
|
64
|
+
"outputModes": { "type": "array", "items": { "type": "string" } }
|
|
65
|
+
},
|
|
66
|
+
"required": ["id", "name"]
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"reconnectIntervalMs": {
|
|
72
|
+
"type": "integer",
|
|
73
|
+
"minimum": 100,
|
|
74
|
+
"default": 5000,
|
|
75
|
+
"description": "Initial reconnect delay in milliseconds. The SDK backs off exponentially up to a 5-minute cap."
|
|
76
|
+
},
|
|
77
|
+
"requestTimeoutMs": {
|
|
78
|
+
"type": "integer",
|
|
79
|
+
"minimum": 1000,
|
|
80
|
+
"default": 180000,
|
|
81
|
+
"description": "Timeout in milliseconds for outbound requests and inbound message-response waits."
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"uiHints": {
|
|
86
|
+
"": {
|
|
87
|
+
"label": "A2A (GopherHole)",
|
|
88
|
+
"help": "Connect this OpenClaw instance to the GopherHole hub so other AI agents can discover and message it. Get an API key at https://gopherhole.ai."
|
|
89
|
+
},
|
|
90
|
+
"apiKey": {
|
|
91
|
+
"label": "API Key",
|
|
92
|
+
"help": "Your GopherHole API key (starts with gph_). Create one at https://gopherhole.ai settings.",
|
|
93
|
+
"sensitive": true,
|
|
94
|
+
"placeholder": "gph_..."
|
|
95
|
+
},
|
|
96
|
+
"bridgeUrl": {
|
|
97
|
+
"label": "Bridge URL",
|
|
98
|
+
"help": "WebSocket endpoint of the GopherHole hub. Only override for self-hosted deployments.",
|
|
99
|
+
"advanced": true,
|
|
100
|
+
"placeholder": "wss://hub.gopherhole.ai/ws"
|
|
101
|
+
},
|
|
102
|
+
"agentId": {
|
|
103
|
+
"label": "Agent ID",
|
|
104
|
+
"help": "Hub-assigned agent ID. Find it in your GopherHole admin dashboard.",
|
|
105
|
+
"advanced": true,
|
|
106
|
+
"placeholder": "agent-xxxxxxxx"
|
|
107
|
+
},
|
|
108
|
+
"agentName": {
|
|
109
|
+
"label": "Display Name",
|
|
110
|
+
"help": "Human-readable name shown in agent cards and discovery listings."
|
|
111
|
+
},
|
|
112
|
+
"agentCard": {
|
|
113
|
+
"label": "Agent Card",
|
|
114
|
+
"help": "Advanced: fully override the agent card metadata (name, description, version, skills) registered with the hub on connect.",
|
|
115
|
+
"advanced": true
|
|
116
|
+
},
|
|
117
|
+
"reconnectIntervalMs": {
|
|
118
|
+
"label": "Reconnect Interval (ms)",
|
|
119
|
+
"advanced": true
|
|
120
|
+
},
|
|
121
|
+
"requestTimeoutMs": {
|
|
122
|
+
"label": "Request Timeout (ms)",
|
|
123
|
+
"advanced": true
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
13
127
|
}
|
|
14
128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gopherhole_openclaw_a2a",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "GopherHole A2A plugin for OpenClaw - connect your AI agent to the GopherHole network",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -53,4 +53,4 @@
|
|
|
53
53
|
"README.md",
|
|
54
54
|
"SKILL.md"
|
|
55
55
|
]
|
|
56
|
-
}
|
|
56
|
+
}
|