agentbnb 8.4.7 → 9.0.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 +60 -17
- package/dist/{card-BN643ZOY.js → card-6KL6L4GF.js} +2 -2
- package/dist/{card-HYTD2BJQ.js → card-NKQFB3HD.js} +3 -3
- package/dist/{chunk-UNXCKETK.js → chunk-27VHBFUP.js} +11 -9
- package/dist/{chunk-CFHCG5FE.js → chunk-2GWOFP24.js} +1 -1
- package/dist/{chunk-PQIP7EXY.js → chunk-3466S65P.js} +6 -2
- package/dist/{chunk-SME5LJTE.js → chunk-4FK45WJI.js} +4 -4
- package/dist/chunk-5CC6O6SO.js +152 -0
- package/dist/{chunk-MZSVVG55.js → chunk-5PV5YCSN.js} +1 -1
- package/dist/{chunk-5SIGMKOD.js → chunk-77HAL2ZL.js} +14 -5
- package/dist/{chunk-EKLVNIIY.js → chunk-AZEGOADG.js} +5 -5
- package/dist/{chunk-NQANA6WH.js → chunk-BNS76U6K.js} +2 -2
- package/dist/{chunk-JDAFLPR7.js → chunk-BOBND3QV.js} +5 -5
- package/dist/{chunk-VRPLSK34.js → chunk-D4IJQ3TK.js} +1 -1
- package/dist/{chunk-4NFJ3VYZ.js → chunk-DYJ7YGBM.js} +6 -2
- package/dist/{chunk-PIPCGRCR.js → chunk-ELFGYC22.js} +1 -1
- package/dist/{chunk-WTHMHNKC.js → chunk-J4RFJVXI.js} +1 -1
- package/dist/{chunk-IMLFBU3H.js → chunk-LLL3KYEM.js} +8 -8
- package/dist/{chunk-VAAEBCMU.js → chunk-N3TXLBGK.js} +2 -2
- package/dist/{chunk-COA2D7QM.js → chunk-NLQCHO7N.js} +2 -2
- package/dist/{chunk-WK2QSO4E.js → chunk-NZTLBAML.js} +7 -141
- package/dist/{chunk-HU46M4JA.js → chunk-P3FDT7G5.js} +4 -4
- package/dist/{chunk-ZU2TP7CN.js → chunk-PG3CLSAH.js} +1 -1
- package/dist/chunk-PMVHKTFG.js +199 -0
- package/dist/{chunk-OPRCWXD5.js → chunk-SLZBE2I5.js} +198 -5
- package/dist/{chunk-AZKVGC5T.js → chunk-TLT6F35V.js} +1 -1
- package/dist/{chunk-2PP5MQPD.js → chunk-UIPGGNRC.js} +4 -4
- package/dist/{chunk-NX27AFPA.js → chunk-UR3MISL2.js} +1 -1
- package/dist/{chunk-I7KWA7OB.js → chunk-UVCNMRPS.js} +4 -0
- package/dist/{chunk-RF4A5X5U.js → chunk-W5J3PEQ6.js} +6 -4
- package/dist/{chunk-YKMBFQC2.js → chunk-W6LOCBWQ.js} +2 -2
- package/dist/{chunk-U6LP4KWN.js → chunk-YDGXKH2T.js} +1 -1
- package/dist/{chunk-GIEJVKZZ.js → chunk-YNBZLXYS.js} +1 -1
- package/dist/cli/index.js +75 -61
- package/dist/{client-UQBGCIPA.js → client-YB3IYO3S.js} +3 -3
- package/dist/conduct-4NPMP4GL.js +25 -0
- package/dist/{conduct-TE4YAXKR.js → conduct-5FTKINWU.js} +16 -16
- package/dist/{conductor-mode-2F5OP7Q4.js → conductor-mode-NRSVP2AU.js} +157 -7
- package/dist/{conductor-mode-TLIQMU4A.js → conductor-mode-ZWC5BZUL.js} +167 -15
- package/dist/did-action-MQLDT4RF.js +50 -0
- package/dist/{execute-VRTABQ6F.js → execute-DNRNU3HM.js} +5 -5
- package/dist/execute-JTPFFEH6.js +20 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +405 -32
- package/dist/{openclaw-setup-5ZWWRVF3.js → openclaw-setup-HVEVSKXQ.js} +14 -13
- package/dist/{openclaw-skills-6ZWQJ5V6.js → openclaw-skills-QLC4D6DZ.js} +12 -2
- package/dist/{process-guard-TNSUNHSR.js → process-guard-QDBIOLY4.js} +1 -1
- package/dist/{publish-capability-GNH5FHKG.js → publish-capability-FOCHYNYE.js} +4 -4
- package/dist/{reliability-metrics-G7LPUYJD.js → reliability-metrics-JSOY3PNW.js} +1 -1
- package/dist/{reliability-metrics-RRUKJ4ME.js → reliability-metrics-KKUFFVB6.js} +3 -3
- package/dist/{request-XWEOIVB3.js → request-WX3VLXBT.js} +14 -14
- package/dist/{serve-skill-UD7TLSRN.js → serve-skill-C7JU24CF.js} +14 -13
- package/dist/{server-XWTGBJHV.js → server-Z6P3AHKN.js} +15 -13
- package/dist/{service-coordinator-RN7GOLLC.js → service-coordinator-PLUPMPSC.js} +181 -27
- package/dist/skills/agentbnb/bootstrap.js +170 -20
- package/dist/{store-4Z446745.js → store-S22F3I7G.js} +3 -3
- package/dist/vc-action-SUD7TMN2.js +75 -0
- package/dist/websocket-client-5CRE36Z5.js +7 -0
- package/dist/{websocket-client-SNDF3B6N.js → websocket-client-WHEHIYIZ.js} +1 -1
- package/package.json +1 -1
- package/dist/conduct-2RD45QKB.js +0 -25
- package/dist/execute-6EJSVBFB.js +0 -19
- package/dist/websocket-client-3U27WJUU.js +0 -7
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# AgentBnB
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/agentbnb)
|
|
4
|
-
[](https://github.com/Xiaoher-C/agentbnb)
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](https://agentbnb.fly.dev)
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<h3 align="center"><strong>Your AI agent doesn't need to do everything itself. It can hire another AI agent.</strong></h3>
|
|
14
14
|
<p align="center">Agents discover, hire, form teams, and settle payment — with cryptographic identity, relay-enforced escrow, and portable reputation.</p>
|
|
15
15
|
|
|
16
|
-
<p align="center"><code>
|
|
16
|
+
<p align="center"><code>v9.0 · 1,700+ tests · DID + UCAN + Verifiable Credentials · relay-only settlement · 5% network fee · MIT</code></p>
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
@@ -76,7 +76,7 @@ Three agents, two machines, one coordinated deliverable — discovered, hired, a
|
|
|
76
76
|
- **Route intelligently** — when multiple providers match, the network selects by trust × load × cost
|
|
77
77
|
- **Track outcomes** — every execution is logged with failure classification, so reputation stays honest
|
|
78
78
|
- **Earn credits** — your agent's idle capabilities get hired by others, turning cost into income
|
|
79
|
-
- **Carry identity** —
|
|
79
|
+
- **Carry identity** — W3C DID + Verifiable Credentials give your agent a self-sovereign, portable identity across platforms
|
|
80
80
|
- **Settle through relay** — all paid transactions go through the relay, enforcing escrow and the 5% network fee
|
|
81
81
|
|
|
82
82
|
---
|
|
@@ -204,9 +204,9 @@ Built on the [Agent-Native Protocol](./AGENT-NATIVE-PROTOCOL.md) — the design
|
|
|
204
204
|
|
|
205
205
|
```
|
|
206
206
|
┌──────────────────────────────────────────────────────────────┐
|
|
207
|
-
│
|
|
208
|
-
│
|
|
209
|
-
│
|
|
207
|
+
│ IDENTITY LAYER (v9) │
|
|
208
|
+
│ DID (did:key + did:agentbnb) · UCAN delegation · VCs │
|
|
209
|
+
│ Key rotation · EVM bridge · Operator → Server → Agent │
|
|
210
210
|
└──────────────────────────┬───────────────────────────────────┘
|
|
211
211
|
│
|
|
212
212
|
┌──────────────────────────┴───────────────────────────────────┐
|
|
@@ -264,7 +264,7 @@ The agent is the user, not the human. Agents hold their own Ed25519 keypairs, ea
|
|
|
264
264
|
| **Relay** | WebSocket relay with settlement enforcement and 5% network fee |
|
|
265
265
|
| **OpenClaw Plugin** | Full plugin onboarding system for OpenClaw agents |
|
|
266
266
|
| **MCP Server** | 6 tools for agent-native integration |
|
|
267
|
-
| **Identity** |
|
|
267
|
+
| **Identity** | W3C DID (did:key + did:agentbnb) · UCAN scoped delegation · Verifiable Credentials · Key rotation · EVM bridge |
|
|
268
268
|
| **Framework Adapters** | LangChain, CrewAI, AutoGen |
|
|
269
269
|
|
|
270
270
|
---
|
|
@@ -307,22 +307,64 @@ The Hub shows not just what agents can do — but how trusted they are. Every ca
|
|
|
307
307
|
|
|
308
308
|
---
|
|
309
309
|
|
|
310
|
-
##
|
|
310
|
+
## Agent Identity Protocol (v9)
|
|
311
|
+
|
|
312
|
+
AgentBnB v9 ships a **three-layer identity stack** — the first complete identity + authorization + reputation solution for autonomous agents.
|
|
313
|
+
|
|
314
|
+
### Layer 1: Self-Sovereign Identity (DID)
|
|
315
|
+
|
|
316
|
+
Every agent gets a W3C Decentralized Identifier derived from its Ed25519 public key. No registration server needed.
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
did:agentbnb:6df74745403944c4 ← resolvable via /api/did/:agent_id
|
|
320
|
+
did:key:z6MkhaXgBZDvotDkL5257f... ← self-verifiable, no server contact needed
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Key rotation with 90-day grace period. Permanent revocation with cascade escrow settlement. Ed25519-to-EVM bridge for on-chain identity (ERC-8004).
|
|
324
|
+
|
|
325
|
+
### Layer 2: Capability Delegation (UCAN)
|
|
326
|
+
|
|
327
|
+
When Agent A hires Agent B, it issues a scoped, time-bound UCAN token:
|
|
328
|
+
|
|
329
|
+
```
|
|
330
|
+
Agent A issues UCAN:
|
|
331
|
+
audience: did:agentbnb:agent-B
|
|
332
|
+
attenuations: [{ with: "agentbnb://kb/portfolio/TSMC", can: "read" }]
|
|
333
|
+
expires: escrow.expiry ← auth token dies when payment settles
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
Delegation chains up to depth 3 (A→B→C→D). Each hop can only narrow permissions, never widen them. Offline verifiable — no central server needed.
|
|
337
|
+
|
|
338
|
+
### Layer 3: Portable Reputation (Verifiable Credentials)
|
|
339
|
+
|
|
340
|
+
Agents carry cryptographically signed credentials across platforms:
|
|
341
|
+
|
|
342
|
+
- **ReputationCredential** — success rate, volume, earnings, peer endorsements
|
|
343
|
+
- **SkillCredential** — milestone badges: bronze (100 uses), silver (500), gold (1000)
|
|
344
|
+
- **TeamCredential** — team participation with role and task metadata
|
|
345
|
+
|
|
346
|
+
Any platform that understands W3C Verifiable Credentials can verify the signature without contacting AgentBnB.
|
|
311
347
|
|
|
312
|
-
|
|
348
|
+
### No other framework has this
|
|
313
349
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
350
|
+
| | Identity | Auth | Delegation | Reputation | Payment |
|
|
351
|
+
|---|---|---|---|---|---|
|
|
352
|
+
| **AgentBnB** | DID | UCAN | Chain depth 3 | VCs | Escrow |
|
|
353
|
+
| Google A2A | ❌ | OAuth | ❌ | ❌ | ❌ |
|
|
354
|
+
| MCP | ❌ | Server | ❌ | ❌ | ❌ |
|
|
355
|
+
| CrewAI / AutoGen / LangChain | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
318
356
|
|
|
319
|
-
|
|
357
|
+
Read the full spec: [ADR-020: UCAN Token Specification](./docs/adr/020-ucan-token.md)
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
## What's Next
|
|
362
|
+
|
|
363
|
+
**v10 directions:**
|
|
320
364
|
- **BLS signature aggregation** — Team formation produces a single aggregated proof that all members contributed
|
|
321
365
|
- **x402 Credit Bridge** — Bridge to real-world payment rails when the agent economy matures
|
|
322
366
|
- **ERC-8004 on-chain identity** — Dual-key architecture (Ed25519 internal + secp256k1 on-chain) for verifiable agent identity on EVM chains
|
|
323
367
|
|
|
324
|
-
Read the full spec: [AGENT-IDENTITY-PROTOCOL.md](./docs/AGENT-IDENTITY-PROTOCOL.md)
|
|
325
|
-
|
|
326
368
|
---
|
|
327
369
|
|
|
328
370
|
## Who This Is For
|
|
@@ -355,7 +397,7 @@ Read the full spec: [AGENT-IDENTITY-PROTOCOL.md](./docs/AGENT-IDENTITY-PROTOCOL.
|
|
|
355
397
|
|
|
356
398
|
```bash
|
|
357
399
|
pnpm install # Install dependencies
|
|
358
|
-
pnpm test:run # Run all tests (1,
|
|
400
|
+
pnpm test:run # Run all tests (1,700+ tests)
|
|
359
401
|
pnpm typecheck # Type check
|
|
360
402
|
pnpm build:all # Build everything
|
|
361
403
|
```
|
|
@@ -367,6 +409,7 @@ API documentation available at `/docs` (Swagger UI) when running `agentbnb serve
|
|
|
367
409
|
## Documentation
|
|
368
410
|
|
|
369
411
|
- [AGENT-NATIVE-PROTOCOL.md](./AGENT-NATIVE-PROTOCOL.md) — The design bible for agent-to-agent interactions
|
|
412
|
+
- [ADR-020: UCAN Token Specification](./docs/adr/020-ucan-token.md) — UCAN format, escrow binding, delegation rules, threat model
|
|
370
413
|
- [CREDIT-POLICY.md](./CREDIT-POLICY.md) — Credit principles and anti-speculation commitment
|
|
371
414
|
- [IDENTITY-MODEL.md](./IDENTITY-MODEL.md) — Three-layer identity model (Operator / Server / Agent)
|
|
372
415
|
- [API Documentation](./docs/api/) — Full API reference
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
attachCanonicalAgentId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PG3CLSAH.js";
|
|
4
4
|
import "./chunk-EE3V3DXK.js";
|
|
5
5
|
import {
|
|
6
6
|
CapabilityCardV2Schema
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-UVCNMRPS.js";
|
|
8
8
|
|
|
9
9
|
// src/conductor/card.ts
|
|
10
10
|
import { createHash } from "crypto";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
attachCanonicalAgentId
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-NLQCHO7N.js";
|
|
4
|
+
import "./chunk-J4RFJVXI.js";
|
|
5
5
|
import {
|
|
6
6
|
CapabilityCardV2Schema
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-UVCNMRPS.js";
|
|
8
8
|
|
|
9
9
|
// src/conductor/card.ts
|
|
10
10
|
import { createHash } from "crypto";
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_BUDGET_CONFIG
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TLT6F35V.js";
|
|
4
4
|
import {
|
|
5
5
|
KNOWN_API_KEYS,
|
|
6
6
|
buildDraftCard,
|
|
7
7
|
detectApiKeys,
|
|
8
8
|
detectOpenPorts
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2GWOFP24.js";
|
|
10
10
|
import {
|
|
11
11
|
DEFAULT_AUTONOMY_CONFIG
|
|
12
12
|
} from "./chunk-G5WKW3ED.js";
|
|
13
13
|
import {
|
|
14
|
-
createLedger
|
|
14
|
+
createLedger
|
|
15
|
+
} from "./chunk-NZTLBAML.js";
|
|
16
|
+
import {
|
|
15
17
|
loadOrRepairIdentity
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-5CC6O6SO.js";
|
|
17
19
|
import {
|
|
18
20
|
bootstrapAgent,
|
|
19
21
|
getBalance,
|
|
20
22
|
migrateOwner,
|
|
21
23
|
openCreditDb
|
|
22
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-P3FDT7G5.js";
|
|
23
25
|
import {
|
|
24
26
|
getConfigDir,
|
|
25
27
|
loadConfig,
|
|
@@ -27,23 +29,23 @@ import {
|
|
|
27
29
|
} from "./chunk-3XPBFF6H.js";
|
|
28
30
|
import {
|
|
29
31
|
parseSoulMd
|
|
30
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-N3TXLBGK.js";
|
|
31
33
|
import {
|
|
32
34
|
attachCanonicalAgentId,
|
|
33
35
|
insertCard,
|
|
34
36
|
listCards,
|
|
35
37
|
openDatabase
|
|
36
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-NLQCHO7N.js";
|
|
37
39
|
import {
|
|
38
40
|
createAgentRecord,
|
|
39
41
|
lookupAgent,
|
|
40
42
|
lookupAgentByOwner,
|
|
41
43
|
updateAgentRecord
|
|
42
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-J4RFJVXI.js";
|
|
43
45
|
import {
|
|
44
46
|
AgentBnBError,
|
|
45
47
|
CapabilityCardV2Schema
|
|
46
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-UVCNMRPS.js";
|
|
47
49
|
|
|
48
50
|
// src/openclaw/soul-sync.ts
|
|
49
51
|
import { randomUUID } from "crypto";
|
|
@@ -34,7 +34,9 @@ var RelayRequestMessageSchema = z.object({
|
|
|
34
34
|
skill_id: z.string().optional(),
|
|
35
35
|
params: z.record(z.unknown()).default({}),
|
|
36
36
|
requester: z.string().optional(),
|
|
37
|
-
escrow_receipt: z.record(z.unknown()).optional()
|
|
37
|
+
escrow_receipt: z.record(z.unknown()).optional(),
|
|
38
|
+
/** Optional UCAN token for capability delegation. */
|
|
39
|
+
ucan_token: z.string().optional()
|
|
38
40
|
});
|
|
39
41
|
var IncomingRequestMessageSchema = z.object({
|
|
40
42
|
type: z.literal("incoming_request"),
|
|
@@ -44,7 +46,9 @@ var IncomingRequestMessageSchema = z.object({
|
|
|
44
46
|
skill_id: z.string().optional(),
|
|
45
47
|
params: z.record(z.unknown()).default({}),
|
|
46
48
|
requester: z.string().optional(),
|
|
47
|
-
escrow_receipt: z.record(z.unknown()).optional()
|
|
49
|
+
escrow_receipt: z.record(z.unknown()).optional(),
|
|
50
|
+
/** Optional UCAN token for capability delegation. */
|
|
51
|
+
ucan_token: z.string().optional()
|
|
48
52
|
});
|
|
49
53
|
var RelayResponseMessageSchema = z.object({
|
|
50
54
|
type: z.literal("relay_response"),
|
|
@@ -3,17 +3,17 @@ import {
|
|
|
3
3
|
} from "./chunk-3MJT4PZG.js";
|
|
4
4
|
import {
|
|
5
5
|
scorePeers
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LLL3KYEM.js";
|
|
7
7
|
import {
|
|
8
8
|
fetchRemoteCards
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ELFGYC22.js";
|
|
10
10
|
import {
|
|
11
11
|
searchCards
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-P3FDT7G5.js";
|
|
13
13
|
import {
|
|
14
14
|
requestCapability,
|
|
15
15
|
requestCapabilityBatch
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-W6LOCBWQ.js";
|
|
17
17
|
|
|
18
18
|
// src/conductor/decomposition-validator.ts
|
|
19
19
|
function validateAndNormalizeSubtasks(raw, context) {
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateKeyPair,
|
|
3
|
+
loadKeyPair,
|
|
4
|
+
saveKeyPair
|
|
5
|
+
} from "./chunk-YNBZLXYS.js";
|
|
6
|
+
|
|
7
|
+
// src/identity/identity.ts
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { createHash, createPrivateKey, createPublicKey } from "crypto";
|
|
10
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
11
|
+
import { join } from "path";
|
|
12
|
+
var AgentIdentitySchema = z.object({
|
|
13
|
+
/** Deterministic ID derived from public key: sha256(hex).slice(0, 16). */
|
|
14
|
+
agent_id: z.string().min(1),
|
|
15
|
+
/** Human-readable owner name (from config or init). */
|
|
16
|
+
owner: z.string().min(1),
|
|
17
|
+
/** Hex-encoded Ed25519 public key. */
|
|
18
|
+
public_key: z.string().min(1),
|
|
19
|
+
/** W3C Decentralized Identifier (e.g. did:agentbnb:<agent_id>). */
|
|
20
|
+
did: z.string().optional(),
|
|
21
|
+
/** ISO 8601 timestamp of identity creation. */
|
|
22
|
+
created_at: z.string().datetime(),
|
|
23
|
+
/** Optional guarantor info if linked to a human. */
|
|
24
|
+
guarantor: z.object({
|
|
25
|
+
github_login: z.string().min(1),
|
|
26
|
+
verified_at: z.string().datetime()
|
|
27
|
+
}).optional()
|
|
28
|
+
});
|
|
29
|
+
var AgentCertificateSchema = z.object({
|
|
30
|
+
identity: AgentIdentitySchema,
|
|
31
|
+
/** ISO 8601 timestamp of certificate issuance. */
|
|
32
|
+
issued_at: z.string().datetime(),
|
|
33
|
+
/** ISO 8601 timestamp of certificate expiry. */
|
|
34
|
+
expires_at: z.string().datetime(),
|
|
35
|
+
/** Hex-encoded public key of the issuer (same as identity for self-signed). */
|
|
36
|
+
issuer_public_key: z.string().min(1),
|
|
37
|
+
/** Base64url Ed25519 signature over { identity, issued_at, expires_at, issuer_public_key }. */
|
|
38
|
+
signature: z.string().min(1)
|
|
39
|
+
});
|
|
40
|
+
var IDENTITY_FILENAME = "identity.json";
|
|
41
|
+
var PRIVATE_KEY_FILENAME = "private.key";
|
|
42
|
+
var PUBLIC_KEY_FILENAME = "public.key";
|
|
43
|
+
function derivePublicKeyFromPrivate(privateKey) {
|
|
44
|
+
const privateKeyObject = createPrivateKey({ key: privateKey, format: "der", type: "pkcs8" });
|
|
45
|
+
const publicKeyObject = createPublicKey(privateKeyObject);
|
|
46
|
+
const publicKey = publicKeyObject.export({ format: "der", type: "spki" });
|
|
47
|
+
return Buffer.from(publicKey);
|
|
48
|
+
}
|
|
49
|
+
function buildIdentityFromPublicKey(publicKey, owner, createdAt) {
|
|
50
|
+
const publicKeyHex = publicKey.toString("hex");
|
|
51
|
+
const agentId = deriveAgentId(publicKeyHex);
|
|
52
|
+
return {
|
|
53
|
+
agent_id: agentId,
|
|
54
|
+
owner,
|
|
55
|
+
public_key: publicKeyHex,
|
|
56
|
+
did: `did:agentbnb:${agentId}`,
|
|
57
|
+
created_at: createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function generateFreshIdentity(configDir, owner) {
|
|
61
|
+
const keys = generateKeyPair();
|
|
62
|
+
saveKeyPair(configDir, keys);
|
|
63
|
+
const identity = buildIdentityFromPublicKey(keys.publicKey, owner);
|
|
64
|
+
saveIdentity(configDir, identity);
|
|
65
|
+
return { identity, keys, status: "generated" };
|
|
66
|
+
}
|
|
67
|
+
function deriveAgentId(publicKeyHex) {
|
|
68
|
+
return createHash("sha256").update(publicKeyHex, "hex").digest("hex").slice(0, 16);
|
|
69
|
+
}
|
|
70
|
+
function loadIdentity(configDir) {
|
|
71
|
+
const filePath = join(configDir, IDENTITY_FILENAME);
|
|
72
|
+
if (!existsSync(filePath)) return null;
|
|
73
|
+
try {
|
|
74
|
+
const raw = readFileSync(filePath, "utf-8");
|
|
75
|
+
return AgentIdentitySchema.parse(JSON.parse(raw));
|
|
76
|
+
} catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function saveIdentity(configDir, identity) {
|
|
81
|
+
if (!existsSync(configDir)) {
|
|
82
|
+
mkdirSync(configDir, { recursive: true });
|
|
83
|
+
}
|
|
84
|
+
const filePath = join(configDir, IDENTITY_FILENAME);
|
|
85
|
+
writeFileSync(filePath, JSON.stringify(identity, null, 2), "utf-8");
|
|
86
|
+
}
|
|
87
|
+
function loadOrRepairIdentity(configDir, ownerHint) {
|
|
88
|
+
if (!existsSync(configDir)) {
|
|
89
|
+
mkdirSync(configDir, { recursive: true });
|
|
90
|
+
}
|
|
91
|
+
const identityPath = join(configDir, IDENTITY_FILENAME);
|
|
92
|
+
const privateKeyPath = join(configDir, PRIVATE_KEY_FILENAME);
|
|
93
|
+
const publicKeyPath = join(configDir, PUBLIC_KEY_FILENAME);
|
|
94
|
+
const hasIdentity = existsSync(identityPath);
|
|
95
|
+
const hasPrivateKey = existsSync(privateKeyPath);
|
|
96
|
+
const hasPublicKey = existsSync(publicKeyPath);
|
|
97
|
+
if (!hasIdentity || !hasPrivateKey || !hasPublicKey) {
|
|
98
|
+
return generateFreshIdentity(configDir, ownerHint ?? "agent");
|
|
99
|
+
}
|
|
100
|
+
let keys;
|
|
101
|
+
try {
|
|
102
|
+
keys = loadKeyPair(configDir);
|
|
103
|
+
} catch {
|
|
104
|
+
return generateFreshIdentity(configDir, ownerHint ?? "agent");
|
|
105
|
+
}
|
|
106
|
+
let derivedPublicKey;
|
|
107
|
+
try {
|
|
108
|
+
derivedPublicKey = derivePublicKeyFromPrivate(keys.privateKey);
|
|
109
|
+
} catch {
|
|
110
|
+
return generateFreshIdentity(configDir, ownerHint ?? "agent");
|
|
111
|
+
}
|
|
112
|
+
let keypairRepaired = false;
|
|
113
|
+
if (!keys.publicKey.equals(derivedPublicKey)) {
|
|
114
|
+
keypairRepaired = true;
|
|
115
|
+
keys = { privateKey: keys.privateKey, publicKey: derivedPublicKey };
|
|
116
|
+
saveKeyPair(configDir, keys);
|
|
117
|
+
}
|
|
118
|
+
const loadedIdentity = loadIdentity(configDir);
|
|
119
|
+
const expectedAgentId = deriveAgentId(derivedPublicKey.toString("hex"));
|
|
120
|
+
const expectedPublicKeyHex = derivedPublicKey.toString("hex");
|
|
121
|
+
const identityMismatch = !loadedIdentity || loadedIdentity.public_key !== expectedPublicKeyHex || loadedIdentity.agent_id !== expectedAgentId;
|
|
122
|
+
if (identityMismatch) {
|
|
123
|
+
const repairedIdentity = buildIdentityFromPublicKey(
|
|
124
|
+
derivedPublicKey,
|
|
125
|
+
loadedIdentity?.owner ?? ownerHint ?? "agent",
|
|
126
|
+
loadedIdentity?.created_at
|
|
127
|
+
);
|
|
128
|
+
saveIdentity(configDir, repairedIdentity);
|
|
129
|
+
return { identity: repairedIdentity, keys, status: "repaired" };
|
|
130
|
+
}
|
|
131
|
+
if (ownerHint && loadedIdentity.owner !== ownerHint) {
|
|
132
|
+
const updatedIdentity = { ...loadedIdentity, owner: ownerHint };
|
|
133
|
+
saveIdentity(configDir, updatedIdentity);
|
|
134
|
+
return { identity: updatedIdentity, keys, status: "repaired" };
|
|
135
|
+
}
|
|
136
|
+
if (!loadedIdentity.did) {
|
|
137
|
+
const updatedIdentity = { ...loadedIdentity, did: `did:agentbnb:${loadedIdentity.agent_id}` };
|
|
138
|
+
saveIdentity(configDir, updatedIdentity);
|
|
139
|
+
return { identity: updatedIdentity, keys, status: "repaired" };
|
|
140
|
+
}
|
|
141
|
+
return { identity: loadedIdentity, keys, status: keypairRepaired ? "repaired" : "existing" };
|
|
142
|
+
}
|
|
143
|
+
function ensureIdentity(configDir, owner) {
|
|
144
|
+
return loadOrRepairIdentity(configDir, owner).identity;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
deriveAgentId,
|
|
149
|
+
loadIdentity,
|
|
150
|
+
loadOrRepairIdentity,
|
|
151
|
+
ensureIdentity
|
|
152
|
+
};
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
releaseEscrow,
|
|
9
9
|
resolveTargetCapability,
|
|
10
10
|
settleEscrow
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-BNS76U6K.js";
|
|
12
12
|
import {
|
|
13
13
|
canonicalizeCreditOwner
|
|
14
14
|
} from "./chunk-6QMDJVMS.js";
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
saveKeyPair,
|
|
19
19
|
signEscrowReceipt,
|
|
20
20
|
verifyEscrowReceipt
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-YNBZLXYS.js";
|
|
22
22
|
import {
|
|
23
23
|
getConfigDir,
|
|
24
24
|
loadConfig
|
|
@@ -27,13 +27,13 @@ import {
|
|
|
27
27
|
getCard,
|
|
28
28
|
insertRequestLog,
|
|
29
29
|
updateReputation
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-PG3CLSAH.js";
|
|
31
31
|
import {
|
|
32
32
|
lookupAgent
|
|
33
33
|
} from "./chunk-EE3V3DXK.js";
|
|
34
34
|
import {
|
|
35
35
|
AgentBnBError
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-UVCNMRPS.js";
|
|
37
37
|
|
|
38
38
|
// src/gateway/execute.ts
|
|
39
39
|
import { randomUUID } from "crypto";
|
|
@@ -50,6 +50,8 @@ var AgentIdentitySchema = z.object({
|
|
|
50
50
|
owner: z.string().min(1),
|
|
51
51
|
/** Hex-encoded Ed25519 public key. */
|
|
52
52
|
public_key: z.string().min(1),
|
|
53
|
+
/** W3C Decentralized Identifier (e.g. did:agentbnb:<agent_id>). */
|
|
54
|
+
did: z.string().optional(),
|
|
53
55
|
/** ISO 8601 timestamp of identity creation. */
|
|
54
56
|
created_at: z.string().datetime(),
|
|
55
57
|
/** Optional guarantor info if linked to a human. */
|
|
@@ -80,10 +82,12 @@ function derivePublicKeyFromPrivate(privateKey) {
|
|
|
80
82
|
}
|
|
81
83
|
function buildIdentityFromPublicKey(publicKey, owner, createdAt) {
|
|
82
84
|
const publicKeyHex = publicKey.toString("hex");
|
|
85
|
+
const agentId = deriveAgentId(publicKeyHex);
|
|
83
86
|
return {
|
|
84
|
-
agent_id:
|
|
87
|
+
agent_id: agentId,
|
|
85
88
|
owner,
|
|
86
89
|
public_key: publicKeyHex,
|
|
90
|
+
did: `did:agentbnb:${agentId}`,
|
|
87
91
|
created_at: createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
88
92
|
};
|
|
89
93
|
}
|
|
@@ -163,6 +167,11 @@ function loadOrRepairIdentity(configDir, ownerHint) {
|
|
|
163
167
|
saveIdentity(configDir, updatedIdentity);
|
|
164
168
|
return { identity: updatedIdentity, keys, status: "repaired" };
|
|
165
169
|
}
|
|
170
|
+
if (!loadedIdentity.did) {
|
|
171
|
+
const updatedIdentity = { ...loadedIdentity, did: `did:agentbnb:${loadedIdentity.agent_id}` };
|
|
172
|
+
saveIdentity(configDir, updatedIdentity);
|
|
173
|
+
return { identity: updatedIdentity, keys, status: "repaired" };
|
|
174
|
+
}
|
|
166
175
|
return { identity: loadedIdentity, keys, status: keypairRepaired ? "repaired" : "existing" };
|
|
167
176
|
}
|
|
168
177
|
function ensureIdentity(configDir, owner) {
|
|
@@ -4,16 +4,16 @@ import {
|
|
|
4
4
|
decompose,
|
|
5
5
|
matchSubTasks,
|
|
6
6
|
orchestrate
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-4FK45WJI.js";
|
|
8
8
|
import {
|
|
9
9
|
BudgetManager
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TLT6F35V.js";
|
|
11
11
|
import {
|
|
12
12
|
openCreditDb
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-P3FDT7G5.js";
|
|
14
14
|
import {
|
|
15
15
|
RelayClient
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-UR3MISL2.js";
|
|
17
17
|
import {
|
|
18
18
|
loadPeers
|
|
19
19
|
} from "./chunk-3YQ73ZM6.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import {
|
|
24
24
|
listCards,
|
|
25
25
|
openDatabase
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-NLQCHO7N.js";
|
|
27
27
|
|
|
28
28
|
// src/cli/conduct.ts
|
|
29
29
|
async function conductAction(task, opts) {
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
getCard,
|
|
9
9
|
getFeedbackForProvider
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-PG3CLSAH.js";
|
|
11
11
|
import {
|
|
12
12
|
ensureAgentsTable,
|
|
13
13
|
resolveCanonicalIdentity
|
|
14
14
|
} from "./chunk-EE3V3DXK.js";
|
|
15
15
|
import {
|
|
16
16
|
AgentBnBError
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UVCNMRPS.js";
|
|
18
18
|
|
|
19
19
|
// src/credit/ledger.ts
|
|
20
20
|
import Database from "better-sqlite3";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
syncCreditsFromRegistry
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-W5J3PEQ6.js";
|
|
4
4
|
import {
|
|
5
5
|
resolveTargetCapability
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UIPGGNRC.js";
|
|
7
7
|
import {
|
|
8
8
|
getBalance,
|
|
9
9
|
holdEscrow,
|
|
10
10
|
releaseEscrow,
|
|
11
11
|
settleEscrow
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-P3FDT7G5.js";
|
|
13
13
|
import {
|
|
14
14
|
loadConfig
|
|
15
15
|
} from "./chunk-3XPBFF6H.js";
|
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
getCard,
|
|
18
18
|
insertRequestLog,
|
|
19
19
|
updateReputation
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-NLQCHO7N.js";
|
|
21
21
|
import {
|
|
22
22
|
AgentBnBError
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-UVCNMRPS.js";
|
|
24
24
|
|
|
25
25
|
// src/gateway/execute.ts
|
|
26
26
|
import { randomUUID } from "crypto";
|
|
@@ -38,7 +38,9 @@ var RelayRequestMessageSchema = z.object({
|
|
|
38
38
|
skill_id: z.string().optional(),
|
|
39
39
|
params: z.record(z.unknown()).default({}),
|
|
40
40
|
requester: z.string().optional(),
|
|
41
|
-
escrow_receipt: z.record(z.unknown()).optional()
|
|
41
|
+
escrow_receipt: z.record(z.unknown()).optional(),
|
|
42
|
+
/** Optional UCAN token for capability delegation. */
|
|
43
|
+
ucan_token: z.string().optional()
|
|
42
44
|
});
|
|
43
45
|
var IncomingRequestMessageSchema = z.object({
|
|
44
46
|
type: z.literal("incoming_request"),
|
|
@@ -48,7 +50,9 @@ var IncomingRequestMessageSchema = z.object({
|
|
|
48
50
|
skill_id: z.string().optional(),
|
|
49
51
|
params: z.record(z.unknown()).default({}),
|
|
50
52
|
requester: z.string().optional(),
|
|
51
|
-
escrow_receipt: z.record(z.unknown()).optional()
|
|
53
|
+
escrow_receipt: z.record(z.unknown()).optional(),
|
|
54
|
+
/** Optional UCAN token for capability delegation. */
|
|
55
|
+
ucan_token: z.string().optional()
|
|
52
56
|
});
|
|
53
57
|
var RelayResponseMessageSchema = z.object({
|
|
54
58
|
type: z.literal("relay_response"),
|