a2acalling 0.6.45 → 0.6.47

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "a2acalling",
3
- "version": "0.6.45",
3
+ "version": "0.6.47",
4
4
  "description": "Agent-to-agent calling for OpenClaw - A2A agent communication",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -608,6 +608,8 @@ Use ALL available context to build a reasonable disclosure profile. If truly not
608
608
 
609
609
  const jsonBlock = `\`\`\`json
610
610
  {
611
+ "owner_name": "The human owner's real name (extracted from USER.md, git config, etc.)",
612
+ "agent_name": "The agent's display name (extracted from USER.md or workspace context)",
611
613
  "tiers": {
612
614
  "public": {
613
615
  "topics": [
@@ -0,0 +1,103 @@
1
+ /**
2
+ * PID File Management
3
+ *
4
+ * Writes/reads/removes a PID file for the A2A server process.
5
+ * Used by server.js on startup and cli.js for pre-start cleanup.
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const { spawnSync } = require('child_process');
11
+
12
+ const CONFIG_DIR = process.env.A2A_CONFIG_DIR ||
13
+ process.env.OPENCLAW_CONFIG_DIR ||
14
+ path.join(process.env.HOME || '/tmp', '.config', 'openclaw');
15
+
16
+ const PID_FILE = path.join(CONFIG_DIR, 'a2a-server.pid');
17
+
18
+ function writePidFile(pid) {
19
+ try {
20
+ if (!fs.existsSync(CONFIG_DIR)) {
21
+ fs.mkdirSync(CONFIG_DIR, { recursive: true });
22
+ }
23
+ fs.writeFileSync(PID_FILE, String(pid) + '\n', { mode: 0o600 });
24
+ } catch (e) {
25
+ // Best effort — don't crash the server if PID file write fails
26
+ }
27
+ }
28
+
29
+ function readPidFile() {
30
+ try {
31
+ const content = fs.readFileSync(PID_FILE, 'utf8').trim();
32
+ const pid = parseInt(content, 10);
33
+ return Number.isFinite(pid) && pid > 0 ? pid : null;
34
+ } catch (e) {
35
+ return null;
36
+ }
37
+ }
38
+
39
+ function removePidFile() {
40
+ try {
41
+ fs.rmSync(PID_FILE, { force: true });
42
+ } catch (e) {
43
+ // Best effort
44
+ }
45
+ }
46
+
47
+ function isProcessAlive(pid) {
48
+ try {
49
+ process.kill(pid, 0);
50
+ return true;
51
+ } catch (e) {
52
+ return false;
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Kill the server process recorded in the PID file.
58
+ * Returns { killed: boolean, pid: number|null }.
59
+ */
60
+ function killExistingServer() {
61
+ const pid = readPidFile();
62
+ if (!pid) return { killed: false, pid: null };
63
+
64
+ if (!isProcessAlive(pid)) {
65
+ // Stale PID file — clean up
66
+ removePidFile();
67
+ return { killed: false, pid };
68
+ }
69
+
70
+ try {
71
+ process.kill(pid, 'SIGTERM');
72
+ } catch (e) {
73
+ removePidFile();
74
+ return { killed: false, pid };
75
+ }
76
+
77
+ // Wait up to 3s for graceful exit
78
+ const start = Date.now();
79
+ while (Date.now() - start < 3000) {
80
+ if (!isProcessAlive(pid)) {
81
+ removePidFile();
82
+ return { killed: true, pid };
83
+ }
84
+ spawnSync('sleep', ['0.1'], { timeout: 500 });
85
+ }
86
+
87
+ // Force kill
88
+ try {
89
+ process.kill(pid, 'SIGKILL');
90
+ } catch (e) {}
91
+
92
+ removePidFile();
93
+ return { killed: true, pid };
94
+ }
95
+
96
+ module.exports = {
97
+ writePidFile,
98
+ readPidFile,
99
+ removePidFile,
100
+ isProcessAlive,
101
+ killExistingServer,
102
+ PID_FILE
103
+ };