agentbnb 8.2.2 → 8.2.3

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.
@@ -0,0 +1,44 @@
1
+ import {
2
+ holdEscrow
3
+ } from "./chunk-RYISHSHB.js";
4
+ import {
5
+ signEscrowReceipt
6
+ } from "./chunk-EJKW57ZV.js";
7
+
8
+ // src/credit/escrow-receipt.ts
9
+ import { z } from "zod";
10
+ import { randomUUID } from "crypto";
11
+ var EscrowReceiptSchema = z.object({
12
+ requester_owner: z.string().min(1),
13
+ requester_agent_id: z.string().optional(),
14
+ requester_public_key: z.string().min(1),
15
+ amount: z.number().positive(),
16
+ card_id: z.string().min(1),
17
+ skill_id: z.string().optional(),
18
+ timestamp: z.string(),
19
+ nonce: z.string().uuid(),
20
+ signature: z.string().min(1)
21
+ });
22
+ function createSignedEscrowReceipt(db, privateKey, publicKey, opts) {
23
+ const escrowId = holdEscrow(db, opts.owner, opts.amount, opts.cardId);
24
+ const receiptData = {
25
+ requester_owner: opts.owner,
26
+ ...opts.agent_id ? { requester_agent_id: opts.agent_id } : {},
27
+ requester_public_key: publicKey.toString("hex"),
28
+ amount: opts.amount,
29
+ card_id: opts.cardId,
30
+ ...opts.skillId ? { skill_id: opts.skillId } : {},
31
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
32
+ nonce: randomUUID()
33
+ };
34
+ const signature = signEscrowReceipt(receiptData, privateKey);
35
+ const receipt = {
36
+ ...receiptData,
37
+ signature
38
+ };
39
+ return { escrowId, receipt };
40
+ }
41
+
42
+ export {
43
+ createSignedEscrowReceipt
44
+ };
package/dist/cli/index.js CHANGED
@@ -17,6 +17,9 @@ import {
17
17
  releaseRequesterEscrow,
18
18
  settleRequesterEscrow
19
19
  } from "../chunk-WNXXLCV5.js";
