agentbnb 2.2.0 → 3.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.
@@ -0,0 +1,491 @@
1
+ import {
2
+ AgentBnBError,
3
+ CapabilityCardSchema
4
+ } from "./chunk-TQMI73LL.js";
5
+
6
+ // src/registry/store.ts
7
+ import Database from "better-sqlite3";
8
+
9
+ // src/registry/request-log.ts
10
+ var SINCE_MS = {
11
+ "24h": 864e5,
12
+ "7d": 6048e5,
13
+ "30d": 2592e6
14
+ };
15
+ function createRequestLogTable(db) {
16
+ db.exec(`
17
+ CREATE TABLE IF NOT EXISTS request_log (
18
+ id TEXT PRIMARY KEY,
19
+ card_id TEXT NOT NULL,
20
+ card_name TEXT NOT NULL,
21
+ requester TEXT NOT NULL,
22
+ status TEXT NOT NULL CHECK(status IN ('success', 'failure', 'timeout')),
23
+ latency_ms INTEGER NOT NULL,
24
+ credits_charged INTEGER NOT NULL,
25
+ created_at TEXT NOT NULL
26
+ );
27
+
28
+ CREATE INDEX IF NOT EXISTS request_log_created_at_idx
29
+ ON request_log (created_at DESC);
30
+ `);
31
+ try {
32
+ db.exec("ALTER TABLE request_log ADD COLUMN skill_id TEXT");
33
+ } catch {
34
+ }
35
+ try {
36
+ db.exec("ALTER TABLE request_log ADD COLUMN action_type TEXT");
37
+ } catch {
38
+ }
39
+ try {
40
+ db.exec("ALTER TABLE request_log ADD COLUMN tier_invoked INTEGER");
41
+ } catch {
42
+ }
43
+ }
44
+ function insertRequestLog(db, entry) {
45
+ const stmt = db.prepare(`
46
+ INSERT INTO request_log (id, card_id, card_name, requester, status, latency_ms, credits_charged, created_at, skill_id, action_type, tier_invoked)
47
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
48
+ `);
49
+ stmt.run(
50
+ entry.id,
51
+ entry.card_id,
52
+ entry.card_name,
53
+ entry.requester,
54
+ entry.status,
55
+ entry.latency_ms,
56
+ entry.credits_charged,
57
+ entry.created_at,
58
+ entry.skill_id ?? null,
59
+ entry.action_type ?? null,
60
+ entry.tier_invoked ?? null
61
+ );
62
+ }
63
+ function getSkillRequestCount(db, skillId, windowMs) {
64
+ const cutoff = new Date(Date.now() - windowMs).toISOString();
65
+ const stmt = db.prepare(
66
+ `SELECT COUNT(*) as cnt FROM request_log
67
+ WHERE skill_id = ? AND created_at >= ? AND status = 'success' AND action_type IS NULL`
68
+ );
69
+ const row = stmt.get(skillId, cutoff);
70
+ return row.cnt;
71
+ }
72
+ function getActivityFeed(db, limit = 20, since) {
73
+ const effectiveLimit = Math.min(limit, 100);
74
+ if (since !== void 0) {
75
+ const stmt2 = db.prepare(`
76
+ SELECT r.id, r.card_name, r.requester, c.owner AS provider,
77
+ r.status, r.credits_charged, r.latency_ms, r.created_at, r.action_type
78
+ FROM request_log r
79
+ LEFT JOIN capability_cards c ON r.card_id = c.id
80
+ WHERE (r.action_type IS NULL OR r.action_type = 'auto_share')
81
+ AND r.created_at > ?
82
+ ORDER BY r.created_at DESC
83
+ LIMIT ?
84
+ `);
85
+ return stmt2.all(since, effectiveLimit);
86
+ }
87
+ const stmt = 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 = 'auto_share')
93
+ ORDER BY r.created_at DESC
94
+ LIMIT ?
95
+ `);
96
+ return stmt.all(effectiveLimit);
97
+ }
98
+ function getRequestLog(db, limit = 10, since) {
99
+ if (since !== void 0) {
100
+ const cutoff = new Date(Date.now() - SINCE_MS[since]).toISOString();
101
+ const stmt2 = db.prepare(`
102
+ SELECT id, card_id, card_name, requester, status, latency_ms, credits_charged, created_at, skill_id, action_type, tier_invoked
103
+ FROM request_log
104
+ WHERE created_at >= ?
105
+ ORDER BY created_at DESC
106
+ LIMIT ?
107
+ `);
108
+ return stmt2.all(cutoff, limit);
109
+ }
110
+ const stmt = db.prepare(`
111
+ SELECT id, card_id, card_name, requester, status, latency_ms, credits_charged, created_at, skill_id, action_type, tier_invoked
112
+ FROM request_log
113
+ ORDER BY created_at DESC
114
+ LIMIT ?
115
+ `);
116
+ return stmt.all(limit);
117
+ }
118
+
119
+ // src/registry/store.ts
120
+ var V2_FTS_TRIGGERS = `
121
+ DROP TRIGGER IF EXISTS cards_ai;
122
+ DROP TRIGGER IF EXISTS cards_au;
123
+ DROP TRIGGER IF EXISTS cards_ad;
124
+
125
+ CREATE TRIGGER cards_ai AFTER INSERT ON capability_cards BEGIN
126
+ INSERT INTO cards_fts(rowid, id, owner, name, description, tags)
127
+ VALUES (
128
+ new.rowid,
129
+ new.id,
130
+ new.owner,
131
+ COALESCE(
132
+ (SELECT group_concat(json_extract(value, '$.name'), ' ')
133
+ FROM json_each(json_extract(new.data, '$.skills'))),
134
+ json_extract(new.data, '$.name'),
135
+ ''
136
+ ),
137
+ COALESCE(
138
+ (SELECT group_concat(json_extract(value, '$.description'), ' ')
139
+ FROM json_each(json_extract(new.data, '$.skills'))),
140
+ json_extract(new.data, '$.description'),
141
+ ''
142
+ ),
143
+ COALESCE(
144
+ (SELECT group_concat(json_extract(value, '$.metadata.tags'), ' ')
145
+ FROM json_each(json_extract(new.data, '$.skills'))),
146
+ (SELECT group_concat(value, ' ')
147
+ FROM json_each(json_extract(new.data, '$.metadata.tags'))),
148
+ ''
149
+ )
150
+ );
151
+ END;
152
+
153
+ CREATE TRIGGER cards_au AFTER UPDATE ON capability_cards BEGIN
154
+ INSERT INTO cards_fts(cards_fts, rowid, id, owner, name, description, tags)
155
+ VALUES (
156
+ 'delete',
157
+ old.rowid,
158
+ old.id,
159
+ old.owner,
160
+ COALESCE(
161
+ (SELECT group_concat(json_extract(value, '$.name'), ' ')
162
+ FROM json_each(json_extract(old.data, '$.skills'))),
163
+ json_extract(old.data, '$.name'),
164
+ ''
165
+ ),
166
+ COALESCE(
167
+ (SELECT group_concat(json_extract(value, '$.description'), ' ')
168
+ FROM json_each(json_extract(old.data, '$.skills'))),
169
+ json_extract(old.data, '$.description'),
170
+ ''
171
+ ),
172
+ COALESCE(
173
+ (SELECT group_concat(json_extract(value, '$.metadata.tags'), ' ')
174
+ FROM json_each(json_extract(old.data, '$.skills'))),
175
+ (SELECT group_concat(value, ' ')
176
+ FROM json_each(json_extract(old.data, '$.metadata.tags'))),
177
+ ''
178
+ )
179
+ );
180
+ INSERT INTO cards_fts(rowid, id, owner, name, description, tags)
181
+ VALUES (
182
+ new.rowid,
183
+ new.id,
184
+ new.owner,
185
+ COALESCE(
186
+ (SELECT group_concat(json_extract(value, '$.name'), ' ')
187
+ FROM json_each(json_extract(new.data, '$.skills'))),
188
+ json_extract(new.data, '$.name'),
189
+ ''
190
+ ),
191
+ COALESCE(
192
+ (SELECT group_concat(json_extract(value, '$.description'), ' ')
193
+ FROM json_each(json_extract(new.data, '$.skills'))),
194
+ json_extract(new.data, '$.description'),
195
+ ''
196
+ ),
197
+ COALESCE(
198
+ (SELECT group_concat(json_extract(value, '$.metadata.tags'), ' ')
199
+ FROM json_each(json_extract(new.data, '$.skills'))),
200
+ (SELECT group_concat(value, ' ')
201
+ FROM json_each(json_extract(new.data, '$.metadata.tags'))),
202
+ ''
203
+ )
204
+ );
205
+ END;
206
+
207
+ CREATE TRIGGER cards_ad AFTER DELETE ON capability_cards BEGIN
208
+ INSERT INTO cards_fts(cards_fts, rowid, id, owner, name, description, tags)
209
+ VALUES (
210
+ 'delete',
211
+ old.rowid,
212
+ old.id,
213
+ old.owner,
214
+ COALESCE(
215
+ (SELECT group_concat(json_extract(value, '$.name'), ' ')
216
+ FROM json_each(json_extract(old.data, '$.skills'))),
217
+ json_extract(old.data, '$.name'),
218
+ ''
219
+ ),
220
+ COALESCE(
221
+ (SELECT group_concat(json_extract(value, '$.description'), ' ')
222
+ FROM json_each(json_extract(old.data, '$.skills'))),
223
+ json_extract(old.data, '$.description'),
224
+ ''
225
+ ),
226
+ COALESCE(
227
+ (SELECT group_concat(json_extract(value, '$.metadata.tags'), ' ')
228
+ FROM json_each(json_extract(old.data, '$.skills'))),
229
+ (SELECT group_concat(value, ' ')
230
+ FROM json_each(json_extract(old.data, '$.metadata.tags'))),
231
+ ''
232
+ )
233
+ );
234
+ END;
235
+ `;
236
+ function openDatabase(path = ":memory:") {
237
+ const db = new Database(path);
238
+ db.pragma("journal_mode = WAL");
239
+ db.pragma("foreign_keys = ON");
240
+ db.exec(`
241
+ CREATE TABLE IF NOT EXISTS capability_cards (
242
+ id TEXT PRIMARY KEY,
243
+ owner TEXT NOT NULL,
244
+ data TEXT NOT NULL,
245
+ created_at TEXT NOT NULL,
246
+ updated_at TEXT NOT NULL
247
+ );
248
+
249
+ CREATE TABLE IF NOT EXISTS pending_requests (
250
+ id TEXT PRIMARY KEY,
251
+ skill_query TEXT NOT NULL,
252
+ max_cost_credits REAL NOT NULL,
253
+ selected_peer TEXT,
254
+ selected_card_id TEXT,
255
+ selected_skill_id TEXT,
256
+ credits REAL NOT NULL,
257
+ status TEXT NOT NULL DEFAULT 'pending',
258
+ params TEXT,
259
+ created_at TEXT NOT NULL,
260
+ resolved_at TEXT
261
+ );
262
+
263
+ CREATE VIRTUAL TABLE IF NOT EXISTS cards_fts USING fts5(
264
+ id UNINDEXED,
265
+ owner,
266
+ name,
267
+ description,
268
+ tags,
269
+ content=""
270
+ );
271
+ `);
272
+ createRequestLogTable(db);
273
+ runMigrations(db);
274
+ return db;
275
+ }
276
+ function runMigrations(db) {
277
+ const version = db.pragma("user_version")[0]?.user_version ?? 0;
278
+ if (version < 2) {
279
+ migrateV1toV2(db);
280
+ }
281
+ }
282
+ function migrateV1toV2(db) {
283
+ const migrate = db.transaction(() => {
284
+ const rows = db.prepare("SELECT rowid, id, data FROM capability_cards").all();
285
+ const now = (/* @__PURE__ */ new Date()).toISOString();
286
+ for (const row of rows) {
287
+ const parsed = JSON.parse(row.data);
288
+ if (parsed["spec_version"] === "2.0") continue;
289
+ const v1 = parsed;
290
+ const v2 = {
291
+ spec_version: "2.0",
292
+ id: v1.id,
293
+ owner: v1.owner,
294
+ agent_name: v1.name,
295
+ skills: [
296
+ {
297
+ id: `skill-${v1.id}`,
298
+ name: v1.name,
299
+ description: v1.description,
300
+ level: v1.level,
301
+ inputs: v1.inputs,
302
+ outputs: v1.outputs,
303
+ pricing: v1.pricing,
304
+ availability: { online: v1.availability.online },
305
+ powered_by: v1.powered_by,
306
+ metadata: v1.metadata,
307
+ _internal: v1._internal
308
+ }
309
+ ],
310
+ availability: v1.availability,
311
+ created_at: v1.created_at,
312
+ updated_at: now
313
+ };
314
+ db.prepare("UPDATE capability_cards SET data = ?, updated_at = ? WHERE id = ?").run(
315
+ JSON.stringify(v2),
316
+ now,
317
+ v2.id
318
+ );
319
+ }
320
+ db.exec(V2_FTS_TRIGGERS);
321
+ db.exec(`INSERT INTO cards_fts(cards_fts) VALUES('delete-all')`);
322
+ const allRows = db.prepare("SELECT rowid, id, owner, data FROM capability_cards").all();
323
+ const ftsInsert = db.prepare(
324
+ "INSERT INTO cards_fts(rowid, id, owner, name, description, tags) VALUES (?, ?, ?, ?, ?, ?)"
325
+ );
326
+ for (const row of allRows) {
327
+ const data = JSON.parse(row.data);
328
+ const skills = data["skills"] ?? [];
329
+ let name;
330
+ let description;
331
+ let tags;
332
+ if (skills.length > 0) {
333
+ name = skills.map((s) => String(s["name"] ?? "")).join(" ");
334
+ description = skills.map((s) => String(s["description"] ?? "")).join(" ");
335
+ tags = skills.flatMap((s) => {
336
+ const meta = s["metadata"];
337
+ return meta?.["tags"] ?? [];
338
+ }).join(" ");
339
+ } else {
340
+ name = String(data["name"] ?? "");
341
+ description = String(data["description"] ?? "");
342
+ const meta = data["metadata"];
343
+ const rawTags = meta?.["tags"] ?? [];
344
+ tags = rawTags.join(" ");
345
+ }
346
+ ftsInsert.run(row.rowid, row.id, row.owner, name, description, tags);
347
+ }
348
+ db.pragma("user_version = 2");
349
+ });
350
+ migrate();
351
+ }
352
+ function insertCard(db, card) {
353
+ const now = (/* @__PURE__ */ new Date()).toISOString();
354
+ const withTimestamps = { ...card, created_at: card.created_at ?? now, updated_at: now };
355
+ const parsed = CapabilityCardSchema.safeParse(withTimestamps);
356
+ if (!parsed.success) {
357
+ throw new AgentBnBError(
358
+ `Card validation failed: ${parsed.error.message}`,
359
+ "VALIDATION_ERROR"
360
+ );
361
+ }
362
+ const stmt = db.prepare(`
363
+ INSERT INTO capability_cards (id, owner, data, created_at, updated_at)
364
+ VALUES (?, ?, ?, ?, ?)
365
+ `);
366
+ stmt.run(
367
+ parsed.data.id,
368
+ parsed.data.owner,
369
+ JSON.stringify(parsed.data),
370
+ parsed.data.created_at ?? now,
371
+ parsed.data.updated_at ?? now
372
+ );
373
+ }
374
+ function getCard(db, id) {
375
+ const stmt = db.prepare("SELECT data FROM capability_cards WHERE id = ?");
376
+ const row = stmt.get(id);
377
+ if (!row) return null;
378
+ return JSON.parse(row.data);
379
+ }
380
+ function updateCard(db, id, owner, updates) {
381
+ const existing = getCard(db, id);
382
+ if (!existing) {
383
+ throw new AgentBnBError(`Card not found: ${id}`, "NOT_FOUND");
384
+ }
385
+ if (existing.owner !== owner) {
386
+ throw new AgentBnBError("Forbidden: you do not own this card", "FORBIDDEN");
387
+ }
388
+ const now = (/* @__PURE__ */ new Date()).toISOString();
389
+ const merged = { ...existing, ...updates, updated_at: now };
390
+ const parsed = CapabilityCardSchema.safeParse(merged);
391
+ if (!parsed.success) {
392
+ throw new AgentBnBError(
393
+ `Card validation failed: ${parsed.error.message}`,
394
+ "VALIDATION_ERROR"
395
+ );
396
+ }
397
+ const stmt = db.prepare(`
398
+ UPDATE capability_cards
399
+ SET data = ?, updated_at = ?
400
+ WHERE id = ?
401
+ `);
402
+ stmt.run(JSON.stringify(parsed.data), now, id);
403
+ }
404
+ function updateReputation(db, cardId, success, latencyMs) {
405
+ const existing = getCard(db, cardId);
406
+ if (!existing) return;
407
+ const ALPHA = 0.1;
408
+ const observed = success ? 1 : 0;
409
+ const prevSuccessRate = existing.metadata?.success_rate;
410
+ const prevLatency = existing.metadata?.avg_latency_ms;
411
+ const newSuccessRate = prevSuccessRate === void 0 ? observed : ALPHA * observed + (1 - ALPHA) * prevSuccessRate;
412
+ const newLatency = prevLatency === void 0 ? latencyMs : ALPHA * latencyMs + (1 - ALPHA) * prevLatency;
413
+ const now = (/* @__PURE__ */ new Date()).toISOString();
414
+ const updatedMetadata = {
415
+ ...existing.metadata,
416
+ success_rate: Math.round(newSuccessRate * 1e3) / 1e3,
417
+ avg_latency_ms: Math.round(newLatency)
418
+ };
419
+ const updatedCard = { ...existing, metadata: updatedMetadata, updated_at: now };
420
+ const stmt = db.prepare(`
421
+ UPDATE capability_cards
422
+ SET data = ?, updated_at = ?
423
+ WHERE id = ?
424
+ `);
425
+ stmt.run(JSON.stringify(updatedCard), now, cardId);
426
+ }
427
+ function updateSkillAvailability(db, cardId, skillId, online) {
428
+ const row = db.prepare("SELECT data FROM capability_cards WHERE id = ?").get(cardId);
429
+ if (!row) return;
430
+ const card = JSON.parse(row.data);
431
+ const skills = card["skills"];
432
+ if (!skills) return;
433
+ const skill = skills.find((s) => s["id"] === skillId);
434
+ if (!skill) return;
435
+ const existing = skill["availability"] ?? {};
436
+ skill["availability"] = { ...existing, online };
437
+ const now = (/* @__PURE__ */ new Date()).toISOString();
438
+ db.prepare("UPDATE capability_cards SET data = ?, updated_at = ? WHERE id = ?").run(
439
+ JSON.stringify(card),
440
+ now,
441
+ cardId
442
+ );
443
+ }
444
+ function updateSkillIdleRate(db, cardId, skillId, idleRate) {
445
+ const row = db.prepare("SELECT data FROM capability_cards WHERE id = ?").get(cardId);
446
+ if (!row) return;
447
+ const card = JSON.parse(row.data);
448
+ const skills = card["skills"];
449
+ if (!skills) return;
450
+ const skill = skills.find((s) => s["id"] === skillId);
451
+ if (!skill) return;
452
+ const existing = skill["_internal"] ?? {};
453
+ skill["_internal"] = {
454
+ ...existing,
455
+ idle_rate: idleRate,
456
+ idle_rate_computed_at: (/* @__PURE__ */ new Date()).toISOString()
457
+ };
458
+ const now = (/* @__PURE__ */ new Date()).toISOString();
459
+ db.prepare("UPDATE capability_cards SET data = ?, updated_at = ? WHERE id = ?").run(
460
+ JSON.stringify(card),
461
+ now,
462
+ cardId
463
+ );
464
+ }
465
+ function listCards(db, owner) {
466
+ let stmt;
467
+ let rows;
468
+ if (owner !== void 0) {
469
+ stmt = db.prepare("SELECT data FROM capability_cards WHERE owner = ?");
470
+ rows = stmt.all(owner);
471
+ } else {
472
+ stmt = db.prepare("SELECT data FROM capability_cards");
473
+ rows = stmt.all();
474
+ }
475
+ return rows.map((row) => JSON.parse(row.data));
476
+ }
477
+
478
+ export {
479
+ insertRequestLog,
480
+ getSkillRequestCount,
481
+ getActivityFeed,
482
+ getRequestLog,
483
+ openDatabase,
484
+ insertCard,
485
+ getCard,
486
+ updateCard,
487
+ updateReputation,
488
+ updateSkillAvailability,
489
+ updateSkillIdleRate,
490
+ listCards
491
+ };
@@ -0,0 +1,125 @@
1
+ // src/types/index.ts
2
+ import { z } from "zod";
3
+ var IOSchemaSchema = z.object({
4
+ name: z.string(),
5
+ type: z.enum(["text", "json", "file", "audio", "image", "video", "stream"]),
6
+ description: z.string().optional(),
7
+ required: z.boolean().default(true),
8
+ schema: z.record(z.unknown()).optional()
9
+ // JSON Schema
10
+ });
11
+ var PoweredBySchema = z.object({
12
+ provider: z.string().min(1),
13
+ model: z.string().optional(),
14
+ tier: z.string().optional()
15
+ });
16
+ var CapabilityCardSchema = z.object({
17
+ spec_version: z.literal("1.0").default("1.0"),
18
+ id: z.string().uuid(),
19
+ owner: z.string().min(1),
20
+ name: z.string().min(1).max(100),
21
+ description: z.string().max(500),
22
+ level: z.union([z.literal(1), z.literal(2), z.literal(3)]),
23
+ inputs: z.array(IOSchemaSchema),
24
+ outputs: z.array(IOSchemaSchema),
25
+ pricing: z.object({
26
+ credits_per_call: z.number().nonnegative(),
27
+ credits_per_minute: z.number().nonnegative().optional(),
28
+ /** Number of free monthly calls. Shown as a "N free/mo" badge in the Hub. */
29
+ free_tier: z.number().nonnegative().optional()
30
+ }),
31
+ availability: z.object({
32
+ online: z.boolean(),
33
+ schedule: z.string().optional()
34
+ // cron expression
35
+ }),
36
+ powered_by: z.array(PoweredBySchema).optional(),
37
+ /**
38
+ * Private per-card metadata. Stripped from all API and CLI responses —
39
+ * never transmitted beyond the local store.
40
+ */
41
+ _internal: z.record(z.unknown()).optional(),
42
+ metadata: z.object({
43
+ apis_used: z.array(z.string()).optional(),
44
+ avg_latency_ms: z.number().nonnegative().optional(),
45
+ success_rate: z.number().min(0).max(1).optional(),
46
+ tags: z.array(z.string()).optional()
47
+ }).optional(),
48
+ created_at: z.string().datetime().optional(),
49
+ updated_at: z.string().datetime().optional()
50
+ });
51
+ var SkillSchema = z.object({
52
+ /** Stable skill identifier, e.g. 'tts-elevenlabs'. Used for gateway routing and idle tracking. */
53
+ id: z.string().min(1),
54
+ name: z.string().min(1).max(100),
55
+ description: z.string().max(500),
56
+ level: z.union([z.literal(1), z.literal(2), z.literal(3)]),
57
+ /** Optional grouping category, e.g. 'tts' | 'video_gen' | 'code_review'. */
58
+ category: z.string().optional(),
59
+ inputs: z.array(IOSchemaSchema),
60
+ outputs: z.array(IOSchemaSchema),
61
+ pricing: z.object({
62
+ credits_per_call: z.number().nonnegative(),
63
+ credits_per_minute: z.number().nonnegative().optional(),
64
+ free_tier: z.number().nonnegative().optional()
65
+ }),
66
+ /** Per-skill online flag — overrides card-level availability for this skill. */
67
+ availability: z.object({ online: z.boolean() }).optional(),
68
+ powered_by: z.array(PoweredBySchema).optional(),
69
+ metadata: z.object({
70
+ apis_used: z.array(z.string()).optional(),
71
+ avg_latency_ms: z.number().nonnegative().optional(),
72
+ success_rate: z.number().min(0).max(1).optional(),
73
+ tags: z.array(z.string()).optional(),
74
+ capacity: z.object({
75
+ calls_per_hour: z.number().positive().default(60)
76
+ }).optional()
77
+ }).optional(),
78
+ /**
79
+ * Private per-skill metadata. Stripped from all API and CLI responses —
80
+ * never transmitted beyond the local store.
81
+ */
82
+ _internal: z.record(z.unknown()).optional()
83
+ });
84
+ var CapabilityCardV2Schema = z.object({
85
+ spec_version: z.literal("2.0"),
86
+ id: z.string().uuid(),
87
+ owner: z.string().min(1),
88
+ /** Agent display name — was 'name' in v1.0. */
89
+ agent_name: z.string().min(1).max(100),
90
+ /** At least one skill is required. */
91
+ skills: z.array(SkillSchema).min(1),
92
+ availability: z.object({
93
+ online: z.boolean(),
94
+ schedule: z.string().optional()
95
+ }),
96
+ /** Optional deployment environment metadata. */
97
+ environment: z.object({
98
+ runtime: z.string(),
99
+ region: z.string().optional()
100
+ }).optional(),
101
+ /**
102
+ * Private per-card metadata. Stripped from all API and CLI responses —
103
+ * never transmitted beyond the local store.
104
+ */
105
+ _internal: z.record(z.unknown()).optional(),
106
+ created_at: z.string().datetime().optional(),
107
+ updated_at: z.string().datetime().optional()
108
+ });
109
+ var AnyCardSchema = z.discriminatedUnion("spec_version", [
110
+ CapabilityCardSchema,
111
+ CapabilityCardV2Schema
112
+ ]);
113
+ var AgentBnBError = class extends Error {
114
+ constructor(message, code) {
115
+ super(message);
116
+ this.code = code;
117
+ this.name = "AgentBnBError";
118
+ }
119
+ };
120
+
121
+ export {
122
+ CapabilityCardSchema,
123
+ CapabilityCardV2Schema,
124
+ AgentBnBError
125
+ };