agentbnb 4.0.2 → 5.1.0
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/README.md +31 -2
- package/dist/chunk-AUBHR7HH.js +25 -0
- package/dist/chunk-B5FTAGFN.js +393 -0
- package/dist/{chunk-GGYC5U2Z.js → chunk-BTTL24TZ.js} +29 -91
- package/dist/chunk-C6KPAFCC.js +387 -0
- package/dist/chunk-CRFCWD6V.js +366 -0
- package/dist/chunk-CSATDXZC.js +89 -0
- package/dist/{chunk-T7NS2J2B.js → chunk-DFBX3BBD.js} +84 -1
- package/dist/{chunk-DNWT5FZQ.js → chunk-EANI2N2V.js} +98 -1
- package/dist/{chunk-HH24WMFN.js → chunk-FLY3WIQR.js} +1 -1
- package/dist/chunk-HLUEOLSZ.js +62 -0
- package/dist/chunk-IVOYM3WG.js +25 -0
- package/dist/chunk-LCAIAAG2.js +916 -0
- package/dist/chunk-MLS6IGGG.js +294 -0
- package/dist/{chunk-4P3EMGL4.js → chunk-MNO4COST.js} +5 -3
- package/dist/chunk-NH2FIERR.js +138 -0
- package/dist/chunk-UKT6H7YT.js +29 -0
- package/dist/{chunk-BH6WGYFB.js → chunk-VE3E4AMH.js} +8 -8
- package/dist/{chunk-7NA43XCG.js → chunk-W5BZMKMF.js} +163 -29
- package/dist/{chunk-FF226TIV.js → chunk-ZX5623ER.js} +0 -57
- package/dist/cli/index.js +362 -4631
- package/dist/{conduct-N52JX7RT.js → conduct-KM6ZNJGE.js} +10 -8
- package/dist/{conduct-GZQNFTRP.js → conduct-WGTMQND5.js} +10 -8
- package/dist/{conductor-mode-XUWGR4ZE.js → conductor-mode-OL2FNOYY.js} +6 -4
- package/dist/conductor-mode-VRO7TYW2.js +592 -0
- package/dist/execute-CPFSOOO3.js +13 -0
- package/dist/execute-IP2QHALV.js +10 -0
- package/dist/index.d.ts +19 -8
- package/dist/index.js +190 -37
- package/dist/peers-CJ7T4RJO.js +13 -0
- package/dist/process-guard-CC7CNRQJ.js +176 -0
- package/dist/{request-4GQSSM4B.js → request-YOWPXVLQ.js} +13 -10
- package/dist/schema-7BSSLZ4S.js +8 -0
- package/dist/{serve-skill-TPHZH6BS.js → serve-skill-JHFNR7BW.js} +8 -7
- package/dist/{server-365V3GYD.js → server-HKJJWFRG.js} +10 -8
- package/dist/service-coordinator-5R4LQW6L.js +4917 -0
- package/dist/skills/agentbnb/bootstrap.js +6181 -0
- package/dist/websocket-client-WRN3HO73.js +6 -0
- package/openclaw.plugin.json +54 -0
- package/package.json +11 -2
- package/skills/agentbnb/SKILL.md +87 -70
- package/skills/agentbnb/bootstrap.test.ts +142 -242
- package/skills/agentbnb/bootstrap.ts +88 -95
- package/skills/agentbnb/install.sh +97 -27
- package/dist/execute-PNGQOMYO.js +0 -10
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentBnBError
|
|
3
|
+
} from "./chunk-WGZ5AGOX.js";
|
|
4
|
+
|
|
5
|
+
// src/runtime/process-guard.ts
|
|
6
|
+
import { dirname, join } from "path";
|
|
7
|
+
import {
|
|
8
|
+
closeSync,
|
|
9
|
+
existsSync,
|
|
10
|
+
mkdirSync,
|
|
11
|
+
openSync,
|
|
12
|
+
readFileSync,
|
|
13
|
+
unlinkSync,
|
|
14
|
+
writeFileSync
|
|
15
|
+
} from "fs";
|
|
16
|
+
import { homedir } from "os";
|
|
17
|
+
var ProcessGuard = class {
|
|
18
|
+
pidFilePath;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a ProcessGuard that controls single-process ownership via pid file.
|
|
21
|
+
*
|
|
22
|
+
* @param pidFilePath - Absolute path to pid file. Defaults to ~/.agentbnb/.pid.
|
|
23
|
+
*/
|
|
24
|
+
constructor(pidFilePath) {
|
|
25
|
+
this.pidFilePath = pidFilePath ?? join(homedir(), ".agentbnb", ".pid");
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Acquires process lock atomically.
|
|
29
|
+
*
|
|
30
|
+
* Uses fs open mode 'wx' so lock creation is a single atomic operation.
|
|
31
|
+
* If a pid file already exists, stale pids are cleaned automatically and
|
|
32
|
+
* acquisition is retried.
|
|
33
|
+
*
|
|
34
|
+
* @param meta - Lock metadata excluding pid (pid is always current process pid).
|
|
35
|
+
* @throws {AgentBnBError} PROCESS_ALREADY_RUNNING if another live process holds lock.
|
|
36
|
+
*/
|
|
37
|
+
acquire(meta) {
|
|
38
|
+
mkdirSync(dirname(this.pidFilePath), { recursive: true });
|
|
39
|
+
const payload = {
|
|
40
|
+
pid: process.pid,
|
|
41
|
+
started_at: meta.started_at,
|
|
42
|
+
port: meta.port,
|
|
43
|
+
owner: meta.owner
|
|
44
|
+
};
|
|
45
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
46
|
+
let fd = null;
|
|
47
|
+
try {
|
|
48
|
+
fd = openSync(this.pidFilePath, "wx");
|
|
49
|
+
writeFileSync(fd, `${JSON.stringify(payload)}
|
|
50
|
+
`, "utf8");
|
|
51
|
+
return;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
const fsErr = err;
|
|
54
|
+
if (fsErr.code !== "EEXIST") {
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
const cleaned = this.cleanupStaleLock();
|
|
58
|
+
if (cleaned) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const running = this.readPidFile();
|
|
62
|
+
const details = running ? `pid=${running.pid} owner=${running.owner} port=${running.port}` : `pid-file=${this.pidFilePath}`;
|
|
63
|
+
throw new AgentBnBError(
|
|
64
|
+
`AgentBnB process already running (${details})`,
|
|
65
|
+
"PROCESS_ALREADY_RUNNING"
|
|
66
|
+
);
|
|
67
|
+
} finally {
|
|
68
|
+
if (fd !== null) {
|
|
69
|
+
closeSync(fd);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
throw new AgentBnBError(
|
|
74
|
+
`Failed to acquire process lock: ${this.pidFilePath}`,
|
|
75
|
+
"PROCESS_GUARD_ACQUIRE_FAILED"
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Releases process lock.
|
|
80
|
+
*
|
|
81
|
+
* Removes pid file only when:
|
|
82
|
+
* - lock belongs to current process, or
|
|
83
|
+
* - lock holder pid is stale.
|
|
84
|
+
*/
|
|
85
|
+
release() {
|
|
86
|
+
const current = this.readPidFile();
|
|
87
|
+
if (!current) return;
|
|
88
|
+
if (current.pid === process.pid || !this.isPidAlive(current.pid)) {
|
|
89
|
+
this.safeUnlink();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns running process metadata if lock holder pid is alive.
|
|
94
|
+
* Automatically clears stale pid files.
|
|
95
|
+
*
|
|
96
|
+
* @returns Running metadata or null when no live lock holder exists.
|
|
97
|
+
*/
|
|
98
|
+
getRunningMeta() {
|
|
99
|
+
const meta = this.readPidFile();
|
|
100
|
+
if (!meta) return null;
|
|
101
|
+
if (!this.isPidAlive(meta.pid)) {
|
|
102
|
+
this.safeUnlink();
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return meta;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Returns true when a live lock holder exists.
|
|
109
|
+
*/
|
|
110
|
+
isRunning() {
|
|
111
|
+
return this.getRunningMeta() !== null;
|
|
112
|
+
}
|
|
113
|
+
readPidFile() {
|
|
114
|
+
if (!existsSync(this.pidFilePath)) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const raw = readFileSync(this.pidFilePath, "utf8");
|
|
119
|
+
const parsed = JSON.parse(raw);
|
|
120
|
+
if (!isPidFileContent(parsed)) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
return parsed;
|
|
124
|
+
} catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
cleanupStaleLock() {
|
|
129
|
+
const existing = this.readPidFile();
|
|
130
|
+
if (!existing) {
|
|
131
|
+
return this.safeUnlink();
|
|
132
|
+
}
|
|
133
|
+
if (this.isPidAlive(existing.pid)) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
return this.safeUnlink();
|
|
137
|
+
}
|
|
138
|
+
safeUnlink() {
|
|
139
|
+
try {
|
|
140
|
+
unlinkSync(this.pidFilePath);
|
|
141
|
+
return true;
|
|
142
|
+
} catch (err) {
|
|
143
|
+
const fsErr = err;
|
|
144
|
+
if (fsErr.code === "ENOENT") {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
throw err;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
isPidAlive(pid) {
|
|
151
|
+
if (!Number.isInteger(pid) || pid <= 0) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
process.kill(pid, 0);
|
|
156
|
+
return true;
|
|
157
|
+
} catch (err) {
|
|
158
|
+
const killErr = err;
|
|
159
|
+
if (killErr.code === "EPERM") {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
if (killErr.code === "ESRCH") {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
function isPidFileContent(value) {
|
|
170
|
+
if (value === null || typeof value !== "object") return false;
|
|
171
|
+
const record = value;
|
|
172
|
+
return Number.isInteger(record["pid"]) && typeof record["started_at"] === "string" && Number.isInteger(record["port"]) && typeof record["owner"] === "string";
|
|
173
|
+
}
|
|
174
|
+
export {
|
|
175
|
+
ProcessGuard
|
|
176
|
+
};
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLedger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FLY3WIQR.js";
|
|
4
|
+
import {
|
|
5
|
+
RelayClient
|
|
6
|
+
} from "./chunk-JOY533UH.js";
|
|
7
|
+
import "./chunk-QT7TEVNV.js";
|
|
4
8
|
import {
|
|
5
9
|
AutoRequestor,
|
|
6
10
|
BudgetManager,
|
|
7
|
-
DEFAULT_AUTONOMY_CONFIG,
|
|
8
11
|
DEFAULT_BUDGET_CONFIG
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import
|
|
12
|
+
} from "./chunk-BTTL24TZ.js";
|
|
13
|
+
import {
|
|
14
|
+
DEFAULT_AUTONOMY_CONFIG
|
|
15
|
+
} from "./chunk-CSATDXZC.js";
|
|
16
|
+
import "./chunk-ZX5623ER.js";
|
|
17
|
+
import "./chunk-NH2FIERR.js";
|
|
11
18
|
import {
|
|
12
19
|
requestCapability
|
|
13
20
|
} from "./chunk-XND2DWTZ.js";
|
|
@@ -15,18 +22,14 @@ import "./chunk-5AH3CMOX.js";
|
|
|
15
22
|
import "./chunk-75OC6E4F.js";
|
|
16
23
|
import {
|
|
17
24
|
openDatabase
|
|
18
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-DFBX3BBD.js";
|
|
19
26
|
import {
|
|
20
27
|
openCreditDb
|
|
21
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-EANI2N2V.js";
|
|
22
29
|
import {
|
|
23
30
|
loadKeyPair
|
|
24
31
|
} from "./chunk-5KFI5X7B.js";
|
|
25
32
|
import "./chunk-WGZ5AGOX.js";
|
|
26
|
-
import {
|
|
27
|
-
RelayClient
|
|
28
|
-
} from "./chunk-JOY533UH.js";
|
|
29
|
-
import "./chunk-QT7TEVNV.js";
|
|
30
33
|
|
|
31
34
|
// src/mcp/tools/request.ts
|
|
32
35
|
import { z } from "zod";
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RelayClient
|
|
3
|
+
} from "./chunk-JOY533UH.js";
|
|
4
|
+
import "./chunk-QT7TEVNV.js";
|
|
1
5
|
import {
|
|
2
6
|
executeCapabilityRequest
|
|
3
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-W5BZMKMF.js";
|
|
8
|
+
import "./chunk-UKT6H7YT.js";
|
|
4
9
|
import {
|
|
5
10
|
listCards,
|
|
6
11
|
openDatabase
|
|
7
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-DFBX3BBD.js";
|
|
8
13
|
import {
|
|
9
14
|
openCreditDb
|
|
10
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-EANI2N2V.js";
|
|
11
16
|
import "./chunk-5KFI5X7B.js";
|
|
12
17
|
import "./chunk-WGZ5AGOX.js";
|
|
13
|
-
import {
|
|
14
|
-
RelayClient
|
|
15
|
-
} from "./chunk-JOY533UH.js";
|
|
16
|
-
import "./chunk-QT7TEVNV.js";
|
|
17
18
|
|
|
18
19
|
// src/mcp/tools/serve-skill.ts
|
|
19
20
|
import { z } from "zod";
|
|
@@ -3,12 +3,14 @@ import {
|
|
|
3
3
|
} from "./chunk-QITOPASZ.js";
|
|
4
4
|
import {
|
|
5
5
|
createLedger
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FLY3WIQR.js";
|
|
7
7
|
import {
|
|
8
8
|
fetchRemoteCards,
|
|
9
|
-
mergeResults
|
|
9
|
+
mergeResults
|
|
10
|
+
} from "./chunk-ZX5623ER.js";
|
|
11
|
+
import {
|
|
10
12
|
searchCards
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-NH2FIERR.js";
|
|
12
14
|
import {
|
|
13
15
|
getConfigDir,
|
|
14
16
|
loadConfig
|
|
@@ -16,11 +18,11 @@ import {
|
|
|
16
18
|
import {
|
|
17
19
|
insertCard,
|
|
18
20
|
openDatabase
|
|
19
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-DFBX3BBD.js";
|
|
20
22
|
import {
|
|
21
23
|
getBalance,
|
|
22
24
|
openCreditDb
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-EANI2N2V.js";
|
|
24
26
|
import {
|
|
25
27
|
loadKeyPair
|
|
26
28
|
} from "./chunk-5KFI5X7B.js";
|
|
@@ -273,9 +275,9 @@ async function startMcpServer() {
|
|
|
273
275
|
registerDiscoverTool(server, ctx);
|
|
274
276
|
registerStatusTool(server, ctx);
|
|
275
277
|
registerPublishTool(server, ctx);
|
|
276
|
-
const { registerRequestTool } = await import("./request-
|
|
277
|
-
const { registerConductTool } = await import("./conduct-
|
|
278
|
-
const { registerServeSkillTool } = await import("./serve-skill-
|
|
278
|
+
const { registerRequestTool } = await import("./request-YOWPXVLQ.js");
|
|
279
|
+
const { registerConductTool } = await import("./conduct-KM6ZNJGE.js");
|
|
280
|
+
const { registerServeSkillTool } = await import("./serve-skill-JHFNR7BW.js");
|
|
279
281
|
registerRequestTool(server, ctx);
|
|
280
282
|
registerConductTool(server, ctx);
|
|
281
283
|
registerServeSkillTool(server, ctx);
|