agentbnb 8.3.1 → 8.4.1
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/{card-T2XJZA5A.js → card-HYTD2BJQ.js} +1 -1
- package/dist/{chunk-S7DZHKCG.js → chunk-2PP5MQPD.js} +5 -3
- package/dist/{chunk-75OC6E4F.js → chunk-3XPBFF6H.js} +1 -0
- package/dist/{chunk-5AH3CMOX.js → chunk-3YQ73ZM6.js} +1 -1
- package/dist/{chunk-FELGHDCA.js → chunk-6FZ4WYQL.js} +38 -4
- package/dist/{chunk-D242QZCR.js → chunk-6XCN62YU.js} +10 -54
- package/dist/chunk-AZKVGC5T.js +53 -0
- package/dist/{chunk-O4Q7BRG6.js → chunk-CFHCG5FE.js} +6 -206
- package/dist/{chunk-5AIYALBX.js → chunk-COA2D7QM.js} +4 -3
- package/dist/chunk-G5WKW3ED.js +41 -0
- package/dist/{chunk-F3KIEVJ2.js → chunk-HU46M4JA.js} +2 -87
- package/dist/{chunk-77KGEDH4.js → chunk-MZSVVG55.js} +2 -41
- package/dist/chunk-PCQEHIGF.js +750 -0
- package/dist/chunk-PIPCGRCR.js +91 -0
- package/dist/{chunk-QFPXZITP.js → chunk-PMRTQ2RL.js} +34 -0
- package/dist/{chunk-7IQE34QK.js → chunk-UF6R2RVN.js} +5 -3
- package/dist/{chunk-IGQNP3ZO.js → chunk-VAAEBCMU.js} +1 -1
- package/dist/chunk-VRPLSK34.js +214 -0
- package/dist/{chunk-BARHNIKG.js → chunk-WK2QSO4E.js} +1 -1
- package/dist/chunk-WPB5LFGI.js +132 -0
- package/dist/chunk-XGOA5J2K.js +173 -0
- package/dist/{chunk-VJ7XBEY6.js → chunk-Z5726VPY.js} +6 -6
- package/dist/cli/index.js +131 -791
- package/dist/conduct-FZPUMPCI.js +25 -0
- package/dist/{conduct-VYYBCPHA.js → conduct-J2NXU6RM.js} +12 -9
- package/dist/{conductor-mode-SBDCRIX6.js → conductor-mode-HNNMWZIH.js} +11 -8
- package/dist/config-IRWLG6IW.js +12 -0
- package/dist/{execute-FZLQGIXB.js → execute-UAD5T3BQ.js} +1 -1
- package/dist/{execute-TEZPQ5WP.js → execute-UP46R7KS.js} +6 -5
- package/dist/index.js +34 -0
- package/dist/openclaw-setup-KA72IIEW.js +296 -0
- package/dist/openclaw-skills-CT673RBL.js +370 -0
- package/dist/{peers-K7FSHPN3.js → peers-F2EWUMVQ.js} +2 -2
- package/dist/{publish-capability-HVYILTPR.js → publish-capability-GNH5FHKG.js} +2 -2
- package/dist/{request-KJNKR27T.js → request-IM3ZLAOA.js} +13 -9
- package/dist/scanner-F5VNV5FP.js +8 -0
- package/dist/{serve-skill-GC6NIQ5T.js → serve-skill-6RKMVDMK.js} +6 -5
- package/dist/{server-YVLMQ2BO.js → server-MH7FTZFN.js} +11 -9
- package/dist/{service-coordinator-SCP2YIFT.js → service-coordinator-R5LZVM6A.js} +31 -26
- package/dist/skills/agentbnb/bootstrap.js +63 -23
- package/dist/store-4Z446745.js +32 -0
- package/dist/writer-4QJ3U3WE.js +16 -0
- package/package.json +1 -1
- package/skills/agentbnb/bootstrap.ts +58 -16
- package/dist/conduct-4JDMWBQD.js +0 -22
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
fetchRemoteCards
|
|
2
|
+
fetchRemoteCards
|
|
3
|
+
} from "./chunk-PIPCGRCR.js";
|
|
4
|
+
import {
|
|
3
5
|
searchCards
|
|
4
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HU46M4JA.js";
|
|
5
7
|
import {
|
|
6
8
|
getCard
|
|
7
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-COA2D7QM.js";
|
|
8
10
|
import {
|
|
9
11
|
resolveCanonicalIdentity
|
|
10
12
|
} from "./chunk-WTHMHNKC.js";
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveTargetCapability
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2PP5MQPD.js";
|
|
4
4
|
import {
|
|
5
5
|
getBalance,
|
|
6
6
|
holdEscrow,
|
|
7
7
|
releaseEscrow,
|
|
8
8
|
settleEscrow
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HU46M4JA.js";
|
|
10
10
|
import {
|
|
11
11
|
loadConfig
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-3XPBFF6H.js";
|
|
13
13
|
import {
|
|
14
14
|
getCard,
|
|
15
15
|
insertRequestLog,
|
|
16
16
|
updateReputation
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-COA2D7QM.js";
|
|
18
18
|
import {
|
|
19
19
|
AgentBnBError
|
|
20
20
|
} from "./chunk-I7KWA7OB.js";
|
|
@@ -43,6 +43,29 @@ async function notifyTelegramSkillExecuted(opts) {
|
|
|
43
43
|
body: JSON.stringify({ chat_id: chatId, text })
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
+
async function notifyTelegramSkillFailed(opts) {
|
|
47
|
+
const cfg = loadConfig();
|
|
48
|
+
if (!cfg?.telegram_notifications) return;
|
|
49
|
+
const token = cfg.telegram_bot_token ?? process.env["TELEGRAM_BOT_TOKEN"];
|
|
50
|
+
const chatId = cfg.telegram_chat_id ?? process.env["TELEGRAM_CHAT_ID"];
|
|
51
|
+
if (!token || !chatId) return;
|
|
52
|
+
const balance = getBalance(opts.creditDb, opts.owner);
|
|
53
|
+
const skillLabel = opts.skillId ? `${opts.skillName} (${opts.skillId})` : opts.skillName;
|
|
54
|
+
const text = [
|
|
55
|
+
"[AgentBnB] Skill failed",
|
|
56
|
+
`Skill: ${skillLabel}`,
|
|
57
|
+
`Requester: ${opts.requester}`,
|
|
58
|
+
`Reason: ${opts.failureReason}`,
|
|
59
|
+
`Error: ${opts.message}`,
|
|
60
|
+
`Balance: ${balance} credits`,
|
|
61
|
+
`Latency: ${opts.latencyMs}ms`
|
|
62
|
+
].join("\n");
|
|
63
|
+
await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
|
|
64
|
+
method: "POST",
|
|
65
|
+
headers: { "Content-Type": "application/json" },
|
|
66
|
+
body: JSON.stringify({ chat_id: chatId, text })
|
|
67
|
+
});
|
|
68
|
+
}
|
|
46
69
|
async function executeCapabilityRequest(opts) {
|
|
47
70
|
const {
|
|
48
71
|
registryDb,
|
|
@@ -143,6 +166,17 @@ async function executeCapabilityRequest(opts) {
|
|
|
143
166
|
});
|
|
144
167
|
} catch {
|
|
145
168
|
}
|
|
169
|
+
notifyTelegramSkillFailed({
|
|
170
|
+
creditDb,
|
|
171
|
+
owner: card.owner,
|
|
172
|
+
skillName: cardName,
|
|
173
|
+
skillId: resolvedSkillId ?? null,
|
|
174
|
+
requester,
|
|
175
|
+
latencyMs,
|
|
176
|
+
failureReason,
|
|
177
|
+
message
|
|
178
|
+
}).catch(() => {
|
|
179
|
+
});
|
|
146
180
|
return { success: false, error: { code: -32603, message } };
|
|
147
181
|
};
|
|
148
182
|
const handleSuccess = (result, latencyMs) => {
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createPendingRequest
|
|
2
|
+
createPendingRequest
|
|
3
|
+
} from "./chunk-MZSVVG55.js";
|
|
4
|
+
import {
|
|
3
5
|
getAutonomyTier,
|
|
4
6
|
insertAuditEvent
|
|
5
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-G5WKW3ED.js";
|
|
6
8
|
import {
|
|
7
9
|
resolveTargetCapability
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2PP5MQPD.js";
|
|
11
|
+
import {
|
|
12
|
+
fetchRemoteCards
|
|
13
|
+
} from "./chunk-PIPCGRCR.js";
|
|
9
14
|
import {
|
|
10
|
-
fetchRemoteCards,
|
|
11
|
-
getBalance,
|
|
12
15
|
holdEscrow,
|
|
13
16
|
releaseEscrow,
|
|
14
17
|
searchCards,
|
|
15
18
|
settleEscrow
|
|
16
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-HU46M4JA.js";
|
|
17
20
|
import {
|
|
18
21
|
RelayClient
|
|
19
22
|
} from "./chunk-NX27AFPA.js";
|
|
@@ -23,7 +26,7 @@ import {
|
|
|
23
26
|
} from "./chunk-YKMBFQC2.js";
|
|
24
27
|
import {
|
|
25
28
|
findPeer
|
|
26
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-3YQ73ZM6.js";
|
|
27
30
|
import {
|
|
28
31
|
resolveCanonicalIdentity
|
|
29
32
|
} from "./chunk-WTHMHNKC.js";
|
|
@@ -90,51 +93,6 @@ async function requestViaTemporaryRelay(opts) {
|
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
// src/credit/budget.ts
|
|
94
|
-
var DEFAULT_BUDGET_CONFIG = {
|
|
95
|
-
reserve_credits: 20
|
|
96
|
-
};
|
|
97
|
-
var BudgetManager = class {
|
|
98
|
-
/**
|
|
99
|
-
* Creates a new BudgetManager.
|
|
100
|
-
*
|
|
101
|
-
* @param creditDb - The credit SQLite database instance.
|
|
102
|
-
* @param owner - Agent owner identifier.
|
|
103
|
-
* @param config - Budget configuration. Defaults to DEFAULT_BUDGET_CONFIG (20 credit reserve).
|
|
104
|
-
*/
|
|
105
|
-
constructor(creditDb, owner, config = DEFAULT_BUDGET_CONFIG) {
|
|
106
|
-
this.creditDb = creditDb;
|
|
107
|
-
this.owner = owner;
|
|
108
|
-
this.config = config;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Returns the number of credits available for spending.
|
|
112
|
-
* Computed as: max(0, balance - reserve_credits).
|
|
113
|
-
* Always returns a non-negative number — never goes below zero.
|
|
114
|
-
*
|
|
115
|
-
* @returns Available credits (balance minus reserve, floored at 0).
|
|
116
|
-
*/
|
|
117
|
-
availableCredits() {
|
|
118
|
-
const balance = getBalance(this.creditDb, this.owner);
|
|
119
|
-
return Math.max(0, balance - this.config.reserve_credits);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Returns true if spending `amount` credits is permitted by budget rules.
|
|
123
|
-
*
|
|
124
|
-
* Rules:
|
|
125
|
-
* - Zero-cost calls (amount <= 0) always return true.
|
|
126
|
-
* - Any positive amount requires availableCredits() >= amount.
|
|
127
|
-
* - If balance is at or below the reserve floor, all positive-cost calls return false.
|
|
128
|
-
*
|
|
129
|
-
* @param amount - Number of credits to spend.
|
|
130
|
-
* @returns true if the spend is allowed, false if it would breach the reserve floor.
|
|
131
|
-
*/
|
|
132
|
-
canSpend(amount) {
|
|
133
|
-
if (amount <= 0) return true;
|
|
134
|
-
return this.availableCredits() >= amount;
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
96
|
// src/autonomy/auto-request.ts
|
|
139
97
|
function minMaxNormalize(values) {
|
|
140
98
|
if (values.length === 0) return [];
|
|
@@ -522,8 +480,6 @@ var AutoRequestor = class {
|
|
|
522
480
|
|
|
523
481
|
export {
|
|
524
482
|
requestViaTemporaryRelay,
|
|
525
|
-
DEFAULT_BUDGET_CONFIG,
|
|
526
|
-
BudgetManager,
|
|
527
483
|
scorePeers,
|
|
528
484
|
AutoRequestor
|
|
529
485
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getBalance
|
|
3
|
+
} from "./chunk-HU46M4JA.js";
|
|
4
|
+
|
|
5
|
+
// src/credit/budget.ts
|
|
6
|
+
var DEFAULT_BUDGET_CONFIG = {
|
|
7
|
+
reserve_credits: 20
|
|
8
|
+
};
|
|
9
|
+
var BudgetManager = class {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new BudgetManager.
|
|
12
|
+
*
|
|
13
|
+
* @param creditDb - The credit SQLite database instance.
|
|
14
|
+
* @param owner - Agent owner identifier.
|
|
15
|
+
* @param config - Budget configuration. Defaults to DEFAULT_BUDGET_CONFIG (20 credit reserve).
|
|
16
|
+
*/
|
|
17
|
+
constructor(creditDb, owner, config = DEFAULT_BUDGET_CONFIG) {
|
|
18
|
+
this.creditDb = creditDb;
|
|
19
|
+
this.owner = owner;
|
|
20
|
+
this.config = config;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the number of credits available for spending.
|
|
24
|
+
* Computed as: max(0, balance - reserve_credits).
|
|
25
|
+
* Always returns a non-negative number — never goes below zero.
|
|
26
|
+
*
|
|
27
|
+
* @returns Available credits (balance minus reserve, floored at 0).
|
|
28
|
+
*/
|
|
29
|
+
availableCredits() {
|
|
30
|
+
const balance = getBalance(this.creditDb, this.owner);
|
|
31
|
+
return Math.max(0, balance - this.config.reserve_credits);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns true if spending `amount` credits is permitted by budget rules.
|
|
35
|
+
*
|
|
36
|
+
* Rules:
|
|
37
|
+
* - Zero-cost calls (amount <= 0) always return true.
|
|
38
|
+
* - Any positive amount requires availableCredits() >= amount.
|
|
39
|
+
* - If balance is at or below the reserve floor, all positive-cost calls return false.
|
|
40
|
+
*
|
|
41
|
+
* @param amount - Number of credits to spend.
|
|
42
|
+
* @returns true if the spend is allowed, false if it would breach the reserve floor.
|
|
43
|
+
*/
|
|
44
|
+
canSpend(amount) {
|
|
45
|
+
if (amount <= 0) return true;
|
|
46
|
+
return this.availableCredits() >= amount;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
DEFAULT_BUDGET_CONFIG,
|
|
52
|
+
BudgetManager
|
|
53
|
+
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
searchCards
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
AgentBnBError
|
|
6
|
-
} from "./chunk-I7KWA7OB.js";
|
|
3
|
+
} from "./chunk-HU46M4JA.js";
|
|
7
4
|
|
|
8
5
|
// src/registry/pricing.ts
|
|
9
6
|
function getPricingStats(db, query) {
|
|
@@ -46,199 +43,6 @@ function computeMedian(sorted) {
|
|
|
46
43
|
return (sorted[mid - 1] + sorted[mid]) / 2;
|
|
47
44
|
}
|
|
48
45
|
|
|
49
|
-
// src/discovery/mdns.ts
|
|
50
|
-
import { Bonjour } from "bonjour-service";
|
|
51
|
-
var bonjourInstance = null;
|
|
52
|
-
function getBonjour() {
|
|
53
|
-
if (bonjourInstance === null) {
|
|
54
|
-
bonjourInstance = new Bonjour();
|
|
55
|
-
}
|
|
56
|
-
return bonjourInstance;
|
|
57
|
-
}
|
|
58
|
-
function announceGateway(owner, port, metadata) {
|
|
59
|
-
const bonjour = getBonjour();
|
|
60
|
-
const txt = {
|
|
61
|
-
owner,
|
|
62
|
-
version: "1.0",
|
|
63
|
-
...metadata
|
|
64
|
-
};
|
|
65
|
-
bonjour.publish({
|
|
66
|
-
name: owner,
|
|
67
|
-
type: "agentbnb",
|
|
68
|
-
port,
|
|
69
|
-
txt
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
function discoverLocalAgents(onFound, onDown) {
|
|
73
|
-
const bonjour = getBonjour();
|
|
74
|
-
const browser = bonjour.find({ type: "agentbnb" });
|
|
75
|
-
browser.on("up", (service) => {
|
|
76
|
-
const addresses = service.addresses ?? [];
|
|
77
|
-
const ipv4Addresses = addresses.filter((addr) => !addr.includes(":"));
|
|
78
|
-
const host = ipv4Addresses.length > 0 ? ipv4Addresses[0] : service.host;
|
|
79
|
-
const url = `http://${host}:${service.port}`;
|
|
80
|
-
const owner = service.txt?.owner ?? service.name;
|
|
81
|
-
onFound({
|
|
82
|
-
name: service.name,
|
|
83
|
-
url,
|
|
84
|
-
owner
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
if (onDown) {
|
|
88
|
-
browser.on("down", (service) => {
|
|
89
|
-
const addresses = service.addresses ?? [];
|
|
90
|
-
const ipv4Addresses = addresses.filter((addr) => !addr.includes(":"));
|
|
91
|
-
const host = ipv4Addresses.length > 0 ? ipv4Addresses[0] : service.host;
|
|
92
|
-
const url = `http://${host}:${service.port}`;
|
|
93
|
-
const owner = service.txt?.owner ?? service.name;
|
|
94
|
-
onDown({
|
|
95
|
-
name: service.name,
|
|
96
|
-
url,
|
|
97
|
-
owner
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
stop: () => browser.stop()
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
async function stopAnnouncement() {
|
|
106
|
-
if (bonjourInstance === null) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const instance = bonjourInstance;
|
|
110
|
-
bonjourInstance = null;
|
|
111
|
-
await new Promise((resolve2) => {
|
|
112
|
-
instance.unpublishAll(() => {
|
|
113
|
-
instance.destroy();
|
|
114
|
-
resolve2();
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// src/runtime/resolve-self-cli.ts
|
|
120
|
-
import { execFileSync } from "child_process";
|
|
121
|
-
import { existsSync, realpathSync } from "fs";
|
|
122
|
-
import { createRequire } from "module";
|
|
123
|
-
import { homedir } from "os";
|
|
124
|
-
import { basename, isAbsolute, join, resolve } from "path";
|
|
125
|
-
function resolveSelfCli() {
|
|
126
|
-
const require2 = createRequire(import.meta.url);
|
|
127
|
-
return resolveSelfCliWithDeps({
|
|
128
|
-
argv1: process.argv[1],
|
|
129
|
-
cwd: process.cwd(),
|
|
130
|
-
platform: process.platform,
|
|
131
|
-
homeDir: homedir(),
|
|
132
|
-
envPath: process.env["PATH"],
|
|
133
|
-
exists: existsSync,
|
|
134
|
-
realpath: realpathSync,
|
|
135
|
-
runWhich: (pathEnv) => execFileSync("which", ["agentbnb"], {
|
|
136
|
-
encoding: "utf8",
|
|
137
|
-
env: { ...process.env, PATH: pathEnv }
|
|
138
|
-
}).trim(),
|
|
139
|
-
requireResolve: (id) => require2.resolve(id)
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
function resolveSelfCliWithDeps(deps) {
|
|
143
|
-
const tried = [];
|
|
144
|
-
const tryCandidate = (rawPath, label, requireCliShape = false) => {
|
|
145
|
-
if (!rawPath || rawPath.trim().length === 0) {
|
|
146
|
-
tried.push(`${label}: <empty>`);
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
|
-
const maybeAbsolute = isAbsolute(rawPath) ? rawPath : resolve(deps.cwd, rawPath);
|
|
150
|
-
tried.push(`${label}: ${maybeAbsolute}`);
|
|
151
|
-
if (!deps.exists(maybeAbsolute)) return null;
|
|
152
|
-
const resolvedPath = safeRealpath(deps.realpath, maybeAbsolute);
|
|
153
|
-
if (requireCliShape && !looksLikeAgentbnbCli(resolvedPath)) return null;
|
|
154
|
-
return resolvedPath;
|
|
155
|
-
};
|
|
156
|
-
const argvPath = tryCandidate(deps.argv1, "process.argv[1]", true);
|
|
157
|
-
if (argvPath) return argvPath;
|
|
158
|
-
const fullPathEnv = buildFullPathEnv(deps.envPath, deps.homeDir);
|
|
159
|
-
tried.push(`which agentbnb PATH=${fullPathEnv}`);
|
|
160
|
-
try {
|
|
161
|
-
const whichPath = tryCandidate(deps.runWhich(fullPathEnv), "which agentbnb");
|
|
162
|
-
if (whichPath) return whichPath;
|
|
163
|
-
} catch (err) {
|
|
164
|
-
tried.push(`which agentbnb failed: ${extractErrorMessage(err)}`);
|
|
165
|
-
}
|
|
166
|
-
const npmGlobalCandidates = ["/usr/local/bin/agentbnb", "/opt/homebrew/bin/agentbnb"];
|
|
167
|
-
for (const candidate of npmGlobalCandidates) {
|
|
168
|
-
const resolvedPath = tryCandidate(candidate, "npm-global");
|
|
169
|
-
if (resolvedPath) return resolvedPath;
|
|
170
|
-
}
|
|
171
|
-
const pnpmCandidates = getPnpmGlobalCandidates(deps.platform, deps.homeDir);
|
|
172
|
-
for (const candidate of pnpmCandidates) {
|
|
173
|
-
const resolvedPath = tryCandidate(candidate, "pnpm-global");
|
|
174
|
-
if (resolvedPath) return resolvedPath;
|
|
175
|
-
}
|
|
176
|
-
try {
|
|
177
|
-
const requireResolved = deps.requireResolve("agentbnb/dist/cli/index.js");
|
|
178
|
-
const resolvedPath = tryCandidate(requireResolved, "require.resolve(agentbnb/dist/cli/index.js)");
|
|
179
|
-
if (resolvedPath) return resolvedPath;
|
|
180
|
-
} catch (err) {
|
|
181
|
-
tried.push(`require.resolve(agentbnb/dist/cli/index.js) failed: ${extractErrorMessage(err)}`);
|
|
182
|
-
}
|
|
183
|
-
throw new AgentBnBError(
|
|
184
|
-
`Unable to resolve absolute path to agentbnb CLI.
|
|
185
|
-
Paths tried:
|
|
186
|
-
${tried.map((item) => `- ${item}`).join("\n")}`,
|
|
187
|
-
"CLI_ENTRY_NOT_FOUND"
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
function buildFullPathEnv(pathEnv, homeDir) {
|
|
191
|
-
const values = /* @__PURE__ */ new Set();
|
|
192
|
-
for (const item of (pathEnv ?? "").split(":")) {
|
|
193
|
-
if (item.trim()) values.add(item.trim());
|
|
194
|
-
}
|
|
195
|
-
for (const extra of [
|
|
196
|
-
"/usr/local/bin",
|
|
197
|
-
"/opt/homebrew/bin",
|
|
198
|
-
"/usr/bin",
|
|
199
|
-
"/bin",
|
|
200
|
-
"/usr/sbin",
|
|
201
|
-
"/sbin",
|
|
202
|
-
join(homeDir, ".local", "bin"),
|
|
203
|
-
join(homeDir, "Library", "pnpm"),
|
|
204
|
-
join(homeDir, ".local", "share", "pnpm")
|
|
205
|
-
]) {
|
|
206
|
-
values.add(extra);
|
|
207
|
-
}
|
|
208
|
-
return [...values].join(":");
|
|
209
|
-
}
|
|
210
|
-
function safeRealpath(realpath, path) {
|
|
211
|
-
try {
|
|
212
|
-
return realpath(path);
|
|
213
|
-
} catch {
|
|
214
|
-
return path;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
function getPnpmGlobalCandidates(platform, homeDir) {
|
|
218
|
-
const candidates = /* @__PURE__ */ new Set();
|
|
219
|
-
if (platform === "darwin") {
|
|
220
|
-
candidates.add(join(homeDir, "Library", "pnpm", "agentbnb"));
|
|
221
|
-
}
|
|
222
|
-
if (platform === "linux") {
|
|
223
|
-
candidates.add(join(homeDir, ".local", "share", "pnpm", "agentbnb"));
|
|
224
|
-
}
|
|
225
|
-
candidates.add(join(homeDir, "Library", "pnpm", "agentbnb"));
|
|
226
|
-
candidates.add(join(homeDir, ".local", "share", "pnpm", "agentbnb"));
|
|
227
|
-
return [...candidates];
|
|
228
|
-
}
|
|
229
|
-
function looksLikeAgentbnbCli(path) {
|
|
230
|
-
const normalized = path.replace(/\\/g, "/").toLowerCase();
|
|
231
|
-
const fileName = basename(normalized);
|
|
232
|
-
if (fileName === "agentbnb" || fileName === "agentbnb.cmd" || fileName === "agentbnb.exe") {
|
|
233
|
-
return true;
|
|
234
|
-
}
|
|
235
|
-
return normalized.includes("/agentbnb/dist/cli/index.") || normalized.endsWith("/dist/cli/index.js") || normalized.endsWith("/dist/cli/index.mjs") || normalized.endsWith("/dist/cli/index.cjs");
|
|
236
|
-
}
|
|
237
|
-
function extractErrorMessage(err) {
|
|
238
|
-
if (err instanceof Error && err.message) return err.message;
|
|
239
|
-
return String(err);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
46
|
// src/cli/onboarding.ts
|
|
243
47
|
import { randomUUID } from "crypto";
|
|
244
48
|
import { createConnection } from "net";
|
|
@@ -360,20 +164,20 @@ function detectApiKeys(knownKeys) {
|
|
|
360
164
|
return knownKeys.filter((key) => key in process.env);
|
|
361
165
|
}
|
|
362
166
|
async function isPortOpen(port, host = "127.0.0.1", timeoutMs = 300) {
|
|
363
|
-
return new Promise((
|
|
167
|
+
return new Promise((resolve) => {
|
|
364
168
|
const socket = createConnection({ port, host });
|
|
365
169
|
const timer = setTimeout(() => {
|
|
366
170
|
socket.destroy();
|
|
367
|
-
|
|
171
|
+
resolve(false);
|
|
368
172
|
}, timeoutMs);
|
|
369
173
|
socket.on("connect", () => {
|
|
370
174
|
clearTimeout(timer);
|
|
371
175
|
socket.destroy();
|
|
372
|
-
|
|
176
|
+
resolve(true);
|
|
373
177
|
});
|
|
374
178
|
socket.on("error", () => {
|
|
375
179
|
clearTimeout(timer);
|
|
376
|
-
|
|
180
|
+
resolve(false);
|
|
377
181
|
});
|
|
378
182
|
});
|
|
379
183
|
}
|
|
@@ -410,12 +214,8 @@ function buildDraftCard(apiKey, owner) {
|
|
|
410
214
|
|
|
411
215
|
export {
|
|
412
216
|
getPricingStats,
|
|
413
|
-
announceGateway,
|
|
414
|
-
discoverLocalAgents,
|
|
415
|
-
stopAnnouncement,
|
|
416
217
|
KNOWN_API_KEYS,
|
|
417
218
|
detectApiKeys,
|
|
418
219
|
detectOpenPorts,
|
|
419
|
-
buildDraftCard
|
|
420
|
-
resolveSelfCli
|
|
220
|
+
buildDraftCard
|
|
421
221
|
};
|
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
CapabilityCardSchema
|
|
9
9
|
} from "./chunk-I7KWA7OB.js";
|
|
10
10
|
|
|
11
|
+
// src/registry/store.ts
|
|
12
|
+
import Database from "better-sqlite3";
|
|
13
|
+
|
|
11
14
|
// src/registry/request-log.ts
|
|
12
15
|
var SINCE_MS = {
|
|
13
16
|
"24h": 864e5,
|
|
@@ -138,9 +141,6 @@ function getRequestLog(db, limit = 10, since) {
|
|
|
138
141
|
return stmt.all(limit);
|
|
139
142
|
}
|
|
140
143
|
|
|
141
|
-
// src/registry/store.ts
|
|
142
|
-
import Database from "better-sqlite3";
|
|
143
|
-
|
|
144
144
|
// src/feedback/store.ts
|
|
145
145
|
import { randomUUID } from "crypto";
|
|
146
146
|
function initFeedbackTable(db) {
|
|
@@ -843,6 +843,7 @@ export {
|
|
|
843
843
|
getLatestEvolution,
|
|
844
844
|
getEvolutionHistory,
|
|
845
845
|
openDatabase,
|
|
846
|
+
runMigrations,
|
|
846
847
|
insertCard,
|
|
847
848
|
getCard,
|
|
848
849
|
attachCanonicalAgentId,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/autonomy/tiers.ts
|
|
2
|
+
import { randomUUID } from "crypto";
|
|
3
|
+
var DEFAULT_AUTONOMY_CONFIG = {
|
|
4
|
+
tier1_max_credits: 0,
|
|
5
|
+
tier2_max_credits: 0
|
|
6
|
+
};
|
|
7
|
+
function getAutonomyTier(creditAmount, config) {
|
|
8
|
+
if (creditAmount < config.tier1_max_credits) return 1;
|
|
9
|
+
if (creditAmount < config.tier2_max_credits) return 2;
|
|
10
|
+
return 3;
|
|
11
|
+
}
|
|
12
|
+
function insertAuditEvent(db, event) {
|
|
13
|
+
const isShareEvent = event.type === "auto_share" || event.type === "auto_share_notify" || event.type === "auto_share_pending";
|
|
14
|
+
const cardId = isShareEvent ? "system" : event.card_id;
|
|
15
|
+
const creditsCharged = isShareEvent ? 0 : event.credits;
|
|
16
|
+
const stmt = db.prepare(`
|
|
17
|
+
INSERT INTO request_log (
|
|
18
|
+
id, card_id, card_name, requester, status, latency_ms, credits_charged,
|
|
19
|
+
created_at, skill_id, action_type, tier_invoked
|
|
20
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
21
|
+
`);
|
|
22
|
+
stmt.run(
|
|
23
|
+
randomUUID(),
|
|
24
|
+
cardId,
|
|
25
|
+
"autonomy-audit",
|
|
26
|
+
"self",
|
|
27
|
+
"success",
|
|
28
|
+
0,
|
|
29
|
+
creditsCharged,
|
|
30
|
+
(/* @__PURE__ */ new Date()).toISOString(),
|
|
31
|
+
event.skill_id,
|
|
32
|
+
event.type,
|
|
33
|
+
event.tier_invoked
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
DEFAULT_AUTONOMY_CONFIG,
|
|
39
|
+
getAutonomyTier,
|
|
40
|
+
insertAuditEvent
|
|
41
|
+
};
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-U6LP4KWN.js";
|
|
7
7
|
import {
|
|
8
8
|
getFeedbackForProvider
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-COA2D7QM.js";
|
|
10
10
|
import {
|
|
11
11
|
ensureAgentsTable
|
|
12
12
|
} from "./chunk-WTHMHNKC.js";
|
|
@@ -531,89 +531,6 @@ function releaseEscrow(db, escrowId) {
|
|
|
531
531
|
release();
|
|
532
532
|
}
|
|
533
533
|
|
|
534
|
-
// src/cli/remote-registry.ts
|
|
535
|
-
var RegistryTimeoutError = class extends AgentBnBError {
|
|
536
|
-
constructor(url) {
|
|
537
|
-
super(
|
|
538
|
-
`Registry at ${url} did not respond within 5s. Showing local results only.`,
|
|
539
|
-
"REGISTRY_TIMEOUT"
|
|
540
|
-
);
|
|
541
|
-
this.name = "RegistryTimeoutError";
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
var RegistryConnectionError = class extends AgentBnBError {
|
|
545
|
-
constructor(url) {
|
|
546
|
-
super(
|
|
547
|
-
`Cannot reach ${url}. Is the registry running? Showing local results only.`,
|
|
548
|
-
"REGISTRY_CONNECTION"
|
|
549
|
-
);
|
|
550
|
-
this.name = "RegistryConnectionError";
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
|
-
var RegistryAuthError = class extends AgentBnBError {
|
|
554
|
-
constructor(url) {
|
|
555
|
-
super(
|
|
556
|
-
`Authentication failed for ${url}. Run \`agentbnb config set token <your-token>\`.`,
|
|
557
|
-
"REGISTRY_AUTH"
|
|
558
|
-
);
|
|
559
|
-
this.name = "RegistryAuthError";
|
|
560
|
-
}
|
|
561
|
-
};
|
|
562
|
-
async function fetchRemoteCards(registryUrl, params, timeoutMs = 5e3) {
|
|
563
|
-
let cardsUrl;
|
|
564
|
-
try {
|
|
565
|
-
cardsUrl = new URL("/cards", registryUrl);
|
|
566
|
-
} catch {
|
|
567
|
-
throw new AgentBnBError(`Invalid registry URL: ${registryUrl}`, "INVALID_REGISTRY_URL");
|
|
568
|
-
}
|
|
569
|
-
const searchParams = new URLSearchParams();
|
|
570
|
-
if (params.q !== void 0) searchParams.set("q", params.q);
|
|
571
|
-
if (params.level !== void 0) searchParams.set("level", String(params.level));
|
|
572
|
-
if (params.online !== void 0) searchParams.set("online", String(params.online));
|
|
573
|
-
if (params.tag !== void 0) searchParams.set("tag", params.tag);
|
|
574
|
-
searchParams.set("limit", "100");
|
|
575
|
-
cardsUrl.search = searchParams.toString();
|
|
576
|
-
const controller = new AbortController();
|
|
577
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
578
|
-
let response;
|
|
579
|
-
try {
|
|
580
|
-
response = await fetch(cardsUrl.toString(), { signal: controller.signal });
|
|
581
|
-
} catch (err) {
|
|
582
|
-
clearTimeout(timer);
|
|
583
|
-
const isTimeout = err instanceof Error && err.name === "AbortError";
|
|
584
|
-
if (isTimeout) {
|
|
585
|
-
throw new RegistryTimeoutError(registryUrl);
|
|
586
|
-
}
|
|
587
|
-
throw new RegistryConnectionError(registryUrl);
|
|
588
|
-
} finally {
|
|
589
|
-
clearTimeout(timer);
|
|
590
|
-
}
|
|
591
|
-
if (response.status === 401 || response.status === 403) {
|
|
592
|
-
throw new RegistryAuthError(registryUrl);
|
|
593
|
-
}
|
|
594
|
-
if (!response.ok) {
|
|
595
|
-
throw new RegistryConnectionError(registryUrl);
|
|
596
|
-
}
|
|
597
|
-
const body = await response.json();
|
|
598
|
-
return body.items;
|
|
599
|
-
}
|
|
600
|
-
function mergeResults(localCards, remoteCards, hasQuery) {
|
|
601
|
-
const taggedLocal = localCards.map((c) => ({ ...c, source: "local" }));
|
|
602
|
-
const taggedRemote = remoteCards.map((c) => ({ ...c, source: "remote" }));
|
|
603
|
-
const localIds = new Set(localCards.map((c) => c.id));
|
|
604
|
-
const dedupedRemote = taggedRemote.filter((c) => !localIds.has(c.id));
|
|
605
|
-
if (!hasQuery) {
|
|
606
|
-
return [...taggedLocal, ...dedupedRemote];
|
|
607
|
-
}
|
|
608
|
-
const result = [];
|
|
609
|
-
const maxLen = Math.max(taggedLocal.length, dedupedRemote.length);
|
|
610
|
-
for (let i = 0; i < maxLen; i++) {
|
|
611
|
-
if (i < taggedLocal.length) result.push(taggedLocal[i]);
|
|
612
|
-
if (i < dedupedRemote.length) result.push(dedupedRemote[i]);
|
|
613
|
-
}
|
|
614
|
-
return result;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
534
|
export {
|
|
618
535
|
openCreditDb,
|
|
619
536
|
bootstrapAgent,
|
|
@@ -629,7 +546,5 @@ export {
|
|
|
629
546
|
markEscrowProgressing,
|
|
630
547
|
markEscrowAbandoned,
|
|
631
548
|
settleEscrow,
|
|
632
|
-
releaseEscrow
|
|
633
|
-
fetchRemoteCards,
|
|
634
|
-
mergeResults
|
|
549
|
+
releaseEscrow
|
|
635
550
|
};
|