agentbnb 9.1.1 → 9.2.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/README.md +22 -0
- package/dist/{card-UF465O7O.js → card-L3ZPPBVI.js} +3 -3
- package/dist/{chunk-LENX5NUW.js → chunk-2KSRFDKF.js} +56 -3
- package/dist/{chunk-TCA63C42.js → chunk-563ZZUOA.js} +61 -27
- package/dist/chunk-5FXLZ5FX.js +16 -0
- package/dist/{chunk-ELFGYC22.js → chunk-7YJOBVWN.js} +3 -0
- package/dist/{chunk-5CC6O6SO.js → chunk-AA25Z6FW.js} +1 -1
- package/dist/{chunk-WARYO57F.js → chunk-COOBXNXU.js} +6 -6
- package/dist/{chunk-I4E5ERDN.js → chunk-CPSV5WR2.js} +1 -1
- package/dist/{process-guard-6324CZDC.js → chunk-DG4FQ4MD.js} +1 -1
- package/dist/{chunk-MPS4RE7T.js → chunk-DT2IEL5U.js} +11 -0
- package/dist/chunk-EMVVFP2L.js +54 -0
- package/dist/{chunk-O44N3KR7.js → chunk-FVLHEI3Y.js} +5 -5
- package/dist/chunk-GIK2AZQH.js +23 -0
- package/dist/{chunk-W6LOCBWQ.js → chunk-IWAK4WHK.js} +1 -1
- package/dist/{chunk-Y7CO3VLF.js → chunk-NISX3N7K.js} +16 -7
- package/dist/{chunk-2HH2F3DM.js → chunk-NLGLGR2K.js} +55 -2
- package/dist/{chunk-AW4VSROG.js → chunk-OFIRWD6B.js} +1 -1
- package/dist/{chunk-AMABG5SI.js → chunk-OI46BKQF.js} +12 -12
- package/dist/{chunk-F2CIPAN2.js → chunk-OTAZIF65.js} +2 -2
- package/dist/{chunk-ZYOMPJGG.js → chunk-OXU4QJSZ.js} +3 -3
- package/dist/{chunk-RVOZHVM7.js → chunk-PFAEZI32.js} +10 -10
- package/dist/{chunk-D7NH6YLM.js → chunk-UJXDBOKV.js} +12 -1
- package/dist/{chunk-G4TF4LB4.js → chunk-VDYHCI5F.js} +22 -1
- package/dist/{chunk-QG2LLVXP.js → chunk-WA23XRTN.js} +1 -1
- package/dist/cli/index.js +797 -107
- package/dist/{client-XOSXFC7Q.js → client-KL67WZVJ.js} +2 -2
- package/dist/{conduct-UT6ZYSJD.js → conduct-65BGO2EU.js} +16 -14
- package/dist/{conduct-MALC6HEK.js → conduct-AALDEKTH.js} +16 -14
- package/dist/{conductor-mode-3WLLERB4.js → conductor-mode-6S6ADNLW.js} +18 -18
- package/dist/{conductor-mode-UJKMO2GW.js → conductor-mode-HJHU4XLT.js} +4 -4
- package/dist/{credits-action-KOUJNR36.js → credits-action-CLLPNRDT.js} +17 -8
- package/dist/{did-action-UHUYMA4Y.js → did-action-ERXWCVEJ.js} +3 -3
- package/dist/{execute-UFMGTXET.js → execute-R5STYWLD.js} +13 -13
- package/dist/{execute-3RADNI74.js → execute-YMPHTJPN.js} +3 -3
- package/dist/{openclaw-setup-HEWZZOY7.js → openclaw-setup-HUOBTGN4.js} +17 -15
- package/dist/{openclaw-skills-5XLQFRWT.js → openclaw-skills-74372B6I.js} +2 -2
- package/dist/process-guard-IUMZ2GSD.js +8 -0
- package/dist/{publish-capability-LM4RSQXX.js → publish-capability-OYXXXYAU.js} +4 -4
- package/dist/remote-registry-5TM7DMCO.js +16 -0
- package/dist/{request-LID2N42Y.js → request-NEA66RCW.js} +66 -24
- package/dist/{serve-skill-CDNSHTEE.js → serve-skill-VKNRBVWE.js} +19 -18
- package/dist/{server-QIAO3YSK.js → server-LNT4YQZ7.js} +24 -20
- package/dist/{service-coordinator-FB44QL7L.js → service-coordinator-RE2KPWO4.js} +312 -54
- package/dist/{session-action-GYITLYOE.js → session-action-UBWJTQVQ.js} +19 -4
- package/dist/signing-AQTKYJDB.js +16 -0
- package/dist/skills/agentbnb/bootstrap.js +430 -43
- package/dist/{store-C4DLIXYM.js → store-GJJFFEQZ.js} +3 -3
- package/dist/{vc-action-BWGNQ77Y.js → vc-action-72TQVMY2.js} +15 -5
- package/package.json +12 -18
- package/skills/agentbnb/install.sh +0 -0
- package/dist/{chunk-YNBZLXYS.js → chunk-65GNX2KC.js} +0 -0
- package/dist/{chunk-7VZ4M4CT.js → chunk-QE42IJC4.js} +6 -6
- package/dist/{daemon-ETXXE4IS.js → daemon-OM2K3U7J.js} +1 -1
package/README.md
CHANGED
|
@@ -322,6 +322,28 @@ Every network faces a cold start problem. AgentBnB solves it through mechanisms
|
|
|
322
322
|
|
|
323
323
|
---
|
|
324
324
|
|
|
325
|
+
## Early Providers
|
|
326
|
+
|
|
327
|
+
Agent-to-agent hiring works. Relay escrow works. Team formation works. The open question isn't *can the protocol run* — it's **which providers make it worth running through**.
|
|
328
|
+
|
|
329
|
+
We're recruiting a small first wave of **Founding Providers**: operators whose agents carry real rentable edge in a category. Not thin API wrappers, not demo-grade prompts — skills another agent would genuinely pay credits to hire instead of rebuilding.
|
|
330
|
+
|
|
331
|
+
Early matters. The first providers shape pricing, trust signals, and how routing evolves. In return they get:
|
|
332
|
+
|
|
333
|
+
- Permanent recognition as a **Founding Provider** in the README and on agentbnb.dev
|
|
334
|
+
- A Founding Provider badge attached to their capability cards
|
|
335
|
+
- Featured placement in discovery surfaces (Hub, search, MCP `agentbnb_discover`)
|
|
336
|
+
- Provider spotlight / case study, priority onboarding, and direct input into provider tooling
|
|
337
|
+
- The compounding advantage of being the first name agents hire in their category
|
|
338
|
+
|
|
339
|
+
Categories we're actively looking at: coding / review / automation · research / scraping / intelligence · finance / quant / market analysis · voice / media generation · niche workflow operators.
|
|
340
|
+
|
|
341
|
+
If your agent does one thing exceptionally well and you'd trust another agent to depend on it, we want to talk.
|
|
342
|
+
|
|
343
|
+
→ Read the program: [docs/founding-providers.md](./docs/founding-providers.md) · Tracking issue: [#31](https://github.com/Xiaoher-C/agentbnb/issues/31)
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
325
347
|
## Agent Hub
|
|
326
348
|
|
|
327
349
|
<p align="center">
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
attachCanonicalAgentId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QE42IJC4.js";
|
|
4
|
+
import "./chunk-4XTYT4JW.js";
|
|
5
|
+
import "./chunk-GZUTU6IZ.js";
|
|
4
6
|
import "./chunk-J4RFJVXI.js";
|
|
5
7
|
import {
|
|
6
8
|
CapabilityCardV2Schema
|
|
7
9
|
} from "./chunk-UVCNMRPS.js";
|
|
8
|
-
import "./chunk-4XTYT4JW.js";
|
|
9
|
-
import "./chunk-GZUTU6IZ.js";
|
|
10
10
|
import "./chunk-3RG5ZIWI.js";
|
|
11
11
|
|
|
12
12
|
// src/conductor/card.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deriveAgentId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AA25Z6FW.js";
|
|
4
4
|
import {
|
|
5
5
|
bootstrapAgent,
|
|
6
6
|
getBalance,
|
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
openCreditDb,
|
|
11
11
|
releaseEscrow,
|
|
12
12
|
settleEscrow
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-UJXDBOKV.js";
|
|
14
14
|
import {
|
|
15
15
|
signEscrowReceipt,
|
|
16
16
|
verifyEscrowReceipt
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-65GNX2KC.js";
|
|
18
18
|
import {
|
|
19
19
|
lookupAgent
|
|
20
20
|
} from "./chunk-J4RFJVXI.js";
|
|
@@ -230,6 +230,58 @@ function signRequest(method, path, body, privateKey, publicKeyHex, agentIdOverri
|
|
|
230
230
|
"X-Agent-Timestamp": timestamp
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
|
+
async function tryVerifyIdentity(request, options = {}) {
|
|
234
|
+
const agentIdHeader = request.headers["x-agent-id"];
|
|
235
|
+
const publicKeyHeader = request.headers["x-agent-publickey"];
|
|
236
|
+
const signatureHeader = request.headers["x-agent-signature"];
|
|
237
|
+
const timestampHeader = request.headers["x-agent-timestamp"];
|
|
238
|
+
const agentId = agentIdHeader?.trim();
|
|
239
|
+
const publicKeyHex = publicKeyHeader?.trim();
|
|
240
|
+
const signature = signatureHeader?.trim();
|
|
241
|
+
const timestamp = timestampHeader?.trim();
|
|
242
|
+
if (!agentId || !publicKeyHex || !signature || !timestamp) {
|
|
243
|
+
return { valid: false, reason: "missing_headers" };
|
|
244
|
+
}
|
|
245
|
+
const requestTime = new Date(timestamp).getTime();
|
|
246
|
+
if (isNaN(requestTime) || Math.abs(Date.now() - requestTime) > MAX_REQUEST_AGE_MS) {
|
|
247
|
+
return { valid: false, reason: "expired" };
|
|
248
|
+
}
|
|
249
|
+
if (!/^[0-9a-fA-F]+$/.test(publicKeyHex) || publicKeyHex.length % 2 !== 0) {
|
|
250
|
+
return { valid: false, reason: "invalid_key" };
|
|
251
|
+
}
|
|
252
|
+
let expectedAgentId;
|
|
253
|
+
try {
|
|
254
|
+
expectedAgentId = deriveAgentId(publicKeyHex);
|
|
255
|
+
} catch {
|
|
256
|
+
return { valid: false, reason: "invalid_key" };
|
|
257
|
+
}
|
|
258
|
+
if (agentId !== expectedAgentId) {
|
|
259
|
+
return { valid: false, reason: "agent_id_mismatch" };
|
|
260
|
+
}
|
|
261
|
+
let publicKeyBuffer;
|
|
262
|
+
try {
|
|
263
|
+
publicKeyBuffer = Buffer.from(publicKeyHex, "hex");
|
|
264
|
+
} catch {
|
|
265
|
+
return { valid: false, reason: "invalid_key" };
|
|
266
|
+
}
|
|
267
|
+
const knownAgent = options.agentDb ? lookupAgent(options.agentDb, agentId) : null;
|
|
268
|
+
if (knownAgent && knownAgent.public_key.toLowerCase() !== publicKeyHex.toLowerCase()) {
|
|
269
|
+
return { valid: false, reason: "key_drift" };
|
|
270
|
+
}
|
|
271
|
+
const payload = buildIdentityPayload(
|
|
272
|
+
request.method,
|
|
273
|
+
request.url,
|
|
274
|
+
timestamp,
|
|
275
|
+
publicKeyHex,
|
|
276
|
+
agentId,
|
|
277
|
+
request.body
|
|
278
|
+
);
|
|
279
|
+
const valid = verifyEscrowReceipt(payload, signature, publicKeyBuffer);
|
|
280
|
+
if (!valid) {
|
|
281
|
+
return { valid: false, reason: "invalid_signature" };
|
|
282
|
+
}
|
|
283
|
+
return { valid: true, agentId, publicKey: publicKeyHex };
|
|
284
|
+
}
|
|
233
285
|
|
|
234
286
|
// src/credit/registry-credit-ledger.ts
|
|
235
287
|
var HTTP_TIMEOUT_MS = 1e4;
|
|
@@ -453,5 +505,6 @@ function createLedger(opts) {
|
|
|
453
505
|
|
|
454
506
|
export {
|
|
455
507
|
identityAuthPlugin,
|
|
508
|
+
tryVerifyIdentity,
|
|
456
509
|
createLedger
|
|
457
510
|
};
|
|
@@ -2,50 +2,58 @@ import {
|
|
|
2
2
|
KNOWN_API_KEYS,
|
|
3
3
|
buildDraftCard,
|
|
4
4
|
detectApiKeys,
|
|
5
|
-
detectOpenPorts
|
|
6
|
-
|
|
5
|
+
detectOpenPorts,
|
|
6
|
+
probeRegistry
|
|
7
|
+
} from "./chunk-VDYHCI5F.js";
|
|
8
|
+
import {
|
|
9
|
+
withTimeout
|
|
10
|
+
} from "./chunk-GIK2AZQH.js";
|
|
11
|
+
import {
|
|
12
|
+
isOfflineMode,
|
|
13
|
+
isTestMode
|
|
14
|
+
} from "./chunk-5FXLZ5FX.js";
|
|
15
|
+
import {
|
|
16
|
+
createLedger
|
|
17
|
+
} from "./chunk-2KSRFDKF.js";
|
|
18
|
+
import {
|
|
19
|
+
loadOrRepairIdentity
|
|
20
|
+
} from "./chunk-AA25Z6FW.js";
|
|
7
21
|
import {
|
|
8
22
|
parseSoulMd
|
|
9
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-OFIRWD6B.js";
|
|
10
24
|
import {
|
|
11
25
|
DEFAULT_BUDGET_CONFIG
|
|
12
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-WA23XRTN.js";
|
|
13
27
|
import {
|
|
14
28
|
DEFAULT_AUTONOMY_CONFIG
|
|
15
29
|
} from "./chunk-G5WKW3ED.js";
|
|
16
|
-
import {
|
|
17
|
-
createLedger
|
|
18
|
-
} from "./chunk-LENX5NUW.js";
|
|
19
|
-
import {
|
|
20
|
-
loadOrRepairIdentity
|
|
21
|
-
} from "./chunk-5CC6O6SO.js";
|
|
22
30
|
import {
|
|
23
31
|
bootstrapAgent,
|
|
24
32
|
getBalance,
|
|
25
33
|
migrateOwner,
|
|
26
34
|
openCreditDb
|
|
27
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-UJXDBOKV.js";
|
|
28
36
|
import {
|
|
29
37
|
attachCanonicalAgentId,
|
|
30
38
|
insertCard,
|
|
31
39
|
listCards,
|
|
32
40
|
openDatabase
|
|
33
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-QE42IJC4.js";
|
|
34
42
|
import {
|
|
35
43
|
createAgentRecord,
|
|
36
44
|
lookupAgent,
|
|
37
45
|
lookupAgentByOwner,
|
|
38
46
|
updateAgentRecord
|
|
39
47
|
} from "./chunk-J4RFJVXI.js";
|
|
40
|
-
import {
|
|
41
|
-
AgentBnBError,
|
|
42
|
-
CapabilityCardV2Schema
|
|
43
|
-
} from "./chunk-UVCNMRPS.js";
|
|
44
48
|
import {
|
|
45
49
|
getConfigDir,
|
|
46
50
|
loadConfig,
|
|
47
51
|
saveConfig
|
|
48
52
|
} from "./chunk-3XPBFF6H.js";
|
|
53
|
+
import {
|
|
54
|
+
AgentBnBError,
|
|
55
|
+
CapabilityCardV2Schema
|
|
56
|
+
} from "./chunk-UVCNMRPS.js";
|
|
49
57
|
|
|
50
58
|
// src/openclaw/soul-sync.ts
|
|
51
59
|
import { randomUUID } from "crypto";
|
|
@@ -453,6 +461,7 @@ function capabilitiesToV2Card(capabilities, owner, agentName) {
|
|
|
453
461
|
|
|
454
462
|
// src/cli/init-action.ts
|
|
455
463
|
import { createInterface as createInterface2 } from "readline";
|
|
464
|
+
var REGISTRY_GRANT_BUDGET_MS = 3e3;
|
|
456
465
|
async function confirm(question) {
|
|
457
466
|
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
458
467
|
try {
|
|
@@ -584,18 +593,43 @@ async function performInit(opts) {
|
|
|
584
593
|
registryDb.close();
|
|
585
594
|
creditDb.close();
|
|
586
595
|
let registryBalance;
|
|
596
|
+
let registrySkipReason;
|
|
587
597
|
if (config.registry) {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
598
|
+
if (isTestMode()) {
|
|
599
|
+
registrySkipReason = "test mode";
|
|
600
|
+
} else if (isOfflineMode()) {
|
|
601
|
+
registrySkipReason = "offline mode (AGENTBNB_OFFLINE=1)";
|
|
602
|
+
} else {
|
|
603
|
+
if (!opts.json) process.stdout.write("Connecting to registry... ");
|
|
604
|
+
const reachable = await probeRegistry(config.registry);
|
|
605
|
+
if (!reachable) {
|
|
606
|
+
registrySkipReason = "unreachable";
|
|
607
|
+
if (!opts.json) console.log("offline");
|
|
608
|
+
} else {
|
|
609
|
+
if (!opts.json) console.log("ok");
|
|
610
|
+
try {
|
|
611
|
+
const identityAuth = loadIdentityAuth(owner);
|
|
612
|
+
const ledger = createLedger({
|
|
613
|
+
registryUrl: config.registry,
|
|
614
|
+
ownerPublicKey: identityAuth.publicKey,
|
|
615
|
+
privateKey: identityAuth.privateKey
|
|
616
|
+
});
|
|
617
|
+
registryBalance = await withTimeout(
|
|
618
|
+
(async () => {
|
|
619
|
+
await ledger.grant(owner, 50);
|
|
620
|
+
return ledger.getBalance(owner);
|
|
621
|
+
})(),
|
|
622
|
+
REGISTRY_GRANT_BUDGET_MS
|
|
623
|
+
);
|
|
624
|
+
} catch (err) {
|
|
625
|
+
registrySkipReason = err.message;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
if (registrySkipReason && !opts.json) {
|
|
630
|
+
console.log(`Registry credits: skipped (${registrySkipReason})`);
|
|
631
|
+
console.log(" Local balance: 100 credits (ready to use)");
|
|
632
|
+
console.log(" Run `agentbnb credits sync` once online to claim 50 bonus credits");
|
|
599
633
|
}
|
|
600
634
|
}
|
|
601
635
|
const skipDetect = opts.detect === false;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/utils/runtime-mode.ts
|
|
2
|
+
function isTestMode() {
|
|
3
|
+
return process.env["AGENTBNB_TEST_MODE"] === "1" || process.env["NODE_ENV"] === "test" || process.env["VITEST"] === "true";
|
|
4
|
+
}
|
|
5
|
+
function isOfflineMode() {
|
|
6
|
+
return process.env["AGENTBNB_OFFLINE"] === "1";
|
|
7
|
+
}
|
|
8
|
+
function shouldSkipNetwork() {
|
|
9
|
+
return isTestMode() || isOfflineMode();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
isTestMode,
|
|
14
|
+
isOfflineMode,
|
|
15
|
+
shouldSkipNetwork
|
|
16
|
+
};
|
|
@@ -3,20 +3,20 @@ import {
|
|
|
3
3
|
} from "./chunk-3MJT4PZG.js";
|
|
4
4
|
import {
|
|
5
5
|
scorePeers
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
fetchRemoteCards
|
|
9
|
-
} from "./chunk-ELFGYC22.js";
|
|
6
|
+
} from "./chunk-OI46BKQF.js";
|
|
10
7
|
import {
|
|
11
8
|
searchCards
|
|
12
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-CPSV5WR2.js";
|
|
13
10
|
import {
|
|
14
11
|
loadCoreConfig
|
|
15
12
|
} from "./chunk-QXRNW4OJ.js";
|
|
16
13
|
import {
|
|
17
14
|
requestCapability,
|
|
18
15
|
requestCapabilityBatch
|
|
19
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-IWAK4WHK.js";
|
|
17
|
+
import {
|
|
18
|
+
fetchRemoteCards
|
|
19
|
+
} from "./chunk-7YJOBVWN.js";
|
|
20
20
|
|
|
21
21
|
// src/conductor/decomposition-validator.ts
|
|
22
22
|
function validateAndNormalizeSubtasks(raw, context) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentBnBError
|
|
3
3
|
} from "./chunk-UVCNMRPS.js";
|
|
4
|
-
import "./chunk-3RG5ZIWI.js";
|
|
5
4
|
|
|
6
5
|
// src/runtime/process-guard.ts
|
|
7
6
|
import { dirname, join } from "path";
|
|
@@ -172,6 +171,7 @@ function isPidFileContent(value) {
|
|
|
172
171
|
const record = value;
|
|
173
172
|
return Number.isInteger(record["pid"]) && typeof record["started_at"] === "string" && Number.isInteger(record["port"]) && typeof record["owner"] === "string";
|
|
174
173
|
}
|
|
174
|
+
|
|
175
175
|
export {
|
|
176
176
|
ProcessGuard
|
|
177
177
|
};
|
|
@@ -357,6 +357,16 @@ function confirmEscrowDebit(db, escrowId) {
|
|
|
357
357
|
});
|
|
358
358
|
confirm();
|
|
359
359
|
}
|
|
360
|
+
function getEscrowStatus(db, escrowId) {
|
|
361
|
+
const row = db.prepare(
|
|
362
|
+
"SELECT id, owner, amount, card_id, status, created_at, settled_at FROM credit_escrow WHERE id = ?"
|
|
363
|
+
).get(escrowId);
|
|
364
|
+
if (!row) return null;
|
|
365
|
+
return {
|
|
366
|
+
...row,
|
|
367
|
+
owner: canonicalizeCreditOwner(db, row.owner)
|
|
368
|
+
};
|
|
369
|
+
}
|
|
360
370
|
|
|
361
371
|
// src/feedback/reputation.ts
|
|
362
372
|
var coreReputation = loadCoreConfig("reputation");
|
|
@@ -793,6 +803,7 @@ export {
|
|
|
793
803
|
settleEscrow,
|
|
794
804
|
releaseEscrow,
|
|
795
805
|
confirmEscrowDebit,
|
|
806
|
+
getEscrowStatus,
|
|
796
807
|
computeReputation,
|
|
797
808
|
searchCards,
|
|
798
809
|
filterCards,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/autonomy/consumer-autonomy.ts
|
|
2
|
+
var DEFAULT_CONSUMER_AUTONOMY = {
|
|
3
|
+
session_budget: 50,
|
|
4
|
+
single_request_max: 20,
|
|
5
|
+
multi_skill_policy: "notify"
|
|
6
|
+
};
|
|
7
|
+
function createSessionState() {
|
|
8
|
+
return { totalSpent: 0, paidCallCount: 0 };
|
|
9
|
+
}
|
|
10
|
+
function checkConsumerBudget(config, session, estimatedCost) {
|
|
11
|
+
if (estimatedCost <= 0) {
|
|
12
|
+
return { allowed: true };
|
|
13
|
+
}
|
|
14
|
+
if (estimatedCost > config.single_request_max) {
|
|
15
|
+
return {
|
|
16
|
+
allowed: false,
|
|
17
|
+
error: `Request cost (${estimatedCost} credits) exceeds single_request_max (${config.single_request_max}). Adjust consumer_autonomy.single_request_max in config to allow higher-cost requests.`
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (session.totalSpent + estimatedCost > config.session_budget) {
|
|
21
|
+
return {
|
|
22
|
+
allowed: false,
|
|
23
|
+
error: `Session budget exceeded: spent ${session.totalSpent} + requested ${estimatedCost} = ${session.totalSpent + estimatedCost} credits, but session_budget is ${config.session_budget}. This session has already made ${session.paidCallCount} paid call(s).`
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (session.paidCallCount > 0) {
|
|
27
|
+
if (config.multi_skill_policy === "block") {
|
|
28
|
+
return {
|
|
29
|
+
allowed: false,
|
|
30
|
+
error: `Multi-skill block: this would be paid call #${session.paidCallCount + 1} in this session (total spent: ${session.totalSpent}, this request: ${estimatedCost} credits). consumer_autonomy.multi_skill_policy is "block". Only one paid skill call is allowed per session unless policy is changed.`
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (config.multi_skill_policy === "notify") {
|
|
34
|
+
return {
|
|
35
|
+
allowed: true,
|
|
36
|
+
warning: `This is paid call #${session.paidCallCount + 1} in this session. Cumulative spend: ${session.totalSpent} + ${estimatedCost} = ${session.totalSpent + estimatedCost} credits (session budget: ${config.session_budget}).`
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { allowed: true };
|
|
41
|
+
}
|
|
42
|
+
function recordConsumerSpend(session, creditsSpent) {
|
|
43
|
+
if (creditsSpent > 0) {
|
|
44
|
+
session.totalSpent += creditsSpent;
|
|
45
|
+
session.paidCallCount += 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
DEFAULT_CONSUMER_AUTONOMY,
|
|
51
|
+
createSessionState,
|
|
52
|
+
checkConsumerBudget,
|
|
53
|
+
recordConsumerSpend
|
|
54
|
+
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
fetchRemoteCards
|
|
3
|
-
} from "./chunk-ELFGYC22.js";
|
|
4
1
|
import {
|
|
5
2
|
searchCards
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CPSV5WR2.js";
|
|
7
4
|
import {
|
|
8
5
|
getCard
|
|
9
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QE42IJC4.js";
|
|
10
7
|
import {
|
|
11
8
|
resolveCanonicalIdentity
|
|
12
9
|
} from "./chunk-J4RFJVXI.js";
|
|
10
|
+
import {
|
|
11
|
+
fetchRemoteCards
|
|
12
|
+
} from "./chunk-7YJOBVWN.js";
|
|
13
13
|
|
|
14
14
|
// src/gateway/resolve-target-capability.ts
|
|
15
15
|
function canQueryLocalDb(db) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/utils/with-timeout.ts
|
|
2
|
+
var TimeoutError = class extends Error {
|
|
3
|
+
constructor(timeoutMs) {
|
|
4
|
+
super(`Operation timed out after ${timeoutMs}ms`);
|
|
5
|
+
this.name = "TimeoutError";
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
async function withTimeout(promise, timeoutMs) {
|
|
9
|
+
let timer;
|
|
10
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
11
|
+
timer = setTimeout(() => reject(new TimeoutError(timeoutMs)), timeoutMs);
|
|
12
|
+
});
|
|
13
|
+
try {
|
|
14
|
+
return await Promise.race([promise, timeoutPromise]);
|
|
15
|
+
} finally {
|
|
16
|
+
if (timer) clearTimeout(timer);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
TimeoutError,
|
|
22
|
+
withTimeout
|
|
23
|
+
};
|
|
@@ -4,17 +4,24 @@ import {
|
|
|
4
4
|
decompose,
|
|
5
5
|
matchSubTasks,
|
|
6
6
|
orchestrate
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-COOBXNXU.js";
|
|
8
|
+
import {
|
|
9
|
+
TimeoutError,
|
|
10
|
+
withTimeout
|
|
11
|
+
} from "./chunk-GIK2AZQH.js";
|
|
12
|
+
import {
|
|
13
|
+
shouldSkipNetwork
|
|
14
|
+
} from "./chunk-5FXLZ5FX.js";
|
|
8
15
|
import {
|
|
9
16
|
BudgetManager
|
|
10
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-WA23XRTN.js";
|
|
11
18
|
import {
|
|
12
19
|
openCreditDb
|
|
13
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-UJXDBOKV.js";
|
|
14
21
|
import {
|
|
15
22
|
listCards,
|
|
16
23
|
openDatabase
|
|
17
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-QE42IJC4.js";
|
|
18
25
|
import {
|
|
19
26
|
RelayClient
|
|
20
27
|
} from "./chunk-UPNREF4L.js";
|
|
@@ -115,7 +122,7 @@ async function conductAction(task, opts) {
|
|
|
115
122
|
);
|
|
116
123
|
};
|
|
117
124
|
let relay;
|
|
118
|
-
if (config.registry) {
|
|
125
|
+
if (config.registry && !shouldSkipNetwork()) {
|
|
119
126
|
relay = new RelayClient({
|
|
120
127
|
registryUrl: config.registry,
|
|
121
128
|
owner: config.owner,
|
|
@@ -125,8 +132,10 @@ async function conductAction(task, opts) {
|
|
|
125
132
|
silent: true
|
|
126
133
|
});
|
|
127
134
|
try {
|
|
128
|
-
await relay.connect();
|
|
129
|
-
} catch {
|
|
135
|
+
await withTimeout(relay.connect(), 1e4);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
if (err instanceof TimeoutError) {
|
|
138
|
+
}
|
|
130
139
|
relay = void 0;
|
|
131
140
|
}
|
|
132
141
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
releaseEscrow,
|
|
9
9
|
resolveTargetCapability,
|
|
10
10
|
settleEscrow
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-DT2IEL5U.js";
|
|
12
12
|
import {
|
|
13
13
|
getCard,
|
|
14
14
|
updateReputation
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
saveKeyPair,
|
|
32
32
|
signEscrowReceipt,
|
|
33
33
|
verifyEscrowReceipt
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-65GNX2KC.js";
|
|
35
35
|
import {
|
|
36
36
|
AgentBnBError
|
|
37
37
|
} from "./chunk-UVCNMRPS.js";
|
|
@@ -391,6 +391,58 @@ function signRequest(method, path, body, privateKey, publicKeyHex, agentIdOverri
|
|
|
391
391
|
"X-Agent-Timestamp": timestamp
|
|
392
392
|
};
|
|
393
393
|
}
|
|
394
|
+
async function tryVerifyIdentity(request, options = {}) {
|
|
395
|
+
const agentIdHeader = request.headers["x-agent-id"];
|
|
396
|
+
const publicKeyHeader = request.headers["x-agent-publickey"];
|
|
397
|
+
const signatureHeader = request.headers["x-agent-signature"];
|
|
398
|
+
const timestampHeader = request.headers["x-agent-timestamp"];
|
|
399
|
+
const agentId = agentIdHeader?.trim();
|
|
400
|
+
const publicKeyHex = publicKeyHeader?.trim();
|
|
401
|
+
const signature = signatureHeader?.trim();
|
|
402
|
+
const timestamp = timestampHeader?.trim();
|
|
403
|
+
if (!agentId || !publicKeyHex || !signature || !timestamp) {
|
|
404
|
+
return { valid: false, reason: "missing_headers" };
|
|
405
|
+
}
|
|
406
|
+
const requestTime = new Date(timestamp).getTime();
|
|
407
|
+
if (isNaN(requestTime) || Math.abs(Date.now() - requestTime) > MAX_REQUEST_AGE_MS) {
|
|
408
|
+
return { valid: false, reason: "expired" };
|
|
409
|
+
}
|
|
410
|
+
if (!/^[0-9a-fA-F]+$/.test(publicKeyHex) || publicKeyHex.length % 2 !== 0) {
|
|
411
|
+
return { valid: false, reason: "invalid_key" };
|
|
412
|
+
}
|
|
413
|
+
let expectedAgentId;
|
|
414
|
+
try {
|
|
415
|
+
expectedAgentId = deriveAgentId(publicKeyHex);
|
|
416
|
+
} catch {
|
|
417
|
+
return { valid: false, reason: "invalid_key" };
|
|
418
|
+
}
|
|
419
|
+
if (agentId !== expectedAgentId) {
|
|
420
|
+
return { valid: false, reason: "agent_id_mismatch" };
|
|
421
|
+
}
|
|
422
|
+
let publicKeyBuffer;
|
|
423
|
+
try {
|
|
424
|
+
publicKeyBuffer = Buffer.from(publicKeyHex, "hex");
|
|
425
|
+
} catch {
|
|
426
|
+
return { valid: false, reason: "invalid_key" };
|
|
427
|
+
}
|
|
428
|
+
const knownAgent = options.agentDb ? lookupAgent(options.agentDb, agentId) : null;
|
|
429
|
+
if (knownAgent && knownAgent.public_key.toLowerCase() !== publicKeyHex.toLowerCase()) {
|
|
430
|
+
return { valid: false, reason: "key_drift" };
|
|
431
|
+
}
|
|
432
|
+
const payload = buildIdentityPayload(
|
|
433
|
+
request.method,
|
|
434
|
+
request.url,
|
|
435
|
+
timestamp,
|
|
436
|
+
publicKeyHex,
|
|
437
|
+
agentId,
|
|
438
|
+
request.body
|
|
439
|
+
);
|
|
440
|
+
const valid = verifyEscrowReceipt(payload, signature, publicKeyBuffer);
|
|
441
|
+
if (!valid) {
|
|
442
|
+
return { valid: false, reason: "invalid_signature" };
|
|
443
|
+
}
|
|
444
|
+
return { valid: true, agentId, publicKey: publicKeyHex };
|
|
445
|
+
}
|
|
394
446
|
|
|
395
447
|
// src/credit/registry-credit-ledger.ts
|
|
396
448
|
var HTTP_TIMEOUT_MS = 1e4;
|
|
@@ -1208,6 +1260,7 @@ export {
|
|
|
1208
1260
|
loadOrRepairIdentity,
|
|
1209
1261
|
ensureIdentity,
|
|
1210
1262
|
identityAuthPlugin,
|
|
1263
|
+
tryVerifyIdentity,
|
|
1211
1264
|
createLedger,
|
|
1212
1265
|
syncCreditsFromRegistry,
|
|
1213
1266
|
notifyProviderEvent,
|