agentbnb 9.0.2 → 9.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/dist/{card-NKQFB3HD.js → card-NQHAGTQQ.js} +3 -1
- package/dist/{card-6KL6L4GF.js → card-VVT3XBOI.js} +3 -1
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/{chunk-76YORWFJ.js → chunk-3Y76PHEY.js} +62 -5
- package/dist/{chunk-QEDVPJKP.js → chunk-4DBSSFHG.js} +20 -16
- package/dist/chunk-4HLGFR72.js +155 -0
- package/dist/{chunk-ERT77HKY.js → chunk-4M6IAIVK.js} +2 -2
- package/dist/{chunk-FUGWPKXN.js → chunk-4UIUIHST.js} +1 -1
- package/dist/chunk-4XTYT4JW.js +147 -0
- package/dist/{chunk-2SOHHB2O.js → chunk-AR7Z3EQB.js} +34 -11
- package/dist/{chunk-Z4IDXMSP.js → chunk-D7NH6YLM.js} +6 -1
- package/dist/{chunk-SLZBE2I5.js → chunk-DBO2335D.js} +17 -12
- package/dist/{chunk-N3TXLBGK.js → chunk-GAZCZCAZ.js} +1 -1
- package/dist/{chunk-UQCQ2JCG.js → chunk-JJHQAZWE.js} +4 -4
- package/dist/{chunk-NLQCHO7N.js → chunk-JKD6QRUD.js} +3 -134
- package/dist/{chunk-74OZGLIT.js → chunk-LENX5NUW.js} +1 -1
- package/dist/{chunk-I3RRMAAD.js → chunk-PIO2FMX4.js} +5 -5
- package/dist/{chunk-77HAL2ZL.js → chunk-PYZGF5QH.js} +60 -3
- package/dist/chunk-Q5OFZ2JR.js +292 -0
- package/dist/{chunk-YJ3RGKPU.js → chunk-QG2LLVXP.js} +6 -2
- package/dist/chunk-QXRNW4OJ.js +35 -0
- package/dist/{chunk-UR3MISL2.js → chunk-UPNREF4L.js} +1 -1
- package/dist/{chunk-SMQDT7CT.js → chunk-UXL7DV7P.js} +7 -3
- package/dist/{chunk-PG3CLSAH.js → chunk-VJ2Q33AP.js} +3 -134
- package/dist/{chunk-DYJ7YGBM.js → chunk-WOVESOQ7.js} +237 -124
- package/dist/{chunk-BNS76U6K.js → chunk-XL5XD3IG.js} +23 -17
- package/dist/{chunk-FMKBCO2Q.js → chunk-ZYOMPJGG.js} +2 -2
- package/dist/cli/index.js +133 -59
- package/dist/{client-YB3IYO3S.js → client-XOSXFC7Q.js} +1 -0
- package/dist/{conduct-URYWMA5T.js → conduct-6C6JWZKZ.js} +13 -10
- package/dist/conduct-VSSHJHVH.js +29 -0
- package/dist/{conductor-mode-NRSVP2AU.js → conductor-mode-KKPSNN7V.js} +9 -6
- package/dist/{conductor-mode-2UFN6BUL.js → conductor-mode-NKHIZG4N.js} +17 -14
- package/dist/{config-IRWLG6IW.js → config-ZFWBAGDU.js} +1 -0
- package/dist/{credits-action-24EPLUHG.js → credits-action-N3WB4WSI.js} +5 -3
- package/dist/{daemon-A7DXZIQW.js → daemon-OM2K3U7J.js} +1 -0
- package/dist/{did-action-MQLDT4RF.js → did-action-3PNFYLX2.js} +1 -0
- package/dist/{execute-DNRNU3HM.js → execute-IEQ3RV7I.js} +6 -3
- package/dist/{execute-2Z3XIUHR.js → execute-QHP4KUV2.js} +10 -7
- package/dist/index.d.ts +412 -275
- package/dist/index.js +886 -282
- package/dist/{openclaw-setup-WA625DZA.js → openclaw-setup-PKGFB4IH.js} +19 -16
- package/dist/{openclaw-skills-76ZWXHFM.js → openclaw-skills-5VJDA6SX.js} +7 -6
- package/dist/{peers-F2EWUMVQ.js → peers-7BMU2775.js} +1 -0
- package/dist/{peers-CJ7T4RJO.js → peers-IOVCBWAI.js} +1 -0
- package/dist/{process-guard-QDBIOLY4.js → process-guard-6324CZDC.js} +1 -0
- package/dist/{publish-capability-FOCHYNYE.js → publish-capability-CHMPZ6W3.js} +4 -2
- package/dist/{reliability-metrics-JSOY3PNW.js → reliability-metrics-22JTZGB4.js} +1 -0
- package/dist/{reliability-metrics-KKUFFVB6.js → reliability-metrics-MIJ3TJWL.js} +1 -0
- package/dist/{request-KPKWBL5W.js → request-6TBVP3GR.js} +12 -9
- package/dist/request-log-2D253WML.js +17 -0
- package/dist/request-log-SIGTGOFA.js +16 -0
- package/dist/{scanner-GP4AOCW6.js → scanner-EFU6NBEJ.js} +1 -0
- package/dist/{schema-7BSSLZ4S.js → schema-FABVZKSI.js} +1 -0
- package/dist/{serve-skill-QSUIK3ZF.js → serve-skill-BRUHUDRA.js} +12 -9
- package/dist/{server-TGV2OPUM.js → server-N4BJW4TS.js} +15 -8
- package/dist/{service-coordinator-4JAUUNUL.js → service-coordinator-M2CBDEUQ.js} +539 -50
- package/dist/session-5AIRM7YF.js +144 -0
- package/dist/session-action-67J57636.js +131 -0
- package/dist/{skill-config-5O2VR546.js → skill-config-VYNF7BCY.js} +1 -0
- package/dist/skill-wrap-IAZHOYM4.js +365 -0
- package/dist/skills/agentbnb/bootstrap.js +564 -75
- package/dist/{store-S22F3I7G.js → store-A4YPEHDV.js} +3 -1
- package/dist/{vc-action-SUD7TMN2.js → vc-action-TSAIABUM.js} +1 -0
- package/dist/websocket-client-FCPZOE4S.js +9 -0
- package/dist/websocket-client-RT4KLJL4.js +8 -0
- package/dist/{writer-4QJ3U3WE.js → writer-V7JBWKKZ.js} +1 -0
- package/package.json +1 -1
- package/dist/chunk-3466S65P.js +0 -179
- package/dist/conduct-UAEEMVFD.js +0 -26
- package/dist/websocket-client-5CRE36Z5.js +0 -7
- package/dist/websocket-client-WHEHIYIZ.js +0 -6
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
attachCanonicalAgentId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JKD6QRUD.js";
|
|
4
4
|
import "./chunk-J4RFJVXI.js";
|
|
5
5
|
import {
|
|
6
6
|
CapabilityCardV2Schema
|
|
7
7
|
} from "./chunk-UVCNMRPS.js";
|
|
8
|
+
import "./chunk-4XTYT4JW.js";
|
|
9
|
+
import "./chunk-3RG5ZIWI.js";
|
|
8
10
|
|
|
9
11
|
// src/conductor/card.ts
|
|
10
12
|
import { createHash } from "crypto";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
attachCanonicalAgentId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VJ2Q33AP.js";
|
|
4
|
+
import "./chunk-4XTYT4JW.js";
|
|
4
5
|
import "./chunk-EE3V3DXK.js";
|
|
5
6
|
import {
|
|
6
7
|
CapabilityCardV2Schema
|
|
7
8
|
} from "./chunk-UVCNMRPS.js";
|
|
9
|
+
import "./chunk-3RG5ZIWI.js";
|
|
8
10
|
|
|
9
11
|
// src/conductor/card.ts
|
|
10
12
|
import { createHash } from "crypto";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__require
|
|
10
|
+
};
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
syncCreditsFromRegistry
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZYOMPJGG.js";
|
|
4
4
|
import {
|
|
5
5
|
resolveTargetCapability
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4M6IAIVK.js";
|
|
7
7
|
import {
|
|
8
8
|
getBalance,
|
|
9
9
|
holdEscrow,
|
|
10
10
|
releaseEscrow,
|
|
11
11
|
settleEscrow
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-D7NH6YLM.js";
|
|
13
13
|
import {
|
|
14
14
|
loadConfig
|
|
15
15
|
} from "./chunk-3XPBFF6H.js";
|
|
16
16
|
import {
|
|
17
17
|
getCard,
|
|
18
|
-
insertRequestLog,
|
|
19
18
|
updateReputation
|
|
20
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-JKD6QRUD.js";
|
|
21
20
|
import {
|
|
22
21
|
AgentBnBError
|
|
23
22
|
} from "./chunk-UVCNMRPS.js";
|
|
23
|
+
import {
|
|
24
|
+
insertRequestLog
|
|
25
|
+
} from "./chunk-4XTYT4JW.js";
|
|
24
26
|
|
|
25
27
|
// src/gateway/execute.ts
|
|
26
28
|
import { randomUUID } from "crypto";
|
|
@@ -69,6 +71,26 @@ async function notifyTelegramSkillFailed(opts) {
|
|
|
69
71
|
body: JSON.stringify({ chat_id: chatId, text })
|
|
70
72
|
});
|
|
71
73
|
}
|
|
74
|
+
async function notifyTelegramSkillReceived(opts) {
|
|
75
|
+
const cfg = loadConfig();
|
|
76
|
+
if (cfg?.provider_gate !== "notify") return;
|
|
77
|
+
const token = cfg.telegram_bot_token ?? process.env["TELEGRAM_BOT_TOKEN"];
|
|
78
|
+
const chatId = cfg.telegram_chat_id ?? process.env["TELEGRAM_CHAT_ID"];
|
|
79
|
+
if (!token || !chatId) return;
|
|
80
|
+
const skillLabel = opts.skillId ? `${opts.skillName} (${opts.skillId})` : opts.skillName;
|
|
81
|
+
const text = [
|
|
82
|
+
"\u{1F4E5} [AgentBnB] Incoming rental request",
|
|
83
|
+
`Skill: ${skillLabel}`,
|
|
84
|
+
`Requester: ${opts.requester}`,
|
|
85
|
+
`Cost: ${opts.cost} credits`,
|
|
86
|
+
`Status: Executing...`
|
|
87
|
+
].join("\n");
|
|
88
|
+
await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
|
|
89
|
+
method: "POST",
|
|
90
|
+
headers: { "Content-Type": "application/json" },
|
|
91
|
+
body: JSON.stringify({ chat_id: chatId, text })
|
|
92
|
+
});
|
|
93
|
+
}
|
|
72
94
|
async function executeCapabilityRequest(opts) {
|
|
73
95
|
const {
|
|
74
96
|
registryDb,
|
|
@@ -160,6 +182,41 @@ async function executeCapabilityRequest(opts) {
|
|
|
160
182
|
return { success: false, error: { code: -32603, message: msg } };
|
|
161
183
|
}
|
|
162
184
|
}
|
|
185
|
+
const providerCfg = loadConfig();
|
|
186
|
+
const providerWhitelist = providerCfg?.provider_whitelist ?? [];
|
|
187
|
+
const isWhitelisted = providerWhitelist.includes(requester);
|
|
188
|
+
if (providerCfg?.provider_accepting === false && !isWhitelisted) {
|
|
189
|
+
if (escrowId) releaseEscrow(creditDb, escrowId);
|
|
190
|
+
return { success: false, error: { code: -32098, message: "Provider is not accepting requests" } };
|
|
191
|
+
}
|
|
192
|
+
if (!isWhitelisted) {
|
|
193
|
+
const blacklist = providerCfg?.provider_blacklist ?? [];
|
|
194
|
+
if (blacklist.includes(requester)) {
|
|
195
|
+
if (escrowId) releaseEscrow(creditDb, escrowId);
|
|
196
|
+
return { success: false, error: { code: -32097, message: "Requester is blocked by provider" } };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!isWhitelisted) {
|
|
200
|
+
const dailyLimit = providerCfg?.provider_daily_limit ?? 0;
|
|
201
|
+
if (dailyLimit > 0) {
|
|
202
|
+
const { countTodayExecutions } = await import("./request-log-2D253WML.js");
|
|
203
|
+
const todayCount = countTodayExecutions(registryDb);
|
|
204
|
+
if (todayCount >= dailyLimit) {
|
|
205
|
+
if (escrowId) releaseEscrow(creditDb, escrowId);
|
|
206
|
+
return {
|
|
207
|
+
success: false,
|
|
208
|
+
error: { code: -32099, message: `Provider daily execution limit reached (${dailyLimit}/day)` }
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
notifyTelegramSkillReceived({
|
|
214
|
+
skillName: cardName,
|
|
215
|
+
skillId: resolvedSkillId ?? null,
|
|
216
|
+
requester,
|
|
217
|
+
cost: creditsNeeded
|
|
218
|
+
}).catch(() => {
|
|
219
|
+
});
|
|
163
220
|
const startMs = Date.now();
|
|
164
221
|
const handleFailure = (status, latencyMs, message, failureReason = "bad_execution") => {
|
|
165
222
|
if (escrowId) releaseEscrow(creditDb, escrowId);
|
|
@@ -1,29 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadCoreConfig
|
|
3
|
+
} from "./chunk-QXRNW4OJ.js";
|
|
1
4
|
import {
|
|
2
5
|
getFeedbackForProvider
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JKD6QRUD.js";
|
|
4
7
|
|
|
5
8
|
// src/feedback/reputation.ts
|
|
9
|
+
var coreReputation = loadCoreConfig("reputation");
|
|
6
10
|
var QUALITY_SCORES = {
|
|
7
|
-
excellent: 1,
|
|
8
|
-
good: 0.8,
|
|
9
|
-
acceptable: 0.6,
|
|
10
|
-
poor: 0.3,
|
|
11
|
-
failed: 0
|
|
11
|
+
excellent: coreReputation?.quality_scores?.["excellent"] ?? 1,
|
|
12
|
+
good: coreReputation?.quality_scores?.["good"] ?? 0.8,
|
|
13
|
+
acceptable: coreReputation?.quality_scores?.["acceptable"] ?? 0.6,
|
|
14
|
+
poor: coreReputation?.quality_scores?.["poor"] ?? 0.3,
|
|
15
|
+
failed: coreReputation?.quality_scores?.["failed"] ?? 0
|
|
12
16
|
};
|
|
13
17
|
var COST_VALUE_SCORES = {
|
|
14
|
-
great: 1,
|
|
15
|
-
fair: 0.6,
|
|
16
|
-
overpriced: 0.2
|
|
18
|
+
great: coreReputation?.cost_value_scores?.["great"] ?? 1,
|
|
19
|
+
fair: coreReputation?.cost_value_scores?.["fair"] ?? 0.6,
|
|
20
|
+
overpriced: coreReputation?.cost_value_scores?.["overpriced"] ?? 0.2
|
|
17
21
|
};
|
|
18
|
-
var DECAY_DAYS = 30;
|
|
22
|
+
var DECAY_DAYS = coreReputation?.decay_days ?? 30;
|
|
19
23
|
var WEIGHTS = {
|
|
20
|
-
rating: 0.4,
|
|
21
|
-
quality: 0.3,
|
|
22
|
-
would_reuse: 0.2,
|
|
23
|
-
cost_value: 0.1
|
|
24
|
+
rating: coreReputation?.weights?.["rating"] ?? 0.4,
|
|
25
|
+
quality: coreReputation?.weights?.["quality"] ?? 0.3,
|
|
26
|
+
would_reuse: coreReputation?.weights?.["would_reuse"] ?? 0.2,
|
|
27
|
+
cost_value: coreReputation?.weights?.["cost_value"] ?? 0.1
|
|
24
28
|
};
|
|
25
29
|
function computeReputation(feedbacks) {
|
|
26
|
-
if (feedbacks.length === 0) return 0.5;
|
|
30
|
+
if (feedbacks.length === 0) return coreReputation?.cold_start_score ?? 0.5;
|
|
27
31
|
const now = Date.now();
|
|
28
32
|
let weightedSum = 0;
|
|
29
33
|
let totalWeight = 0;
|
|
@@ -39,7 +43,7 @@ function computeReputation(feedbacks) {
|
|
|
39
43
|
weightedSum += recencyWeight * componentScore;
|
|
40
44
|
totalWeight += recencyWeight;
|
|
41
45
|
}
|
|
42
|
-
if (totalWeight === 0) return 0.5;
|
|
46
|
+
if (totalWeight === 0) return coreReputation?.cold_start_score ?? 0.5;
|
|
43
47
|
const raw = weightedSum / totalWeight;
|
|
44
48
|
return Math.max(0, Math.min(1, raw));
|
|
45
49
|
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
// src/registry/request-log.ts
|
|
9
|
+
var SINCE_MS = {
|
|
10
|
+
"24h": 864e5,
|
|
11
|
+
"7d": 6048e5,
|
|
12
|
+
"30d": 2592e6
|
|
13
|
+
};
|
|
14
|
+
function createRequestLogTable(db) {
|
|
15
|
+
db.exec(`
|
|
16
|
+
CREATE TABLE IF NOT EXISTS request_log (
|
|
17
|
+
id TEXT PRIMARY KEY,
|
|
18
|
+
card_id TEXT NOT NULL,
|
|
19
|
+
card_name TEXT NOT NULL,
|
|
20
|
+
requester TEXT NOT NULL,
|
|
21
|
+
status TEXT NOT NULL CHECK(status IN ('success', 'failure', 'timeout')),
|
|
22
|
+
latency_ms INTEGER NOT NULL,
|
|
23
|
+
credits_charged INTEGER NOT NULL,
|
|
24
|
+
created_at TEXT NOT NULL
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
CREATE INDEX IF NOT EXISTS request_log_created_at_idx
|
|
28
|
+
ON request_log (created_at DESC);
|
|
29
|
+
`);
|
|
30
|
+
try {
|
|
31
|
+
db.exec("ALTER TABLE request_log ADD COLUMN skill_id TEXT");
|
|
32
|
+
} catch {
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
db.exec("ALTER TABLE request_log ADD COLUMN action_type TEXT");
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
db.exec("ALTER TABLE request_log ADD COLUMN tier_invoked INTEGER");
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
db.exec("ALTER TABLE request_log ADD COLUMN failure_reason TEXT");
|
|
44
|
+
} catch {
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
db.exec("ALTER TABLE request_log ADD COLUMN team_id TEXT");
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
db.exec("ALTER TABLE request_log ADD COLUMN role TEXT");
|
|
52
|
+
} catch {
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
db.exec("ALTER TABLE request_log ADD COLUMN capability_type TEXT");
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function insertRequestLog(db, entry) {
|
|
60
|
+
const stmt = db.prepare(`
|
|
61
|
+
INSERT INTO request_log (id, card_id, card_name, requester, status, latency_ms, credits_charged, created_at, skill_id, action_type, tier_invoked, failure_reason, team_id, role, capability_type)
|
|
62
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
63
|
+
`);
|
|
64
|
+
stmt.run(
|
|
65
|
+
entry.id,
|
|
66
|
+
entry.card_id,
|
|
67
|
+
entry.card_name,
|
|
68
|
+
entry.requester,
|
|
69
|
+
entry.status,
|
|
70
|
+
entry.latency_ms,
|
|
71
|
+
entry.credits_charged,
|
|
72
|
+
entry.created_at,
|
|
73
|
+
entry.skill_id ?? null,
|
|
74
|
+
entry.action_type ?? null,
|
|
75
|
+
entry.tier_invoked ?? null,
|
|
76
|
+
entry.failure_reason ?? null,
|
|
77
|
+
entry.team_id ?? null,
|
|
78
|
+
entry.role ?? null,
|
|
79
|
+
entry.capability_type ?? null
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
function getSkillRequestCount(db, skillId, windowMs) {
|
|
83
|
+
const cutoff = new Date(Date.now() - windowMs).toISOString();
|
|
84
|
+
const stmt = db.prepare(
|
|
85
|
+
`SELECT COUNT(*) as cnt FROM request_log
|
|
86
|
+
WHERE skill_id = ? AND created_at >= ? AND status = 'success' AND action_type IS NULL`
|
|
87
|
+
);
|
|
88
|
+
const row = stmt.get(skillId, cutoff);
|
|
89
|
+
return row.cnt;
|
|
90
|
+
}
|
|
91
|
+
function getActivityFeed(db, limit = 20, since) {
|
|
92
|
+
const effectiveLimit = Math.min(limit, 100);
|
|
93
|
+
if (since !== void 0) {
|
|
94
|
+
const stmt2 = db.prepare(`
|
|
95
|
+
SELECT r.id, r.card_name, r.requester, c.owner AS provider,
|
|
96
|
+
r.status, r.credits_charged, r.latency_ms, r.created_at, r.action_type
|
|
97
|
+
FROM request_log r
|
|
98
|
+
LEFT JOIN capability_cards c ON r.card_id = c.id
|
|
99
|
+
WHERE (r.action_type IS NULL OR r.action_type IN ('auto_share', 'agent_joined'))
|
|
100
|
+
AND r.created_at > ?
|
|
101
|
+
ORDER BY r.created_at DESC
|
|
102
|
+
LIMIT ?
|
|
103
|
+
`);
|
|
104
|
+
return stmt2.all(since, effectiveLimit);
|
|
105
|
+
}
|
|
106
|
+
const stmt = db.prepare(`
|
|
107
|
+
SELECT r.id, r.card_name, r.requester, c.owner AS provider,
|
|
108
|
+
r.status, r.credits_charged, r.latency_ms, r.created_at, r.action_type
|
|
109
|
+
FROM request_log r
|
|
110
|
+
LEFT JOIN capability_cards c ON r.card_id = c.id
|
|
111
|
+
WHERE (r.action_type IS NULL OR r.action_type IN ('auto_share', 'agent_joined'))
|
|
112
|
+
ORDER BY r.created_at DESC
|
|
113
|
+
LIMIT ?
|
|
114
|
+
`);
|
|
115
|
+
return stmt.all(effectiveLimit);
|
|
116
|
+
}
|
|
117
|
+
function countTodayExecutions(db) {
|
|
118
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
119
|
+
const stmt = db.prepare(
|
|
120
|
+
`SELECT COUNT(*) as cnt FROM request_log
|
|
121
|
+
WHERE created_at >= ? AND action_type IS NULL`
|
|
122
|
+
);
|
|
123
|
+
const row = stmt.get(today + "T00:00:00.000Z");
|
|
124
|
+
return row.cnt;
|
|
125
|
+
}
|
|
126
|
+
function getRequestLog(db, limit = 10, since) {
|
|
127
|
+
if (since !== void 0) {
|
|
128
|
+
const cutoff = new Date(Date.now() - SINCE_MS[since]).toISOString();
|
|
129
|
+
const stmt2 = db.prepare(`
|
|
130
|
+
SELECT id, card_id, card_name, requester, status, latency_ms, credits_charged, created_at, skill_id, action_type, tier_invoked, failure_reason, team_id, role, capability_type
|
|
131
|
+
FROM request_log
|
|
132
|
+
WHERE created_at >= ?
|
|
133
|
+
ORDER BY created_at DESC
|
|
134
|
+
LIMIT ?
|
|
135
|
+
`);
|
|
136
|
+
return stmt2.all(cutoff, limit);
|
|
137
|
+
}
|
|
138
|
+
const stmt = db.prepare(`
|
|
139
|
+
SELECT id, card_id, card_name, requester, status, latency_ms, credits_charged, created_at, skill_id, action_type, tier_invoked, failure_reason, team_id, role
|
|
140
|
+
FROM request_log
|
|
141
|
+
ORDER BY created_at DESC
|
|
142
|
+
LIMIT ?
|
|
143
|
+
`);
|
|
144
|
+
return stmt.all(limit);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
__require,
|
|
149
|
+
createRequestLogTable,
|
|
150
|
+
insertRequestLog,
|
|
151
|
+
getSkillRequestCount,
|
|
152
|
+
getActivityFeed,
|
|
153
|
+
countTodayExecutions,
|
|
154
|
+
getRequestLog
|
|
155
|
+
};
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./chunk-ELFGYC22.js";
|
|
4
4
|
import {
|
|
5
5
|
searchCards
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4DBSSFHG.js";
|
|
7
7
|
import {
|
|
8
8
|
getCard
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JKD6QRUD.js";
|
|
10
10
|
import {
|
|
11
11
|
resolveCanonicalIdentity
|
|
12
12
|
} from "./chunk-J4RFJVXI.js";
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// src/registry/request-log.ts
|
|
2
|
+
var SINCE_MS = {
|
|
3
|
+
"24h": 864e5,
|
|
4
|
+
"7d": 6048e5,
|
|
5
|
+
"30d": 2592e6
|
|
6
|
+
};
|
|
7
|
+
function createRequestLogTable(db) {
|
|
8
|
+
db.exec(`
|
|
9
|
+
CREATE TABLE IF NOT EXISTS request_log (
|
|
10
|
+
id TEXT PRIMARY KEY,
|
|
11
|
+
card_id TEXT NOT NULL,
|
|
12
|
+
card_name TEXT NOT NULL,
|
|
13
|
+
requester TEXT NOT NULL,
|
|
14
|
+
status TEXT NOT NULL CHECK(status IN ('success', 'failure', 'timeout')),
|
|
15
|
+
latency_ms INTEGER NOT NULL,
|
|
16
|
+
credits_charged INTEGER NOT NULL,
|
|
17
|
+
created_at TEXT NOT NULL
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
CREATE INDEX IF NOT EXISTS request_log_created_at_idx
|
|
21
|
+
ON request_log (created_at DESC);
|
|
22
|
+
`);
|
|
23
|
+
try {
|
|
24
|
+
db.exec("ALTER TABLE request_log ADD COLUMN skill_id TEXT");
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
db.exec("ALTER TABLE request_log ADD COLUMN action_type TEXT");
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
db.exec("ALTER TABLE request_log ADD COLUMN tier_invoked INTEGER");
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
db.exec("ALTER TABLE request_log ADD COLUMN failure_reason TEXT");
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
db.exec("ALTER TABLE request_log ADD COLUMN team_id TEXT");
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
db.exec("ALTER TABLE request_log ADD COLUMN role TEXT");
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
db.exec("ALTER TABLE request_log ADD COLUMN capability_type TEXT");
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function insertRequestLog(db, entry) {
|
|
53
|
+
const stmt = db.prepare(`
|
|
54
|
+
INSERT INTO request_log (id, card_id, card_name, requester, status, latency_ms, credits_charged, created_at, skill_id, action_type, tier_invoked, failure_reason, team_id, role, capability_type)
|
|
55
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
56
|
+
`);
|
|
57
|
+
stmt.run(
|
|
58
|
+
entry.id,
|
|
59
|
+
entry.card_id,
|
|
60
|
+
entry.card_name,
|
|
61
|
+
entry.requester,
|
|
62
|
+
entry.status,
|
|
63
|
+
entry.latency_ms,
|
|
64
|
+
entry.credits_charged,
|
|
65
|
+
entry.created_at,
|
|
66
|
+
entry.skill_id ?? null,
|
|
67
|
+
entry.action_type ?? null,
|
|
68
|
+
entry.tier_invoked ?? null,
|
|
69
|
+
entry.failure_reason ?? null,
|
|
70
|
+
entry.team_id ?? null,
|
|
71
|
+
entry.role ?? null,
|
|
72
|
+
entry.capability_type ?? null
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
function getSkillRequestCount(db, skillId, windowMs) {
|
|
76
|
+
const cutoff = new Date(Date.now() - windowMs).toISOString();
|
|
77
|
+
const stmt = db.prepare(
|
|
78
|
+
`SELECT COUNT(*) as cnt FROM request_log
|
|
79
|
+
WHERE skill_id = ? AND created_at >= ? AND status = 'success' AND action_type IS NULL`
|
|
80
|
+
);
|
|
81
|
+
const row = stmt.get(skillId, cutoff);
|
|
82
|
+
return row.cnt;
|
|
83
|
+
}
|
|
84
|
+
function getActivityFeed(db, limit = 20, since) {
|
|
85
|
+
const effectiveLimit = Math.min(limit, 100);
|
|
86
|
+
if (since !== void 0) {
|
|
87
|
+
const stmt2 = db.prepare(`
|
|
88
|
+
SELECT r.id, r.card_name, r.requester, c.owner AS provider,
|
|
89
|
+
r.status, r.credits_charged, r.latency_ms, r.created_at, r.action_type
|
|
90
|
+
FROM request_log r
|
|
91
|
+
LEFT JOIN capability_cards c ON r.card_id = c.id
|
|
92
|
+
WHERE (r.action_type IS NULL OR r.action_type IN ('auto_share', 'agent_joined'))
|
|
93
|
+
AND r.created_at > ?
|
|
94
|
+
ORDER BY r.created_at DESC
|
|
95
|
+
LIMIT ?
|
|
96
|
+
`);
|
|
97
|
+
return stmt2.all(since, effectiveLimit);
|
|
98
|
+
}
|
|
99
|
+
const stmt = db.prepare(`
|
|
100
|
+
SELECT r.id, r.card_name, r.requester, c.owner AS provider,
|
|
101
|
+
r.status, r.credits_charged, r.latency_ms, r.created_at, r.action_type
|
|
102
|
+
FROM request_log r
|
|
103
|
+
LEFT JOIN capability_cards c ON r.card_id = c.id
|
|
104
|
+
WHERE (r.action_type IS NULL OR r.action_type IN ('auto_share', 'agent_joined'))
|
|
105
|
+
ORDER BY r.created_at DESC
|
|
106
|
+
LIMIT ?
|
|
107
|
+
`);
|
|
108
|
+
return stmt.all(effectiveLimit);
|
|
109
|
+
}
|
|
110
|
+
function countTodayExecutions(db) {
|
|
111
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
112
|
+
const stmt = db.prepare(
|
|
113
|
+
`SELECT COUNT(*) as cnt FROM request_log
|
|
114
|
+
WHERE created_at >= ? AND action_type IS NULL`
|
|
115
|
+
);
|
|
116
|
+
const row = stmt.get(today + "T00:00:00.000Z");
|
|
117
|
+
return row.cnt;
|
|
118
|
+
}
|
|
119
|
+
function getRequestLog(db, limit = 10, since) {
|
|
120
|
+
if (since !== void 0) {
|
|
121
|
+
const cutoff = new Date(Date.now() - SINCE_MS[since]).toISOString();
|
|
122
|
+
const stmt2 = db.prepare(`
|
|
123
|
+
SELECT id, card_id, card_name, requester, status, latency_ms, credits_charged, created_at, skill_id, action_type, tier_invoked, failure_reason, team_id, role, capability_type
|
|
124
|
+
FROM request_log
|
|
125
|
+
WHERE created_at >= ?
|
|
126
|
+
ORDER BY created_at DESC
|
|
127
|
+
LIMIT ?
|
|
128
|
+
`);
|
|
129
|
+
return stmt2.all(cutoff, limit);
|
|
130
|
+
}
|
|
131
|
+
const stmt = db.prepare(`
|
|
132
|
+
SELECT id, card_id, card_name, requester, status, latency_ms, credits_charged, created_at, skill_id, action_type, tier_invoked, failure_reason, team_id, role
|
|
133
|
+
FROM request_log
|
|
134
|
+
ORDER BY created_at DESC
|
|
135
|
+
LIMIT ?
|
|
136
|
+
`);
|
|
137
|
+
return stmt.all(limit);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export {
|
|
141
|
+
createRequestLogTable,
|
|
142
|
+
insertRequestLog,
|
|
143
|
+
getSkillRequestCount,
|
|
144
|
+
getActivityFeed,
|
|
145
|
+
countTodayExecutions,
|
|
146
|
+
getRequestLog
|
|
147
|
+
};
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_BUDGET_CONFIG
|
|
3
|
-
} from "./chunk-YJ3RGKPU.js";
|
|
4
1
|
import {
|
|
5
2
|
KNOWN_API_KEYS,
|
|
6
3
|
buildDraftCard,
|
|
7
4
|
detectApiKeys,
|
|
8
5
|
detectOpenPorts
|
|
9
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4UIUIHST.js";
|
|
7
|
+
import {
|
|
8
|
+
parseSoulMd
|
|
9
|
+
} from "./chunk-GAZCZCAZ.js";
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_BUDGET_CONFIG
|
|
12
|
+
} from "./chunk-QG2LLVXP.js";
|
|
10
13
|
import {
|
|
11
14
|
DEFAULT_AUTONOMY_CONFIG
|
|
12
15
|
} from "./chunk-G5WKW3ED.js";
|
|
13
16
|
import {
|
|
14
17
|
createLedger
|
|
15
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-LENX5NUW.js";
|
|
16
19
|
import {
|
|
17
20
|
loadOrRepairIdentity
|
|
18
21
|
} from "./chunk-5CC6O6SO.js";
|
|
@@ -21,21 +24,18 @@ import {
|
|
|
21
24
|
getBalance,
|
|
22
25
|
migrateOwner,
|
|
23
26
|
openCreditDb
|
|
24
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-D7NH6YLM.js";
|
|
25
28
|
import {
|
|
26
29
|
getConfigDir,
|
|
27
30
|
loadConfig,
|
|
28
31
|
saveConfig
|
|
29
32
|
} from "./chunk-3XPBFF6H.js";
|
|
30
|
-
import {
|
|
31
|
-
parseSoulMd
|
|
32
|
-
} from "./chunk-N3TXLBGK.js";
|
|
33
33
|
import {
|
|
34
34
|
attachCanonicalAgentId,
|
|
35
35
|
insertCard,
|
|
36
36
|
listCards,
|
|
37
37
|
openDatabase
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-JKD6QRUD.js";
|
|
39
39
|
import {
|
|
40
40
|
createAgentRecord,
|
|
41
41
|
lookupAgent,
|
|
@@ -166,10 +166,12 @@ function publishFromSoulV2(db, soulContent, owner, sharedSkills) {
|
|
|
166
166
|
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
167
167
|
var HEARTBEAT_MARKER_START = "<!-- agentbnb:start -->";
|
|
168
168
|
var HEARTBEAT_MARKER_END = "<!-- agentbnb:end -->";
|
|
169
|
-
function generateHeartbeatSection(autonomy, budget) {
|
|
169
|
+
function generateHeartbeatSection(autonomy, budget, config) {
|
|
170
170
|
const t1 = autonomy.tier1_max_credits;
|
|
171
171
|
const t2 = autonomy.tier2_max_credits;
|
|
172
172
|
const reserve = budget.reserve_credits;
|
|
173
|
+
const dailyLimit = config?.provider_daily_limit ?? 0;
|
|
174
|
+
const dailyLimitLabel = dailyLimit === 0 ? "unlimited" : `${dailyLimit}/day`;
|
|
173
175
|
return [
|
|
174
176
|
HEARTBEAT_MARKER_START,
|
|
175
177
|
"## AgentBnB Protocol",
|
|
@@ -195,6 +197,27 @@ function generateHeartbeatSection(autonomy, budget) {
|
|
|
195
197
|
`- Maintain minimum balance of ${reserve} credits (reserve for emergencies)`,
|
|
196
198
|
`- If balance drops below ${reserve}, increase sharing priority`,
|
|
197
199
|
"- If balance exceeds 500, notify owner of surplus",
|
|
200
|
+
"",
|
|
201
|
+
"### Provider Control",
|
|
202
|
+
"",
|
|
203
|
+
"Owner can control incoming rental requests via natural language.",
|
|
204
|
+
`Current daily limit: ${dailyLimitLabel}.`,
|
|
205
|
+
"",
|
|
206
|
+
"**All commands require the AGENTBNB_DIR prefix for your agent.**",
|
|
207
|
+
"",
|
|
208
|
+
"| Owner says | Command |",
|
|
209
|
+
"|------------|---------|",
|
|
210
|
+
"| Stop accepting / \u505C\u6B62\u63A5\u55AE | `agentbnb config set provider-accepting false` |",
|
|
211
|
+
"| Start accepting / \u958B\u59CB\u63A5\u55AE | `agentbnb config set provider-accepting true` |",
|
|
212
|
+
"| Block \\<agent_id\\> / \u5C01\u9396 | `agentbnb config set provider-blacklist <current>,<agent_id>` |",
|
|
213
|
+
"| Unblock \\<agent_id\\> / \u89E3\u9664\u5C01\u9396 | `agentbnb config set provider-blacklist <without_agent_id>` |",
|
|
214
|
+
"| Set daily limit to N | `agentbnb config set provider-daily-limit N` |",
|
|
215
|
+
"| Remove daily limit | `agentbnb config set provider-daily-limit 0` |",
|
|
216
|
+
"| Check status / \u67E5\u770B\u72C0\u614B | `agentbnb config get provider-accepting` |",
|
|
217
|
+
"",
|
|
218
|
+
"Before modifying blacklist: read current value first with `agentbnb config get provider-blacklist`,",
|
|
219
|
+
"then append or remove the agent ID from the comma-separated list.",
|
|
220
|
+
"Changes take effect immediately \u2014 no serve restart needed.",
|
|
198
221
|
HEARTBEAT_MARKER_END
|
|
199
222
|
].join("\n");
|
|
200
223
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadCoreConfig
|
|
3
|
+
} from "./chunk-QXRNW4OJ.js";
|
|
1
4
|
import {
|
|
2
5
|
canonicalizeCreditOwner,
|
|
3
6
|
ensureReliabilityTable,
|
|
@@ -163,7 +166,8 @@ function migrateOwner(db, oldOwner, newOwner) {
|
|
|
163
166
|
|
|
164
167
|
// src/credit/escrow.ts
|
|
165
168
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
166
|
-
var
|
|
169
|
+
var coreEconomics = loadCoreConfig("economics");
|
|
170
|
+
var NETWORK_FEE_RATE = coreEconomics?.network_fee_rate ?? 0.05;
|
|
167
171
|
var FINALIZABLE_ESCROW_STATUSES = /* @__PURE__ */ new Set([
|
|
168
172
|
"held",
|
|
169
173
|
"started",
|
|
@@ -341,6 +345,7 @@ export {
|
|
|
341
345
|
getBalance,
|
|
342
346
|
getTransactions,
|
|
343
347
|
migrateOwner,
|
|
348
|
+
NETWORK_FEE_RATE,
|
|
344
349
|
holdEscrow,
|
|
345
350
|
markEscrowStarted,
|
|
346
351
|
markEscrowProgressing,
|