20
+ import {
21
+ createSignedEscrowReceipt
22
+ } from "../chunk-TUCEDQGM.js";
20
23
  import {
21
24
  AutoRequestor,
22
25
  BudgetManager,
@@ -33,7 +36,6 @@ import {
33
36
  filterCards,
34
37
  getBalance,
35
38
  getTransactions,
36
- holdEscrow,
37
39
  lookupAgent,
38
40
  lookupAgentByOwner,
39
41
  mergeResults,
@@ -48,8 +50,7 @@ import {
48
50
  import {
49
51
  generateKeyPair,
50
52
  loadKeyPair,
51
- saveKeyPair,
52
- signEscrowReceipt
53
+ saveKeyPair
53
54
  } from "../chunk-EJKW57ZV.js";
54
55
  import {
55
56
  findPeer,
@@ -81,47 +82,13 @@ import {
81
82
  // src/cli/index.ts
82
83
  import { Command } from "commander";
83
84
  import { readFileSync as readFileSync4 } from "fs";
84
- import { randomUUID as randomUUID4 } from "crypto";
85
+ import { randomUUID as randomUUID3 } from "crypto";
85
86
  import { join as join4 } from "path";
86
87
  import { networkInterfaces as networkInterfaces2 } from "os";
87
88
  import { createInterface as createInterface3 } from "readline";
88
89
 
89
- // src/credit/escrow-receipt.ts
90
- import { z } from "zod";
91
- import { randomUUID } from "crypto";
92
- var EscrowReceiptSchema = z.object({
93
- requester_owner: z.string().min(1),
94
- requester_agent_id: z.string().optional(),
95
- requester_public_key: z.string().min(1),
96
- amount: z.number().positive(),
97
- card_id: z.string().min(1),
98
- skill_id: z.string().optional(),
99
- timestamp: z.string(),
100
- nonce: z.string().uuid(),
101
- signature: z.string().min(1)
102
- });
103
- function createSignedEscrowReceipt(db, privateKey, publicKey, opts) {
104
- const escrowId = holdEscrow(db, opts.owner, opts.amount, opts.cardId);
105
- const receiptData = {
106
- requester_owner: opts.owner,
107
- ...opts.agent_id ? { requester_agent_id: opts.agent_id } : {},
108
- requester_public_key: publicKey.toString("hex"),
109
- amount: opts.amount,
110
- card_id: opts.cardId,
111
- ...opts.skillId ? { skill_id: opts.skillId } : {},
112
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
113
- nonce: randomUUID()
114
- };
115
- const signature = signEscrowReceipt(receiptData, privateKey);
116
- const receipt = {
117
- ...receiptData,
118
- signature
119
- };
120
- return { escrowId, receipt };
121
- }
122
-
123
90
  // src/openclaw/soul-sync.ts
124
- import { randomUUID as randomUUID2 } from "crypto";
91
+ import { randomUUID } from "crypto";
125
92
  var SKILL_META_GLOBAL_RE = /(?:^|\s)-\s*(capability_types|requires(?:_capabilities)?|visibility)\s*:\s*([^-][^]*?)(?=\s+-\s+(?:capability_types|requires(?:_capabilities)?|visibility)\s*:|$)/gi;
126
93
  function extractSkillMeta(raw) {
127
94
  let capability_types;
@@ -156,7 +123,7 @@ function parseSoulMdV2(content) {
156
123
  const parsed = parseSoulMd(content);
157
124
  const skills = parsed.capabilities.map((cap) => {
158
125
  const sanitizedId = cap.name.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
159
- const id = sanitizedId.length > 0 ? sanitizedId : randomUUID2();
126
+ const id = sanitizedId.length > 0 ? sanitizedId : randomUUID();
160
127
  const { description: cleanDesc, capability_types, requires_capabilities, visibility } = extractSkillMeta(cap.description);
161
128
  const finalDescription = (cleanDesc || cap.name).slice(0, 500);
162
129
  const skill = {
@@ -210,7 +177,7 @@ function publishFromSoulV2(db, soulContent, owner, sharedSkills) {
210
177
  (c) => c.spec_version === "2.0"
211
178
  );
212
179
  const now = (/* @__PURE__ */ new Date()).toISOString();
213
- const cardId = existingV2?.id ?? randomUUID2();
180
+ const cardId = existingV2?.id ?? randomUUID();
214
181
  const card = {
215
182
  spec_version: "2.0",
216
183
  id: cardId,
@@ -326,7 +293,7 @@ import { join as join2 } from "path";
326
293
  import { networkInterfaces } from "os";
327
294
 
328
295
  // src/onboarding/index.ts
329
- import { randomUUID as randomUUID3 } from "crypto";
296
+ import { randomUUID as randomUUID2 } from "crypto";
330
297
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
331
298
  import { join } from "path";
332
299
 
@@ -489,7 +456,7 @@ function capabilitiesToV2Card(capabilities, owner, agentName) {
489
456
  }));
490
457
  const card = {
491
458
  spec_version: "2.0",
492
- id: randomUUID3(),
459
+ id: randomUUID2(),
493
460
  owner,
494
461
  agent_name: agentName ?? owner,
495
462
  skills,
@@ -981,7 +948,7 @@ Skills: ${skills.skillCount} skill(s) in ${skills.path}`);
981
948
  }
982
949
 
983
950
  // src/cli/index.ts
984
- var VERSION = "8.2.2";
951
+ var VERSION = "8.2.3";
985
952
  function loadIdentityAuth2(owner) {
986
953
  const configDir = getConfigDir();
987
954
  let keys;
@@ -1190,7 +1157,7 @@ program.command("publish-skills").description("Publish capabilities from skills.
1190
1157
  const now = (/* @__PURE__ */ new Date()).toISOString();
1191
1158
  const card = {
1192
1159
  spec_version: "2.0",
1193
- id: randomUUID4(),
1160
+ id: randomUUID3(),
1194
1161
  owner: config.owner,
1195
1162
  agent_name: config.owner,
1196
1163
  skills,
@@ -1697,12 +1664,12 @@ Batch Results (${res.results.length} items):`);
1697
1664
  const tryViaRelay = async () => {
1698
1665
  const { RelayClient } = await import("../websocket-client-QOVARTRN.js");
1699
1666
  const { requestViaRelay } = await import("../client-XOLP5IUZ.js");
1700
- const requesterId = `${config.owner}:req:${randomUUID4()}`;
1667
+ const requesterId = `${config.owner}:req:${randomUUID3()}`;
1701
1668
  const tempRelay = new RelayClient({
1702
1669
  registryUrl: config.registry,
1703
1670
  owner: requesterId,
1704
1671
  token: config.token,
1705
- card: { id: randomUUID4(), owner: requesterId, name: requesterId, description: "Requester", level: 1, spec_version: "1.0", inputs: [], outputs: [], pricing: { credits_per_call: 1 }, availability: { online: false } },
1672
+ card: { id: randomUUID3(), owner: requesterId, name: requesterId, description: "Requester", level: 1, spec_version: "1.0", inputs: [], outputs: [], pricing: { credits_per_call: 1 }, availability: { online: false } },
1706
1673
  onRequest: async () => ({ error: { code: -32601, message: "Not serving" } }),
1707
1674
  silent: true
1708
1675
  });
@@ -2312,7 +2279,7 @@ Feedback for skill: ${opts.skill} (${feedbacks.length} entries)
2312
2279
  });
2313
2280
  program.command("quickstart").alias("qs").description("One-command setup: init + skills.yaml + MCP registration + serve daemon").option("--owner <name>", "Agent owner name").option("--port <port>", "Gateway port", "7700").option("--no-serve", "Skip starting background daemon").option("--no-mcp", "Skip MCP registration with Claude Code").option("--json", "Output as JSON").action(runQuickstart);
2314
2281
  program.command("mcp-server").description("Start an MCP (Model Context Protocol) server for IDE integration").action(async () => {
2315
- const { startMcpServer } = await import("../server-VBCT32FC.js");
2282
+ const { startMcpServer } = await import("../server-46VEG2W7.js");
2316
2283
  await startMcpServer();
2317
2284
  });
2318
2285
  await program.parseAsync(process.argv);
@@ -1,3 +1,6 @@
1
+ import {
2
+ createSignedEscrowReceipt
3
+ } from "./chunk-TUCEDQGM.js";
1
4
  import {
2
5
  AutoRequestor,
3
6
  BudgetManager,
@@ -8,7 +11,9 @@ import {
8
11
  } from "./chunk-GKVTD4EZ.js";
9
12
  import "./chunk-CQFBNTGT.js";
10
13
  import {
11
- openCreditDb
14
+ confirmEscrowDebit,
15
+ openCreditDb,
16
+ releaseEscrow
12
17
  } from "./chunk-RYISHSHB.js";
13
18
  import "./chunk-NWIQJ2CL.js";
14
19
  import {
@@ -130,16 +135,59 @@ async function handleRequest(args, ctx) {
130
135
  const targetOwner = remoteCard["owner"] ?? remoteCard["agent_name"];
131
136
  const gatewayUrl = remoteCard["gateway_url"];
132
137
  if (gatewayUrl) {
133
- const result = await requestCapability({
134
- gatewayUrl,
135
- token: "",
136
- cardId,
137
- params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner },
138
- identity: identityAuth
139
- });
140
- return {
141
- content: [{ type: "text", text: JSON.stringify({ success: true, result }, null, 2) }]
142
- };
138
+ let remoteCost = 0;
139
+ const remoteSkills = remoteCard["skills"];
140
+ if (Array.isArray(remoteSkills)) {
141
+ const matchedSkill = args.skill_id ? remoteSkills.find((s) => s.id === args.skill_id) : remoteSkills[0];
142
+ remoteCost = matchedSkill?.pricing?.credits_per_call ?? 0;
143
+ } else {
144
+ const remotePricing = remoteCard["pricing"];
145
+ remoteCost = remotePricing?.credits_per_call ?? 0;
146
+ }
147
+ if (remoteCost > 0) {
148
+ const creditDb = openCreditDb(ctx.config.credit_db_path);
149
+ creditDb.pragma("busy_timeout = 5000");
150
+ try {
151
+ const keys = loadKeyPair(ctx.configDir);
152
+ const { escrowId, receipt } = createSignedEscrowReceipt(creditDb, keys.privateKey, keys.publicKey, {
153
+ owner: ctx.config.owner,
154
+ agent_id: ctx.identity.agent_id,
155
+ amount: remoteCost,
156
+ cardId,
157
+ skillId: args.skill_id
158
+ });
159
+ try {
160
+ const result = await requestCapability({
161
+ gatewayUrl,
162
+ token: ctx.config.token ?? "",
163
+ cardId,
164
+ params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner },
165
+ identity: identityAuth,
166
+ escrowReceipt: receipt
167
+ });
168
+ confirmEscrowDebit(creditDb, escrowId);
169
+ return {
170
+ content: [{ type: "text", text: JSON.stringify({ success: true, result }, null, 2) }]
171
+ };
172
+ } catch (execErr) {
173
+ releaseEscrow(creditDb, escrowId);
174
+ throw execErr;
175
+ }
176
+ } finally {
177
+ creditDb.close();
178
+ }
179
+ } else {
180
+ const result = await requestCapability({
181
+ gatewayUrl,
182
+ token: ctx.config.token ?? "",
183
+ cardId,
184
+ params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner },
185
+ identity: identityAuth
186
+ });
187
+ return {
188
+ content: [{ type: "text", text: JSON.stringify({ success: true, result }, null, 2) }]
189
+ };
190
+ }
143
191
  }
144
192
  if (targetOwner) {
145
193
  const relay = new RelayClient({
@@ -247,7 +247,7 @@ function registerPublishTool(server, ctx) {
247
247
  }
248
248
 
249
249
  // src/mcp/server.ts
250
- var VERSION = "8.2.2";
250
+ var VERSION = "8.2.3";
251
251
  async function startMcpServer() {
252
252
  const config = loadConfig();
253
253
  if (!config) {
@@ -268,7 +268,7 @@ async function startMcpServer() {
268
268
  registerDiscoverTool(server, ctx);
269
269
  registerStatusTool(server, ctx);
270
270
  registerPublishTool(server, ctx);
271
- const { registerRequestTool } = await import("./request-NX7GSPIG.js");
271
+ const { registerRequestTool } = await import("./request-OERS5BE7.js");
272
272
  const { registerConductTool } = await import("./conduct-AZFLNUX3.js");
273
273
  const { registerServeSkillTool } = await import("./serve-skill-E6EJQYAK.js");
274
274
  registerRequestTool(server, ctx);
@@ -35,6 +35,7 @@ import {
35
35
  bootstrapAgent,
36
36
  buildReputationMap,
37
37
  computeReputation,
38
+ confirmEscrowDebit,
38
39
  fetchRemoteCards,
39
40
  filterCards,
40
41
  getActivityFeed,
@@ -7225,16 +7226,59 @@ async function handleRequest(args, ctx) {
7225
7226
  const targetOwner = remoteCard["owner"] ?? remoteCard["agent_name"];
7226
7227
  const gatewayUrl = remoteCard["gateway_url"];
7227
7228
  if (gatewayUrl) {
7228
- const result = await requestCapability({
7229
- gatewayUrl,
7230
- token: "",
7231
- cardId,
7232
- params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner },
7233
- identity: identityAuth
7234
- });
7235
- return {
7236
- content: [{ type: "text", text: JSON.stringify({ success: true, result }, null, 2) }]
7237
- };
7229
+ let remoteCost = 0;
7230
+ const remoteSkills = remoteCard["skills"];
7231
+ if (Array.isArray(remoteSkills)) {
7232
+ const matchedSkill = args.skill_id ? remoteSkills.find((s) => s.id === args.skill_id) : remoteSkills[0];
7233
+ remoteCost = matchedSkill?.pricing?.credits_per_call ?? 0;
7234
+ } else {
7235
+ const remotePricing = remoteCard["pricing"];
7236
+ remoteCost = remotePricing?.credits_per_call ?? 0;
7237
+ }
7238
+ if (remoteCost > 0) {
7239
+ const creditDb = openCreditDb(ctx.config.credit_db_path);
7240
+ creditDb.pragma("busy_timeout = 5000");
7241
+ try {
7242
+ const keys = loadKeyPair(ctx.configDir);
7243
+ const { escrowId, receipt } = createSignedEscrowReceipt(creditDb, keys.privateKey, keys.publicKey, {
7244
+ owner: ctx.config.owner,
7245
+ agent_id: ctx.identity.agent_id,
7246
+ amount: remoteCost,
7247
+ cardId,
7248
+ skillId: args.skill_id
7249
+ });
7250
+ try {
7251
+ const result = await requestCapability({
7252
+ gatewayUrl,
7253
+ token: ctx.config.token ?? "",
7254
+ cardId,
7255
+ params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner },
7256
+ identity: identityAuth,
7257
+ escrowReceipt: receipt
7258
+ });
7259
+ confirmEscrowDebit(creditDb, escrowId);
7260
+ return {
7261
+ content: [{ type: "text", text: JSON.stringify({ success: true, result }, null, 2) }]
7262
+ };
7263
+ } catch (execErr) {
7264
+ releaseEscrow(creditDb, escrowId);
7265
+ throw execErr;
7266
+ }
7267
+ } finally {
7268
+ creditDb.close();
7269
+ }
7270
+ } else {
7271
+ const result = await requestCapability({
7272
+ gatewayUrl,
7273
+ token: ctx.config.token ?? "",
7274
+ cardId,
7275
+ params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner },
7276
+ identity: identityAuth
7277
+ });
7278
+ return {
7279
+ content: [{ type: "text", text: JSON.stringify({ success: true, result }, null, 2) }]
7280
+ };
7281
+ }
7238
7282
  }
7239
7283
  if (targetOwner) {
7240
7284
  const relay = new RelayClient({
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "workspaces": [
4
4
  "packages/*"
5
5
  ],
6
- "version": "8.2.2",
6
+ "version": "8.2.3",
7
7
  "description": "P2P Agent Capability Sharing Protocol — Airbnb for AI agent pipelines",
8
8
  "type": "module",
9
9
  "main": "dist/index.js",
@@ -32,6 +32,18 @@
32
32
  "import": "./dist/identity/index.js"
33
33
  }
34
34
  },
35
+ "scripts": {
36
+ "build": "tsup",
37
+ "build:hub": "cd hub && pnpm install && pnpm build",
38
+ "build:all": "pnpm build && pnpm build:hub",
39
+ "dev": "tsx watch src/cli/index.ts",
40
+ "test": "vitest run",
41
+ "test:run": "vitest run",
42
+ "test:watch": "vitest",
43
+ "lint": "eslint src/",
44
+ "typecheck": "tsc --noEmit",
45
+ "prepublishOnly": "pnpm run build && pnpm run typecheck && pnpm run test:run"
46
+ },
35
47
  "keywords": [
36
48
  "ai",
37
49
  "agent",
@@ -82,15 +94,9 @@
82
94
  "engines": {
83
95
  "node": ">=20.0.0"
84
96
  },
85
- "scripts": {
86
- "build": "tsup",
87
- "build:hub": "cd hub && pnpm install && pnpm build",
88
- "build:all": "pnpm build && pnpm build:hub",
89
- "dev": "tsx watch src/cli/index.ts",
90
- "test": "vitest run",
91
- "test:run": "vitest run",
92
- "test:watch": "vitest",
93
- "lint": "eslint src/",
94
- "typecheck": "tsc --noEmit"
97
+ "pnpm": {
98
+ "onlyBuiltDependencies": [
99
+ "better-sqlite3"
100
+ ]
95
101
  }
96
- }
102
+ }
File without changes