gopherhole_openclaw_a2a 0.4.4 → 0.4.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.
@@ -7,6 +7,8 @@ const DEFAULT_ACCOUNT_ID = 'default';
7
7
  function normalizeAccountId(id) {
8
8
  return id?.trim()?.toLowerCase() || DEFAULT_ACCOUNT_ID;
9
9
  }
10
+ import { existsSync, readFileSync } from 'fs';
11
+ import { join } from 'path';
10
12
  import { A2AConnectionManager } from './connection.js';
11
13
  import { sendChatMessage } from './gateway-client.js';
12
14
  import { a2aLog } from './logger.js';
@@ -16,6 +18,27 @@ let currentRuntime = null;
16
18
  export function setA2ARuntime(runtime) {
17
19
  currentRuntime = runtime;
18
20
  }
21
+ function loadAgentSecrets(agentId) {
22
+ const secretsDir = join(process.cwd(), '.gopherhole', 'secrets');
23
+ const filePath = join(secretsDir, `${agentId}.json`);
24
+ if (!existsSync(filePath))
25
+ return null;
26
+ try {
27
+ const raw = readFileSync(filePath, 'utf-8');
28
+ const parsed = JSON.parse(raw);
29
+ if (typeof parsed !== 'object' || parsed === null)
30
+ return null;
31
+ const secrets = {};
32
+ for (const [k, v] of Object.entries(parsed)) {
33
+ if (typeof v === 'string')
34
+ secrets[k] = v;
35
+ }
36
+ return Object.keys(secrets).length > 0 ? secrets : null;
37
+ }
38
+ catch {
39
+ return null;
40
+ }
41
+ }
19
42
  function resolveA2AConfig(cfg) {
20
43
  return cfg?.channels?.a2a ?? {};
21
44
  }
@@ -145,7 +168,8 @@ export const a2aPlugin = {
145
168
  return { channel: 'a2a', success: false, error: 'A2A not connected' };
146
169
  }
147
170
  try {
148
- const response = await connectionManager.sendMessage(to, text);
171
+ const secrets = loadAgentSecrets(to) ?? undefined;
172
+ const response = await connectionManager.sendMessage(to, text, secrets ? { secrets } : undefined);
149
173
  return {
150
174
  channel: 'a2a',
151
175
  success: true,
@@ -25,7 +25,10 @@ export declare class A2AConnectionManager {
25
25
  /**
26
26
  * Send a message to another agent via GopherHole and wait for response
27
27
  */
28
- sendMessage(targetAgentId: string, text: string, _contextId?: string): Promise<A2AResponse>;
28
+ sendMessage(targetAgentId: string, text: string, opts?: {
29
+ contextId?: string;
30
+ secrets?: Record<string, string>;
31
+ }): Promise<A2AResponse>;
29
32
  /**
30
33
  * Send a multi-part message via GopherHole hub
31
34
  * Supports text, images, and other MIME types
@@ -35,7 +38,7 @@ export declare class A2AConnectionManager {
35
38
  text?: string;
36
39
  data?: string;
37
40
  mimeType?: string;
38
- }>, contextId?: string): Promise<A2AResponse>;
41
+ }>, contextId?: string, secrets?: Record<string, string>): Promise<A2AResponse>;
39
42
  /**
40
43
  * Send a response to an incoming message via GopherHole
41
44
  * Uses SDK's respond() method to complete the original task
@@ -197,14 +197,14 @@ export class A2AConnectionManager {
197
197
  /**
198
198
  * Send a message to another agent via GopherHole and wait for response
199
199
  */
200
- async sendMessage(targetAgentId, text, _contextId) {
201
- return this.sendPartsViaGopherHole(targetAgentId, [{ kind: 'text', text }]);
200
+ async sendMessage(targetAgentId, text, opts) {
201
+ return this.sendPartsViaGopherHole(targetAgentId, [{ kind: 'text', text }], opts?.contextId, opts?.secrets);
202
202
  }
203
203
  /**
204
204
  * Send a multi-part message via GopherHole hub
205
205
  * Supports text, images, and other MIME types
206
206
  */
207
- async sendPartsViaGopherHole(targetAgentId, parts, contextId) {
207
+ async sendPartsViaGopherHole(targetAgentId, parts, contextId, secrets) {
208
208
  if (!this.gopherhole || !this.connected) {
209
209
  throw new Error('GopherHole not connected');
210
210
  }
@@ -219,7 +219,7 @@ export class A2AConnectionManager {
219
219
  data: p.data,
220
220
  mimeType: p.mimeType,
221
221
  })),
222
- }, { contextId });
222
+ }, { contextId, secrets });
223
223
  // Wait for task completion
224
224
  const completedTask = await this.gopherhole.waitForTask(task.id, {
225
225
  pollIntervalMs: 1000,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gopherhole_openclaw_a2a",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
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",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "license": "MIT",
37
37
  "dependencies": {
38
- "@gopherhole/sdk": "^0.7.4",
38
+ "@gopherhole/sdk": "^0.7.5",
39
39
  "uuid": "^10.0.0"
40
40
  },
41
41
  "devDependencies": {