agentbnb 3.1.6 → 4.0.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 +117 -86
- package/dist/{card-IE5UV5QX.js → card-4XH4AOTE.js} +11 -4
- package/dist/chunk-3MJT4PZG.js +50 -0
- package/dist/{conduct-IEQ567ET.js → chunk-3UKAVIMC.js} +70 -31
- package/dist/chunk-5AH3CMOX.js +62 -0
- package/dist/{chunk-IZZ4FP45.js → chunk-6K5WUVF3.js} +33 -166
- package/dist/chunk-75OC6E4F.js +33 -0
- package/dist/chunk-DVAS2443.js +63 -0
- package/dist/{chunk-XA63SD4T.js → chunk-FNKBHBYK.js} +3 -0
- package/dist/{websocket-client-5TIQDYQ4.js → chunk-JOY533UH.js} +38 -4
- package/dist/chunk-KJG2UJV5.js +83 -0
- package/dist/chunk-M3G5NR2Z.js +90 -0
- package/dist/{chunk-7OACGAFD.js → chunk-MQKYGY5I.js} +63 -24
- package/dist/chunk-ODBGCCEH.js +358 -0
- package/dist/{chunk-QSPWE5AE.js → chunk-Q7HRI666.js} +9 -6
- package/dist/chunk-QJEOCKVF.js +148 -0
- package/dist/{chunk-3Y36WQDV.js → chunk-QT7TEVNV.js} +14 -2
- package/dist/{chunk-UOGDK2S2.js → chunk-TLU7ALCZ.js} +1 -1
- package/dist/{chunk-QHQPXO67.js → chunk-XQHN6ITI.js} +1 -58
- package/dist/cli/index.js +2734 -850
- package/dist/client-BTPIFY7E.js +10 -0
- package/dist/conduct-CW62HBPT.js +52 -0
- package/dist/conduct-FXLVGKD5.js +19 -0
- package/dist/{conductor-mode-IO45PWMI.js → conductor-mode-3JS4VWCR.js} +16 -7
- package/dist/execute-EXOITLHN.js +10 -0
- package/dist/index.d.ts +1005 -916
- package/dist/index.js +516 -120
- package/dist/{peers-G36URZYB.js → peers-K7FSHPN3.js} +2 -1
- package/dist/request-CNZ3XIVX.js +196 -0
- package/dist/serve-skill-SUOGUM7N.js +104 -0
- package/dist/server-2LWHL24P.js +295 -0
- package/dist/types-FGBUZ3QV.js +18 -0
- package/dist/websocket-client-6IIDGXKB.js +7 -0
- package/package.json +4 -1
- package/dist/chunk-BEI5MTNZ.js +0 -91
- package/dist/cli/index.d.ts +0 -1
- package/dist/execute-SWWEHV2K.js +0 -9
|
@@ -4,8 +4,10 @@ var RegisterMessageSchema = z.object({
|
|
|
4
4
|
type: z.literal("register"),
|
|
5
5
|
owner: z.string().min(1),
|
|
6
6
|
token: z.string().min(1),
|
|
7
|
-
card: z.record(z.unknown())
|
|
7
|
+
card: z.record(z.unknown()),
|
|
8
8
|
// CapabilityCard (validated separately)
|
|
9
|
+
cards: z.array(z.record(z.unknown())).optional()
|
|
10
|
+
// Additional cards (e.g., conductor card)
|
|
9
11
|
});
|
|
10
12
|
var RegisteredMessageSchema = z.object({
|
|
11
13
|
type: z.literal("registered"),
|
|
@@ -55,6 +57,15 @@ var ErrorMessageSchema = z.object({
|
|
|
55
57
|
message: z.string(),
|
|
56
58
|
request_id: z.string().optional()
|
|
57
59
|
});
|
|
60
|
+
var RelayProgressMessageSchema = z.object({
|
|
61
|
+
type: z.literal("relay_progress"),
|
|
62
|
+
id: z.string().uuid(),
|
|
63
|
+
// request ID this progress relates to
|
|
64
|
+
progress: z.number().min(0).max(100).optional(),
|
|
65
|
+
// optional percentage
|
|
66
|
+
message: z.string().optional()
|
|
67
|
+
// optional status message
|
|
68
|
+
});
|
|
58
69
|
var RelayMessageSchema = z.discriminatedUnion("type", [
|
|
59
70
|
RegisterMessageSchema,
|
|
60
71
|
RegisteredMessageSchema,
|
|
@@ -62,7 +73,8 @@ var RelayMessageSchema = z.discriminatedUnion("type", [
|
|
|
62
73
|
IncomingRequestMessageSchema,
|
|
63
74
|
RelayResponseMessageSchema,
|
|
64
75
|
ResponseMessageSchema,
|
|
65
|
-
ErrorMessageSchema
|
|
76
|
+
ErrorMessageSchema,
|
|
77
|
+
RelayProgressMessageSchema
|
|
66
78
|
]);
|
|
67
79
|
|
|
68
80
|
export {
|
|
@@ -1,58 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentBnBError
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
|
|
5
|
-
// src/credit/signing.ts
|
|
6
|
-
import { generateKeyPairSync, sign, verify, createPublicKey, createPrivateKey } from "crypto";
|
|
7
|
-
import { writeFileSync, readFileSync, existsSync, chmodSync } from "fs";
|
|
8
|
-
import { join } from "path";
|
|
9
|
-
function generateKeyPair() {
|
|
10
|
-
const { publicKey, privateKey } = generateKeyPairSync("ed25519", {
|
|
11
|
-
publicKeyEncoding: { type: "spki", format: "der" },
|
|
12
|
-
privateKeyEncoding: { type: "pkcs8", format: "der" }
|
|
13
|
-
});
|
|
14
|
-
return {
|
|
15
|
-
publicKey: Buffer.from(publicKey),
|
|
16
|
-
privateKey: Buffer.from(privateKey)
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function saveKeyPair(configDir, keys) {
|
|
20
|
-
const privatePath = join(configDir, "private.key");
|
|
21
|
-
const publicPath = join(configDir, "public.key");
|
|
22
|
-
writeFileSync(privatePath, keys.privateKey);
|
|
23
|
-
chmodSync(privatePath, 384);
|
|
24
|
-
writeFileSync(publicPath, keys.publicKey);
|
|
25
|
-
}
|
|
26
|
-
function loadKeyPair(configDir) {
|
|
27
|
-
const privatePath = join(configDir, "private.key");
|
|
28
|
-
const publicPath = join(configDir, "public.key");
|
|
29
|
-
if (!existsSync(privatePath) || !existsSync(publicPath)) {
|
|
30
|
-
throw new AgentBnBError("Keypair not found. Run `agentbnb init` to generate one.", "KEYPAIR_NOT_FOUND");
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
publicKey: readFileSync(publicPath),
|
|
34
|
-
privateKey: readFileSync(privatePath)
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function canonicalJson(data) {
|
|
38
|
-
return JSON.stringify(data, Object.keys(data).sort());
|
|
39
|
-
}
|
|
40
|
-
function signEscrowReceipt(data, privateKey) {
|
|
41
|
-
const message = Buffer.from(canonicalJson(data), "utf-8");
|
|
42
|
-
const keyObject = createPrivateKey({ key: privateKey, format: "der", type: "pkcs8" });
|
|
43
|
-
const signature = sign(null, message, keyObject);
|
|
44
|
-
return signature.toString("base64url");
|
|
45
|
-
}
|
|
46
|
-
function verifyEscrowReceipt(data, signature, publicKey) {
|
|
47
|
-
try {
|
|
48
|
-
const message = Buffer.from(canonicalJson(data), "utf-8");
|
|
49
|
-
const keyObject = createPublicKey({ key: publicKey, format: "der", type: "spki" });
|
|
50
|
-
const sigBuffer = Buffer.from(signature, "base64url");
|
|
51
|
-
return verify(null, message, keyObject, sigBuffer);
|
|
52
|
-
} catch {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
3
|
+
} from "./chunk-FNKBHBYK.js";
|
|
56
4
|
|
|
57
5
|
// src/credit/escrow.ts
|
|
58
6
|
import { randomUUID } from "crypto";
|
|
@@ -232,11 +180,6 @@ function recordEarning(db, owner, amount, _cardId, receiptNonce) {
|
|
|
232
180
|
}
|
|
233
181
|
|
|
234
182
|
export {
|
|
235
|
-
generateKeyPair,
|
|
236
|
-
saveKeyPair,
|
|
237
|
-
loadKeyPair,
|
|
238
|
-
signEscrowReceipt,
|
|
239
|
-
verifyEscrowReceipt,
|
|
240
183
|
holdEscrow,
|
|
241
184
|
settleEscrow,
|
|
242
185
|
releaseEscrow,
|