agentbnb 3.1.0 → 3.1.2

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,3780 @@
1
+ import { z } from 'zod';
2
+ import Database from 'better-sqlite3';
3
+ import { FastifyInstance } from 'fastify';
4
+
5
+ /**
6
+ * Capability Card — the core unit of AgentBnB
7
+ *
8
+ * Level 1 (Atomic): Single API capability (e.g. ElevenLabs TTS)
9
+ * Level 2 (Pipeline): Multiple Atomics chained (e.g. text → voice → video)
10
+ * Level 3 (Environment): Full deployment with all dependencies
11
+ */
12
+ declare const CapabilityCardSchema: z.ZodObject<{
13
+ spec_version: z.ZodDefault<z.ZodLiteral<"1.0">>;
14
+ id: z.ZodString;
15
+ owner: z.ZodString;
16
+ name: z.ZodString;
17
+ description: z.ZodString;
18
+ level: z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
19
+ inputs: z.ZodArray<z.ZodObject<{
20
+ name: z.ZodString;
21
+ type: z.ZodEnum<["text", "json", "file", "audio", "image", "video", "stream"]>;
22
+ description: z.ZodOptional<z.ZodString>;
23
+ required: z.ZodDefault<z.ZodBoolean>;
24
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
25
+ }, "strip", z.ZodTypeAny, {
26
+ name: string;
27
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
28
+ required: boolean;
29
+ description?: string | undefined;
30
+ schema?: Record<string, unknown> | undefined;
31
+ }, {
32
+ name: string;
33
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
34
+ description?: string | undefined;
35
+ required?: boolean | undefined;
36
+ schema?: Record<string, unknown> | undefined;
37
+ }>, "many">;
38
+ outputs: z.ZodArray<z.ZodObject<{
39
+ name: z.ZodString;
40
+ type: z.ZodEnum<["text", "json", "file", "audio", "image", "video", "stream"]>;
41
+ description: z.ZodOptional<z.ZodString>;
42
+ required: z.ZodDefault<z.ZodBoolean>;
43
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
44
+ }, "strip", z.ZodTypeAny, {
45
+ name: string;
46
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
47
+ required: boolean;
48
+ description?: string | undefined;
49
+ schema?: Record<string, unknown> | undefined;
50
+ }, {
51
+ name: string;
52
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
53
+ description?: string | undefined;
54
+ required?: boolean | undefined;
55
+ schema?: Record<string, unknown> | undefined;
56
+ }>, "many">;
57
+ pricing: z.ZodObject<{
58
+ credits_per_call: z.ZodNumber;
59
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
60
+ /** Number of free monthly calls. Shown as a "N free/mo" badge in the Hub. */
61
+ free_tier: z.ZodOptional<z.ZodNumber>;
62
+ }, "strip", z.ZodTypeAny, {
63
+ credits_per_call: number;
64
+ credits_per_minute?: number | undefined;
65
+ free_tier?: number | undefined;
66
+ }, {
67
+ credits_per_call: number;
68
+ credits_per_minute?: number | undefined;
69
+ free_tier?: number | undefined;
70
+ }>;
71
+ availability: z.ZodObject<{
72
+ online: z.ZodBoolean;
73
+ schedule: z.ZodOptional<z.ZodString>;
74
+ }, "strip", z.ZodTypeAny, {
75
+ online: boolean;
76
+ schedule?: string | undefined;
77
+ }, {
78
+ online: boolean;
79
+ schedule?: string | undefined;
80
+ }>;
81
+ powered_by: z.ZodOptional<z.ZodArray<z.ZodObject<{
82
+ provider: z.ZodString;
83
+ model: z.ZodOptional<z.ZodString>;
84
+ tier: z.ZodOptional<z.ZodString>;
85
+ }, "strip", z.ZodTypeAny, {
86
+ provider: string;
87
+ model?: string | undefined;
88
+ tier?: string | undefined;
89
+ }, {
90
+ provider: string;
91
+ model?: string | undefined;
92
+ tier?: string | undefined;
93
+ }>, "many">>;
94
+ /**
95
+ * Private per-card metadata. Stripped from all API and CLI responses —
96
+ * never transmitted beyond the local store.
97
+ */
98
+ _internal: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
99
+ /** Public gateway URL where this agent accepts requests. Populated on remote publish. */
100
+ gateway_url: z.ZodOptional<z.ZodString>;
101
+ metadata: z.ZodOptional<z.ZodObject<{
102
+ apis_used: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
103
+ avg_latency_ms: z.ZodOptional<z.ZodNumber>;
104
+ success_rate: z.ZodOptional<z.ZodNumber>;
105
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
106
+ }, "strip", z.ZodTypeAny, {
107
+ apis_used?: string[] | undefined;
108
+ avg_latency_ms?: number | undefined;
109
+ success_rate?: number | undefined;
110
+ tags?: string[] | undefined;
111
+ }, {
112
+ apis_used?: string[] | undefined;
113
+ avg_latency_ms?: number | undefined;
114
+ success_rate?: number | undefined;
115
+ tags?: string[] | undefined;
116
+ }>>;
117
+ created_at: z.ZodOptional<z.ZodString>;
118
+ updated_at: z.ZodOptional<z.ZodString>;
119
+ }, "strip", z.ZodTypeAny, {
120
+ name: string;
121
+ description: string;
122
+ spec_version: "1.0";
123
+ id: string;
124
+ owner: string;
125
+ level: 1 | 2 | 3;
126
+ inputs: {
127
+ name: string;
128
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
129
+ required: boolean;
130
+ description?: string | undefined;
131
+ schema?: Record<string, unknown> | undefined;
132
+ }[];
133
+ outputs: {
134
+ name: string;
135
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
136
+ required: boolean;
137
+ description?: string | undefined;
138
+ schema?: Record<string, unknown> | undefined;
139
+ }[];
140
+ pricing: {
141
+ credits_per_call: number;
142
+ credits_per_minute?: number | undefined;
143
+ free_tier?: number | undefined;
144
+ };
145
+ availability: {
146
+ online: boolean;
147
+ schedule?: string | undefined;
148
+ };
149
+ powered_by?: {
150
+ provider: string;
151
+ model?: string | undefined;
152
+ tier?: string | undefined;
153
+ }[] | undefined;
154
+ _internal?: Record<string, unknown> | undefined;
155
+ gateway_url?: string | undefined;
156
+ metadata?: {
157
+ apis_used?: string[] | undefined;
158
+ avg_latency_ms?: number | undefined;
159
+ success_rate?: number | undefined;
160
+ tags?: string[] | undefined;
161
+ } | undefined;
162
+ created_at?: string | undefined;
163
+ updated_at?: string | undefined;
164
+ }, {
165
+ name: string;
166
+ description: string;
167
+ id: string;
168
+ owner: string;
169
+ level: 1 | 2 | 3;
170
+ inputs: {
171
+ name: string;
172
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
173
+ description?: string | undefined;
174
+ required?: boolean | undefined;
175
+ schema?: Record<string, unknown> | undefined;
176
+ }[];
177
+ outputs: {
178
+ name: string;
179
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
180
+ description?: string | undefined;
181
+ required?: boolean | undefined;
182
+ schema?: Record<string, unknown> | undefined;
183
+ }[];
184
+ pricing: {
185
+ credits_per_call: number;
186
+ credits_per_minute?: number | undefined;
187
+ free_tier?: number | undefined;
188
+ };
189
+ availability: {
190
+ online: boolean;
191
+ schedule?: string | undefined;
192
+ };
193
+ spec_version?: "1.0" | undefined;
194
+ powered_by?: {
195
+ provider: string;
196
+ model?: string | undefined;
197
+ tier?: string | undefined;
198
+ }[] | undefined;
199
+ _internal?: Record<string, unknown> | undefined;
200
+ gateway_url?: string | undefined;
201
+ metadata?: {
202
+ apis_used?: string[] | undefined;
203
+ avg_latency_ms?: number | undefined;
204
+ success_rate?: number | undefined;
205
+ tags?: string[] | undefined;
206
+ } | undefined;
207
+ created_at?: string | undefined;
208
+ updated_at?: string | undefined;
209
+ }>;
210
+ type CapabilityCard = z.infer<typeof CapabilityCardSchema>;
211
+ /**
212
+ * Capability Card v2.0 — one card per agent, multiple independently-priced skills.
213
+ *
214
+ * Introduced in Phase 4 (Plan 02). Existing v1.0 cards are migrated to this
215
+ * shape by `runMigrations()` in `src/registry/store.ts`.
216
+ */
217
+ declare const CapabilityCardV2Schema: z.ZodObject<{
218
+ spec_version: z.ZodLiteral<"2.0">;
219
+ id: z.ZodString;
220
+ owner: z.ZodString;
221
+ /** Agent display name — was 'name' in v1.0. */
222
+ agent_name: z.ZodString;
223
+ /** At least one skill is required. */
224
+ skills: z.ZodArray<z.ZodObject<{
225
+ /** Stable skill identifier, e.g. 'tts-elevenlabs'. Used for gateway routing and idle tracking. */
226
+ id: z.ZodString;
227
+ name: z.ZodString;
228
+ description: z.ZodString;
229
+ level: z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
230
+ /** Optional grouping category, e.g. 'tts' | 'video_gen' | 'code_review'. */
231
+ category: z.ZodOptional<z.ZodString>;
232
+ inputs: z.ZodArray<z.ZodObject<{
233
+ name: z.ZodString;
234
+ type: z.ZodEnum<["text", "json", "file", "audio", "image", "video", "stream"]>;
235
+ description: z.ZodOptional<z.ZodString>;
236
+ required: z.ZodDefault<z.ZodBoolean>;
237
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
238
+ }, "strip", z.ZodTypeAny, {
239
+ name: string;
240
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
241
+ required: boolean;
242
+ description?: string | undefined;
243
+ schema?: Record<string, unknown> | undefined;
244
+ }, {
245
+ name: string;
246
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
247
+ description?: string | undefined;
248
+ required?: boolean | undefined;
249
+ schema?: Record<string, unknown> | undefined;
250
+ }>, "many">;
251
+ outputs: z.ZodArray<z.ZodObject<{
252
+ name: z.ZodString;
253
+ type: z.ZodEnum<["text", "json", "file", "audio", "image", "video", "stream"]>;
254
+ description: z.ZodOptional<z.ZodString>;
255
+ required: z.ZodDefault<z.ZodBoolean>;
256
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
257
+ }, "strip", z.ZodTypeAny, {
258
+ name: string;
259
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
260
+ required: boolean;
261
+ description?: string | undefined;
262
+ schema?: Record<string, unknown> | undefined;
263
+ }, {
264
+ name: string;
265
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
266
+ description?: string | undefined;
267
+ required?: boolean | undefined;
268
+ schema?: Record<string, unknown> | undefined;
269
+ }>, "many">;
270
+ pricing: z.ZodObject<{
271
+ credits_per_call: z.ZodNumber;
272
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
273
+ free_tier: z.ZodOptional<z.ZodNumber>;
274
+ }, "strip", z.ZodTypeAny, {
275
+ credits_per_call: number;
276
+ credits_per_minute?: number | undefined;
277
+ free_tier?: number | undefined;
278
+ }, {
279
+ credits_per_call: number;
280
+ credits_per_minute?: number | undefined;
281
+ free_tier?: number | undefined;
282
+ }>;
283
+ /** Per-skill online flag — overrides card-level availability for this skill. */
284
+ availability: z.ZodOptional<z.ZodObject<{
285
+ online: z.ZodBoolean;
286
+ }, "strip", z.ZodTypeAny, {
287
+ online: boolean;
288
+ }, {
289
+ online: boolean;
290
+ }>>;
291
+ powered_by: z.ZodOptional<z.ZodArray<z.ZodObject<{
292
+ provider: z.ZodString;
293
+ model: z.ZodOptional<z.ZodString>;
294
+ tier: z.ZodOptional<z.ZodString>;
295
+ }, "strip", z.ZodTypeAny, {
296
+ provider: string;
297
+ model?: string | undefined;
298
+ tier?: string | undefined;
299
+ }, {
300
+ provider: string;
301
+ model?: string | undefined;
302
+ tier?: string | undefined;
303
+ }>, "many">>;
304
+ metadata: z.ZodOptional<z.ZodObject<{
305
+ apis_used: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
306
+ avg_latency_ms: z.ZodOptional<z.ZodNumber>;
307
+ success_rate: z.ZodOptional<z.ZodNumber>;
308
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
309
+ capacity: z.ZodOptional<z.ZodObject<{
310
+ calls_per_hour: z.ZodDefault<z.ZodNumber>;
311
+ }, "strip", z.ZodTypeAny, {
312
+ calls_per_hour: number;
313
+ }, {
314
+ calls_per_hour?: number | undefined;
315
+ }>>;
316
+ }, "strip", z.ZodTypeAny, {
317
+ apis_used?: string[] | undefined;
318
+ avg_latency_ms?: number | undefined;
319
+ success_rate?: number | undefined;
320
+ tags?: string[] | undefined;
321
+ capacity?: {
322
+ calls_per_hour: number;
323
+ } | undefined;
324
+ }, {
325
+ apis_used?: string[] | undefined;
326
+ avg_latency_ms?: number | undefined;
327
+ success_rate?: number | undefined;
328
+ tags?: string[] | undefined;
329
+ capacity?: {
330
+ calls_per_hour?: number | undefined;
331
+ } | undefined;
332
+ }>>;
333
+ /**
334
+ * Private per-skill metadata. Stripped from all API and CLI responses —
335
+ * never transmitted beyond the local store.
336
+ */
337
+ _internal: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
338
+ }, "strip", z.ZodTypeAny, {
339
+ name: string;
340
+ description: string;
341
+ id: string;
342
+ level: 1 | 2 | 3;
343
+ inputs: {
344
+ name: string;
345
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
346
+ required: boolean;
347
+ description?: string | undefined;
348
+ schema?: Record<string, unknown> | undefined;
349
+ }[];
350
+ outputs: {
351
+ name: string;
352
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
353
+ required: boolean;
354
+ description?: string | undefined;
355
+ schema?: Record<string, unknown> | undefined;
356
+ }[];
357
+ pricing: {
358
+ credits_per_call: number;
359
+ credits_per_minute?: number | undefined;
360
+ free_tier?: number | undefined;
361
+ };
362
+ availability?: {
363
+ online: boolean;
364
+ } | undefined;
365
+ powered_by?: {
366
+ provider: string;
367
+ model?: string | undefined;
368
+ tier?: string | undefined;
369
+ }[] | undefined;
370
+ _internal?: Record<string, unknown> | undefined;
371
+ metadata?: {
372
+ apis_used?: string[] | undefined;
373
+ avg_latency_ms?: number | undefined;
374
+ success_rate?: number | undefined;
375
+ tags?: string[] | undefined;
376
+ capacity?: {
377
+ calls_per_hour: number;
378
+ } | undefined;
379
+ } | undefined;
380
+ category?: string | undefined;
381
+ }, {
382
+ name: string;
383
+ description: string;
384
+ id: string;
385
+ level: 1 | 2 | 3;
386
+ inputs: {
387
+ name: string;
388
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
389
+ description?: string | undefined;
390
+ required?: boolean | undefined;
391
+ schema?: Record<string, unknown> | undefined;
392
+ }[];
393
+ outputs: {
394
+ name: string;
395
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
396
+ description?: string | undefined;
397
+ required?: boolean | undefined;
398
+ schema?: Record<string, unknown> | undefined;
399
+ }[];
400
+ pricing: {
401
+ credits_per_call: number;
402
+ credits_per_minute?: number | undefined;
403
+ free_tier?: number | undefined;
404
+ };
405
+ availability?: {
406
+ online: boolean;
407
+ } | undefined;
408
+ powered_by?: {
409
+ provider: string;
410
+ model?: string | undefined;
411
+ tier?: string | undefined;
412
+ }[] | undefined;
413
+ _internal?: Record<string, unknown> | undefined;
414
+ metadata?: {
415
+ apis_used?: string[] | undefined;
416
+ avg_latency_ms?: number | undefined;
417
+ success_rate?: number | undefined;
418
+ tags?: string[] | undefined;
419
+ capacity?: {
420
+ calls_per_hour?: number | undefined;
421
+ } | undefined;
422
+ } | undefined;
423
+ category?: string | undefined;
424
+ }>, "many">;
425
+ availability: z.ZodObject<{
426
+ online: z.ZodBoolean;
427
+ schedule: z.ZodOptional<z.ZodString>;
428
+ }, "strip", z.ZodTypeAny, {
429
+ online: boolean;
430
+ schedule?: string | undefined;
431
+ }, {
432
+ online: boolean;
433
+ schedule?: string | undefined;
434
+ }>;
435
+ /** Optional deployment environment metadata. */
436
+ environment: z.ZodOptional<z.ZodObject<{
437
+ runtime: z.ZodString;
438
+ region: z.ZodOptional<z.ZodString>;
439
+ }, "strip", z.ZodTypeAny, {
440
+ runtime: string;
441
+ region?: string | undefined;
442
+ }, {
443
+ runtime: string;
444
+ region?: string | undefined;
445
+ }>>;
446
+ /**
447
+ * Private per-card metadata. Stripped from all API and CLI responses —
448
+ * never transmitted beyond the local store.
449
+ */
450
+ _internal: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
451
+ /** Public gateway URL where this agent accepts requests. Populated on remote publish. */
452
+ gateway_url: z.ZodOptional<z.ZodString>;
453
+ created_at: z.ZodOptional<z.ZodString>;
454
+ updated_at: z.ZodOptional<z.ZodString>;
455
+ }, "strip", z.ZodTypeAny, {
456
+ spec_version: "2.0";
457
+ id: string;
458
+ owner: string;
459
+ availability: {
460
+ online: boolean;
461
+ schedule?: string | undefined;
462
+ };
463
+ agent_name: string;
464
+ skills: {
465
+ name: string;
466
+ description: string;
467
+ id: string;
468
+ level: 1 | 2 | 3;
469
+ inputs: {
470
+ name: string;
471
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
472
+ required: boolean;
473
+ description?: string | undefined;
474
+ schema?: Record<string, unknown> | undefined;
475
+ }[];
476
+ outputs: {
477
+ name: string;
478
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
479
+ required: boolean;
480
+ description?: string | undefined;
481
+ schema?: Record<string, unknown> | undefined;
482
+ }[];
483
+ pricing: {
484
+ credits_per_call: number;
485
+ credits_per_minute?: number | undefined;
486
+ free_tier?: number | undefined;
487
+ };
488
+ availability?: {
489
+ online: boolean;
490
+ } | undefined;
491
+ powered_by?: {
492
+ provider: string;
493
+ model?: string | undefined;
494
+ tier?: string | undefined;
495
+ }[] | undefined;
496
+ _internal?: Record<string, unknown> | undefined;
497
+ metadata?: {
498
+ apis_used?: string[] | undefined;
499
+ avg_latency_ms?: number | undefined;
500
+ success_rate?: number | undefined;
501
+ tags?: string[] | undefined;
502
+ capacity?: {
503
+ calls_per_hour: number;
504
+ } | undefined;
505
+ } | undefined;
506
+ category?: string | undefined;
507
+ }[];
508
+ _internal?: Record<string, unknown> | undefined;
509
+ gateway_url?: string | undefined;
510
+ created_at?: string | undefined;
511
+ updated_at?: string | undefined;
512
+ environment?: {
513
+ runtime: string;
514
+ region?: string | undefined;
515
+ } | undefined;
516
+ }, {
517
+ spec_version: "2.0";
518
+ id: string;
519
+ owner: string;
520
+ availability: {
521
+ online: boolean;
522
+ schedule?: string | undefined;
523
+ };
524
+ agent_name: string;
525
+ skills: {
526
+ name: string;
527
+ description: string;
528
+ id: string;
529
+ level: 1 | 2 | 3;
530
+ inputs: {
531
+ name: string;
532
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
533
+ description?: string | undefined;
534
+ required?: boolean | undefined;
535
+ schema?: Record<string, unknown> | undefined;
536
+ }[];
537
+ outputs: {
538
+ name: string;
539
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
540
+ description?: string | undefined;
541
+ required?: boolean | undefined;
542
+ schema?: Record<string, unknown> | undefined;
543
+ }[];
544
+ pricing: {
545
+ credits_per_call: number;
546
+ credits_per_minute?: number | undefined;
547
+ free_tier?: number | undefined;
548
+ };
549
+ availability?: {
550
+ online: boolean;
551
+ } | undefined;
552
+ powered_by?: {
553
+ provider: string;
554
+ model?: string | undefined;
555
+ tier?: string | undefined;
556
+ }[] | undefined;
557
+ _internal?: Record<string, unknown> | undefined;
558
+ metadata?: {
559
+ apis_used?: string[] | undefined;
560
+ avg_latency_ms?: number | undefined;
561
+ success_rate?: number | undefined;
562
+ tags?: string[] | undefined;
563
+ capacity?: {
564
+ calls_per_hour?: number | undefined;
565
+ } | undefined;
566
+ } | undefined;
567
+ category?: string | undefined;
568
+ }[];
569
+ _internal?: Record<string, unknown> | undefined;
570
+ gateway_url?: string | undefined;
571
+ created_at?: string | undefined;
572
+ updated_at?: string | undefined;
573
+ environment?: {
574
+ runtime: string;
575
+ region?: string | undefined;
576
+ } | undefined;
577
+ }>;
578
+ type CapabilityCardV2 = z.infer<typeof CapabilityCardV2Schema>;
579
+ /**
580
+ * Signed escrow receipt — cryptographic proof that a requester has committed credits.
581
+ * Sent to the provider so they can verify the requester's credit commitment
582
+ * without needing access to the requester's local database.
583
+ */
584
+ interface EscrowReceipt {
585
+ /** Agent owner identifier of the requester. */
586
+ requester_owner: string;
587
+ /** Hex-encoded Ed25519 public key of the requester. */
588
+ requester_public_key: string;
589
+ /** Number of credits committed. */
590
+ amount: number;
591
+ /** Capability Card ID being requested. */
592
+ card_id: string;
593
+ /** Optional skill ID within the card. */
594
+ skill_id?: string;
595
+ /** ISO 8601 timestamp of receipt creation. */
596
+ timestamp: string;
597
+ /** UUID nonce — prevents replay attacks. */
598
+ nonce: string;
599
+ /** Base64url Ed25519 signature over all other fields. */
600
+ signature: string;
601
+ }
602
+
603
+ /**
604
+ * Opens a SQLite database at the given path (or in-memory if ':memory:').
605
+ * Applies WAL mode, enables foreign keys, creates base tables and FTS virtual table,
606
+ * calls createRequestLogTable, then runs schema migrations (which installs v2.0 triggers).
607
+ *
608
+ * @param path - File path or ':memory:' for in-memory. Defaults to ':memory:'.
609
+ * @returns Opened Database instance.
610
+ */
611
+ declare function openDatabase(path?: string): Database.Database;
612
+ /**
613
+ * Inserts a CapabilityCard into the registry.
614
+ * Validates the card via Zod schema before inserting.
615
+ * Auto-sets created_at and updated_at to current ISO timestamp.
616
+ *
617
+ * @param db - Open database instance.
618
+ * @param card - Card to insert.
619
+ * @throws {AgentBnBError} with code VALIDATION_ERROR if card fails schema validation.
620
+ */
621
+ declare function insertCard(db: Database.Database, card: CapabilityCard): void;
622
+ /**
623
+ * Retrieves a CapabilityCard by its ID.
624
+ *
625
+ * @param db - Open database instance.
626
+ * @param id - UUID of the card to retrieve.
627
+ * @returns The CapabilityCard if found, or null if not found.
628
+ */
629
+ declare function getCard(db: Database.Database, id: string): CapabilityCard | null;
630
+
631
+ /**
632
+ * Filters for capability card search.
633
+ */
634
+ interface SearchFilters {
635
+ /** Filter to a specific capability level: 1 (Atomic), 2 (Pipeline), 3 (Environment). */
636
+ level?: 1 | 2 | 3;
637
+ /** Filter by online availability. */
638
+ online?: boolean;
639
+ /** Filter cards that use all of the specified APIs. */
640
+ apis_used?: string[];
641
+ }
642
+ /**
643
+ * Searches CapabilityCards using FTS5 full-text search with optional filters.
644
+ * Results are ranked by BM25 relevance score (most relevant first).
645
+ * Returns up to 50 results.
646
+ *
647
+ * @param db - Open database instance.
648
+ * @param query - Full-text search query string.
649
+ * @param filters - Optional filters for level, online status, and apis_used.
650
+ * @returns Array of matching CapabilityCard objects sorted by relevance.
651
+ */
652
+ declare function searchCards(db: Database.Database, query: string, filters?: SearchFilters): CapabilityCard[];
653
+
654
+ /**
655
+ * Opens a SQLite database for the credit system.
656
+ * Uses WAL mode for better read concurrency.
657
+ *
658
+ * @param path - Path to the database file. Defaults to ':memory:' for in-memory.
659
+ * @returns Configured Database instance with all credit tables created.
660
+ */
661
+ declare function openCreditDb(path?: string): Database.Database;
662
+ /**
663
+ * Returns the current credit balance for an agent.
664
+ * Returns 0 if the agent has never been bootstrapped.
665
+ *
666
+ * @param db - The credit database instance.
667
+ * @param owner - Agent identifier.
668
+ * @returns Current balance in credits.
669
+ */
670
+ declare function getBalance(db: Database.Database, owner: string): number;
671
+
672
+ /**
673
+ * Schema for API wrapper skills (Mode A).
674
+ * Wraps a REST API call with input/output mapping.
675
+ */
676
+ declare const ApiSkillConfigSchema: z.ZodObject<{
677
+ id: z.ZodString;
678
+ type: z.ZodLiteral<"api">;
679
+ name: z.ZodString;
680
+ endpoint: z.ZodString;
681
+ method: z.ZodEnum<["GET", "POST", "PUT", "DELETE"]>;
682
+ auth: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
683
+ type: z.ZodLiteral<"bearer">;
684
+ token: z.ZodString;
685
+ }, "strip", z.ZodTypeAny, {
686
+ type: "bearer";
687
+ token: string;
688
+ }, {
689
+ type: "bearer";
690
+ token: string;
691
+ }>, z.ZodObject<{
692
+ type: z.ZodLiteral<"apikey">;
693
+ header: z.ZodDefault<z.ZodString>;
694
+ key: z.ZodString;
695
+ }, "strip", z.ZodTypeAny, {
696
+ type: "apikey";
697
+ header: string;
698
+ key: string;
699
+ }, {
700
+ type: "apikey";
701
+ key: string;
702
+ header?: string | undefined;
703
+ }>, z.ZodObject<{
704
+ type: z.ZodLiteral<"basic">;
705
+ username: z.ZodString;
706
+ password: z.ZodString;
707
+ }, "strip", z.ZodTypeAny, {
708
+ type: "basic";
709
+ username: string;
710
+ password: string;
711
+ }, {
712
+ type: "basic";
713
+ username: string;
714
+ password: string;
715
+ }>]>>;
716
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
717
+ output_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
718
+ pricing: z.ZodObject<{
719
+ credits_per_call: z.ZodNumber;
720
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
721
+ free_tier: z.ZodOptional<z.ZodNumber>;
722
+ }, "strip", z.ZodTypeAny, {
723
+ credits_per_call: number;
724
+ credits_per_minute?: number | undefined;
725
+ free_tier?: number | undefined;
726
+ }, {
727
+ credits_per_call: number;
728
+ credits_per_minute?: number | undefined;
729
+ free_tier?: number | undefined;
730
+ }>;
731
+ timeout_ms: z.ZodDefault<z.ZodNumber>;
732
+ retries: z.ZodDefault<z.ZodNumber>;
733
+ provider: z.ZodOptional<z.ZodString>;
734
+ }, "strip", z.ZodTypeAny, {
735
+ name: string;
736
+ type: "api";
737
+ id: string;
738
+ pricing: {
739
+ credits_per_call: number;
740
+ credits_per_minute?: number | undefined;
741
+ free_tier?: number | undefined;
742
+ };
743
+ endpoint: string;
744
+ method: "GET" | "POST" | "PUT" | "DELETE";
745
+ input_mapping: Record<string, string>;
746
+ output_mapping: Record<string, string>;
747
+ timeout_ms: number;
748
+ retries: number;
749
+ provider?: string | undefined;
750
+ auth?: {
751
+ type: "bearer";
752
+ token: string;
753
+ } | {
754
+ type: "apikey";
755
+ header: string;
756
+ key: string;
757
+ } | {
758
+ type: "basic";
759
+ username: string;
760
+ password: string;
761
+ } | undefined;
762
+ }, {
763
+ name: string;
764
+ type: "api";
765
+ id: string;
766
+ pricing: {
767
+ credits_per_call: number;
768
+ credits_per_minute?: number | undefined;
769
+ free_tier?: number | undefined;
770
+ };
771
+ endpoint: string;
772
+ method: "GET" | "POST" | "PUT" | "DELETE";
773
+ provider?: string | undefined;
774
+ auth?: {
775
+ type: "bearer";
776
+ token: string;
777
+ } | {
778
+ type: "apikey";
779
+ key: string;
780
+ header?: string | undefined;
781
+ } | {
782
+ type: "basic";
783
+ username: string;
784
+ password: string;
785
+ } | undefined;
786
+ input_mapping?: Record<string, string> | undefined;
787
+ output_mapping?: Record<string, string> | undefined;
788
+ timeout_ms?: number | undefined;
789
+ retries?: number | undefined;
790
+ }>;
791
+ /**
792
+ * Schema for pipeline skills (Mode B).
793
+ * Chains multiple skills or commands sequentially.
794
+ */
795
+ declare const PipelineSkillConfigSchema: z.ZodObject<{
796
+ id: z.ZodString;
797
+ type: z.ZodLiteral<"pipeline">;
798
+ name: z.ZodString;
799
+ steps: z.ZodArray<z.ZodUnion<[z.ZodObject<{
800
+ skill_id: z.ZodString;
801
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
802
+ }, "strip", z.ZodTypeAny, {
803
+ input_mapping: Record<string, string>;
804
+ skill_id: string;
805
+ }, {
806
+ skill_id: string;
807
+ input_mapping?: Record<string, string> | undefined;
808
+ }>, z.ZodObject<{
809
+ command: z.ZodString;
810
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
811
+ }, "strip", z.ZodTypeAny, {
812
+ input_mapping: Record<string, string>;
813
+ command: string;
814
+ }, {
815
+ command: string;
816
+ input_mapping?: Record<string, string> | undefined;
817
+ }>]>, "many">;
818
+ pricing: z.ZodObject<{
819
+ credits_per_call: z.ZodNumber;
820
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
821
+ free_tier: z.ZodOptional<z.ZodNumber>;
822
+ }, "strip", z.ZodTypeAny, {
823
+ credits_per_call: number;
824
+ credits_per_minute?: number | undefined;
825
+ free_tier?: number | undefined;
826
+ }, {
827
+ credits_per_call: number;
828
+ credits_per_minute?: number | undefined;
829
+ free_tier?: number | undefined;
830
+ }>;
831
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
832
+ }, "strip", z.ZodTypeAny, {
833
+ name: string;
834
+ type: "pipeline";
835
+ id: string;
836
+ pricing: {
837
+ credits_per_call: number;
838
+ credits_per_minute?: number | undefined;
839
+ free_tier?: number | undefined;
840
+ };
841
+ steps: ({
842
+ input_mapping: Record<string, string>;
843
+ skill_id: string;
844
+ } | {
845
+ input_mapping: Record<string, string>;
846
+ command: string;
847
+ })[];
848
+ timeout_ms?: number | undefined;
849
+ }, {
850
+ name: string;
851
+ type: "pipeline";
852
+ id: string;
853
+ pricing: {
854
+ credits_per_call: number;
855
+ credits_per_minute?: number | undefined;
856
+ free_tier?: number | undefined;
857
+ };
858
+ steps: ({
859
+ skill_id: string;
860
+ input_mapping?: Record<string, string> | undefined;
861
+ } | {
862
+ command: string;
863
+ input_mapping?: Record<string, string> | undefined;
864
+ })[];
865
+ timeout_ms?: number | undefined;
866
+ }>;
867
+ /**
868
+ * Schema for OpenClaw bridge skills (Mode C).
869
+ * Forwards execution to a local OpenClaw agent.
870
+ */
871
+ declare const OpenClawSkillConfigSchema: z.ZodObject<{
872
+ id: z.ZodString;
873
+ type: z.ZodLiteral<"openclaw">;
874
+ name: z.ZodString;
875
+ agent_name: z.ZodString;
876
+ channel: z.ZodEnum<["telegram", "webhook", "process"]>;
877
+ pricing: z.ZodObject<{
878
+ credits_per_call: z.ZodNumber;
879
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
880
+ free_tier: z.ZodOptional<z.ZodNumber>;
881
+ }, "strip", z.ZodTypeAny, {
882
+ credits_per_call: number;
883
+ credits_per_minute?: number | undefined;
884
+ free_tier?: number | undefined;
885
+ }, {
886
+ credits_per_call: number;
887
+ credits_per_minute?: number | undefined;
888
+ free_tier?: number | undefined;
889
+ }>;
890
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
891
+ }, "strip", z.ZodTypeAny, {
892
+ name: string;
893
+ type: "openclaw";
894
+ id: string;
895
+ pricing: {
896
+ credits_per_call: number;
897
+ credits_per_minute?: number | undefined;
898
+ free_tier?: number | undefined;
899
+ };
900
+ agent_name: string;
901
+ channel: "telegram" | "webhook" | "process";
902
+ timeout_ms?: number | undefined;
903
+ }, {
904
+ name: string;
905
+ type: "openclaw";
906
+ id: string;
907
+ pricing: {
908
+ credits_per_call: number;
909
+ credits_per_minute?: number | undefined;
910
+ free_tier?: number | undefined;
911
+ };
912
+ agent_name: string;
913
+ channel: "telegram" | "webhook" | "process";
914
+ timeout_ms?: number | undefined;
915
+ }>;
916
+ /**
917
+ * Schema for command execution skills (Mode D).
918
+ * Runs local shell commands with parameter substitution.
919
+ */
920
+ declare const CommandSkillConfigSchema: z.ZodObject<{
921
+ id: z.ZodString;
922
+ type: z.ZodLiteral<"command">;
923
+ name: z.ZodString;
924
+ command: z.ZodString;
925
+ output_type: z.ZodEnum<["json", "text", "file"]>;
926
+ allowed_commands: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
927
+ working_dir: z.ZodOptional<z.ZodString>;
928
+ timeout_ms: z.ZodDefault<z.ZodNumber>;
929
+ pricing: z.ZodObject<{
930
+ credits_per_call: z.ZodNumber;
931
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
932
+ free_tier: z.ZodOptional<z.ZodNumber>;
933
+ }, "strip", z.ZodTypeAny, {
934
+ credits_per_call: number;
935
+ credits_per_minute?: number | undefined;
936
+ free_tier?: number | undefined;
937
+ }, {
938
+ credits_per_call: number;
939
+ credits_per_minute?: number | undefined;
940
+ free_tier?: number | undefined;
941
+ }>;
942
+ }, "strip", z.ZodTypeAny, {
943
+ name: string;
944
+ type: "command";
945
+ id: string;
946
+ pricing: {
947
+ credits_per_call: number;
948
+ credits_per_minute?: number | undefined;
949
+ free_tier?: number | undefined;
950
+ };
951
+ timeout_ms: number;
952
+ command: string;
953
+ output_type: "text" | "json" | "file";
954
+ allowed_commands?: string[] | undefined;
955
+ working_dir?: string | undefined;
956
+ }, {
957
+ name: string;
958
+ type: "command";
959
+ id: string;
960
+ pricing: {
961
+ credits_per_call: number;
962
+ credits_per_minute?: number | undefined;
963
+ free_tier?: number | undefined;
964
+ };
965
+ command: string;
966
+ output_type: "text" | "json" | "file";
967
+ timeout_ms?: number | undefined;
968
+ allowed_commands?: string[] | undefined;
969
+ working_dir?: string | undefined;
970
+ }>;
971
+ /**
972
+ * Schema for conductor orchestration skills (Mode E).
973
+ * Routes execution to the ConductorMode for task decomposition and multi-agent orchestration.
974
+ */
975
+ declare const ConductorSkillConfigSchema: z.ZodObject<{
976
+ id: z.ZodString;
977
+ type: z.ZodLiteral<"conductor">;
978
+ name: z.ZodString;
979
+ conductor_skill: z.ZodEnum<["orchestrate", "plan"]>;
980
+ pricing: z.ZodObject<{
981
+ credits_per_call: z.ZodNumber;
982
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
983
+ free_tier: z.ZodOptional<z.ZodNumber>;
984
+ }, "strip", z.ZodTypeAny, {
985
+ credits_per_call: number;
986
+ credits_per_minute?: number | undefined;
987
+ free_tier?: number | undefined;
988
+ }, {
989
+ credits_per_call: number;
990
+ credits_per_minute?: number | undefined;
991
+ free_tier?: number | undefined;
992
+ }>;
993
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
994
+ }, "strip", z.ZodTypeAny, {
995
+ name: string;
996
+ type: "conductor";
997
+ id: string;
998
+ pricing: {
999
+ credits_per_call: number;
1000
+ credits_per_minute?: number | undefined;
1001
+ free_tier?: number | undefined;
1002
+ };
1003
+ conductor_skill: "orchestrate" | "plan";
1004
+ timeout_ms?: number | undefined;
1005
+ }, {
1006
+ name: string;
1007
+ type: "conductor";
1008
+ id: string;
1009
+ pricing: {
1010
+ credits_per_call: number;
1011
+ credits_per_minute?: number | undefined;
1012
+ free_tier?: number | undefined;
1013
+ };
1014
+ conductor_skill: "orchestrate" | "plan";
1015
+ timeout_ms?: number | undefined;
1016
+ }>;
1017
+ /**
1018
+ * Discriminated union over all five skill configuration types.
1019
+ * Used by SkillExecutor to dispatch to the correct executor mode.
1020
+ */
1021
+ declare const SkillConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1022
+ id: z.ZodString;
1023
+ type: z.ZodLiteral<"api">;
1024
+ name: z.ZodString;
1025
+ endpoint: z.ZodString;
1026
+ method: z.ZodEnum<["GET", "POST", "PUT", "DELETE"]>;
1027
+ auth: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1028
+ type: z.ZodLiteral<"bearer">;
1029
+ token: z.ZodString;
1030
+ }, "strip", z.ZodTypeAny, {
1031
+ type: "bearer";
1032
+ token: string;
1033
+ }, {
1034
+ type: "bearer";
1035
+ token: string;
1036
+ }>, z.ZodObject<{
1037
+ type: z.ZodLiteral<"apikey">;
1038
+ header: z.ZodDefault<z.ZodString>;
1039
+ key: z.ZodString;
1040
+ }, "strip", z.ZodTypeAny, {
1041
+ type: "apikey";
1042
+ header: string;
1043
+ key: string;
1044
+ }, {
1045
+ type: "apikey";
1046
+ key: string;
1047
+ header?: string | undefined;
1048
+ }>, z.ZodObject<{
1049
+ type: z.ZodLiteral<"basic">;
1050
+ username: z.ZodString;
1051
+ password: z.ZodString;
1052
+ }, "strip", z.ZodTypeAny, {
1053
+ type: "basic";
1054
+ username: string;
1055
+ password: string;
1056
+ }, {
1057
+ type: "basic";
1058
+ username: string;
1059
+ password: string;
1060
+ }>]>>;
1061
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1062
+ output_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1063
+ pricing: z.ZodObject<{
1064
+ credits_per_call: z.ZodNumber;
1065
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1066
+ free_tier: z.ZodOptional<z.ZodNumber>;
1067
+ }, "strip", z.ZodTypeAny, {
1068
+ credits_per_call: number;
1069
+ credits_per_minute?: number | undefined;
1070
+ free_tier?: number | undefined;
1071
+ }, {
1072
+ credits_per_call: number;
1073
+ credits_per_minute?: number | undefined;
1074
+ free_tier?: number | undefined;
1075
+ }>;
1076
+ timeout_ms: z.ZodDefault<z.ZodNumber>;
1077
+ retries: z.ZodDefault<z.ZodNumber>;
1078
+ provider: z.ZodOptional<z.ZodString>;
1079
+ }, "strip", z.ZodTypeAny, {
1080
+ name: string;
1081
+ type: "api";
1082
+ id: string;
1083
+ pricing: {
1084
+ credits_per_call: number;
1085
+ credits_per_minute?: number | undefined;
1086
+ free_tier?: number | undefined;
1087
+ };
1088
+ endpoint: string;
1089
+ method: "GET" | "POST" | "PUT" | "DELETE";
1090
+ input_mapping: Record<string, string>;
1091
+ output_mapping: Record<string, string>;
1092
+ timeout_ms: number;
1093
+ retries: number;
1094
+ provider?: string | undefined;
1095
+ auth?: {
1096
+ type: "bearer";
1097
+ token: string;
1098
+ } | {
1099
+ type: "apikey";
1100
+ header: string;
1101
+ key: string;
1102
+ } | {
1103
+ type: "basic";
1104
+ username: string;
1105
+ password: string;
1106
+ } | undefined;
1107
+ }, {
1108
+ name: string;
1109
+ type: "api";
1110
+ id: string;
1111
+ pricing: {
1112
+ credits_per_call: number;
1113
+ credits_per_minute?: number | undefined;
1114
+ free_tier?: number | undefined;
1115
+ };
1116
+ endpoint: string;
1117
+ method: "GET" | "POST" | "PUT" | "DELETE";
1118
+ provider?: string | undefined;
1119
+ auth?: {
1120
+ type: "bearer";
1121
+ token: string;
1122
+ } | {
1123
+ type: "apikey";
1124
+ key: string;
1125
+ header?: string | undefined;
1126
+ } | {
1127
+ type: "basic";
1128
+ username: string;
1129
+ password: string;
1130
+ } | undefined;
1131
+ input_mapping?: Record<string, string> | undefined;
1132
+ output_mapping?: Record<string, string> | undefined;
1133
+ timeout_ms?: number | undefined;
1134
+ retries?: number | undefined;
1135
+ }>, z.ZodObject<{
1136
+ id: z.ZodString;
1137
+ type: z.ZodLiteral<"pipeline">;
1138
+ name: z.ZodString;
1139
+ steps: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1140
+ skill_id: z.ZodString;
1141
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1142
+ }, "strip", z.ZodTypeAny, {
1143
+ input_mapping: Record<string, string>;
1144
+ skill_id: string;
1145
+ }, {
1146
+ skill_id: string;
1147
+ input_mapping?: Record<string, string> | undefined;
1148
+ }>, z.ZodObject<{
1149
+ command: z.ZodString;
1150
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1151
+ }, "strip", z.ZodTypeAny, {
1152
+ input_mapping: Record<string, string>;
1153
+ command: string;
1154
+ }, {
1155
+ command: string;
1156
+ input_mapping?: Record<string, string> | undefined;
1157
+ }>]>, "many">;
1158
+ pricing: z.ZodObject<{
1159
+ credits_per_call: z.ZodNumber;
1160
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1161
+ free_tier: z.ZodOptional<z.ZodNumber>;
1162
+ }, "strip", z.ZodTypeAny, {
1163
+ credits_per_call: number;
1164
+ credits_per_minute?: number | undefined;
1165
+ free_tier?: number | undefined;
1166
+ }, {
1167
+ credits_per_call: number;
1168
+ credits_per_minute?: number | undefined;
1169
+ free_tier?: number | undefined;
1170
+ }>;
1171
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1172
+ }, "strip", z.ZodTypeAny, {
1173
+ name: string;
1174
+ type: "pipeline";
1175
+ id: string;
1176
+ pricing: {
1177
+ credits_per_call: number;
1178
+ credits_per_minute?: number | undefined;
1179
+ free_tier?: number | undefined;
1180
+ };
1181
+ steps: ({
1182
+ input_mapping: Record<string, string>;
1183
+ skill_id: string;
1184
+ } | {
1185
+ input_mapping: Record<string, string>;
1186
+ command: string;
1187
+ })[];
1188
+ timeout_ms?: number | undefined;
1189
+ }, {
1190
+ name: string;
1191
+ type: "pipeline";
1192
+ id: string;
1193
+ pricing: {
1194
+ credits_per_call: number;
1195
+ credits_per_minute?: number | undefined;
1196
+ free_tier?: number | undefined;
1197
+ };
1198
+ steps: ({
1199
+ skill_id: string;
1200
+ input_mapping?: Record<string, string> | undefined;
1201
+ } | {
1202
+ command: string;
1203
+ input_mapping?: Record<string, string> | undefined;
1204
+ })[];
1205
+ timeout_ms?: number | undefined;
1206
+ }>, z.ZodObject<{
1207
+ id: z.ZodString;
1208
+ type: z.ZodLiteral<"openclaw">;
1209
+ name: z.ZodString;
1210
+ agent_name: z.ZodString;
1211
+ channel: z.ZodEnum<["telegram", "webhook", "process"]>;
1212
+ pricing: z.ZodObject<{
1213
+ credits_per_call: z.ZodNumber;
1214
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1215
+ free_tier: z.ZodOptional<z.ZodNumber>;
1216
+ }, "strip", z.ZodTypeAny, {
1217
+ credits_per_call: number;
1218
+ credits_per_minute?: number | undefined;
1219
+ free_tier?: number | undefined;
1220
+ }, {
1221
+ credits_per_call: number;
1222
+ credits_per_minute?: number | undefined;
1223
+ free_tier?: number | undefined;
1224
+ }>;
1225
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1226
+ }, "strip", z.ZodTypeAny, {
1227
+ name: string;
1228
+ type: "openclaw";
1229
+ id: string;
1230
+ pricing: {
1231
+ credits_per_call: number;
1232
+ credits_per_minute?: number | undefined;
1233
+ free_tier?: number | undefined;
1234
+ };
1235
+ agent_name: string;
1236
+ channel: "telegram" | "webhook" | "process";
1237
+ timeout_ms?: number | undefined;
1238
+ }, {
1239
+ name: string;
1240
+ type: "openclaw";
1241
+ id: string;
1242
+ pricing: {
1243
+ credits_per_call: number;
1244
+ credits_per_minute?: number | undefined;
1245
+ free_tier?: number | undefined;
1246
+ };
1247
+ agent_name: string;
1248
+ channel: "telegram" | "webhook" | "process";
1249
+ timeout_ms?: number | undefined;
1250
+ }>, z.ZodObject<{
1251
+ id: z.ZodString;
1252
+ type: z.ZodLiteral<"command">;
1253
+ name: z.ZodString;
1254
+ command: z.ZodString;
1255
+ output_type: z.ZodEnum<["json", "text", "file"]>;
1256
+ allowed_commands: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1257
+ working_dir: z.ZodOptional<z.ZodString>;
1258
+ timeout_ms: z.ZodDefault<z.ZodNumber>;
1259
+ pricing: z.ZodObject<{
1260
+ credits_per_call: z.ZodNumber;
1261
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1262
+ free_tier: z.ZodOptional<z.ZodNumber>;
1263
+ }, "strip", z.ZodTypeAny, {
1264
+ credits_per_call: number;
1265
+ credits_per_minute?: number | undefined;
1266
+ free_tier?: number | undefined;
1267
+ }, {
1268
+ credits_per_call: number;
1269
+ credits_per_minute?: number | undefined;
1270
+ free_tier?: number | undefined;
1271
+ }>;
1272
+ }, "strip", z.ZodTypeAny, {
1273
+ name: string;
1274
+ type: "command";
1275
+ id: string;
1276
+ pricing: {
1277
+ credits_per_call: number;
1278
+ credits_per_minute?: number | undefined;
1279
+ free_tier?: number | undefined;
1280
+ };
1281
+ timeout_ms: number;
1282
+ command: string;
1283
+ output_type: "text" | "json" | "file";
1284
+ allowed_commands?: string[] | undefined;
1285
+ working_dir?: string | undefined;
1286
+ }, {
1287
+ name: string;
1288
+ type: "command";
1289
+ id: string;
1290
+ pricing: {
1291
+ credits_per_call: number;
1292
+ credits_per_minute?: number | undefined;
1293
+ free_tier?: number | undefined;
1294
+ };
1295
+ command: string;
1296
+ output_type: "text" | "json" | "file";
1297
+ timeout_ms?: number | undefined;
1298
+ allowed_commands?: string[] | undefined;
1299
+ working_dir?: string | undefined;
1300
+ }>, z.ZodObject<{
1301
+ id: z.ZodString;
1302
+ type: z.ZodLiteral<"conductor">;
1303
+ name: z.ZodString;
1304
+ conductor_skill: z.ZodEnum<["orchestrate", "plan"]>;
1305
+ pricing: z.ZodObject<{
1306
+ credits_per_call: z.ZodNumber;
1307
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1308
+ free_tier: z.ZodOptional<z.ZodNumber>;
1309
+ }, "strip", z.ZodTypeAny, {
1310
+ credits_per_call: number;
1311
+ credits_per_minute?: number | undefined;
1312
+ free_tier?: number | undefined;
1313
+ }, {
1314
+ credits_per_call: number;
1315
+ credits_per_minute?: number | undefined;
1316
+ free_tier?: number | undefined;
1317
+ }>;
1318
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1319
+ }, "strip", z.ZodTypeAny, {
1320
+ name: string;
1321
+ type: "conductor";
1322
+ id: string;
1323
+ pricing: {
1324
+ credits_per_call: number;
1325
+ credits_per_minute?: number | undefined;
1326
+ free_tier?: number | undefined;
1327
+ };
1328
+ conductor_skill: "orchestrate" | "plan";
1329
+ timeout_ms?: number | undefined;
1330
+ }, {
1331
+ name: string;
1332
+ type: "conductor";
1333
+ id: string;
1334
+ pricing: {
1335
+ credits_per_call: number;
1336
+ credits_per_minute?: number | undefined;
1337
+ free_tier?: number | undefined;
1338
+ };
1339
+ conductor_skill: "orchestrate" | "plan";
1340
+ timeout_ms?: number | undefined;
1341
+ }>]>;
1342
+ /**
1343
+ * Root schema for a skills.yaml file.
1344
+ * Contains a list of skill configurations.
1345
+ */
1346
+ declare const SkillsFileSchema: z.ZodObject<{
1347
+ skills: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1348
+ id: z.ZodString;
1349
+ type: z.ZodLiteral<"api">;
1350
+ name: z.ZodString;
1351
+ endpoint: z.ZodString;
1352
+ method: z.ZodEnum<["GET", "POST", "PUT", "DELETE"]>;
1353
+ auth: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1354
+ type: z.ZodLiteral<"bearer">;
1355
+ token: z.ZodString;
1356
+ }, "strip", z.ZodTypeAny, {
1357
+ type: "bearer";
1358
+ token: string;
1359
+ }, {
1360
+ type: "bearer";
1361
+ token: string;
1362
+ }>, z.ZodObject<{
1363
+ type: z.ZodLiteral<"apikey">;
1364
+ header: z.ZodDefault<z.ZodString>;
1365
+ key: z.ZodString;
1366
+ }, "strip", z.ZodTypeAny, {
1367
+ type: "apikey";
1368
+ header: string;
1369
+ key: string;
1370
+ }, {
1371
+ type: "apikey";
1372
+ key: string;
1373
+ header?: string | undefined;
1374
+ }>, z.ZodObject<{
1375
+ type: z.ZodLiteral<"basic">;
1376
+ username: z.ZodString;
1377
+ password: z.ZodString;
1378
+ }, "strip", z.ZodTypeAny, {
1379
+ type: "basic";
1380
+ username: string;
1381
+ password: string;
1382
+ }, {
1383
+ type: "basic";
1384
+ username: string;
1385
+ password: string;
1386
+ }>]>>;
1387
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1388
+ output_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1389
+ pricing: z.ZodObject<{
1390
+ credits_per_call: z.ZodNumber;
1391
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1392
+ free_tier: z.ZodOptional<z.ZodNumber>;
1393
+ }, "strip", z.ZodTypeAny, {
1394
+ credits_per_call: number;
1395
+ credits_per_minute?: number | undefined;
1396
+ free_tier?: number | undefined;
1397
+ }, {
1398
+ credits_per_call: number;
1399
+ credits_per_minute?: number | undefined;
1400
+ free_tier?: number | undefined;
1401
+ }>;
1402
+ timeout_ms: z.ZodDefault<z.ZodNumber>;
1403
+ retries: z.ZodDefault<z.ZodNumber>;
1404
+ provider: z.ZodOptional<z.ZodString>;
1405
+ }, "strip", z.ZodTypeAny, {
1406
+ name: string;
1407
+ type: "api";
1408
+ id: string;
1409
+ pricing: {
1410
+ credits_per_call: number;
1411
+ credits_per_minute?: number | undefined;
1412
+ free_tier?: number | undefined;
1413
+ };
1414
+ endpoint: string;
1415
+ method: "GET" | "POST" | "PUT" | "DELETE";
1416
+ input_mapping: Record<string, string>;
1417
+ output_mapping: Record<string, string>;
1418
+ timeout_ms: number;
1419
+ retries: number;
1420
+ provider?: string | undefined;
1421
+ auth?: {
1422
+ type: "bearer";
1423
+ token: string;
1424
+ } | {
1425
+ type: "apikey";
1426
+ header: string;
1427
+ key: string;
1428
+ } | {
1429
+ type: "basic";
1430
+ username: string;
1431
+ password: string;
1432
+ } | undefined;
1433
+ }, {
1434
+ name: string;
1435
+ type: "api";
1436
+ id: string;
1437
+ pricing: {
1438
+ credits_per_call: number;
1439
+ credits_per_minute?: number | undefined;
1440
+ free_tier?: number | undefined;
1441
+ };
1442
+ endpoint: string;
1443
+ method: "GET" | "POST" | "PUT" | "DELETE";
1444
+ provider?: string | undefined;
1445
+ auth?: {
1446
+ type: "bearer";
1447
+ token: string;
1448
+ } | {
1449
+ type: "apikey";
1450
+ key: string;
1451
+ header?: string | undefined;
1452
+ } | {
1453
+ type: "basic";
1454
+ username: string;
1455
+ password: string;
1456
+ } | undefined;
1457
+ input_mapping?: Record<string, string> | undefined;
1458
+ output_mapping?: Record<string, string> | undefined;
1459
+ timeout_ms?: number | undefined;
1460
+ retries?: number | undefined;
1461
+ }>, z.ZodObject<{
1462
+ id: z.ZodString;
1463
+ type: z.ZodLiteral<"pipeline">;
1464
+ name: z.ZodString;
1465
+ steps: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1466
+ skill_id: z.ZodString;
1467
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1468
+ }, "strip", z.ZodTypeAny, {
1469
+ input_mapping: Record<string, string>;
1470
+ skill_id: string;
1471
+ }, {
1472
+ skill_id: string;
1473
+ input_mapping?: Record<string, string> | undefined;
1474
+ }>, z.ZodObject<{
1475
+ command: z.ZodString;
1476
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1477
+ }, "strip", z.ZodTypeAny, {
1478
+ input_mapping: Record<string, string>;
1479
+ command: string;
1480
+ }, {
1481
+ command: string;
1482
+ input_mapping?: Record<string, string> | undefined;
1483
+ }>]>, "many">;
1484
+ pricing: z.ZodObject<{
1485
+ credits_per_call: z.ZodNumber;
1486
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1487
+ free_tier: z.ZodOptional<z.ZodNumber>;
1488
+ }, "strip", z.ZodTypeAny, {
1489
+ credits_per_call: number;
1490
+ credits_per_minute?: number | undefined;
1491
+ free_tier?: number | undefined;
1492
+ }, {
1493
+ credits_per_call: number;
1494
+ credits_per_minute?: number | undefined;
1495
+ free_tier?: number | undefined;
1496
+ }>;
1497
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1498
+ }, "strip", z.ZodTypeAny, {
1499
+ name: string;
1500
+ type: "pipeline";
1501
+ id: string;
1502
+ pricing: {
1503
+ credits_per_call: number;
1504
+ credits_per_minute?: number | undefined;
1505
+ free_tier?: number | undefined;
1506
+ };
1507
+ steps: ({
1508
+ input_mapping: Record<string, string>;
1509
+ skill_id: string;
1510
+ } | {
1511
+ input_mapping: Record<string, string>;
1512
+ command: string;
1513
+ })[];
1514
+ timeout_ms?: number | undefined;
1515
+ }, {
1516
+ name: string;
1517
+ type: "pipeline";
1518
+ id: string;
1519
+ pricing: {
1520
+ credits_per_call: number;
1521
+ credits_per_minute?: number | undefined;
1522
+ free_tier?: number | undefined;
1523
+ };
1524
+ steps: ({
1525
+ skill_id: string;
1526
+ input_mapping?: Record<string, string> | undefined;
1527
+ } | {
1528
+ command: string;
1529
+ input_mapping?: Record<string, string> | undefined;
1530
+ })[];
1531
+ timeout_ms?: number | undefined;
1532
+ }>, z.ZodObject<{
1533
+ id: z.ZodString;
1534
+ type: z.ZodLiteral<"openclaw">;
1535
+ name: z.ZodString;
1536
+ agent_name: z.ZodString;
1537
+ channel: z.ZodEnum<["telegram", "webhook", "process"]>;
1538
+ pricing: z.ZodObject<{
1539
+ credits_per_call: z.ZodNumber;
1540
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1541
+ free_tier: z.ZodOptional<z.ZodNumber>;
1542
+ }, "strip", z.ZodTypeAny, {
1543
+ credits_per_call: number;
1544
+ credits_per_minute?: number | undefined;
1545
+ free_tier?: number | undefined;
1546
+ }, {
1547
+ credits_per_call: number;
1548
+ credits_per_minute?: number | undefined;
1549
+ free_tier?: number | undefined;
1550
+ }>;
1551
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1552
+ }, "strip", z.ZodTypeAny, {
1553
+ name: string;
1554
+ type: "openclaw";
1555
+ id: string;
1556
+ pricing: {
1557
+ credits_per_call: number;
1558
+ credits_per_minute?: number | undefined;
1559
+ free_tier?: number | undefined;
1560
+ };
1561
+ agent_name: string;
1562
+ channel: "telegram" | "webhook" | "process";
1563
+ timeout_ms?: number | undefined;
1564
+ }, {
1565
+ name: string;
1566
+ type: "openclaw";
1567
+ id: string;
1568
+ pricing: {
1569
+ credits_per_call: number;
1570
+ credits_per_minute?: number | undefined;
1571
+ free_tier?: number | undefined;
1572
+ };
1573
+ agent_name: string;
1574
+ channel: "telegram" | "webhook" | "process";
1575
+ timeout_ms?: number | undefined;
1576
+ }>, z.ZodObject<{
1577
+ id: z.ZodString;
1578
+ type: z.ZodLiteral<"command">;
1579
+ name: z.ZodString;
1580
+ command: z.ZodString;
1581
+ output_type: z.ZodEnum<["json", "text", "file"]>;
1582
+ allowed_commands: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1583
+ working_dir: z.ZodOptional<z.ZodString>;
1584
+ timeout_ms: z.ZodDefault<z.ZodNumber>;
1585
+ pricing: z.ZodObject<{
1586
+ credits_per_call: z.ZodNumber;
1587
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1588
+ free_tier: z.ZodOptional<z.ZodNumber>;
1589
+ }, "strip", z.ZodTypeAny, {
1590
+ credits_per_call: number;
1591
+ credits_per_minute?: number | undefined;
1592
+ free_tier?: number | undefined;
1593
+ }, {
1594
+ credits_per_call: number;
1595
+ credits_per_minute?: number | undefined;
1596
+ free_tier?: number | undefined;
1597
+ }>;
1598
+ }, "strip", z.ZodTypeAny, {
1599
+ name: string;
1600
+ type: "command";
1601
+ id: string;
1602
+ pricing: {
1603
+ credits_per_call: number;
1604
+ credits_per_minute?: number | undefined;
1605
+ free_tier?: number | undefined;
1606
+ };
1607
+ timeout_ms: number;
1608
+ command: string;
1609
+ output_type: "text" | "json" | "file";
1610
+ allowed_commands?: string[] | undefined;
1611
+ working_dir?: string | undefined;
1612
+ }, {
1613
+ name: string;
1614
+ type: "command";
1615
+ id: string;
1616
+ pricing: {
1617
+ credits_per_call: number;
1618
+ credits_per_minute?: number | undefined;
1619
+ free_tier?: number | undefined;
1620
+ };
1621
+ command: string;
1622
+ output_type: "text" | "json" | "file";
1623
+ timeout_ms?: number | undefined;
1624
+ allowed_commands?: string[] | undefined;
1625
+ working_dir?: string | undefined;
1626
+ }>, z.ZodObject<{
1627
+ id: z.ZodString;
1628
+ type: z.ZodLiteral<"conductor">;
1629
+ name: z.ZodString;
1630
+ conductor_skill: z.ZodEnum<["orchestrate", "plan"]>;
1631
+ pricing: z.ZodObject<{
1632
+ credits_per_call: z.ZodNumber;
1633
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1634
+ free_tier: z.ZodOptional<z.ZodNumber>;
1635
+ }, "strip", z.ZodTypeAny, {
1636
+ credits_per_call: number;
1637
+ credits_per_minute?: number | undefined;
1638
+ free_tier?: number | undefined;
1639
+ }, {
1640
+ credits_per_call: number;
1641
+ credits_per_minute?: number | undefined;
1642
+ free_tier?: number | undefined;
1643
+ }>;
1644
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1645
+ }, "strip", z.ZodTypeAny, {
1646
+ name: string;
1647
+ type: "conductor";
1648
+ id: string;
1649
+ pricing: {
1650
+ credits_per_call: number;
1651
+ credits_per_minute?: number | undefined;
1652
+ free_tier?: number | undefined;
1653
+ };
1654
+ conductor_skill: "orchestrate" | "plan";
1655
+ timeout_ms?: number | undefined;
1656
+ }, {
1657
+ name: string;
1658
+ type: "conductor";
1659
+ id: string;
1660
+ pricing: {
1661
+ credits_per_call: number;
1662
+ credits_per_minute?: number | undefined;
1663
+ free_tier?: number | undefined;
1664
+ };
1665
+ conductor_skill: "orchestrate" | "plan";
1666
+ timeout_ms?: number | undefined;
1667
+ }>]>, "many">;
1668
+ }, "strip", z.ZodTypeAny, {
1669
+ skills: ({
1670
+ name: string;
1671
+ type: "api";
1672
+ id: string;
1673
+ pricing: {
1674
+ credits_per_call: number;
1675
+ credits_per_minute?: number | undefined;
1676
+ free_tier?: number | undefined;
1677
+ };
1678
+ endpoint: string;
1679
+ method: "GET" | "POST" | "PUT" | "DELETE";
1680
+ input_mapping: Record<string, string>;
1681
+ output_mapping: Record<string, string>;
1682
+ timeout_ms: number;
1683
+ retries: number;
1684
+ provider?: string | undefined;
1685
+ auth?: {
1686
+ type: "bearer";
1687
+ token: string;
1688
+ } | {
1689
+ type: "apikey";
1690
+ header: string;
1691
+ key: string;
1692
+ } | {
1693
+ type: "basic";
1694
+ username: string;
1695
+ password: string;
1696
+ } | undefined;
1697
+ } | {
1698
+ name: string;
1699
+ type: "pipeline";
1700
+ id: string;
1701
+ pricing: {
1702
+ credits_per_call: number;
1703
+ credits_per_minute?: number | undefined;
1704
+ free_tier?: number | undefined;
1705
+ };
1706
+ steps: ({
1707
+ input_mapping: Record<string, string>;
1708
+ skill_id: string;
1709
+ } | {
1710
+ input_mapping: Record<string, string>;
1711
+ command: string;
1712
+ })[];
1713
+ timeout_ms?: number | undefined;
1714
+ } | {
1715
+ name: string;
1716
+ type: "openclaw";
1717
+ id: string;
1718
+ pricing: {
1719
+ credits_per_call: number;
1720
+ credits_per_minute?: number | undefined;
1721
+ free_tier?: number | undefined;
1722
+ };
1723
+ agent_name: string;
1724
+ channel: "telegram" | "webhook" | "process";
1725
+ timeout_ms?: number | undefined;
1726
+ } | {
1727
+ name: string;
1728
+ type: "command";
1729
+ id: string;
1730
+ pricing: {
1731
+ credits_per_call: number;
1732
+ credits_per_minute?: number | undefined;
1733
+ free_tier?: number | undefined;
1734
+ };
1735
+ timeout_ms: number;
1736
+ command: string;
1737
+ output_type: "text" | "json" | "file";
1738
+ allowed_commands?: string[] | undefined;
1739
+ working_dir?: string | undefined;
1740
+ } | {
1741
+ name: string;
1742
+ type: "conductor";
1743
+ id: string;
1744
+ pricing: {
1745
+ credits_per_call: number;
1746
+ credits_per_minute?: number | undefined;
1747
+ free_tier?: number | undefined;
1748
+ };
1749
+ conductor_skill: "orchestrate" | "plan";
1750
+ timeout_ms?: number | undefined;
1751
+ })[];
1752
+ }, {
1753
+ skills: ({
1754
+ name: string;
1755
+ type: "api";
1756
+ id: string;
1757
+ pricing: {
1758
+ credits_per_call: number;
1759
+ credits_per_minute?: number | undefined;
1760
+ free_tier?: number | undefined;
1761
+ };
1762
+ endpoint: string;
1763
+ method: "GET" | "POST" | "PUT" | "DELETE";
1764
+ provider?: string | undefined;
1765
+ auth?: {
1766
+ type: "bearer";
1767
+ token: string;
1768
+ } | {
1769
+ type: "apikey";
1770
+ key: string;
1771
+ header?: string | undefined;
1772
+ } | {
1773
+ type: "basic";
1774
+ username: string;
1775
+ password: string;
1776
+ } | undefined;
1777
+ input_mapping?: Record<string, string> | undefined;
1778
+ output_mapping?: Record<string, string> | undefined;
1779
+ timeout_ms?: number | undefined;
1780
+ retries?: number | undefined;
1781
+ } | {
1782
+ name: string;
1783
+ type: "pipeline";
1784
+ id: string;
1785
+ pricing: {
1786
+ credits_per_call: number;
1787
+ credits_per_minute?: number | undefined;
1788
+ free_tier?: number | undefined;
1789
+ };
1790
+ steps: ({
1791
+ skill_id: string;
1792
+ input_mapping?: Record<string, string> | undefined;
1793
+ } | {
1794
+ command: string;
1795
+ input_mapping?: Record<string, string> | undefined;
1796
+ })[];
1797
+ timeout_ms?: number | undefined;
1798
+ } | {
1799
+ name: string;
1800
+ type: "openclaw";
1801
+ id: string;
1802
+ pricing: {
1803
+ credits_per_call: number;
1804
+ credits_per_minute?: number | undefined;
1805
+ free_tier?: number | undefined;
1806
+ };
1807
+ agent_name: string;
1808
+ channel: "telegram" | "webhook" | "process";
1809
+ timeout_ms?: number | undefined;
1810
+ } | {
1811
+ name: string;
1812
+ type: "command";
1813
+ id: string;
1814
+ pricing: {
1815
+ credits_per_call: number;
1816
+ credits_per_minute?: number | undefined;
1817
+ free_tier?: number | undefined;
1818
+ };
1819
+ command: string;
1820
+ output_type: "text" | "json" | "file";
1821
+ timeout_ms?: number | undefined;
1822
+ allowed_commands?: string[] | undefined;
1823
+ working_dir?: string | undefined;
1824
+ } | {
1825
+ name: string;
1826
+ type: "conductor";
1827
+ id: string;
1828
+ pricing: {
1829
+ credits_per_call: number;
1830
+ credits_per_minute?: number | undefined;
1831
+ free_tier?: number | undefined;
1832
+ };
1833
+ conductor_skill: "orchestrate" | "plan";
1834
+ timeout_ms?: number | undefined;
1835
+ })[];
1836
+ }>;
1837
+ /** TypeScript type for any skill config entry */
1838
+ type SkillConfig = z.infer<typeof SkillConfigSchema>;
1839
+ /** TypeScript type for an API-mode skill config */
1840
+ type ApiSkillConfig = z.infer<typeof ApiSkillConfigSchema>;
1841
+ /** TypeScript type for a pipeline-mode skill config */
1842
+ type PipelineSkillConfig = z.infer<typeof PipelineSkillConfigSchema>;
1843
+ /** TypeScript type for an OpenClaw-mode skill config */
1844
+ type OpenClawSkillConfig = z.infer<typeof OpenClawSkillConfigSchema>;
1845
+ /** TypeScript type for a command-mode skill config */
1846
+ type CommandSkillConfig = z.infer<typeof CommandSkillConfigSchema>;
1847
+ /** TypeScript type for a conductor-mode skill config */
1848
+ type ConductorSkillConfig = z.infer<typeof ConductorSkillConfigSchema>;
1849
+ /**
1850
+ * Expands `${VAR_NAME}` patterns in a string using process.env.
1851
+ *
1852
+ * Only matches env-var-style names: uppercase letters, digits, and underscores
1853
+ * (e.g. `${API_KEY}`, `${MY_TOKEN_123}`). Patterns containing dots or lowercase
1854
+ * letters (e.g. `${params.text}`, `${prev.result}`) are left untouched — those
1855
+ * are runtime interpolation placeholders handled by the interpolation engine.
1856
+ *
1857
+ * @param value - The string potentially containing `${ENV_VAR}` references.
1858
+ * @returns The string with env var references replaced; runtime placeholders preserved.
1859
+ * @throws Error if a referenced env var is not defined.
1860
+ */
1861
+ declare function expandEnvVars(value: string): string;
1862
+ /**
1863
+ * Parses a skills.yaml file content string into a typed SkillConfig array.
1864
+ *
1865
+ * 1. Parses YAML string into a raw object (throws on invalid YAML).
1866
+ * 2. Expands all `${ENV_VAR}` references in string values using process.env.
1867
+ * 3. Validates the result with the SkillsFileSchema Zod schema (throws ZodError on invalid shape).
1868
+ *
1869
+ * @param yamlContent - Raw YAML string (contents of skills.yaml).
1870
+ * @returns Parsed and validated array of SkillConfig objects.
1871
+ * @throws YAMLException if YAML syntax is invalid.
1872
+ * @throws ZodError if schema validation fails.
1873
+ * @throws Error if any referenced environment variable is not defined.
1874
+ */
1875
+ declare function parseSkillsFile(yamlContent: string): SkillConfig[];
1876
+
1877
+ /**
1878
+ * Result returned by SkillExecutor.execute() for every invocation.
1879
+ * Always includes timing data regardless of success or failure.
1880
+ */
1881
+ interface ExecutionResult {
1882
+ /** Whether the skill executed successfully. */
1883
+ success: boolean;
1884
+ /** The output produced by the skill on success. */
1885
+ result?: unknown;
1886
+ /** Error message if success is false. */
1887
+ error?: string;
1888
+ /** Wall-clock execution time in milliseconds. */
1889
+ latency_ms: number;
1890
+ }
1891
+ /**
1892
+ * Interface that all executor mode implementations must satisfy.
1893
+ * Each mode handles one skill type: 'api' | 'pipeline' | 'openclaw' | 'command'.
1894
+ */
1895
+ interface ExecutorMode {
1896
+ /**
1897
+ * Execute a skill with the given config and input parameters.
1898
+ *
1899
+ * @param config - The validated SkillConfig for this skill.
1900
+ * @param params - The input parameters passed by the caller.
1901
+ * @returns A partial ExecutionResult without latency_ms (added by SkillExecutor).
1902
+ */
1903
+ execute(config: SkillConfig, params: Record<string, unknown>): Promise<Omit<ExecutionResult, 'latency_ms'>>;
1904
+ }
1905
+ /**
1906
+ * Central dispatcher that routes skill execution requests to the appropriate
1907
+ * executor mode based on the skill's `type` field.
1908
+ *
1909
+ * Usage:
1910
+ * ```ts
1911
+ * const executor = createSkillExecutor(configs, modes);
1912
+ * const result = await executor.execute('tts-skill', { text: 'hello' });
1913
+ * ```
1914
+ */
1915
+ declare class SkillExecutor {
1916
+ private readonly skillMap;
1917
+ private readonly modeMap;
1918
+ /**
1919
+ * @param configs - Parsed SkillConfig array (from parseSkillsFile).
1920
+ * @param modes - Map from skill type string to its executor implementation.
1921
+ */
1922
+ constructor(configs: SkillConfig[], modes: Map<string, ExecutorMode>);
1923
+ /**
1924
+ * Execute a skill by ID with the given input parameters.
1925
+ *
1926
+ * Dispatch order:
1927
+ * 1. Look up skill config by skillId.
1928
+ * 2. Find executor mode by config.type.
1929
+ * 3. Invoke mode.execute(), wrap with latency timing.
1930
+ * 4. Catch any thrown errors and return as ExecutionResult with success:false.
1931
+ *
1932
+ * @param skillId - The ID of the skill to execute.
1933
+ * @param params - Input parameters for the skill.
1934
+ * @returns ExecutionResult including success, result/error, and latency_ms.
1935
+ */
1936
+ execute(skillId: string, params: Record<string, unknown>): Promise<ExecutionResult>;
1937
+ /**
1938
+ * Returns the IDs of all registered skills.
1939
+ *
1940
+ * @returns Array of skill ID strings.
1941
+ */
1942
+ listSkills(): string[];
1943
+ /**
1944
+ * Returns the SkillConfig for a given skill ID, or undefined if not found.
1945
+ *
1946
+ * @param skillId - The skill ID to look up.
1947
+ * @returns The SkillConfig or undefined.
1948
+ */
1949
+ getSkillConfig(skillId: string): SkillConfig | undefined;
1950
+ }
1951
+ /**
1952
+ * Factory function to create a SkillExecutor with the given configs and mode implementations.
1953
+ *
1954
+ * @param configs - Array of parsed SkillConfig objects.
1955
+ * @param modes - Map from type key to ExecutorMode implementation.
1956
+ * @returns A configured SkillExecutor instance.
1957
+ */
1958
+ declare function createSkillExecutor(configs: SkillConfig[], modes: Map<string, ExecutorMode>): SkillExecutor;
1959
+
1960
+ /**
1961
+ * Options for creating a gateway server.
1962
+ */
1963
+ interface GatewayOptions {
1964
+ /** Port to listen on. Default 7700. */
1965
+ port?: number;
1966
+ /** Open registry database instance. */
1967
+ registryDb: Database.Database;
1968
+ /** Open credit database instance. */
1969
+ creditDb: Database.Database;
1970
+ /** Valid bearer tokens for auth. */
1971
+ tokens: string[];
1972
+ /** URL of the local capability handler. */
1973
+ handlerUrl: string;
1974
+ /** Request timeout in ms. Default 30000. */
1975
+ timeoutMs?: number;
1976
+ /** Disable logging (useful for tests). */
1977
+ silent?: boolean;
1978
+ /**
1979
+ * Optional SkillExecutor instance.
1980
+ * When provided, skill execution is dispatched through SkillExecutor.execute()
1981
+ * instead of forwarding via fetch(handlerUrl).
1982
+ * When absent, the original handlerUrl fetch path is used (backward compat).
1983
+ */
1984
+ skillExecutor?: SkillExecutor;
1985
+ }
1986
+ /**
1987
+ * Creates a Fastify gateway server for agent-to-agent communication.
1988
+ * Registers /health (unauthenticated) and /rpc (token-authenticated) endpoints.
1989
+ * Returns a configured Fastify instance (call .ready() before using inject,
1990
+ * or .listen() to start accepting connections).
1991
+ *
1992
+ * @param opts - Gateway configuration options.
1993
+ * @returns Configured Fastify instance (not yet listening).
1994
+ */
1995
+ declare function createGatewayServer(opts: GatewayOptions): FastifyInstance;
1996
+
1997
+ /**
1998
+ * Extracts a nested value from an object using dot-notation path.
1999
+ * e.g. `extractByPath({ data: { audio: 'abc' } }, 'data.audio')` returns `'abc'`
2000
+ *
2001
+ * When path starts with "response.", the "response" prefix is stripped
2002
+ * (the mapping convention uses "response.xxx" but the actual response body
2003
+ * is the root object passed in).
2004
+ *
2005
+ * @param obj - The object to traverse.
2006
+ * @param dotPath - Dot-separated property path.
2007
+ * @returns The value at the path, or `undefined` if any step is missing.
2008
+ */
2009
+ declare function extractByPath(obj: unknown, dotPath: string): unknown;
2010
+ /**
2011
+ * Builds the Authorization / API-key headers for the configured auth type.
2012
+ *
2013
+ * @param auth - The auth config from ApiSkillConfig.
2014
+ * @returns A plain object of header name → value entries.
2015
+ */
2016
+ declare function buildAuthHeaders(auth: ApiSkillConfig['auth']): Record<string, string>;
2017
+ /**
2018
+ * Routes a set of input parameters to their respective destination buckets
2019
+ * (body, query, path, header) based on the `input_mapping` config.
2020
+ *
2021
+ * @param params - The input parameters passed to execute().
2022
+ * @param mapping - The `input_mapping` record from ApiSkillConfig.
2023
+ * @returns Four buckets: body, query, pathParams, headers.
2024
+ */
2025
+ declare function applyInputMapping(params: Record<string, unknown>, mapping: Record<string, string>): {
2026
+ body: Record<string, unknown>;
2027
+ query: Record<string, string>;
2028
+ pathParams: Record<string, string>;
2029
+ headers: Record<string, string>;
2030
+ };
2031
+ /**
2032
+ * API Executor (Mode A) — config-driven REST API calls.
2033
+ *
2034
+ * Supports:
2035
+ * - All 4 HTTP methods: GET, POST, PUT, DELETE
2036
+ * - Input mapping to body, query string, path params, or request headers
2037
+ * - Auth: bearer token, API key header, HTTP Basic
2038
+ * - Output mapping via dot-notation extraction from JSON response
2039
+ * - Retry with exponential backoff on 429/500/503
2040
+ * - Timeout via AbortController
2041
+ *
2042
+ * Implements {@link ExecutorMode} — registered under the `"api"` type key.
2043
+ */
2044
+ declare class ApiExecutor implements ExecutorMode {
2045
+ /**
2046
+ * Execute an API call described by the given skill config.
2047
+ *
2048
+ * @param config - The validated SkillConfig (must be ApiSkillConfig).
2049
+ * @param params - Input parameters to map to the HTTP request.
2050
+ * @returns Partial ExecutionResult (without latency_ms — added by SkillExecutor).
2051
+ */
2052
+ execute(config: SkillConfig, params: Record<string, unknown>): Promise<Omit<ExecutionResult, 'latency_ms'>>;
2053
+ }
2054
+
2055
+ /**
2056
+ * Executor mode for pipeline-type skills (Mode B).
2057
+ *
2058
+ * Chains multiple skill invocations or shell commands sequentially.
2059
+ * Each step can reference previous step outputs via `${prev.result.*}` or
2060
+ * `${steps[N].result.*}` in its `input_mapping` values.
2061
+ *
2062
+ * Usage:
2063
+ * ```ts
2064
+ * const pipelineExecutor = new PipelineExecutor(skillExecutor);
2065
+ * modes.set('pipeline', pipelineExecutor);
2066
+ * ```
2067
+ */
2068
+ declare class PipelineExecutor implements ExecutorMode {
2069
+ private readonly skillExecutor;
2070
+ /**
2071
+ * @param skillExecutor - The parent SkillExecutor used to dispatch sub-skill calls.
2072
+ */
2073
+ constructor(skillExecutor: SkillExecutor);
2074
+ /**
2075
+ * Execute a pipeline skill config sequentially.
2076
+ *
2077
+ * Algorithm:
2078
+ * 1. Initialise context: { params, steps: [], prev: { result: null } }
2079
+ * 2. For each step:
2080
+ * a. Resolve input_mapping keys against current context via interpolateObject.
2081
+ * b. If step has `skill_id`: dispatch via skillExecutor.execute(). On failure → stop.
2082
+ * c. If step has `command`: interpolate command string, run via exec(). On non-zero exit → stop.
2083
+ * d. Store step result in context.steps[i] and context.prev.
2084
+ * 3. Return success with final step result (or null for empty pipeline).
2085
+ *
2086
+ * @param config - The PipelineSkillConfig for this skill.
2087
+ * @param params - Input parameters from the caller.
2088
+ * @returns Partial ExecutionResult (without latency_ms — added by SkillExecutor wrapper).
2089
+ */
2090
+ execute(config: SkillConfig, params: Record<string, unknown>): Promise<Omit<ExecutionResult, 'latency_ms'>>;
2091
+ }
2092
+
2093
+ /**
2094
+ * OpenClaw Bridge — ExecutorMode C.
2095
+ *
2096
+ * Forwards AgentBnB skill execution requests to an OpenClaw agent via one of
2097
+ * three configurable channels:
2098
+ * - `webhook` — HTTP POST to OpenClaw agent's local webhook endpoint
2099
+ * - `process` — spawn `openclaw run <agent_name>` subprocess
2100
+ * - `telegram` — fire-and-forget POST to Telegram Bot API
2101
+ *
2102
+ * Implements the {@link ExecutorMode} interface so it can be registered into
2103
+ * a {@link SkillExecutor} mode map under the key `'openclaw'`.
2104
+ *
2105
+ * @example
2106
+ * ```ts
2107
+ * const modes = new Map([['openclaw', new OpenClawBridge()]]);
2108
+ * const executor = createSkillExecutor(configs, modes);
2109
+ * ```
2110
+ */
2111
+ declare class OpenClawBridge implements ExecutorMode {
2112
+ /**
2113
+ * Execute a skill with the given config and input parameters.
2114
+ *
2115
+ * @param config - The SkillConfig for this skill (must be type 'openclaw').
2116
+ * @param params - Input parameters passed by the caller.
2117
+ * @returns Partial ExecutionResult without latency_ms.
2118
+ */
2119
+ execute(config: SkillConfig, params: Record<string, unknown>): Promise<Omit<ExecutionResult, 'latency_ms'>>;
2120
+ }
2121
+
2122
+ /**
2123
+ * Implements the Command Executor mode (Mode D) for the SkillExecutor.
2124
+ *
2125
+ * Wraps local shell commands as skills with:
2126
+ * - Parameter substitution via `${params.x}` interpolation
2127
+ * - Three output types: text (raw stdout), json (parsed), file (path from stdout)
2128
+ * - Security allowlist via `allowed_commands` (base command checked against list)
2129
+ * - Configurable timeout and working directory
2130
+ */
2131
+ declare class CommandExecutor implements ExecutorMode {
2132
+ /**
2133
+ * Execute a command skill with the provided parameters.
2134
+ *
2135
+ * Steps:
2136
+ * 1. Security check: base command must be in `allowed_commands` if set.
2137
+ * 2. Interpolate `config.command` using `{ params }` context.
2138
+ * 3. Run via `child_process.exec` with timeout and cwd.
2139
+ * 4. Parse stdout based on `output_type`: text | json | file.
2140
+ *
2141
+ * @param config - Validated CommandSkillConfig.
2142
+ * @param params - Input parameters passed by the caller.
2143
+ * @returns Partial ExecutionResult (without latency_ms).
2144
+ */
2145
+ execute(config: SkillConfig, params: Record<string, unknown>): Promise<Omit<ExecutionResult, 'latency_ms'>>;
2146
+ }
2147
+
2148
+ /**
2149
+ * Resolves a dot-path expression (optionally with array index notation) against an object.
2150
+ *
2151
+ * Examples:
2152
+ * - "name" → obj.name
2153
+ * - "a.b.c" → obj.a.b.c
2154
+ * - "steps[0].result" → obj.steps[0].result
2155
+ *
2156
+ * @param obj - The root object to traverse.
2157
+ * @param path - A dot-separated path string, supporting `[N]` array index notation.
2158
+ * @returns The resolved value, or `undefined` if any segment is missing.
2159
+ */
2160
+ declare function resolvePath(obj: unknown, path: string): unknown;
2161
+ /**
2162
+ * Interpolates `${expression}` placeholders in a template string against a context object.
2163
+ *
2164
+ * - Resolves dot-path and array-index expressions against `context`.
2165
+ * - Object values are JSON.stringify'd.
2166
+ * - Missing paths resolve to empty string.
2167
+ * - Non-string (number, boolean, etc.) values are converted via String().
2168
+ *
2169
+ * @param template - A string containing zero or more `${...}` expressions.
2170
+ * @param context - The object to resolve expressions against.
2171
+ * @returns The interpolated string.
2172
+ */
2173
+ declare function interpolate(template: string, context: Record<string, unknown>): string;
2174
+ /**
2175
+ * Deep-walks an object and interpolates all string leaf values using the given context.
2176
+ *
2177
+ * Handles nested objects and arrays recursively. Non-string leaf values are preserved
2178
+ * unchanged.
2179
+ *
2180
+ * @param obj - The object whose string values should be interpolated.
2181
+ * @param context - The interpolation context (same as `interpolate`).
2182
+ * @returns A new object with all string leaves interpolated.
2183
+ */
2184
+ declare function interpolateObject(obj: Record<string, unknown>, context: Record<string, unknown>): Record<string, unknown>;
2185
+
2186
+ /**
2187
+ * Shared types for the Conductor module — task decomposition, matching, budgeting, and orchestration.
2188
+ */
2189
+ /**
2190
+ * A single sub-task produced by the TaskDecomposer.
2191
+ * Represents one step in a multi-step orchestration plan.
2192
+ */
2193
+ interface SubTask {
2194
+ /** Unique identifier for this sub-task (UUID). */
2195
+ id: string;
2196
+ /** Human-readable description of what this step does. */
2197
+ description: string;
2198
+ /** The capability category required to execute this step (e.g. 'tts', 'text_gen'). */
2199
+ required_capability: string;
2200
+ /** Parameters to pass to the executing agent's skill. */
2201
+ params: Record<string, unknown>;
2202
+ /** IDs of sub-tasks that must complete before this one can start. */
2203
+ depends_on: string[];
2204
+ /** Estimated credit cost for this step. */
2205
+ estimated_credits: number;
2206
+ }
2207
+ /**
2208
+ * Result of matching a SubTask to an available agent/skill.
2209
+ */
2210
+ interface MatchResult {
2211
+ /** ID of the sub-task this match is for. */
2212
+ subtask_id: string;
2213
+ /** Owner/agent ID of the selected peer. */
2214
+ selected_agent: string;
2215
+ /** Skill ID on the selected agent's card. */
2216
+ selected_skill: string;
2217
+ /** Match quality score (0-1). */
2218
+ score: number;
2219
+ /** Negotiated credit cost. */
2220
+ credits: number;
2221
+ /** Alternative matches considered. */
2222
+ alternatives: Array<{
2223
+ agent: string;
2224
+ skill: string;
2225
+ score: number;
2226
+ credits: number;
2227
+ }>;
2228
+ }
2229
+ /**
2230
+ * Budget constraints for an orchestration run.
2231
+ */
2232
+ interface ExecutionBudget {
2233
+ /** Sum of all sub-task estimated_credits. */
2234
+ estimated_total: number;
2235
+ /** Hard ceiling — abort if exceeded. */
2236
+ max_budget: number;
2237
+ /** Credits retained by the Conductor for coordination. */
2238
+ orchestration_fee: number;
2239
+ /** Per-task actual spending tracker. */
2240
+ per_task_spending: Map<string, number>;
2241
+ /** Whether human/agent approval is needed before execution. */
2242
+ requires_approval: boolean;
2243
+ }
2244
+ /**
2245
+ * Final result of a completed orchestration.
2246
+ */
2247
+ interface OrchestrationResult {
2248
+ /** Whether all sub-tasks completed successfully. */
2249
+ success: boolean;
2250
+ /** Per-subtask output data, keyed by sub-task ID. */
2251
+ results: Map<string, unknown>;
2252
+ /** Total credits spent across all sub-tasks + orchestration fee. */
2253
+ total_credits: number;
2254
+ /** Wall-clock time from start to finish. */
2255
+ latency_ms: number;
2256
+ /** Error messages for failed sub-tasks. */
2257
+ errors?: string[];
2258
+ }
2259
+
2260
+ /**
2261
+ * Template step definition used internally to generate SubTask instances.
2262
+ */
2263
+ interface TemplateStep {
2264
+ description: string;
2265
+ required_capability: string;
2266
+ estimated_credits: number;
2267
+ /**
2268
+ * Dependency indices — references to other steps in the same template (0-based).
2269
+ * Converted to UUIDs at decomposition time.
2270
+ */
2271
+ depends_on_indices: number[];
2272
+ }
2273
+ /**
2274
+ * A decomposition template: keyword triggers + ordered steps.
2275
+ */
2276
+ interface Template {
2277
+ keywords: readonly string[];
2278
+ steps: readonly TemplateStep[];
2279
+ }
2280
+ /**
2281
+ * Hardcoded decomposition templates for MVP.
2282
+ *
2283
+ * Each template maps keywords to a DAG of steps.
2284
+ * Future versions will replace this with LLM-driven decomposition.
2285
+ */
2286
+ declare const TEMPLATES: Readonly<Record<string, Template>>;
2287
+ /**
2288
+ * Decomposes a natural-language task description into an ordered array of SubTasks
2289
+ * using hardcoded keyword-matching templates.
2290
+ *
2291
+ * Returns the first matching template's steps as SubTask[], or an empty array
2292
+ * if no template matches.
2293
+ *
2294
+ * @param task - Natural language task description.
2295
+ * @param _availableCapabilities - Reserved for future filtering (unused in MVP).
2296
+ * @returns Array of SubTask objects forming a dependency DAG.
2297
+ */
2298
+ declare function decompose(task: string, _availableCapabilities?: string[]): SubTask[];
2299
+
2300
+ /**
2301
+ * CapabilityMatcher — finds the best agent for each sub-task using registry search + peer scoring.
2302
+ *
2303
+ * Wraps the existing searchCards() for card discovery and scorePeers() for ranked selection
2304
+ * with self-exclusion. Returns alternatives for failover when the primary agent fails.
2305
+ */
2306
+
2307
+ /**
2308
+ * Options for matchSubTasks.
2309
+ */
2310
+ interface MatchOptions {
2311
+ /** Open SQLite database with registry tables. */
2312
+ db: Database.Database;
2313
+ /** Sub-tasks to find agents for. */
2314
+ subtasks: SubTask[];
2315
+ /** Owner ID of the conductor agent — excluded from matches (self-exclusion). */
2316
+ conductorOwner: string;
2317
+ }
2318
+ /**
2319
+ * Finds the best agent for each sub-task using registry FTS search and peer scoring.
2320
+ *
2321
+ * For each sub-task:
2322
+ * 1. Searches cards via FTS5 with `{ online: true }` filter
2323
+ * 2. Builds Candidate[] from both v1.0 (card-level pricing) and v2.0 (skill-level pricing) cards
2324
+ * 3. Scores and ranks candidates via scorePeers() with self-exclusion
2325
+ * 4. Selects the top scorer as the primary agent and up to 2 alternatives
2326
+ *
2327
+ * Sub-tasks with no matching cards return a MatchResult with empty selected_agent and score 0.
2328
+ *
2329
+ * @param opts - Match configuration including database, subtasks, and conductor owner ID.
2330
+ * @returns MatchResult[] in the same order as the input subtasks.
2331
+ */
2332
+ declare function matchSubTasks(opts: MatchOptions): MatchResult[];
2333
+
2334
+ /**
2335
+ * Configuration for credit budget enforcement.
2336
+ * Controls how many credits are kept in reserve and unavailable for auto-spending.
2337
+ */
2338
+ interface BudgetConfig {
2339
+ /** Minimum credits to keep in reserve. Auto-requests cannot reduce balance below this floor. Default: 20. */
2340
+ reserve_credits: number;
2341
+ }
2342
+ /**
2343
+ * Enforces credit reserve floors to prevent auto-request from draining balances to zero.
2344
+ *
2345
+ * Phase 7 auto-request MUST call canSpend() before every escrow hold.
2346
+ * Without reserve enforcement, auto-request can drain credits to zero,
2347
+ * isolating the agent from the network.
2348
+ *
2349
+ * @example
2350
+ * ```typescript
2351
+ * const budget = new BudgetManager(creditDb, config.owner, config.budget);
2352
+ * if (!budget.canSpend(card.pricing.credits_per_call)) {
2353
+ * throw new AgentBnBError('Insufficient credits — reserve floor would be breached');
2354
+ * }
2355
+ * ```
2356
+ */
2357
+ declare class BudgetManager {
2358
+ private readonly creditDb;
2359
+ private readonly owner;
2360
+ private readonly config;
2361
+ /**
2362
+ * Creates a new BudgetManager.
2363
+ *
2364
+ * @param creditDb - The credit SQLite database instance.
2365
+ * @param owner - Agent owner identifier.
2366
+ * @param config - Budget configuration. Defaults to DEFAULT_BUDGET_CONFIG (20 credit reserve).
2367
+ */
2368
+ constructor(creditDb: Database.Database, owner: string, config?: BudgetConfig);
2369
+ /**
2370
+ * Returns the number of credits available for spending.
2371
+ * Computed as: max(0, balance - reserve_credits).
2372
+ * Always returns a non-negative number — never goes below zero.
2373
+ *
2374
+ * @returns Available credits (balance minus reserve, floored at 0).
2375
+ */
2376
+ availableCredits(): number;
2377
+ /**
2378
+ * Returns true if spending `amount` credits is permitted by budget rules.
2379
+ *
2380
+ * Rules:
2381
+ * - Zero-cost calls (amount <= 0) always return true.
2382
+ * - Any positive amount requires availableCredits() >= amount.
2383
+ * - If balance is at or below the reserve floor, all positive-cost calls return false.
2384
+ *
2385
+ * @param amount - Number of credits to spend.
2386
+ * @returns true if the spend is allowed, false if it would breach the reserve floor.
2387
+ */
2388
+ canSpend(amount: number): boolean;
2389
+ }
2390
+
2391
+ /**
2392
+ * BudgetController — pre-calculates orchestration cost and enforces spending limits.
2393
+ *
2394
+ * Extends BudgetManager to add orchestration-specific logic: fee calculation,
2395
+ * approval gating when estimated cost exceeds max budget, and per-task spending tracking.
2396
+ */
2397
+
2398
+ /** Credits retained by the Conductor for coordination overhead. */
2399
+ declare const ORCHESTRATION_FEE = 5;
2400
+ /**
2401
+ * Controls budget enforcement for orchestration runs.
2402
+ *
2403
+ * Wraps BudgetManager and adds:
2404
+ * - Pre-calculation of total cost (sub-task credits + orchestration fee)
2405
+ * - Approval gating when estimated total exceeds max budget
2406
+ * - Reserve floor enforcement via BudgetManager.canSpend()
2407
+ *
2408
+ * @example
2409
+ * ```typescript
2410
+ * const controller = new BudgetController(budgetManager, 100);
2411
+ * const budget = controller.calculateBudget(matchResults);
2412
+ * if (controller.canExecute(budget)) {
2413
+ * // proceed with orchestration
2414
+ * }
2415
+ * ```
2416
+ */
2417
+ declare class BudgetController {
2418
+ private readonly budgetManager;
2419
+ private readonly maxBudget;
2420
+ /**
2421
+ * Creates a new BudgetController.
2422
+ *
2423
+ * @param budgetManager - Underlying BudgetManager for reserve floor enforcement.
2424
+ * @param maxBudget - Hard ceiling for the orchestration run.
2425
+ */
2426
+ constructor(budgetManager: BudgetManager, maxBudget: number);
2427
+ /**
2428
+ * Pre-calculates the total budget for an orchestration run.
2429
+ *
2430
+ * Sums all matched sub-task credits, adds the orchestration fee,
2431
+ * and determines whether approval is required (estimated > max).
2432
+ *
2433
+ * @param matches - MatchResult[] from the CapabilityMatcher.
2434
+ * @returns An ExecutionBudget with cost breakdown and approval status.
2435
+ */
2436
+ calculateBudget(matches: MatchResult[]): ExecutionBudget;
2437
+ /**
2438
+ * Checks whether orchestration can proceed without explicit approval.
2439
+ *
2440
+ * Returns true only when:
2441
+ * 1. The budget does NOT require approval (estimated_total <= max_budget)
2442
+ * 2. The BudgetManager confirms sufficient credits (respecting reserve floor)
2443
+ *
2444
+ * @param budget - ExecutionBudget from calculateBudget().
2445
+ * @returns true if execution can proceed autonomously.
2446
+ */
2447
+ canExecute(budget: ExecutionBudget): boolean;
2448
+ /**
2449
+ * Checks budget after explicit user/agent approval.
2450
+ *
2451
+ * Ignores the requires_approval flag — used when the caller has already
2452
+ * obtained explicit approval for the over-budget orchestration.
2453
+ * Still enforces the reserve floor via BudgetManager.canSpend().
2454
+ *
2455
+ * @param budget - ExecutionBudget from calculateBudget().
2456
+ * @returns true if the agent has sufficient credits (reserve floor check only).
2457
+ */
2458
+ approveAndCheck(budget: ExecutionBudget): boolean;
2459
+ }
2460
+
2461
+ /** Fixed owner identifier for the Conductor agent. */
2462
+ declare const CONDUCTOR_OWNER = "agentbnb-conductor";
2463
+ /**
2464
+ * Builds the Conductor's CapabilityCardV2.
2465
+ *
2466
+ * The Conductor exposes two skills:
2467
+ * - `orchestrate` (5 cr): Decomposes and executes multi-agent tasks
2468
+ * - `plan` (1 cr): Returns an execution plan with cost estimate only
2469
+ *
2470
+ * The returned card is validated against CapabilityCardV2Schema before return.
2471
+ *
2472
+ * @returns A valid CapabilityCardV2 for the Conductor.
2473
+ */
2474
+ declare function buildConductorCard(): CapabilityCardV2;
2475
+ /**
2476
+ * Registers the Conductor card in the given SQLite database.
2477
+ *
2478
+ * Idempotent: uses INSERT OR REPLACE to handle repeated calls gracefully.
2479
+ * Stores the v2.0 card as JSON in the same `capability_cards` table used
2480
+ * by the registry, following the same (id, owner, data, created_at, updated_at) schema.
2481
+ *
2482
+ * @param db - Open better-sqlite3 database instance (with migrations applied).
2483
+ * @returns The registered CapabilityCardV2.
2484
+ */
2485
+ declare function registerConductorCard(db: Database.Database): CapabilityCardV2;
2486
+
2487
+ /**
2488
+ * PipelineOrchestrator — DAG-based remote execution engine for the Conductor.
2489
+ *
2490
+ * Executes sub-tasks across remote agents via the Gateway client,
2491
+ * respecting dependency ordering (parallel waves for independent tasks),
2492
+ * output piping between steps, and retry with alternative agents on failure.
2493
+ *
2494
+ * Budget checking is NOT done here — the caller (ConductorMode) handles that.
2495
+ * This module is pure execution.
2496
+ */
2497
+
2498
+ /**
2499
+ * Options for the orchestrate() function.
2500
+ */
2501
+ interface OrchestrateOptions {
2502
+ /** Ordered list of sub-tasks forming a dependency DAG. */
2503
+ subtasks: SubTask[];
2504
+ /** Match results keyed by subtask ID. */
2505
+ matches: Map<string, MatchResult>;
2506
+ /** Bearer token for authenticating with remote agents. */
2507
+ gatewayToken: string;
2508
+ /** Resolves an agent owner to their gateway URL and card ID. */
2509
+ resolveAgentUrl: (agentOwner: string) => {
2510
+ url: string;
2511
+ cardId: string;
2512
+ };
2513
+ /** Per-task timeout in milliseconds. Default 30000. */
2514
+ timeoutMs?: number;
2515
+ /** Maximum budget in credits. If set, aborts remaining tasks when exceeded. */
2516
+ maxBudget?: number;
2517
+ }
2518
+ /**
2519
+ * Executes a DAG of sub-tasks across remote agents via Gateway.
2520
+ *
2521
+ * Execution flow:
2522
+ * 1. Computes execution waves from dependency graph
2523
+ * 2. For each wave, executes all tasks in parallel via Promise.allSettled
2524
+ * 3. Before each task, interpolates params against completed step outputs
2525
+ * 4. On failure, retries with the first alternative agent from MatchResult
2526
+ * 5. Tracks per-task spending and total credits
2527
+ * 6. Optionally enforces a maxBudget ceiling
2528
+ *
2529
+ * @param opts - Orchestration options.
2530
+ * @returns Aggregated orchestration result.
2531
+ */
2532
+ declare function orchestrate(opts: OrchestrateOptions): Promise<OrchestrationResult>;
2533
+
2534
+ /**
2535
+ * ConductorMode — ExecutorMode implementation for Conductor skills.
2536
+ *
2537
+ * Chains TaskDecomposer -> CapabilityMatcher -> BudgetController -> PipelineOrchestrator
2538
+ * to execute multi-agent orchestration pipelines via the SkillExecutor dispatch system.
2539
+ *
2540
+ * Supports two conductor skills:
2541
+ * - `orchestrate`: Full pipeline — decompose, match, budget check, execute, return results.
2542
+ * - `plan`: Planning only — decompose, match, budget check, return plan without executing.
2543
+ */
2544
+
2545
+ /**
2546
+ * Configuration options for ConductorMode.
2547
+ */
2548
+ interface ConductorModeOptions {
2549
+ /** Registry database for card search (FTS5). */
2550
+ db: Database.Database;
2551
+ /** Credit database for budget checks. */
2552
+ creditDb: Database.Database;
2553
+ /** Owner ID of the conductor agent — used for self-exclusion in matching. */
2554
+ conductorOwner: string;
2555
+ /** Bearer token for authenticating with remote agents. */
2556
+ gatewayToken: string;
2557
+ /** Resolves an agent owner to their gateway URL and card ID. */
2558
+ resolveAgentUrl: (owner: string) => {
2559
+ url: string;
2560
+ cardId: string;
2561
+ };
2562
+ /** Maximum budget in credits for orchestration runs. Default 100. */
2563
+ maxBudget?: number;
2564
+ }
2565
+ /**
2566
+ * ExecutorMode implementation for Conductor skills ('orchestrate' and 'plan').
2567
+ *
2568
+ * Dispatches through the full Conductor pipeline:
2569
+ * 1. TaskDecomposer breaks the task into SubTasks
2570
+ * 2. CapabilityMatcher finds agents for each sub-task
2571
+ * 3. BudgetController validates cost against limits
2572
+ * 4. PipelineOrchestrator executes the DAG (orchestrate only)
2573
+ */
2574
+ declare class ConductorMode implements ExecutorMode {
2575
+ private readonly db;
2576
+ private readonly creditDb;
2577
+ private readonly conductorOwner;
2578
+ private readonly gatewayToken;
2579
+ private readonly resolveAgentUrl;
2580
+ private readonly maxBudget;
2581
+ constructor(opts: ConductorModeOptions);
2582
+ /**
2583
+ * Execute a conductor skill with the given config and params.
2584
+ *
2585
+ * @param config - SkillConfig with type 'conductor' and conductor_skill field.
2586
+ * @param params - Must include `task` string.
2587
+ * @returns Execution result without latency_ms (added by SkillExecutor).
2588
+ */
2589
+ execute(config: SkillConfig, params: Record<string, unknown>): Promise<Omit<ExecutionResult, 'latency_ms'>>;
2590
+ }
2591
+
2592
+ /**
2593
+ * Ed25519 keypair as raw DER-encoded Buffers.
2594
+ */
2595
+ interface KeyPair {
2596
+ publicKey: Buffer;
2597
+ privateKey: Buffer;
2598
+ }
2599
+ /**
2600
+ * Generates a new Ed25519 keypair.
2601
+ * Uses Node.js built-in crypto — no external dependencies.
2602
+ *
2603
+ * @returns Object with publicKey and privateKey as DER-encoded Buffers.
2604
+ */
2605
+ declare function generateKeyPair(): KeyPair;
2606
+ /**
2607
+ * Saves an Ed25519 keypair to disk.
2608
+ * Private key is written with mode 0o600 (owner read/write only).
2609
+ *
2610
+ * @param configDir - Directory to write key files into.
2611
+ * @param keys - The keypair to persist.
2612
+ */
2613
+ declare function saveKeyPair(configDir: string, keys: KeyPair): void;
2614
+ /**
2615
+ * Loads an Ed25519 keypair from disk.
2616
+ *
2617
+ * @param configDir - Directory containing private.key and public.key files.
2618
+ * @returns The loaded keypair.
2619
+ * @throws {AgentBnBError} with code 'KEYPAIR_NOT_FOUND' if either key file is missing.
2620
+ */
2621
+ declare function loadKeyPair(configDir: string): KeyPair;
2622
+ /**
2623
+ * Signs escrow receipt data with an Ed25519 private key.
2624
+ * Data is serialized to canonical JSON (sorted keys) before signing.
2625
+ *
2626
+ * @param data - The receipt data to sign (all fields except 'signature').
2627
+ * @param privateKey - DER-encoded Ed25519 private key.
2628
+ * @returns Base64url-encoded signature string.
2629
+ */
2630
+ declare function signEscrowReceipt(data: Record<string, unknown>, privateKey: Buffer): string;
2631
+ /**
2632
+ * Verifies an Ed25519 signature over escrow receipt data.
2633
+ * Returns false (does not throw) for invalid signatures or wrong keys.
2634
+ *
2635
+ * @param data - The receipt data that was signed (all fields except 'signature').
2636
+ * @param signature - Base64url-encoded signature string.
2637
+ * @param publicKey - DER-encoded Ed25519 public key.
2638
+ * @returns true if signature is valid, false otherwise.
2639
+ */
2640
+ declare function verifyEscrowReceipt(data: Record<string, unknown>, signature: string, publicKey: Buffer): boolean;
2641
+
2642
+ /**
2643
+ * Zod schema for validating EscrowReceipt objects.
2644
+ * Used by providers to validate incoming receipts before verification.
2645
+ */
2646
+ declare const EscrowReceiptSchema: z.ZodObject<{
2647
+ requester_owner: z.ZodString;
2648
+ requester_public_key: z.ZodString;
2649
+ amount: z.ZodNumber;
2650
+ card_id: z.ZodString;
2651
+ skill_id: z.ZodOptional<z.ZodString>;
2652
+ timestamp: z.ZodString;
2653
+ nonce: z.ZodString;
2654
+ signature: z.ZodString;
2655
+ }, "strip", z.ZodTypeAny, {
2656
+ signature: string;
2657
+ requester_owner: string;
2658
+ requester_public_key: string;
2659
+ amount: number;
2660
+ card_id: string;
2661
+ timestamp: string;
2662
+ nonce: string;
2663
+ skill_id?: string | undefined;
2664
+ }, {
2665
+ signature: string;
2666
+ requester_owner: string;
2667
+ requester_public_key: string;
2668
+ amount: number;
2669
+ card_id: string;
2670
+ timestamp: string;
2671
+ nonce: string;
2672
+ skill_id?: string | undefined;
2673
+ }>;
2674
+ /**
2675
+ * Options for creating a signed escrow receipt.
2676
+ */
2677
+ interface CreateReceiptOpts {
2678
+ /** Agent owner identifier (requester). */
2679
+ owner: string;
2680
+ /** Number of credits to commit. */
2681
+ amount: number;
2682
+ /** Capability Card ID being requested. */
2683
+ cardId: string;
2684
+ /** Optional skill ID within the card. */
2685
+ skillId?: string;
2686
+ }
2687
+ /**
2688
+ * Creates a signed escrow receipt by atomically holding credits in the local DB
2689
+ * and producing a cryptographically signed receipt that can be sent to a provider.
2690
+ *
2691
+ * This combines local escrow hold + receipt generation from the requester's perspective.
2692
+ *
2693
+ * @param db - The credit database instance.
2694
+ * @param privateKey - DER-encoded Ed25519 private key for signing.
2695
+ * @param publicKey - DER-encoded Ed25519 public key (included in receipt for verification).
2696
+ * @param opts - Receipt creation options (owner, amount, cardId, skillId).
2697
+ * @returns Object with escrowId (local reference) and signed receipt (for transmission).
2698
+ * @throws {AgentBnBError} with code 'INSUFFICIENT_CREDITS' if balance is too low.
2699
+ */
2700
+ declare function createSignedEscrowReceipt(db: Database.Database, privateKey: Buffer, publicKey: Buffer, opts: CreateReceiptOpts): {
2701
+ escrowId: string;
2702
+ receipt: EscrowReceipt;
2703
+ };
2704
+
2705
+ /**
2706
+ * Provider-side settlement: records earnings from a signed escrow receipt.
2707
+ * The provider calls this after successfully executing a capability.
2708
+ * Credits are recorded in the provider's own local DB.
2709
+ *
2710
+ * @param providerDb - The provider's local credit database.
2711
+ * @param providerOwner - Provider agent identifier.
2712
+ * @param receipt - The signed escrow receipt from the requester.
2713
+ * @returns Object indicating settlement success.
2714
+ */
2715
+ declare function settleProviderEarning(providerDb: Database.Database, providerOwner: string, receipt: EscrowReceipt): {
2716
+ settled: true;
2717
+ };
2718
+ /**
2719
+ * Requester-side settlement: confirms that the escrow debit is permanent.
2720
+ * Called after the requester receives confirmation that the provider
2721
+ * successfully executed the capability. Marks escrow as 'settled' without
2722
+ * crediting anyone (credits stay deducted from requester).
2723
+ *
2724
+ * @param requesterDb - The requester's local credit database.
2725
+ * @param escrowId - The escrow ID to confirm as settled.
2726
+ */
2727
+ declare function settleRequesterEscrow(requesterDb: Database.Database, escrowId: string): void;
2728
+ /**
2729
+ * Requester-side failure handling: releases escrowed credits (refund).
2730
+ * Called when the capability execution fails and the requester needs
2731
+ * their credits back.
2732
+ *
2733
+ * @param requesterDb - The requester's local credit database.
2734
+ * @param escrowId - The escrow ID to release.
2735
+ */
2736
+ declare function releaseRequesterEscrow(requesterDb: Database.Database, escrowId: string): void;
2737
+
2738
+ /**
2739
+ * Agent Identity — the unified identity record for an AgentBnB agent.
2740
+ * Stored at ~/.agentbnb/identity.json.
2741
+ */
2742
+ declare const AgentIdentitySchema: z.ZodObject<{
2743
+ /** Deterministic ID derived from public key: sha256(hex).slice(0, 16). */
2744
+ agent_id: z.ZodString;
2745
+ /** Human-readable owner name (from config or init). */
2746
+ owner: z.ZodString;
2747
+ /** Hex-encoded Ed25519 public key. */
2748
+ public_key: z.ZodString;
2749
+ /** ISO 8601 timestamp of identity creation. */
2750
+ created_at: z.ZodString;
2751
+ /** Optional guarantor info if linked to a human. */
2752
+ guarantor: z.ZodOptional<z.ZodObject<{
2753
+ github_login: z.ZodString;
2754
+ verified_at: z.ZodString;
2755
+ }, "strip", z.ZodTypeAny, {
2756
+ github_login: string;
2757
+ verified_at: string;
2758
+ }, {
2759
+ github_login: string;
2760
+ verified_at: string;
2761
+ }>>;
2762
+ }, "strip", z.ZodTypeAny, {
2763
+ owner: string;
2764
+ created_at: string;
2765
+ agent_id: string;
2766
+ public_key: string;
2767
+ guarantor?: {
2768
+ github_login: string;
2769
+ verified_at: string;
2770
+ } | undefined;
2771
+ }, {
2772
+ owner: string;
2773
+ created_at: string;
2774
+ agent_id: string;
2775
+ public_key: string;
2776
+ guarantor?: {
2777
+ github_login: string;
2778
+ verified_at: string;
2779
+ } | undefined;
2780
+ }>;
2781
+ type AgentIdentity = z.infer<typeof AgentIdentitySchema>;
2782
+ /**
2783
+ * Agent Certificate — a self-signed attestation of agent identity.
2784
+ * Used for P2P identity verification without a shared auth server.
2785
+ */
2786
+ declare const AgentCertificateSchema: z.ZodObject<{
2787
+ identity: z.ZodObject<{
2788
+ /** Deterministic ID derived from public key: sha256(hex).slice(0, 16). */
2789
+ agent_id: z.ZodString;
2790
+ /** Human-readable owner name (from config or init). */
2791
+ owner: z.ZodString;
2792
+ /** Hex-encoded Ed25519 public key. */
2793
+ public_key: z.ZodString;
2794
+ /** ISO 8601 timestamp of identity creation. */
2795
+ created_at: z.ZodString;
2796
+ /** Optional guarantor info if linked to a human. */
2797
+ guarantor: z.ZodOptional<z.ZodObject<{
2798
+ github_login: z.ZodString;
2799
+ verified_at: z.ZodString;
2800
+ }, "strip", z.ZodTypeAny, {
2801
+ github_login: string;
2802
+ verified_at: string;
2803
+ }, {
2804
+ github_login: string;
2805
+ verified_at: string;
2806
+ }>>;
2807
+ }, "strip", z.ZodTypeAny, {
2808
+ owner: string;
2809
+ created_at: string;
2810
+ agent_id: string;
2811
+ public_key: string;
2812
+ guarantor?: {
2813
+ github_login: string;
2814
+ verified_at: string;
2815
+ } | undefined;
2816
+ }, {
2817
+ owner: string;
2818
+ created_at: string;
2819
+ agent_id: string;
2820
+ public_key: string;
2821
+ guarantor?: {
2822
+ github_login: string;
2823
+ verified_at: string;
2824
+ } | undefined;
2825
+ }>;
2826
+ /** ISO 8601 timestamp of certificate issuance. */
2827
+ issued_at: z.ZodString;
2828
+ /** ISO 8601 timestamp of certificate expiry. */
2829
+ expires_at: z.ZodString;
2830
+ /** Hex-encoded public key of the issuer (same as identity for self-signed). */
2831
+ issuer_public_key: z.ZodString;
2832
+ /** Base64url Ed25519 signature over { identity, issued_at, expires_at, issuer_public_key }. */
2833
+ signature: z.ZodString;
2834
+ }, "strip", z.ZodTypeAny, {
2835
+ signature: string;
2836
+ identity: {
2837
+ owner: string;
2838
+ created_at: string;
2839
+ agent_id: string;
2840
+ public_key: string;
2841
+ guarantor?: {
2842
+ github_login: string;
2843
+ verified_at: string;
2844
+ } | undefined;
2845
+ };
2846
+ issued_at: string;
2847
+ expires_at: string;
2848
+ issuer_public_key: string;
2849
+ }, {
2850
+ signature: string;
2851
+ identity: {
2852
+ owner: string;
2853
+ created_at: string;
2854
+ agent_id: string;
2855
+ public_key: string;
2856
+ guarantor?: {
2857
+ github_login: string;
2858
+ verified_at: string;
2859
+ } | undefined;
2860
+ };
2861
+ issued_at: string;
2862
+ expires_at: string;
2863
+ issuer_public_key: string;
2864
+ }>;
2865
+ type AgentCertificate = z.infer<typeof AgentCertificateSchema>;
2866
+ /**
2867
+ * Derives a deterministic agent_id from a hex-encoded public key.
2868
+ * Uses first 16 chars of SHA-256 hash.
2869
+ */
2870
+ declare function deriveAgentId(publicKeyHex: string): string;
2871
+ /**
2872
+ * Creates a new agent identity. Generates an Ed25519 keypair if one does not
2873
+ * already exist. Writes identity.json to the config directory.
2874
+ *
2875
+ * @param configDir - Directory to write identity.json into (e.g. ~/.agentbnb).
2876
+ * @param owner - Human-readable agent owner name.
2877
+ * @returns The newly created AgentIdentity.
2878
+ */
2879
+ declare function createIdentity(configDir: string, owner: string): AgentIdentity;
2880
+ /**
2881
+ * Loads an existing agent identity from disk.
2882
+ *
2883
+ * @param configDir - Directory containing identity.json.
2884
+ * @returns Parsed AgentIdentity or null if file does not exist.
2885
+ */
2886
+ declare function loadIdentity(configDir: string): AgentIdentity | null;
2887
+ /**
2888
+ * Persists an agent identity to disk.
2889
+ *
2890
+ * @param configDir - Directory to write identity.json into.
2891
+ * @param identity - The identity to save.
2892
+ */
2893
+ declare function saveIdentity(configDir: string, identity: AgentIdentity): void;
2894
+ /**
2895
+ * Issues a self-signed Agent Certificate. Valid for 365 days.
2896
+ *
2897
+ * @param identity - The agent identity to certify.
2898
+ * @param privateKey - DER-encoded Ed25519 private key.
2899
+ * @returns A signed AgentCertificate.
2900
+ */
2901
+ declare function issueAgentCertificate(identity: AgentIdentity, privateKey: Buffer): AgentCertificate;
2902
+ /**
2903
+ * Verifies an Agent Certificate's signature and expiry.
2904
+ *
2905
+ * @param cert - The certificate to verify.
2906
+ * @returns true if signature is valid and certificate has not expired.
2907
+ */
2908
+ declare function verifyAgentCertificate(cert: AgentCertificate): boolean;
2909
+ /**
2910
+ * Ensures an identity exists for the given config directory.
2911
+ * If identity.json already exists, returns it. Otherwise creates a new one.
2912
+ *
2913
+ * @param configDir - Config directory path.
2914
+ * @param owner - Owner name to use if creating new identity.
2915
+ * @returns The loaded or newly created AgentIdentity.
2916
+ */
2917
+ declare function ensureIdentity(configDir: string, owner: string): AgentIdentity;
2918
+
2919
+ /**
2920
+ * Options for constructing an AgentBnBConsumer.
2921
+ */
2922
+ interface ConsumerOptions {
2923
+ /** Override the config directory (default: ~/.agentbnb or AGENTBNB_DIR). */
2924
+ configDir?: string;
2925
+ }
2926
+ /**
2927
+ * Options for requesting a capability.
2928
+ */
2929
+ interface ConsumerRequestOptions {
2930
+ /** Gateway URL of the target agent. */
2931
+ gatewayUrl: string;
2932
+ /** Bearer token for the target agent's gateway. */
2933
+ token: string;
2934
+ /** Capability Card ID to execute. */
2935
+ cardId: string;
2936
+ /** Optional skill ID within the card. */
2937
+ skillId?: string;
2938
+ /** Input parameters for the capability. */
2939
+ params?: Record<string, unknown>;
2940
+ /** Credit amount to commit (escrow). */
2941
+ credits: number;
2942
+ /** Timeout in milliseconds. Default 30000. */
2943
+ timeoutMs?: number;
2944
+ }
2945
+ /**
2946
+ * AgentBnBConsumer — high-level SDK class for agents consuming capabilities.
2947
+ *
2948
+ * Encapsulates the full request lifecycle: identity loading, escrow creation,
2949
+ * capability request, and settlement/release.
2950
+ *
2951
+ * @example
2952
+ * ```typescript
2953
+ * const consumer = new AgentBnBConsumer();
2954
+ * consumer.authenticate();
2955
+ * const result = await consumer.request({
2956
+ * gatewayUrl: 'http://peer:7700',
2957
+ * token: 'peer-token',
2958
+ * cardId: 'uuid-of-card',
2959
+ * credits: 5,
2960
+ * });
2961
+ * ```
2962
+ */
2963
+ declare class AgentBnBConsumer {
2964
+ private configDir;
2965
+ private identity;
2966
+ private keys;
2967
+ private creditDb;
2968
+ constructor(opts?: ConsumerOptions);
2969
+ /**
2970
+ * Loads agent identity and keypair from disk.
2971
+ * Creates identity if none exists (uses owner from config.json or generates one).
2972
+ *
2973
+ * @returns The loaded AgentIdentity.
2974
+ * @throws {AgentBnBError} if keypair is missing and cannot be created.
2975
+ */
2976
+ authenticate(): AgentIdentity;
2977
+ /**
2978
+ * Returns the cached identity. Throws if not yet authenticated.
2979
+ */
2980
+ getIdentity(): AgentIdentity;
2981
+ /**
2982
+ * Requests a capability from a remote agent with full escrow lifecycle.
2983
+ *
2984
+ * 1. Creates a signed escrow receipt (holds credits locally)
2985
+ * 2. Sends the request to the target gateway
2986
+ * 3. Settles escrow on success, releases on failure
2987
+ *
2988
+ * @param opts - Request options including target, card, credits, and params.
2989
+ * @returns The result from the capability execution.
2990
+ * @throws {AgentBnBError} on insufficient credits, network error, or RPC error.
2991
+ */
2992
+ request(opts: ConsumerRequestOptions): Promise<unknown>;
2993
+ /**
2994
+ * Returns the current credit balance for this agent.
2995
+ */
2996
+ getBalance(): number;
2997
+ /**
2998
+ * Returns basic reputation data from the local credit database.
2999
+ * Note: success_rate is computed from local request history only.
3000
+ */
3001
+ getReputation(): {
3002
+ success_rate: number;
3003
+ total_requests: number;
3004
+ };
3005
+ /**
3006
+ * Closes the credit database connection. Call when done.
3007
+ */
3008
+ close(): void;
3009
+ /** Lazily opens and caches the credit database. */
3010
+ private getCreditDb;
3011
+ }
3012
+
3013
+ /**
3014
+ * Options for constructing an AgentBnBProvider.
3015
+ */
3016
+ interface ProviderOptions {
3017
+ /** Override the config directory (default: ~/.agentbnb or AGENTBNB_DIR). */
3018
+ configDir?: string;
3019
+ }
3020
+ /**
3021
+ * Options for starting the sharing gateway.
3022
+ */
3023
+ interface StartSharingOptions {
3024
+ /** Port to listen on (default: from config or 7700). */
3025
+ port?: number;
3026
+ /** Host to bind to (default: '0.0.0.0'). */
3027
+ host?: string;
3028
+ }
3029
+ /**
3030
+ * Context returned after sharing starts.
3031
+ */
3032
+ interface SharingContext {
3033
+ /** The Fastify gateway server instance. */
3034
+ gateway: FastifyInstance;
3035
+ /** Port the gateway is listening on. */
3036
+ port: number;
3037
+ }
3038
+ /**
3039
+ * AgentBnBProvider — high-level SDK class for agents providing capabilities.
3040
+ *
3041
+ * Manages identity, gateway lifecycle, and capability listing.
3042
+ *
3043
+ * @example
3044
+ * ```typescript
3045
+ * const provider = new AgentBnBProvider();
3046
+ * provider.authenticate();
3047
+ * const ctx = await provider.startSharing({ port: 7700 });
3048
+ * console.log(provider.listCapabilities());
3049
+ * await provider.stopSharing();
3050
+ * ```
3051
+ */
3052
+ declare class AgentBnBProvider {
3053
+ private configDir;
3054
+ private identity;
3055
+ private registryDb;
3056
+ private creditDb;
3057
+ private gateway;
3058
+ constructor(opts?: ProviderOptions);
3059
+ /**
3060
+ * Loads agent identity from disk.
3061
+ * Creates identity if none exists.
3062
+ *
3063
+ * @returns The loaded AgentIdentity.
3064
+ */
3065
+ authenticate(): AgentIdentity;
3066
+ /**
3067
+ * Returns the cached identity. Throws if not yet authenticated.
3068
+ */
3069
+ getIdentity(): AgentIdentity;
3070
+ /**
3071
+ * Starts the gateway server to share capabilities.
3072
+ *
3073
+ * @param opts - Optional port and host configuration.
3074
+ * @returns Context with the gateway server and port.
3075
+ */
3076
+ startSharing(opts?: StartSharingOptions): Promise<SharingContext>;
3077
+ /**
3078
+ * Stops the gateway server.
3079
+ */
3080
+ stopSharing(): Promise<void>;
3081
+ /**
3082
+ * Returns all capability cards owned by this agent.
3083
+ */
3084
+ listCapabilities(): CapabilityCard[];
3085
+ /**
3086
+ * Returns the current credit balance for this agent.
3087
+ */
3088
+ getBalance(): number;
3089
+ /**
3090
+ * Closes all database connections and stops the gateway. Call when done.
3091
+ */
3092
+ close(): Promise<void>;
3093
+ /** Lazily opens and caches the registry database. */
3094
+ private getRegistryDb;
3095
+ /** Lazily opens and caches the credit database. */
3096
+ private getCreditDb;
3097
+ }
3098
+
3099
+ /** Maximum agents a single human guarantor can back. */
3100
+ declare const MAX_AGENTS_PER_GUARANTOR = 10;
3101
+ /** Free credits granted per human guarantor registration. */
3102
+ declare const GUARANTOR_CREDIT_POOL = 50;
3103
+ /**
3104
+ * A Human Guarantor — a real person backing one or more agents.
3105
+ * Provides initial trust and credit pool for the agent network.
3106
+ */
3107
+ declare const GuarantorRecordSchema: z.ZodObject<{
3108
+ id: z.ZodString;
3109
+ github_login: z.ZodString;
3110
+ agent_count: z.ZodNumber;
3111
+ credit_pool: z.ZodNumber;
3112
+ created_at: z.ZodString;
3113
+ }, "strip", z.ZodTypeAny, {
3114
+ id: string;
3115
+ created_at: string;
3116
+ github_login: string;
3117
+ agent_count: number;
3118
+ credit_pool: number;
3119
+ }, {
3120
+ id: string;
3121
+ created_at: string;
3122
+ github_login: string;
3123
+ agent_count: number;
3124
+ credit_pool: number;
3125
+ }>;
3126
+ type GuarantorRecord = z.infer<typeof GuarantorRecordSchema>;
3127
+ /**
3128
+ * Registers a new human guarantor via GitHub login.
3129
+ * Grants GUARANTOR_CREDIT_POOL (50) credits to be distributed among linked agents.
3130
+ *
3131
+ * @param db - The credit database instance.
3132
+ * @param githubLogin - GitHub username of the guarantor.
3133
+ * @returns The created GuarantorRecord.
3134
+ * @throws {AgentBnBError} with code 'GUARANTOR_EXISTS' if login already registered.
3135
+ */
3136
+ declare function registerGuarantor(db: Database.Database, githubLogin: string): GuarantorRecord;
3137
+ /**
3138
+ * Links an agent to a human guarantor.
3139
+ * Enforces the MAX_AGENTS_PER_GUARANTOR limit (10).
3140
+ *
3141
+ * @param db - The credit database instance.
3142
+ * @param agentId - The agent_id to link.
3143
+ * @param githubLogin - The guarantor's GitHub login.
3144
+ * @returns Updated GuarantorRecord.
3145
+ * @throws {AgentBnBError} with code 'GUARANTOR_NOT_FOUND' if login not registered.
3146
+ * @throws {AgentBnBError} with code 'MAX_AGENTS_EXCEEDED' if limit reached.
3147
+ * @throws {AgentBnBError} with code 'AGENT_ALREADY_LINKED' if agent already has a guarantor.
3148
+ */
3149
+ declare function linkAgentToGuarantor(db: Database.Database, agentId: string, githubLogin: string): GuarantorRecord;
3150
+ /**
3151
+ * Retrieves a guarantor record by GitHub login.
3152
+ *
3153
+ * @param db - The credit database instance.
3154
+ * @param githubLogin - The GitHub username to look up.
3155
+ * @returns GuarantorRecord or null if not found.
3156
+ */
3157
+ declare function getGuarantor(db: Database.Database, githubLogin: string): GuarantorRecord | null;
3158
+ /**
3159
+ * Gets the guarantor linked to an agent, if any.
3160
+ *
3161
+ * @param db - The credit database instance.
3162
+ * @param agentId - The agent_id to look up.
3163
+ * @returns GuarantorRecord or null if agent has no guarantor.
3164
+ */
3165
+ declare function getAgentGuarantor(db: Database.Database, agentId: string): GuarantorRecord | null;
3166
+ /**
3167
+ * Initiates a GitHub OAuth flow for guarantor verification.
3168
+ * This is a STUB — returns placeholder values. Actual OAuth implementation
3169
+ * is deferred to a future version.
3170
+ *
3171
+ * @returns Object with auth_url and state for the OAuth flow.
3172
+ */
3173
+ declare function initiateGithubAuth(): {
3174
+ auth_url: string;
3175
+ state: string;
3176
+ };
3177
+
3178
+ /**
3179
+ * WebSocket relay message types for agent-to-registry communication.
3180
+ * All messages are JSON-encoded with a discriminating `type` field.
3181
+ */
3182
+ /** Agent → Registry: Register agent and card on connect */
3183
+ declare const RegisterMessageSchema: z.ZodObject<{
3184
+ type: z.ZodLiteral<"register">;
3185
+ owner: z.ZodString;
3186
+ token: z.ZodString;
3187
+ card: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3188
+ }, "strip", z.ZodTypeAny, {
3189
+ type: "register";
3190
+ owner: string;
3191
+ token: string;
3192
+ card: Record<string, unknown>;
3193
+ }, {
3194
+ type: "register";
3195
+ owner: string;
3196
+ token: string;
3197
+ card: Record<string, unknown>;
3198
+ }>;
3199
+ /** Registry → Agent: Acknowledge registration */
3200
+ declare const RegisteredMessageSchema: z.ZodObject<{
3201
+ type: z.ZodLiteral<"registered">;
3202
+ agent_id: z.ZodString;
3203
+ }, "strip", z.ZodTypeAny, {
3204
+ type: "registered";
3205
+ agent_id: string;
3206
+ }, {
3207
+ type: "registered";
3208
+ agent_id: string;
3209
+ }>;
3210
+ /** Agent A → Registry: Request relay to another agent */
3211
+ declare const RelayRequestMessageSchema: z.ZodObject<{
3212
+ type: z.ZodLiteral<"relay_request">;
3213
+ id: z.ZodString;
3214
+ target_owner: z.ZodString;
3215
+ card_id: z.ZodString;
3216
+ skill_id: z.ZodOptional<z.ZodString>;
3217
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3218
+ requester: z.ZodOptional<z.ZodString>;
3219
+ escrow_receipt: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3220
+ }, "strip", z.ZodTypeAny, {
3221
+ type: "relay_request";
3222
+ params: Record<string, unknown>;
3223
+ id: string;
3224
+ card_id: string;
3225
+ target_owner: string;
3226
+ skill_id?: string | undefined;
3227
+ requester?: string | undefined;
3228
+ escrow_receipt?: Record<string, unknown> | undefined;
3229
+ }, {
3230
+ type: "relay_request";
3231
+ id: string;
3232
+ card_id: string;
3233
+ target_owner: string;
3234
+ params?: Record<string, unknown> | undefined;
3235
+ skill_id?: string | undefined;
3236
+ requester?: string | undefined;
3237
+ escrow_receipt?: Record<string, unknown> | undefined;
3238
+ }>;
3239
+ /** Registry → Agent B: Incoming request forwarded from Agent A */
3240
+ declare const IncomingRequestMessageSchema: z.ZodObject<{
3241
+ type: z.ZodLiteral<"incoming_request">;
3242
+ id: z.ZodString;
3243
+ from_owner: z.ZodString;
3244
+ card_id: z.ZodString;
3245
+ skill_id: z.ZodOptional<z.ZodString>;
3246
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3247
+ requester: z.ZodOptional<z.ZodString>;
3248
+ escrow_receipt: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3249
+ }, "strip", z.ZodTypeAny, {
3250
+ type: "incoming_request";
3251
+ params: Record<string, unknown>;
3252
+ id: string;
3253
+ card_id: string;
3254
+ from_owner: string;
3255
+ skill_id?: string | undefined;
3256
+ requester?: string | undefined;
3257
+ escrow_receipt?: Record<string, unknown> | undefined;
3258
+ }, {
3259
+ type: "incoming_request";
3260
+ id: string;
3261
+ card_id: string;
3262
+ from_owner: string;
3263
+ params?: Record<string, unknown> | undefined;
3264
+ skill_id?: string | undefined;
3265
+ requester?: string | undefined;
3266
+ escrow_receipt?: Record<string, unknown> | undefined;
3267
+ }>;
3268
+ /** Agent B → Registry: Response to a relayed request */
3269
+ declare const RelayResponseMessageSchema: z.ZodObject<{
3270
+ type: z.ZodLiteral<"relay_response">;
3271
+ id: z.ZodString;
3272
+ result: z.ZodOptional<z.ZodUnknown>;
3273
+ error: z.ZodOptional<z.ZodObject<{
3274
+ code: z.ZodNumber;
3275
+ message: z.ZodString;
3276
+ }, "strip", z.ZodTypeAny, {
3277
+ code: number;
3278
+ message: string;
3279
+ }, {
3280
+ code: number;
3281
+ message: string;
3282
+ }>>;
3283
+ }, "strip", z.ZodTypeAny, {
3284
+ type: "relay_response";
3285
+ id: string;
3286
+ result?: unknown;
3287
+ error?: {
3288
+ code: number;
3289
+ message: string;
3290
+ } | undefined;
3291
+ }, {
3292
+ type: "relay_response";
3293
+ id: string;
3294
+ result?: unknown;
3295
+ error?: {
3296
+ code: number;
3297
+ message: string;
3298
+ } | undefined;
3299
+ }>;
3300
+ /** Registry → Agent A: Forwarded response from Agent B */
3301
+ declare const ResponseMessageSchema: z.ZodObject<{
3302
+ type: z.ZodLiteral<"response">;
3303
+ id: z.ZodString;
3304
+ result: z.ZodOptional<z.ZodUnknown>;
3305
+ error: z.ZodOptional<z.ZodObject<{
3306
+ code: z.ZodNumber;
3307
+ message: z.ZodString;
3308
+ }, "strip", z.ZodTypeAny, {
3309
+ code: number;
3310
+ message: string;
3311
+ }, {
3312
+ code: number;
3313
+ message: string;
3314
+ }>>;
3315
+ }, "strip", z.ZodTypeAny, {
3316
+ type: "response";
3317
+ id: string;
3318
+ result?: unknown;
3319
+ error?: {
3320
+ code: number;
3321
+ message: string;
3322
+ } | undefined;
3323
+ }, {
3324
+ type: "response";
3325
+ id: string;
3326
+ result?: unknown;
3327
+ error?: {
3328
+ code: number;
3329
+ message: string;
3330
+ } | undefined;
3331
+ }>;
3332
+ /** Error message (either direction) */
3333
+ declare const ErrorMessageSchema: z.ZodObject<{
3334
+ type: z.ZodLiteral<"error">;
3335
+ code: z.ZodString;
3336
+ message: z.ZodString;
3337
+ request_id: z.ZodOptional<z.ZodString>;
3338
+ }, "strip", z.ZodTypeAny, {
3339
+ type: "error";
3340
+ code: string;
3341
+ message: string;
3342
+ request_id?: string | undefined;
3343
+ }, {
3344
+ type: "error";
3345
+ code: string;
3346
+ message: string;
3347
+ request_id?: string | undefined;
3348
+ }>;
3349
+ /** Discriminated union of all relay messages */
3350
+ declare const RelayMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
3351
+ type: z.ZodLiteral<"register">;
3352
+ owner: z.ZodString;
3353
+ token: z.ZodString;
3354
+ card: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3355
+ }, "strip", z.ZodTypeAny, {
3356
+ type: "register";
3357
+ owner: string;
3358
+ token: string;
3359
+ card: Record<string, unknown>;
3360
+ }, {
3361
+ type: "register";
3362
+ owner: string;
3363
+ token: string;
3364
+ card: Record<string, unknown>;
3365
+ }>, z.ZodObject<{
3366
+ type: z.ZodLiteral<"registered">;
3367
+ agent_id: z.ZodString;
3368
+ }, "strip", z.ZodTypeAny, {
3369
+ type: "registered";
3370
+ agent_id: string;
3371
+ }, {
3372
+ type: "registered";
3373
+ agent_id: string;
3374
+ }>, z.ZodObject<{
3375
+ type: z.ZodLiteral<"relay_request">;
3376
+ id: z.ZodString;
3377
+ target_owner: z.ZodString;
3378
+ card_id: z.ZodString;
3379
+ skill_id: z.ZodOptional<z.ZodString>;
3380
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3381
+ requester: z.ZodOptional<z.ZodString>;
3382
+ escrow_receipt: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3383
+ }, "strip", z.ZodTypeAny, {
3384
+ type: "relay_request";
3385
+ params: Record<string, unknown>;
3386
+ id: string;
3387
+ card_id: string;
3388
+ target_owner: string;
3389
+ skill_id?: string | undefined;
3390
+ requester?: string | undefined;
3391
+ escrow_receipt?: Record<string, unknown> | undefined;
3392
+ }, {
3393
+ type: "relay_request";
3394
+ id: string;
3395
+ card_id: string;
3396
+ target_owner: string;
3397
+ params?: Record<string, unknown> | undefined;
3398
+ skill_id?: string | undefined;
3399
+ requester?: string | undefined;
3400
+ escrow_receipt?: Record<string, unknown> | undefined;
3401
+ }>, z.ZodObject<{
3402
+ type: z.ZodLiteral<"incoming_request">;
3403
+ id: z.ZodString;
3404
+ from_owner: z.ZodString;
3405
+ card_id: z.ZodString;
3406
+ skill_id: z.ZodOptional<z.ZodString>;
3407
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3408
+ requester: z.ZodOptional<z.ZodString>;
3409
+ escrow_receipt: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3410
+ }, "strip", z.ZodTypeAny, {
3411
+ type: "incoming_request";
3412
+ params: Record<string, unknown>;
3413
+ id: string;
3414
+ card_id: string;
3415
+ from_owner: string;
3416
+ skill_id?: string | undefined;
3417
+ requester?: string | undefined;
3418
+ escrow_receipt?: Record<string, unknown> | undefined;
3419
+ }, {
3420
+ type: "incoming_request";
3421
+ id: string;
3422
+ card_id: string;
3423
+ from_owner: string;
3424
+ params?: Record<string, unknown> | undefined;
3425
+ skill_id?: string | undefined;
3426
+ requester?: string | undefined;
3427
+ escrow_receipt?: Record<string, unknown> | undefined;
3428
+ }>, z.ZodObject<{
3429
+ type: z.ZodLiteral<"relay_response">;
3430
+ id: z.ZodString;
3431
+ result: z.ZodOptional<z.ZodUnknown>;
3432
+ error: z.ZodOptional<z.ZodObject<{
3433
+ code: z.ZodNumber;
3434
+ message: z.ZodString;
3435
+ }, "strip", z.ZodTypeAny, {
3436
+ code: number;
3437
+ message: string;
3438
+ }, {
3439
+ code: number;
3440
+ message: string;
3441
+ }>>;
3442
+ }, "strip", z.ZodTypeAny, {
3443
+ type: "relay_response";
3444
+ id: string;
3445
+ result?: unknown;
3446
+ error?: {
3447
+ code: number;
3448
+ message: string;
3449
+ } | undefined;
3450
+ }, {
3451
+ type: "relay_response";
3452
+ id: string;
3453
+ result?: unknown;
3454
+ error?: {
3455
+ code: number;
3456
+ message: string;
3457
+ } | undefined;
3458
+ }>, z.ZodObject<{
3459
+ type: z.ZodLiteral<"response">;
3460
+ id: z.ZodString;
3461
+ result: z.ZodOptional<z.ZodUnknown>;
3462
+ error: z.ZodOptional<z.ZodObject<{
3463
+ code: z.ZodNumber;
3464
+ message: z.ZodString;
3465
+ }, "strip", z.ZodTypeAny, {
3466
+ code: number;
3467
+ message: string;
3468
+ }, {
3469
+ code: number;
3470
+ message: string;
3471
+ }>>;
3472
+ }, "strip", z.ZodTypeAny, {
3473
+ type: "response";
3474
+ id: string;
3475
+ result?: unknown;
3476
+ error?: {
3477
+ code: number;
3478
+ message: string;
3479
+ } | undefined;
3480
+ }, {
3481
+ type: "response";
3482
+ id: string;
3483
+ result?: unknown;
3484
+ error?: {
3485
+ code: number;
3486
+ message: string;
3487
+ } | undefined;
3488
+ }>, z.ZodObject<{
3489
+ type: z.ZodLiteral<"error">;
3490
+ code: z.ZodString;
3491
+ message: z.ZodString;
3492
+ request_id: z.ZodOptional<z.ZodString>;
3493
+ }, "strip", z.ZodTypeAny, {
3494
+ type: "error";
3495
+ code: string;
3496
+ message: string;
3497
+ request_id?: string | undefined;
3498
+ }, {
3499
+ type: "error";
3500
+ code: string;
3501
+ message: string;
3502
+ request_id?: string | undefined;
3503
+ }>]>;
3504
+ type RegisterMessage = z.infer<typeof RegisterMessageSchema>;
3505
+ type RegisteredMessage = z.infer<typeof RegisteredMessageSchema>;
3506
+ type RelayRequestMessage = z.infer<typeof RelayRequestMessageSchema>;
3507
+ type IncomingRequestMessage = z.infer<typeof IncomingRequestMessageSchema>;
3508
+ type RelayResponseMessage = z.infer<typeof RelayResponseMessageSchema>;
3509
+ type ResponseMessage = z.infer<typeof ResponseMessageSchema>;
3510
+ type ErrorMessage = z.infer<typeof ErrorMessageSchema>;
3511
+ type RelayMessage = z.infer<typeof RelayMessageSchema>;
3512
+ /** Relay server state returned from registerWebSocketRelay */
3513
+ interface RelayState {
3514
+ /** Number of currently connected agents */
3515
+ getOnlineCount(): number;
3516
+ /** List of connected agent owners */
3517
+ getOnlineOwners(): string[];
3518
+ /** Graceful shutdown — close all connections */
3519
+ shutdown(): void;
3520
+ }
3521
+
3522
+ /**
3523
+ * Registers WebSocket relay on an existing Fastify instance.
3524
+ * Adds a `/ws` route that upgrades HTTP to WebSocket for agent relay.
3525
+ *
3526
+ * @param server - Fastify instance with @fastify/websocket already registered.
3527
+ * @param db - Registry database instance.
3528
+ * @returns RelayState for monitoring and graceful shutdown.
3529
+ */
3530
+ declare function registerWebSocketRelay(server: FastifyInstance, db: Database.Database): RelayState;
3531
+
3532
+ /** Result of handling an incoming relay request */
3533
+ interface RelayHandlerResult {
3534
+ result?: unknown;
3535
+ error?: {
3536
+ code: number;
3537
+ message: string;
3538
+ };
3539
+ }
3540
+ /** Options for the RelayClient constructor */
3541
+ interface RelayClientOptions {
3542
+ /** Registry WebSocket URL (e.g., "wss://hub.agentbnb.dev/ws") */
3543
+ registryUrl: string;
3544
+ /** Agent owner identifier */
3545
+ owner: string;
3546
+ /** Authentication token */
3547
+ token: string;
3548
+ /** Capability card data to register */
3549
+ card: Record<string, unknown>;
3550
+ /** Handler for incoming relay requests from other agents */
3551
+ onRequest: (req: IncomingRequestMessage) => Promise<RelayHandlerResult>;
3552
+ /** Suppress logging. Default false. */
3553
+ silent?: boolean;
3554
+ }
3555
+ /** Options for making a relay request to another agent */
3556
+ interface RelayRequestOptions$1 {
3557
+ targetOwner: string;
3558
+ cardId: string;
3559
+ skillId?: string;
3560
+ params: Record<string, unknown>;
3561
+ requester?: string;
3562
+ escrowReceipt?: Record<string, unknown>;
3563
+ timeoutMs?: number;
3564
+ }
3565
+ /**
3566
+ * WebSocket client for connecting to an AgentBnB registry relay.
3567
+ * Handles registration, auto-reconnect, incoming requests, and outbound relay requests.
3568
+ */
3569
+ declare class RelayClient {
3570
+ private ws;
3571
+ private readonly opts;
3572
+ private readonly pendingRequests;
3573
+ private reconnectAttempts;
3574
+ private reconnectTimer;
3575
+ private intentionalClose;
3576
+ private registered;
3577
+ private pongTimeout;
3578
+ private pingInterval;
3579
+ constructor(opts: RelayClientOptions);
3580
+ /**
3581
+ * Connect to the registry relay and register.
3582
+ * Resolves when registration is acknowledged.
3583
+ */
3584
+ connect(): Promise<void>;
3585
+ /**
3586
+ * Disconnect from the registry relay.
3587
+ */
3588
+ disconnect(): void;
3589
+ /**
3590
+ * Send a relay request to another agent via the registry.
3591
+ * @returns The result from the target agent.
3592
+ */
3593
+ request(opts: RelayRequestOptions$1): Promise<unknown>;
3594
+ /** Whether the client is connected and registered */
3595
+ get isConnected(): boolean;
3596
+ private buildWsUrl;
3597
+ private handleMessage;
3598
+ private handleIncomingRequest;
3599
+ private handleResponse;
3600
+ private handleError;
3601
+ private send;
3602
+ private startPingInterval;
3603
+ private stopPingInterval;
3604
+ private cleanup;
3605
+ private scheduleReconnect;
3606
+ }
3607
+
3608
+ /**
3609
+ * Options for executing a capability request.
3610
+ * Used by both the HTTP /rpc handler and WebSocket relay.
3611
+ */
3612
+ interface ExecuteRequestOptions {
3613
+ registryDb: Database.Database;
3614
+ creditDb: Database.Database;
3615
+ cardId: string;
3616
+ skillId?: string;
3617
+ params: Record<string, unknown>;
3618
+ requester: string;
3619
+ escrowReceipt?: EscrowReceipt;
3620
+ skillExecutor?: SkillExecutor;
3621
+ handlerUrl?: string;
3622
+ timeoutMs?: number;
3623
+ }
3624
+ /**
3625
+ * Result of a capability execution.
3626
+ */
3627
+ type ExecuteResult = {
3628
+ success: true;
3629
+ result: unknown;
3630
+ } | {
3631
+ success: false;
3632
+ error: {
3633
+ code: number;
3634
+ message: string;
3635
+ data?: Record<string, unknown>;
3636
+ };
3637
+ };
3638
+ /**
3639
+ * Executes a capability request with full escrow, reputation, and logging.
3640
+ * Shared between HTTP gateway (/rpc) and WebSocket relay paths.
3641
+ *
3642
+ * @param opts - Execution options including DB handles, card/skill IDs, and executor.
3643
+ * @returns Success with result, or failure with error details.
3644
+ */
3645
+ declare function executeCapabilityRequest(opts: ExecuteRequestOptions): Promise<ExecuteResult>;
3646
+
3647
+ /**
3648
+ * Options for requesting a capability via WebSocket relay.
3649
+ */
3650
+ interface RelayRequestOptions {
3651
+ /** Target agent owner to relay the request to. */
3652
+ targetOwner: string;
3653
+ /** Capability Card ID to execute. */
3654
+ cardId: string;
3655
+ /** Optional skill ID within the card. */
3656
+ skillId?: string;
3657
+ /** Input parameters for the capability. */
3658
+ params?: Record<string, unknown>;
3659
+ /** Signed escrow receipt for cross-machine credit verification. */
3660
+ escrowReceipt?: EscrowReceipt;
3661
+ /** Timeout in milliseconds. Default 30000. */
3662
+ timeoutMs?: number;
3663
+ }
3664
+ /**
3665
+ * Sends a capability request to another agent via the WebSocket relay.
3666
+ *
3667
+ * @param relay - Connected RelayClient instance.
3668
+ * @param opts - Relay request options.
3669
+ * @returns The result from the capability execution.
3670
+ * @throws {AgentBnBError} on relay error, timeout, or target agent offline.
3671
+ */
3672
+ declare function requestViaRelay(relay: RelayClient, opts: RelayRequestOptions): Promise<unknown>;
3673
+
3674
+ /**
3675
+ * Capability detection patterns and templates for smart onboarding.
3676
+ *
3677
+ * Pure data — regex patterns to detect known APIs/tools in markdown files,
3678
+ * and pre-built templates for the interactive fallback menu.
3679
+ */
3680
+ /**
3681
+ * A detected capability from doc scanning or template selection.
3682
+ * Lightweight — converted to a full Skill via capabilitiesToV2Card().
3683
+ */
3684
+ interface DetectedCapability {
3685
+ /** Unique key for deduplication, e.g. 'openai', 'elevenlabs' */
3686
+ key: string;
3687
+ /** Human-readable name, e.g. 'OpenAI Text Generation' */
3688
+ name: string;
3689
+ /** Category label, e.g. 'Text Gen', 'TTS' */
3690
+ category: string;
3691
+ /** Default credits per call */
3692
+ credits_per_call: number;
3693
+ /** Metadata tags for FTS indexing */
3694
+ tags: string[];
3695
+ }
3696
+ /**
3697
+ * A regex pattern entry mapping a pattern to a DetectedCapability.
3698
+ */
3699
+ interface PatternEntry {
3700
+ /** Regex to test against document content */
3701
+ pattern: RegExp;
3702
+ /** The capability to return if the pattern matches */
3703
+ capability: DetectedCapability;
3704
+ }
3705
+ /**
3706
+ * Regex patterns for detecting known APIs and tools in markdown documentation.
3707
+ * Each pattern maps to a DetectedCapability with sensible defaults.
3708
+ */
3709
+ declare const API_PATTERNS: PatternEntry[];
3710
+ /**
3711
+ * Pre-built templates for the interactive onboarding fallback menu.
3712
+ * Shown when no capabilities are auto-detected.
3713
+ */
3714
+ declare const INTERACTIVE_TEMPLATES: DetectedCapability[];
3715
+
3716
+ /**
3717
+ * Scans markdown content for known API/tool patterns and returns detected capabilities.
3718
+ *
3719
+ * - Tests each API_PATTERNS regex against the full content
3720
+ * - Deduplicates by capability key (first match wins)
3721
+ * - Returns empty array if nothing is detected
3722
+ *
3723
+ * @param content - Markdown file content to scan
3724
+ * @returns Array of detected capabilities (may be empty)
3725
+ */
3726
+ declare function detectFromDocs(content: string): DetectedCapability[];
3727
+
3728
+ /**
3729
+ * Result of the capability detection chain.
3730
+ * The `source` field indicates which detection method succeeded.
3731
+ */
3732
+ interface DetectionResult {
3733
+ /** Which detection method produced results */
3734
+ source: 'soul' | 'docs' | 'env' | 'none';
3735
+ /** Detected capabilities (for 'docs' source) */
3736
+ capabilities: DetectedCapability[];
3737
+ /** Raw SOUL.md content (for 'soul' source — caller passes to publishFromSoulV2) */
3738
+ soulContent?: string;
3739
+ /** Detected env var names (for 'env' source — caller passes to buildDraftCard) */
3740
+ envKeys?: string[];
3741
+ /** Which file was used for detection */
3742
+ sourceFile?: string;
3743
+ }
3744
+ /**
3745
+ * Options for the detection chain.
3746
+ */
3747
+ interface DetectOptions {
3748
+ /** Explicit file to parse (--from flag) */
3749
+ fromFile?: string;
3750
+ /** Working directory to search for doc files (default: process.cwd()) */
3751
+ cwd?: string;
3752
+ }
3753
+ /**
3754
+ * Runs the capability detection priority chain.
3755
+ *
3756
+ * Checks sources in order and stops at the first one that produces results:
3757
+ * 1. --from <file> → detectFromDocs()
3758
+ * 2. SOUL.md → returns raw content for publishFromSoulV2()
3759
+ * 3. CLAUDE.md / AGENTS.md / README.md → detectFromDocs()
3760
+ * 4. Environment variables → detectApiKeys()
3761
+ * 5. Returns { source: 'none' } if nothing found
3762
+ *
3763
+ * @param opts - Detection options (fromFile, cwd)
3764
+ * @returns Detection result with source indicator and data
3765
+ */
3766
+ declare function detectCapabilities(opts?: DetectOptions): DetectionResult;
3767
+ /**
3768
+ * Converts detected capabilities into a v2.0 CapabilityCard with skills.
3769
+ *
3770
+ * Each DetectedCapability becomes a Skill on the card. The card is validated
3771
+ * via CapabilityCardV2Schema before returning.
3772
+ *
3773
+ * @param capabilities - Detected capabilities to convert
3774
+ * @param owner - Agent owner name
3775
+ * @param agentName - Optional agent display name (defaults to owner)
3776
+ * @returns A valid v2.0 CapabilityCard
3777
+ */
3778
+ declare function capabilitiesToV2Card(capabilities: DetectedCapability[], owner: string, agentName?: string): CapabilityCardV2;
3779
+
3780
+ export { API_PATTERNS, AgentBnBConsumer, AgentBnBProvider, type AgentCertificate, AgentCertificateSchema, type AgentIdentity, AgentIdentitySchema, ApiExecutor, type ApiSkillConfig, ApiSkillConfigSchema, BudgetController, CONDUCTOR_OWNER, type CapabilityCard, CapabilityCardSchema, CommandExecutor, type CommandSkillConfig, CommandSkillConfigSchema, ConductorMode, type ConductorModeOptions, type ConductorSkillConfig, ConductorSkillConfigSchema, type ConsumerOptions, type ConsumerRequestOptions, type CreateReceiptOpts, type DetectOptions, type DetectedCapability, type DetectionResult, type ErrorMessage, type EscrowReceipt, EscrowReceiptSchema, type ExecuteRequestOptions, type ExecuteResult, type ExecutionBudget, type ExecutionResult, type ExecutorMode, GUARANTOR_CREDIT_POOL, type GuarantorRecord, GuarantorRecordSchema, INTERACTIVE_TEMPLATES, type IncomingRequestMessage, type KeyPair, MAX_AGENTS_PER_GUARANTOR, type MatchOptions, type MatchResult, ORCHESTRATION_FEE, OpenClawBridge, type OpenClawSkillConfig, OpenClawSkillConfigSchema, type OrchestrateOptions, type OrchestrationResult, PipelineExecutor, type PipelineSkillConfig, PipelineSkillConfigSchema, type ProviderOptions, type RegisterMessage, type RegisteredMessage, RelayClient, type RelayClientOptions, type RelayHandlerResult, type RelayMessage, RelayMessageSchema, type RelayRequestMessage, type RelayRequestOptions, type RelayResponseMessage, type RelayState, type ResponseMessage, type SharingContext, type SkillConfig, SkillConfigSchema, SkillExecutor, SkillsFileSchema, type StartSharingOptions, type SubTask, TEMPLATES, applyInputMapping, buildAuthHeaders, buildConductorCard, capabilitiesToV2Card, createGatewayServer, createIdentity, createSignedEscrowReceipt, createSkillExecutor, decompose, deriveAgentId, detectCapabilities, detectFromDocs, ensureIdentity, executeCapabilityRequest, expandEnvVars, extractByPath, generateKeyPair, getAgentGuarantor, getBalance, getCard, getGuarantor, initiateGithubAuth, insertCard, interpolate, interpolateObject, issueAgentCertificate, linkAgentToGuarantor, loadIdentity, loadKeyPair, matchSubTasks, openCreditDb, openDatabase, orchestrate, parseSkillsFile, registerConductorCard, registerGuarantor, registerWebSocketRelay, releaseRequesterEscrow, requestViaRelay, resolvePath, saveIdentity, saveKeyPair, searchCards, settleProviderEarning, settleRequesterEscrow, signEscrowReceipt, verifyAgentCertificate, verifyEscrowReceipt };