agentbnb 2.2.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -204,6 +204,393 @@ declare const CapabilityCardSchema: z.ZodObject<{
204
204
  updated_at?: string | undefined;
205
205
  }>;
206
206
  type CapabilityCard = z.infer<typeof CapabilityCardSchema>;
207
+ /**
208
+ * Capability Card v2.0 — one card per agent, multiple independently-priced skills.
209
+ *
210
+ * Introduced in Phase 4 (Plan 02). Existing v1.0 cards are migrated to this
211
+ * shape by `runMigrations()` in `src/registry/store.ts`.
212
+ */
213
+ declare const CapabilityCardV2Schema: z.ZodObject<{
214
+ spec_version: z.ZodLiteral<"2.0">;
215
+ id: z.ZodString;
216
+ owner: z.ZodString;
217
+ /** Agent display name — was 'name' in v1.0. */
218
+ agent_name: z.ZodString;
219
+ /** At least one skill is required. */
220
+ skills: z.ZodArray<z.ZodObject<{
221
+ /** Stable skill identifier, e.g. 'tts-elevenlabs'. Used for gateway routing and idle tracking. */
222
+ id: z.ZodString;
223
+ name: z.ZodString;
224
+ description: z.ZodString;
225
+ level: z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
226
+ /** Optional grouping category, e.g. 'tts' | 'video_gen' | 'code_review'. */
227
+ category: z.ZodOptional<z.ZodString>;
228
+ inputs: z.ZodArray<z.ZodObject<{
229
+ name: z.ZodString;
230
+ type: z.ZodEnum<["text", "json", "file", "audio", "image", "video", "stream"]>;
231
+ description: z.ZodOptional<z.ZodString>;
232
+ required: z.ZodDefault<z.ZodBoolean>;
233
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
234
+ }, "strip", z.ZodTypeAny, {
235
+ name: string;
236
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
237
+ required: boolean;
238
+ description?: string | undefined;
239
+ schema?: Record<string, unknown> | undefined;
240
+ }, {
241
+ name: string;
242
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
243
+ description?: string | undefined;
244
+ required?: boolean | undefined;
245
+ schema?: Record<string, unknown> | undefined;
246
+ }>, "many">;
247
+ outputs: z.ZodArray<z.ZodObject<{
248
+ name: z.ZodString;
249
+ type: z.ZodEnum<["text", "json", "file", "audio", "image", "video", "stream"]>;
250
+ description: z.ZodOptional<z.ZodString>;
251
+ required: z.ZodDefault<z.ZodBoolean>;
252
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
253
+ }, "strip", z.ZodTypeAny, {
254
+ name: string;
255
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
256
+ required: boolean;
257
+ description?: string | undefined;
258
+ schema?: Record<string, unknown> | undefined;
259
+ }, {
260
+ name: string;
261
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
262
+ description?: string | undefined;
263
+ required?: boolean | undefined;
264
+ schema?: Record<string, unknown> | undefined;
265
+ }>, "many">;
266
+ pricing: z.ZodObject<{
267
+ credits_per_call: z.ZodNumber;
268
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
269
+ free_tier: z.ZodOptional<z.ZodNumber>;
270
+ }, "strip", z.ZodTypeAny, {
271
+ credits_per_call: number;
272
+ credits_per_minute?: number | undefined;
273
+ free_tier?: number | undefined;
274
+ }, {
275
+ credits_per_call: number;
276
+ credits_per_minute?: number | undefined;
277
+ free_tier?: number | undefined;
278
+ }>;
279
+ /** Per-skill online flag — overrides card-level availability for this skill. */
280
+ availability: z.ZodOptional<z.ZodObject<{
281
+ online: z.ZodBoolean;
282
+ }, "strip", z.ZodTypeAny, {
283
+ online: boolean;
284
+ }, {
285
+ online: boolean;
286
+ }>>;
287
+ powered_by: z.ZodOptional<z.ZodArray<z.ZodObject<{
288
+ provider: z.ZodString;
289
+ model: z.ZodOptional<z.ZodString>;
290
+ tier: z.ZodOptional<z.ZodString>;
291
+ }, "strip", z.ZodTypeAny, {
292
+ provider: string;
293
+ model?: string | undefined;
294
+ tier?: string | undefined;
295
+ }, {
296
+ provider: string;
297
+ model?: string | undefined;
298
+ tier?: string | undefined;
299
+ }>, "many">>;
300
+ metadata: z.ZodOptional<z.ZodObject<{
301
+ apis_used: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
302
+ avg_latency_ms: z.ZodOptional<z.ZodNumber>;
303
+ success_rate: z.ZodOptional<z.ZodNumber>;
304
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
305
+ capacity: z.ZodOptional<z.ZodObject<{
306
+ calls_per_hour: z.ZodDefault<z.ZodNumber>;
307
+ }, "strip", z.ZodTypeAny, {
308
+ calls_per_hour: number;
309
+ }, {
310
+ calls_per_hour?: number | undefined;
311
+ }>>;
312
+ }, "strip", z.ZodTypeAny, {
313
+ apis_used?: string[] | undefined;
314
+ avg_latency_ms?: number | undefined;
315
+ success_rate?: number | undefined;
316
+ tags?: string[] | undefined;
317
+ capacity?: {
318
+ calls_per_hour: number;
319
+ } | undefined;
320
+ }, {
321
+ apis_used?: string[] | undefined;
322
+ avg_latency_ms?: number | undefined;
323
+ success_rate?: number | undefined;
324
+ tags?: string[] | undefined;
325
+ capacity?: {
326
+ calls_per_hour?: number | undefined;
327
+ } | undefined;
328
+ }>>;
329
+ /**
330
+ * Private per-skill metadata. Stripped from all API and CLI responses —
331
+ * never transmitted beyond the local store.
332
+ */
333
+ _internal: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
334
+ }, "strip", z.ZodTypeAny, {
335
+ name: string;
336
+ description: string;
337
+ id: string;
338
+ level: 1 | 2 | 3;
339
+ inputs: {
340
+ name: string;
341
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
342
+ required: boolean;
343
+ description?: string | undefined;
344
+ schema?: Record<string, unknown> | undefined;
345
+ }[];
346
+ outputs: {
347
+ name: string;
348
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
349
+ required: boolean;
350
+ description?: string | undefined;
351
+ schema?: Record<string, unknown> | undefined;
352
+ }[];
353
+ pricing: {
354
+ credits_per_call: number;
355
+ credits_per_minute?: number | undefined;
356
+ free_tier?: number | undefined;
357
+ };
358
+ availability?: {
359
+ online: boolean;
360
+ } | undefined;
361
+ powered_by?: {
362
+ provider: string;
363
+ model?: string | undefined;
364
+ tier?: string | undefined;
365
+ }[] | undefined;
366
+ _internal?: Record<string, unknown> | undefined;
367
+ metadata?: {
368
+ apis_used?: string[] | undefined;
369
+ avg_latency_ms?: number | undefined;
370
+ success_rate?: number | undefined;
371
+ tags?: string[] | undefined;
372
+ capacity?: {
373
+ calls_per_hour: number;
374
+ } | undefined;
375
+ } | undefined;
376
+ category?: string | undefined;
377
+ }, {
378
+ name: string;
379
+ description: string;
380
+ id: string;
381
+ level: 1 | 2 | 3;
382
+ inputs: {
383
+ name: string;
384
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
385
+ description?: string | undefined;
386
+ required?: boolean | undefined;
387
+ schema?: Record<string, unknown> | undefined;
388
+ }[];
389
+ outputs: {
390
+ name: string;
391
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
392
+ description?: string | undefined;
393
+ required?: boolean | undefined;
394
+ schema?: Record<string, unknown> | undefined;
395
+ }[];
396
+ pricing: {
397
+ credits_per_call: number;
398
+ credits_per_minute?: number | undefined;
399
+ free_tier?: number | undefined;
400
+ };
401
+ availability?: {
402
+ online: boolean;
403
+ } | undefined;
404
+ powered_by?: {
405
+ provider: string;
406
+ model?: string | undefined;
407
+ tier?: string | undefined;
408
+ }[] | undefined;
409
+ _internal?: Record<string, unknown> | undefined;
410
+ metadata?: {
411
+ apis_used?: string[] | undefined;
412
+ avg_latency_ms?: number | undefined;
413
+ success_rate?: number | undefined;
414
+ tags?: string[] | undefined;
415
+ capacity?: {
416
+ calls_per_hour?: number | undefined;
417
+ } | undefined;
418
+ } | undefined;
419
+ category?: string | undefined;
420
+ }>, "many">;
421
+ availability: z.ZodObject<{
422
+ online: z.ZodBoolean;
423
+ schedule: z.ZodOptional<z.ZodString>;
424
+ }, "strip", z.ZodTypeAny, {
425
+ online: boolean;
426
+ schedule?: string | undefined;
427
+ }, {
428
+ online: boolean;
429
+ schedule?: string | undefined;
430
+ }>;
431
+ /** Optional deployment environment metadata. */
432
+ environment: z.ZodOptional<z.ZodObject<{
433
+ runtime: z.ZodString;
434
+ region: z.ZodOptional<z.ZodString>;
435
+ }, "strip", z.ZodTypeAny, {
436
+ runtime: string;
437
+ region?: string | undefined;
438
+ }, {
439
+ runtime: string;
440
+ region?: string | undefined;
441
+ }>>;
442
+ /**
443
+ * Private per-card metadata. Stripped from all API and CLI responses —
444
+ * never transmitted beyond the local store.
445
+ */
446
+ _internal: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
447
+ created_at: z.ZodOptional<z.ZodString>;
448
+ updated_at: z.ZodOptional<z.ZodString>;
449
+ }, "strip", z.ZodTypeAny, {
450
+ spec_version: "2.0";
451
+ id: string;
452
+ owner: string;
453
+ availability: {
454
+ online: boolean;
455
+ schedule?: string | undefined;
456
+ };
457
+ agent_name: string;
458
+ skills: {
459
+ name: string;
460
+ description: string;
461
+ id: string;
462
+ level: 1 | 2 | 3;
463
+ inputs: {
464
+ name: string;
465
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
466
+ required: boolean;
467
+ description?: string | undefined;
468
+ schema?: Record<string, unknown> | undefined;
469
+ }[];
470
+ outputs: {
471
+ name: string;
472
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
473
+ required: boolean;
474
+ description?: string | undefined;
475
+ schema?: Record<string, unknown> | undefined;
476
+ }[];
477
+ pricing: {
478
+ credits_per_call: number;
479
+ credits_per_minute?: number | undefined;
480
+ free_tier?: number | undefined;
481
+ };
482
+ availability?: {
483
+ online: boolean;
484
+ } | undefined;
485
+ powered_by?: {
486
+ provider: string;
487
+ model?: string | undefined;
488
+ tier?: string | undefined;
489
+ }[] | undefined;
490
+ _internal?: Record<string, unknown> | undefined;
491
+ metadata?: {
492
+ apis_used?: string[] | undefined;
493
+ avg_latency_ms?: number | undefined;
494
+ success_rate?: number | undefined;
495
+ tags?: string[] | undefined;
496
+ capacity?: {
497
+ calls_per_hour: number;
498
+ } | undefined;
499
+ } | undefined;
500
+ category?: string | undefined;
501
+ }[];
502
+ _internal?: Record<string, unknown> | undefined;
503
+ created_at?: string | undefined;
504
+ updated_at?: string | undefined;
505
+ environment?: {
506
+ runtime: string;
507
+ region?: string | undefined;
508
+ } | undefined;
509
+ }, {
510
+ spec_version: "2.0";
511
+ id: string;
512
+ owner: string;
513
+ availability: {
514
+ online: boolean;
515
+ schedule?: string | undefined;
516
+ };
517
+ agent_name: string;
518
+ skills: {
519
+ name: string;
520
+ description: string;
521
+ id: string;
522
+ level: 1 | 2 | 3;
523
+ inputs: {
524
+ name: string;
525
+ type: "text" | "json" | "file" | "audio" | "image" | "video" | "stream";
526
+ description?: string | undefined;
527
+ required?: boolean | undefined;
528
+ schema?: Record<string, unknown> | undefined;
529
+ }[];
530
+ outputs: {
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
+ pricing: {
538
+ credits_per_call: number;
539
+ credits_per_minute?: number | undefined;
540
+ free_tier?: number | undefined;
541
+ };
542
+ availability?: {
543
+ online: boolean;
544
+ } | undefined;
545
+ powered_by?: {
546
+ provider: string;
547
+ model?: string | undefined;
548
+ tier?: string | undefined;
549
+ }[] | undefined;
550
+ _internal?: Record<string, unknown> | undefined;
551
+ metadata?: {
552
+ apis_used?: string[] | undefined;
553
+ avg_latency_ms?: number | undefined;
554
+ success_rate?: number | undefined;
555
+ tags?: string[] | undefined;
556
+ capacity?: {
557
+ calls_per_hour?: number | undefined;
558
+ } | undefined;
559
+ } | undefined;
560
+ category?: string | undefined;
561
+ }[];
562
+ _internal?: Record<string, unknown> | undefined;
563
+ created_at?: string | undefined;
564
+ updated_at?: string | undefined;
565
+ environment?: {
566
+ runtime: string;
567
+ region?: string | undefined;
568
+ } | undefined;
569
+ }>;
570
+ type CapabilityCardV2 = z.infer<typeof CapabilityCardV2Schema>;
571
+ /**
572
+ * Signed escrow receipt — cryptographic proof that a requester has committed credits.
573
+ * Sent to the provider so they can verify the requester's credit commitment
574
+ * without needing access to the requester's local database.
575
+ */
576
+ interface EscrowReceipt {
577
+ /** Agent owner identifier of the requester. */
578
+ requester_owner: string;
579
+ /** Hex-encoded Ed25519 public key of the requester. */
580
+ requester_public_key: string;
581
+ /** Number of credits committed. */
582
+ amount: number;
583
+ /** Capability Card ID being requested. */
584
+ card_id: string;
585
+ /** Optional skill ID within the card. */
586
+ skill_id?: string;
587
+ /** ISO 8601 timestamp of receipt creation. */
588
+ timestamp: string;
589
+ /** UUID nonce — prevents replay attacks. */
590
+ nonce: string;
591
+ /** Base64url Ed25519 signature over all other fields. */
592
+ signature: string;
593
+ }
207
594
 
208
595
  /**
209
596
  * Opens a SQLite database at the given path (or in-memory if ':memory:').
@@ -275,10 +662,10 @@ declare function openCreditDb(path?: string): Database.Database;
275
662
  declare function getBalance(db: Database.Database, owner: string): number;
276
663
 
277
664
  /**
278
- * Discriminated union over all four skill configuration types.
279
- * Used by SkillExecutor to dispatch to the correct executor mode.
665
+ * Schema for API wrapper skills (Mode A).
666
+ * Wraps a REST API call with input/output mapping.
280
667
  */
281
- declare const SkillConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
668
+ declare const ApiSkillConfigSchema: z.ZodObject<{
282
669
  id: z.ZodString;
283
670
  type: z.ZodLiteral<"api">;
284
671
  name: z.ZodString;
@@ -299,8 +686,8 @@ declare const SkillConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
299
686
  key: z.ZodString;
300
687
  }, "strip", z.ZodTypeAny, {
301
688
  type: "apikey";
302
- header: string;
303
689
  key: string;
690
+ header: string;
304
691
  }, {
305
692
  type: "apikey";
306
693
  key: string;
@@ -357,8 +744,8 @@ declare const SkillConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
357
744
  token: string;
358
745
  } | {
359
746
  type: "apikey";
360
- header: string;
361
747
  key: string;
748
+ header: string;
362
749
  } | {
363
750
  type: "basic";
364
751
  username: string;
@@ -392,7 +779,12 @@ declare const SkillConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
392
779
  output_mapping?: Record<string, string> | undefined;
393
780
  timeout_ms?: number | undefined;
394
781
  retries?: number | undefined;
395
- }>, z.ZodObject<{
782
+ }>;
783
+ /**
784
+ * Schema for pipeline skills (Mode B).
785
+ * Chains multiple skills or commands sequentially.
786
+ */
787
+ declare const PipelineSkillConfigSchema: z.ZodObject<{
396
788
  id: z.ZodString;
397
789
  type: z.ZodLiteral<"pipeline">;
398
790
  name: z.ZodString;
@@ -463,7 +855,12 @@ declare const SkillConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
463
855
  input_mapping?: Record<string, string> | undefined;
464
856
  })[];
465
857
  timeout_ms?: number | undefined;
466
- }>, z.ZodObject<{
858
+ }>;
859
+ /**
860
+ * Schema for OpenClaw bridge skills (Mode C).
861
+ * Forwards execution to a local OpenClaw agent.
862
+ */
863
+ declare const OpenClawSkillConfigSchema: z.ZodObject<{
467
864
  id: z.ZodString;
468
865
  type: z.ZodLiteral<"openclaw">;
469
866
  name: z.ZodString;
@@ -507,7 +904,12 @@ declare const SkillConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
507
904
  agent_name: string;
508
905
  channel: "telegram" | "webhook" | "process";
509
906
  timeout_ms?: number | undefined;
510
- }>, z.ZodObject<{
907
+ }>;
908
+ /**
909
+ * Schema for command execution skills (Mode D).
910
+ * Runs local shell commands with parameter substitution.
911
+ */
912
+ declare const CommandSkillConfigSchema: z.ZodObject<{
511
913
  id: z.ZodString;
512
914
  type: z.ZodLiteral<"command">;
513
915
  name: z.ZodString;
@@ -557,120 +959,1772 @@ declare const SkillConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
557
959
  timeout_ms?: number | undefined;
558
960
  allowed_commands?: string[] | undefined;
559
961
  working_dir?: string | undefined;
560
- }>]>;
561
- /** TypeScript type for any skill config entry */
562
- type SkillConfig = z.infer<typeof SkillConfigSchema>;
563
-
564
- /**
565
- * Result returned by SkillExecutor.execute() for every invocation.
566
- * Always includes timing data regardless of success or failure.
567
- */
568
- interface ExecutionResult {
569
- /** Whether the skill executed successfully. */
570
- success: boolean;
571
- /** The output produced by the skill on success. */
572
- result?: unknown;
573
- /** Error message if success is false. */
574
- error?: string;
575
- /** Wall-clock execution time in milliseconds. */
576
- latency_ms: number;
577
- }
578
- /**
579
- * Interface that all executor mode implementations must satisfy.
580
- * Each mode handles one skill type: 'api' | 'pipeline' | 'openclaw' | 'command'.
581
- */
582
- interface ExecutorMode {
583
- /**
584
- * Execute a skill with the given config and input parameters.
585
- *
586
- * @param config - The validated SkillConfig for this skill.
587
- * @param params - The input parameters passed by the caller.
588
- * @returns A partial ExecutionResult without latency_ms (added by SkillExecutor).
589
- */
590
- execute(config: SkillConfig, params: Record<string, unknown>): Promise<Omit<ExecutionResult, 'latency_ms'>>;
591
- }
592
- /**
593
- * Central dispatcher that routes skill execution requests to the appropriate
594
- * executor mode based on the skill's `type` field.
595
- *
596
- * Usage:
597
- * ```ts
598
- * const executor = createSkillExecutor(configs, modes);
599
- * const result = await executor.execute('tts-skill', { text: 'hello' });
600
- * ```
601
- */
602
- declare class SkillExecutor {
603
- private readonly skillMap;
604
- private readonly modeMap;
605
- /**
606
- * @param configs - Parsed SkillConfig array (from parseSkillsFile).
607
- * @param modes - Map from skill type string to its executor implementation.
608
- */
609
- constructor(configs: SkillConfig[], modes: Map<string, ExecutorMode>);
610
- /**
611
- * Execute a skill by ID with the given input parameters.
612
- *
613
- * Dispatch order:
614
- * 1. Look up skill config by skillId.
615
- * 2. Find executor mode by config.type.
616
- * 3. Invoke mode.execute(), wrap with latency timing.
617
- * 4. Catch any thrown errors and return as ExecutionResult with success:false.
618
- *
619
- * @param skillId - The ID of the skill to execute.
620
- * @param params - Input parameters for the skill.
621
- * @returns ExecutionResult including success, result/error, and latency_ms.
622
- */
623
- execute(skillId: string, params: Record<string, unknown>): Promise<ExecutionResult>;
624
- /**
625
- * Returns the IDs of all registered skills.
626
- *
627
- * @returns Array of skill ID strings.
628
- */
629
- listSkills(): string[];
630
- /**
631
- * Returns the SkillConfig for a given skill ID, or undefined if not found.
632
- *
633
- * @param skillId - The skill ID to look up.
634
- * @returns The SkillConfig or undefined.
635
- */
636
- getSkillConfig(skillId: string): SkillConfig | undefined;
637
- }
638
-
962
+ }>;
639
963
  /**
640
- * Options for creating a gateway server.
964
+ * Schema for conductor orchestration skills (Mode E).
965
+ * Routes execution to the ConductorMode for task decomposition and multi-agent orchestration.
641
966
  */
642
- interface GatewayOptions {
643
- /** Port to listen on. Default 7700. */
644
- port?: number;
645
- /** Open registry database instance. */
646
- registryDb: Database.Database;
647
- /** Open credit database instance. */
648
- creditDb: Database.Database;
649
- /** Valid bearer tokens for auth. */
650
- tokens: string[];
651
- /** URL of the local capability handler. */
652
- handlerUrl: string;
653
- /** Request timeout in ms. Default 30000. */
654
- timeoutMs?: number;
655
- /** Disable logging (useful for tests). */
656
- silent?: boolean;
657
- /**
658
- * Optional SkillExecutor instance.
659
- * When provided, skill execution is dispatched through SkillExecutor.execute()
660
- * instead of forwarding via fetch(handlerUrl).
661
- * When absent, the original handlerUrl fetch path is used (backward compat).
662
- */
663
- skillExecutor?: SkillExecutor;
664
- }
967
+ declare const ConductorSkillConfigSchema: z.ZodObject<{
968
+ id: z.ZodString;
969
+ type: z.ZodLiteral<"conductor">;
970
+ name: z.ZodString;
971
+ conductor_skill: z.ZodEnum<["orchestrate", "plan"]>;
972
+ pricing: z.ZodObject<{
973
+ credits_per_call: z.ZodNumber;
974
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
975
+ free_tier: z.ZodOptional<z.ZodNumber>;
976
+ }, "strip", z.ZodTypeAny, {
977
+ credits_per_call: number;
978
+ credits_per_minute?: number | undefined;
979
+ free_tier?: number | undefined;
980
+ }, {
981
+ credits_per_call: number;
982
+ credits_per_minute?: number | undefined;
983
+ free_tier?: number | undefined;
984
+ }>;
985
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
986
+ }, "strip", z.ZodTypeAny, {
987
+ name: string;
988
+ type: "conductor";
989
+ id: string;
990
+ pricing: {
991
+ credits_per_call: number;
992
+ credits_per_minute?: number | undefined;
993
+ free_tier?: number | undefined;
994
+ };
995
+ conductor_skill: "orchestrate" | "plan";
996
+ timeout_ms?: number | undefined;
997
+ }, {
998
+ name: string;
999
+ type: "conductor";
1000
+ id: string;
1001
+ pricing: {
1002
+ credits_per_call: number;
1003
+ credits_per_minute?: number | undefined;
1004
+ free_tier?: number | undefined;
1005
+ };
1006
+ conductor_skill: "orchestrate" | "plan";
1007
+ timeout_ms?: number | undefined;
1008
+ }>;
665
1009
  /**
666
- * Creates a Fastify gateway server for agent-to-agent communication.
667
- * Registers /health (unauthenticated) and /rpc (token-authenticated) endpoints.
668
- * Returns a configured Fastify instance (call .ready() before using inject,
669
- * or .listen() to start accepting connections).
670
- *
671
- * @param opts - Gateway configuration options.
672
- * @returns Configured Fastify instance (not yet listening).
1010
+ * Discriminated union over all five skill configuration types.
1011
+ * Used by SkillExecutor to dispatch to the correct executor mode.
673
1012
  */
674
- declare function createGatewayServer(opts: GatewayOptions): FastifyInstance;
1013
+ declare const SkillConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1014
+ id: z.ZodString;
1015
+ type: z.ZodLiteral<"api">;
1016
+ name: z.ZodString;
1017
+ endpoint: z.ZodString;
1018
+ method: z.ZodEnum<["GET", "POST", "PUT", "DELETE"]>;
1019
+ auth: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1020
+ type: z.ZodLiteral<"bearer">;
1021
+ token: z.ZodString;
1022
+ }, "strip", z.ZodTypeAny, {
1023
+ type: "bearer";
1024
+ token: string;
1025
+ }, {
1026
+ type: "bearer";
1027
+ token: string;
1028
+ }>, z.ZodObject<{
1029
+ type: z.ZodLiteral<"apikey">;
1030
+ header: z.ZodDefault<z.ZodString>;
1031
+ key: z.ZodString;
1032
+ }, "strip", z.ZodTypeAny, {
1033
+ type: "apikey";
1034
+ key: string;
1035
+ header: string;
1036
+ }, {
1037
+ type: "apikey";
1038
+ key: string;
1039
+ header?: string | undefined;
1040
+ }>, z.ZodObject<{
1041
+ type: z.ZodLiteral<"basic">;
1042
+ username: z.ZodString;
1043
+ password: z.ZodString;
1044
+ }, "strip", z.ZodTypeAny, {
1045
+ type: "basic";
1046
+ username: string;
1047
+ password: string;
1048
+ }, {
1049
+ type: "basic";
1050
+ username: string;
1051
+ password: string;
1052
+ }>]>>;
1053
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1054
+ output_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1055
+ pricing: z.ZodObject<{
1056
+ credits_per_call: z.ZodNumber;
1057
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1058
+ free_tier: z.ZodOptional<z.ZodNumber>;
1059
+ }, "strip", z.ZodTypeAny, {
1060
+ credits_per_call: number;
1061
+ credits_per_minute?: number | undefined;
1062
+ free_tier?: number | undefined;
1063
+ }, {
1064
+ credits_per_call: number;
1065
+ credits_per_minute?: number | undefined;
1066
+ free_tier?: number | undefined;
1067
+ }>;
1068
+ timeout_ms: z.ZodDefault<z.ZodNumber>;
1069
+ retries: z.ZodDefault<z.ZodNumber>;
1070
+ provider: z.ZodOptional<z.ZodString>;
1071
+ }, "strip", z.ZodTypeAny, {
1072
+ name: string;
1073
+ type: "api";
1074
+ id: string;
1075
+ pricing: {
1076
+ credits_per_call: number;
1077
+ credits_per_minute?: number | undefined;
1078
+ free_tier?: number | undefined;
1079
+ };
1080
+ endpoint: string;
1081
+ method: "GET" | "POST" | "PUT" | "DELETE";
1082
+ input_mapping: Record<string, string>;
1083
+ output_mapping: Record<string, string>;
1084
+ timeout_ms: number;
1085
+ retries: number;
1086
+ provider?: string | undefined;
1087
+ auth?: {
1088
+ type: "bearer";
1089
+ token: string;
1090
+ } | {
1091
+ type: "apikey";
1092
+ key: string;
1093
+ header: string;
1094
+ } | {
1095
+ type: "basic";
1096
+ username: string;
1097
+ password: string;
1098
+ } | undefined;
1099
+ }, {
1100
+ name: string;
1101
+ type: "api";
1102
+ id: string;
1103
+ pricing: {
1104
+ credits_per_call: number;
1105
+ credits_per_minute?: number | undefined;
1106
+ free_tier?: number | undefined;
1107
+ };
1108
+ endpoint: string;
1109
+ method: "GET" | "POST" | "PUT" | "DELETE";
1110
+ provider?: string | undefined;
1111
+ auth?: {
1112
+ type: "bearer";
1113
+ token: string;
1114
+ } | {
1115
+ type: "apikey";
1116
+ key: string;
1117
+ header?: string | undefined;
1118
+ } | {
1119
+ type: "basic";
1120
+ username: string;
1121
+ password: string;
1122
+ } | undefined;
1123
+ input_mapping?: Record<string, string> | undefined;
1124
+ output_mapping?: Record<string, string> | undefined;
1125
+ timeout_ms?: number | undefined;
1126
+ retries?: number | undefined;
1127
+ }>, z.ZodObject<{
1128
+ id: z.ZodString;
1129
+ type: z.ZodLiteral<"pipeline">;
1130
+ name: z.ZodString;
1131
+ steps: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1132
+ skill_id: z.ZodString;
1133
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1134
+ }, "strip", z.ZodTypeAny, {
1135
+ input_mapping: Record<string, string>;
1136
+ skill_id: string;
1137
+ }, {
1138
+ skill_id: string;
1139
+ input_mapping?: Record<string, string> | undefined;
1140
+ }>, z.ZodObject<{
1141
+ command: z.ZodString;
1142
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1143
+ }, "strip", z.ZodTypeAny, {
1144
+ input_mapping: Record<string, string>;
1145
+ command: string;
1146
+ }, {
1147
+ command: string;
1148
+ input_mapping?: Record<string, string> | undefined;
1149
+ }>]>, "many">;
1150
+ pricing: z.ZodObject<{
1151
+ credits_per_call: z.ZodNumber;
1152
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1153
+ free_tier: z.ZodOptional<z.ZodNumber>;
1154
+ }, "strip", z.ZodTypeAny, {
1155
+ credits_per_call: number;
1156
+ credits_per_minute?: number | undefined;
1157
+ free_tier?: number | undefined;
1158
+ }, {
1159
+ credits_per_call: number;
1160
+ credits_per_minute?: number | undefined;
1161
+ free_tier?: number | undefined;
1162
+ }>;
1163
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1164
+ }, "strip", z.ZodTypeAny, {
1165
+ name: string;
1166
+ type: "pipeline";
1167
+ id: string;
1168
+ pricing: {
1169
+ credits_per_call: number;
1170
+ credits_per_minute?: number | undefined;
1171
+ free_tier?: number | undefined;
1172
+ };
1173
+ steps: ({
1174
+ input_mapping: Record<string, string>;
1175
+ skill_id: string;
1176
+ } | {
1177
+ input_mapping: Record<string, string>;
1178
+ command: string;
1179
+ })[];
1180
+ timeout_ms?: number | undefined;
1181
+ }, {
1182
+ name: string;
1183
+ type: "pipeline";
1184
+ id: string;
1185
+ pricing: {
1186
+ credits_per_call: number;
1187
+ credits_per_minute?: number | undefined;
1188
+ free_tier?: number | undefined;
1189
+ };
1190
+ steps: ({
1191
+ skill_id: string;
1192
+ input_mapping?: Record<string, string> | undefined;
1193
+ } | {
1194
+ command: string;
1195
+ input_mapping?: Record<string, string> | undefined;
1196
+ })[];
1197
+ timeout_ms?: number | undefined;
1198
+ }>, z.ZodObject<{
1199
+ id: z.ZodString;
1200
+ type: z.ZodLiteral<"openclaw">;
1201
+ name: z.ZodString;
1202
+ agent_name: z.ZodString;
1203
+ channel: z.ZodEnum<["telegram", "webhook", "process"]>;
1204
+ pricing: z.ZodObject<{
1205
+ credits_per_call: z.ZodNumber;
1206
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1207
+ free_tier: z.ZodOptional<z.ZodNumber>;
1208
+ }, "strip", z.ZodTypeAny, {
1209
+ credits_per_call: number;
1210
+ credits_per_minute?: number | undefined;
1211
+ free_tier?: number | undefined;
1212
+ }, {
1213
+ credits_per_call: number;
1214
+ credits_per_minute?: number | undefined;
1215
+ free_tier?: number | undefined;
1216
+ }>;
1217
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1218
+ }, "strip", z.ZodTypeAny, {
1219
+ name: string;
1220
+ type: "openclaw";
1221
+ id: string;
1222
+ pricing: {
1223
+ credits_per_call: number;
1224
+ credits_per_minute?: number | undefined;
1225
+ free_tier?: number | undefined;
1226
+ };
1227
+ agent_name: string;
1228
+ channel: "telegram" | "webhook" | "process";
1229
+ timeout_ms?: number | undefined;
1230
+ }, {
1231
+ name: string;
1232
+ type: "openclaw";
1233
+ id: string;
1234
+ pricing: {
1235
+ credits_per_call: number;
1236
+ credits_per_minute?: number | undefined;
1237
+ free_tier?: number | undefined;
1238
+ };
1239
+ agent_name: string;
1240
+ channel: "telegram" | "webhook" | "process";
1241
+ timeout_ms?: number | undefined;
1242
+ }>, z.ZodObject<{
1243
+ id: z.ZodString;
1244
+ type: z.ZodLiteral<"command">;
1245
+ name: z.ZodString;
1246
+ command: z.ZodString;
1247
+ output_type: z.ZodEnum<["json", "text", "file"]>;
1248
+ allowed_commands: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1249
+ working_dir: z.ZodOptional<z.ZodString>;
1250
+ timeout_ms: z.ZodDefault<z.ZodNumber>;
1251
+ pricing: z.ZodObject<{
1252
+ credits_per_call: z.ZodNumber;
1253
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1254
+ free_tier: z.ZodOptional<z.ZodNumber>;
1255
+ }, "strip", z.ZodTypeAny, {
1256
+ credits_per_call: number;
1257
+ credits_per_minute?: number | undefined;
1258
+ free_tier?: number | undefined;
1259
+ }, {
1260
+ credits_per_call: number;
1261
+ credits_per_minute?: number | undefined;
1262
+ free_tier?: number | undefined;
1263
+ }>;
1264
+ }, "strip", z.ZodTypeAny, {
1265
+ name: string;
1266
+ type: "command";
1267
+ id: string;
1268
+ pricing: {
1269
+ credits_per_call: number;
1270
+ credits_per_minute?: number | undefined;
1271
+ free_tier?: number | undefined;
1272
+ };
1273
+ timeout_ms: number;
1274
+ command: string;
1275
+ output_type: "text" | "json" | "file";
1276
+ allowed_commands?: string[] | undefined;
1277
+ working_dir?: string | undefined;
1278
+ }, {
1279
+ name: string;
1280
+ type: "command";
1281
+ id: string;
1282
+ pricing: {
1283
+ credits_per_call: number;
1284
+ credits_per_minute?: number | undefined;
1285
+ free_tier?: number | undefined;
1286
+ };
1287
+ command: string;
1288
+ output_type: "text" | "json" | "file";
1289
+ timeout_ms?: number | undefined;
1290
+ allowed_commands?: string[] | undefined;
1291
+ working_dir?: string | undefined;
1292
+ }>, z.ZodObject<{
1293
+ id: z.ZodString;
1294
+ type: z.ZodLiteral<"conductor">;
1295
+ name: z.ZodString;
1296
+ conductor_skill: z.ZodEnum<["orchestrate", "plan"]>;
1297
+ pricing: z.ZodObject<{
1298
+ credits_per_call: z.ZodNumber;
1299
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1300
+ free_tier: z.ZodOptional<z.ZodNumber>;
1301
+ }, "strip", z.ZodTypeAny, {
1302
+ credits_per_call: number;
1303
+ credits_per_minute?: number | undefined;
1304
+ free_tier?: number | undefined;
1305
+ }, {
1306
+ credits_per_call: number;
1307
+ credits_per_minute?: number | undefined;
1308
+ free_tier?: number | undefined;
1309
+ }>;
1310
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1311
+ }, "strip", z.ZodTypeAny, {
1312
+ name: string;
1313
+ type: "conductor";
1314
+ id: string;
1315
+ pricing: {
1316
+ credits_per_call: number;
1317
+ credits_per_minute?: number | undefined;
1318
+ free_tier?: number | undefined;
1319
+ };
1320
+ conductor_skill: "orchestrate" | "plan";
1321
+ timeout_ms?: number | undefined;
1322
+ }, {
1323
+ name: string;
1324
+ type: "conductor";
1325
+ id: string;
1326
+ pricing: {
1327
+ credits_per_call: number;
1328
+ credits_per_minute?: number | undefined;
1329
+ free_tier?: number | undefined;
1330
+ };
1331
+ conductor_skill: "orchestrate" | "plan";
1332
+ timeout_ms?: number | undefined;
1333
+ }>]>;
1334
+ /**
1335
+ * Root schema for a skills.yaml file.
1336
+ * Contains a list of skill configurations.
1337
+ */
1338
+ declare const SkillsFileSchema: z.ZodObject<{
1339
+ skills: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1340
+ id: z.ZodString;
1341
+ type: z.ZodLiteral<"api">;
1342
+ name: z.ZodString;
1343
+ endpoint: z.ZodString;
1344
+ method: z.ZodEnum<["GET", "POST", "PUT", "DELETE"]>;
1345
+ auth: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1346
+ type: z.ZodLiteral<"bearer">;
1347
+ token: z.ZodString;
1348
+ }, "strip", z.ZodTypeAny, {
1349
+ type: "bearer";
1350
+ token: string;
1351
+ }, {
1352
+ type: "bearer";
1353
+ token: string;
1354
+ }>, z.ZodObject<{
1355
+ type: z.ZodLiteral<"apikey">;
1356
+ header: z.ZodDefault<z.ZodString>;
1357
+ key: z.ZodString;
1358
+ }, "strip", z.ZodTypeAny, {
1359
+ type: "apikey";
1360
+ key: string;
1361
+ header: string;
1362
+ }, {
1363
+ type: "apikey";
1364
+ key: string;
1365
+ header?: string | undefined;
1366
+ }>, z.ZodObject<{
1367
+ type: z.ZodLiteral<"basic">;
1368
+ username: z.ZodString;
1369
+ password: z.ZodString;
1370
+ }, "strip", z.ZodTypeAny, {
1371
+ type: "basic";
1372
+ username: string;
1373
+ password: string;
1374
+ }, {
1375
+ type: "basic";
1376
+ username: string;
1377
+ password: string;
1378
+ }>]>>;
1379
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1380
+ output_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1381
+ pricing: z.ZodObject<{
1382
+ credits_per_call: z.ZodNumber;
1383
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1384
+ free_tier: z.ZodOptional<z.ZodNumber>;
1385
+ }, "strip", z.ZodTypeAny, {
1386
+ credits_per_call: number;
1387
+ credits_per_minute?: number | undefined;
1388
+ free_tier?: number | undefined;
1389
+ }, {
1390
+ credits_per_call: number;
1391
+ credits_per_minute?: number | undefined;
1392
+ free_tier?: number | undefined;
1393
+ }>;
1394
+ timeout_ms: z.ZodDefault<z.ZodNumber>;
1395
+ retries: z.ZodDefault<z.ZodNumber>;
1396
+ provider: z.ZodOptional<z.ZodString>;
1397
+ }, "strip", z.ZodTypeAny, {
1398
+ name: string;
1399
+ type: "api";
1400
+ id: string;
1401
+ pricing: {
1402
+ credits_per_call: number;
1403
+ credits_per_minute?: number | undefined;
1404
+ free_tier?: number | undefined;
1405
+ };
1406
+ endpoint: string;
1407
+ method: "GET" | "POST" | "PUT" | "DELETE";
1408
+ input_mapping: Record<string, string>;
1409
+ output_mapping: Record<string, string>;
1410
+ timeout_ms: number;
1411
+ retries: number;
1412
+ provider?: string | undefined;
1413
+ auth?: {
1414
+ type: "bearer";
1415
+ token: string;
1416
+ } | {
1417
+ type: "apikey";
1418
+ key: string;
1419
+ header: string;
1420
+ } | {
1421
+ type: "basic";
1422
+ username: string;
1423
+ password: string;
1424
+ } | undefined;
1425
+ }, {
1426
+ name: string;
1427
+ type: "api";
1428
+ id: string;
1429
+ pricing: {
1430
+ credits_per_call: number;
1431
+ credits_per_minute?: number | undefined;
1432
+ free_tier?: number | undefined;
1433
+ };
1434
+ endpoint: string;
1435
+ method: "GET" | "POST" | "PUT" | "DELETE";
1436
+ provider?: string | undefined;
1437
+ auth?: {
1438
+ type: "bearer";
1439
+ token: string;
1440
+ } | {
1441
+ type: "apikey";
1442
+ key: string;
1443
+ header?: string | undefined;
1444
+ } | {
1445
+ type: "basic";
1446
+ username: string;
1447
+ password: string;
1448
+ } | undefined;
1449
+ input_mapping?: Record<string, string> | undefined;
1450
+ output_mapping?: Record<string, string> | undefined;
1451
+ timeout_ms?: number | undefined;
1452
+ retries?: number | undefined;
1453
+ }>, z.ZodObject<{
1454
+ id: z.ZodString;
1455
+ type: z.ZodLiteral<"pipeline">;
1456
+ name: z.ZodString;
1457
+ steps: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1458
+ skill_id: z.ZodString;
1459
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1460
+ }, "strip", z.ZodTypeAny, {
1461
+ input_mapping: Record<string, string>;
1462
+ skill_id: string;
1463
+ }, {
1464
+ skill_id: string;
1465
+ input_mapping?: Record<string, string> | undefined;
1466
+ }>, z.ZodObject<{
1467
+ command: z.ZodString;
1468
+ input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1469
+ }, "strip", z.ZodTypeAny, {
1470
+ input_mapping: Record<string, string>;
1471
+ command: string;
1472
+ }, {
1473
+ command: string;
1474
+ input_mapping?: Record<string, string> | undefined;
1475
+ }>]>, "many">;
1476
+ pricing: z.ZodObject<{
1477
+ credits_per_call: z.ZodNumber;
1478
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1479
+ free_tier: z.ZodOptional<z.ZodNumber>;
1480
+ }, "strip", z.ZodTypeAny, {
1481
+ credits_per_call: number;
1482
+ credits_per_minute?: number | undefined;
1483
+ free_tier?: number | undefined;
1484
+ }, {
1485
+ credits_per_call: number;
1486
+ credits_per_minute?: number | undefined;
1487
+ free_tier?: number | undefined;
1488
+ }>;
1489
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1490
+ }, "strip", z.ZodTypeAny, {
1491
+ name: string;
1492
+ type: "pipeline";
1493
+ id: string;
1494
+ pricing: {
1495
+ credits_per_call: number;
1496
+ credits_per_minute?: number | undefined;
1497
+ free_tier?: number | undefined;
1498
+ };
1499
+ steps: ({
1500
+ input_mapping: Record<string, string>;
1501
+ skill_id: string;
1502
+ } | {
1503
+ input_mapping: Record<string, string>;
1504
+ command: string;
1505
+ })[];
1506
+ timeout_ms?: number | undefined;
1507
+ }, {
1508
+ name: string;
1509
+ type: "pipeline";
1510
+ id: string;
1511
+ pricing: {
1512
+ credits_per_call: number;
1513
+ credits_per_minute?: number | undefined;
1514
+ free_tier?: number | undefined;
1515
+ };
1516
+ steps: ({
1517
+ skill_id: string;
1518
+ input_mapping?: Record<string, string> | undefined;
1519
+ } | {
1520
+ command: string;
1521
+ input_mapping?: Record<string, string> | undefined;
1522
+ })[];
1523
+ timeout_ms?: number | undefined;
1524
+ }>, z.ZodObject<{
1525
+ id: z.ZodString;
1526
+ type: z.ZodLiteral<"openclaw">;
1527
+ name: z.ZodString;
1528
+ agent_name: z.ZodString;
1529
+ channel: z.ZodEnum<["telegram", "webhook", "process"]>;
1530
+ pricing: z.ZodObject<{
1531
+ credits_per_call: z.ZodNumber;
1532
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1533
+ free_tier: z.ZodOptional<z.ZodNumber>;
1534
+ }, "strip", z.ZodTypeAny, {
1535
+ credits_per_call: number;
1536
+ credits_per_minute?: number | undefined;
1537
+ free_tier?: number | undefined;
1538
+ }, {
1539
+ credits_per_call: number;
1540
+ credits_per_minute?: number | undefined;
1541
+ free_tier?: number | undefined;
1542
+ }>;
1543
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1544
+ }, "strip", z.ZodTypeAny, {
1545
+ name: string;
1546
+ type: "openclaw";
1547
+ id: string;
1548
+ pricing: {
1549
+ credits_per_call: number;
1550
+ credits_per_minute?: number | undefined;
1551
+ free_tier?: number | undefined;
1552
+ };
1553
+ agent_name: string;
1554
+ channel: "telegram" | "webhook" | "process";
1555
+ timeout_ms?: number | undefined;
1556
+ }, {
1557
+ name: string;
1558
+ type: "openclaw";
1559
+ id: string;
1560
+ pricing: {
1561
+ credits_per_call: number;
1562
+ credits_per_minute?: number | undefined;
1563
+ free_tier?: number | undefined;
1564
+ };
1565
+ agent_name: string;
1566
+ channel: "telegram" | "webhook" | "process";
1567
+ timeout_ms?: number | undefined;
1568
+ }>, z.ZodObject<{
1569
+ id: z.ZodString;
1570
+ type: z.ZodLiteral<"command">;
1571
+ name: z.ZodString;
1572
+ command: z.ZodString;
1573
+ output_type: z.ZodEnum<["json", "text", "file"]>;
1574
+ allowed_commands: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1575
+ working_dir: z.ZodOptional<z.ZodString>;
1576
+ timeout_ms: z.ZodDefault<z.ZodNumber>;
1577
+ pricing: z.ZodObject<{
1578
+ credits_per_call: z.ZodNumber;
1579
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1580
+ free_tier: z.ZodOptional<z.ZodNumber>;
1581
+ }, "strip", z.ZodTypeAny, {
1582
+ credits_per_call: number;
1583
+ credits_per_minute?: number | undefined;
1584
+ free_tier?: number | undefined;
1585
+ }, {
1586
+ credits_per_call: number;
1587
+ credits_per_minute?: number | undefined;
1588
+ free_tier?: number | undefined;
1589
+ }>;
1590
+ }, "strip", z.ZodTypeAny, {
1591
+ name: string;
1592
+ type: "command";
1593
+ id: string;
1594
+ pricing: {
1595
+ credits_per_call: number;
1596
+ credits_per_minute?: number | undefined;
1597
+ free_tier?: number | undefined;
1598
+ };
1599
+ timeout_ms: number;
1600
+ command: string;
1601
+ output_type: "text" | "json" | "file";
1602
+ allowed_commands?: string[] | undefined;
1603
+ working_dir?: string | undefined;
1604
+ }, {
1605
+ name: string;
1606
+ type: "command";
1607
+ id: string;
1608
+ pricing: {
1609
+ credits_per_call: number;
1610
+ credits_per_minute?: number | undefined;
1611
+ free_tier?: number | undefined;
1612
+ };
1613
+ command: string;
1614
+ output_type: "text" | "json" | "file";
1615
+ timeout_ms?: number | undefined;
1616
+ allowed_commands?: string[] | undefined;
1617
+ working_dir?: string | undefined;
1618
+ }>, z.ZodObject<{
1619
+ id: z.ZodString;
1620
+ type: z.ZodLiteral<"conductor">;
1621
+ name: z.ZodString;
1622
+ conductor_skill: z.ZodEnum<["orchestrate", "plan"]>;
1623
+ pricing: z.ZodObject<{
1624
+ credits_per_call: z.ZodNumber;
1625
+ credits_per_minute: z.ZodOptional<z.ZodNumber>;
1626
+ free_tier: z.ZodOptional<z.ZodNumber>;
1627
+ }, "strip", z.ZodTypeAny, {
1628
+ credits_per_call: number;
1629
+ credits_per_minute?: number | undefined;
1630
+ free_tier?: number | undefined;
1631
+ }, {
1632
+ credits_per_call: number;
1633
+ credits_per_minute?: number | undefined;
1634
+ free_tier?: number | undefined;
1635
+ }>;
1636
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1637
+ }, "strip", z.ZodTypeAny, {
1638
+ name: string;
1639
+ type: "conductor";
1640
+ id: string;
1641
+ pricing: {
1642
+ credits_per_call: number;
1643
+ credits_per_minute?: number | undefined;
1644
+ free_tier?: number | undefined;
1645
+ };
1646
+ conductor_skill: "orchestrate" | "plan";
1647
+ timeout_ms?: number | undefined;
1648
+ }, {
1649
+ name: string;
1650
+ type: "conductor";
1651
+ id: string;
1652
+ pricing: {
1653
+ credits_per_call: number;
1654
+ credits_per_minute?: number | undefined;
1655
+ free_tier?: number | undefined;
1656
+ };
1657
+ conductor_skill: "orchestrate" | "plan";
1658
+ timeout_ms?: number | undefined;
1659
+ }>]>, "many">;
1660
+ }, "strip", z.ZodTypeAny, {
1661
+ skills: ({
1662
+ name: string;
1663
+ type: "api";
1664
+ id: string;
1665
+ pricing: {
1666
+ credits_per_call: number;
1667
+ credits_per_minute?: number | undefined;
1668
+ free_tier?: number | undefined;
1669
+ };
1670
+ endpoint: string;
1671
+ method: "GET" | "POST" | "PUT" | "DELETE";
1672
+ input_mapping: Record<string, string>;
1673
+ output_mapping: Record<string, string>;
1674
+ timeout_ms: number;
1675
+ retries: number;
1676
+ provider?: string | undefined;
1677
+ auth?: {
1678
+ type: "bearer";
1679
+ token: string;
1680
+ } | {
1681
+ type: "apikey";
1682
+ key: string;
1683
+ header: string;
1684
+ } | {
1685
+ type: "basic";
1686
+ username: string;
1687
+ password: string;
1688
+ } | undefined;
1689
+ } | {
1690
+ name: string;
1691
+ type: "pipeline";
1692
+ id: string;
1693
+ pricing: {
1694
+ credits_per_call: number;
1695
+ credits_per_minute?: number | undefined;
1696
+ free_tier?: number | undefined;
1697
+ };
1698
+ steps: ({
1699
+ input_mapping: Record<string, string>;
1700
+ skill_id: string;
1701
+ } | {
1702
+ input_mapping: Record<string, string>;
1703
+ command: string;
1704
+ })[];
1705
+ timeout_ms?: number | undefined;
1706
+ } | {
1707
+ name: string;
1708
+ type: "openclaw";
1709
+ id: string;
1710
+ pricing: {
1711
+ credits_per_call: number;
1712
+ credits_per_minute?: number | undefined;
1713
+ free_tier?: number | undefined;
1714
+ };
1715
+ agent_name: string;
1716
+ channel: "telegram" | "webhook" | "process";
1717
+ timeout_ms?: number | undefined;
1718
+ } | {
1719
+ name: string;
1720
+ type: "command";
1721
+ id: string;
1722
+ pricing: {
1723
+ credits_per_call: number;
1724
+ credits_per_minute?: number | undefined;
1725
+ free_tier?: number | undefined;
1726
+ };
1727
+ timeout_ms: number;
1728
+ command: string;
1729
+ output_type: "text" | "json" | "file";
1730
+ allowed_commands?: string[] | undefined;
1731
+ working_dir?: string | undefined;
1732
+ } | {
1733
+ name: string;
1734
+ type: "conductor";
1735
+ id: string;
1736
+ pricing: {
1737
+ credits_per_call: number;
1738
+ credits_per_minute?: number | undefined;
1739
+ free_tier?: number | undefined;
1740
+ };
1741
+ conductor_skill: "orchestrate" | "plan";
1742
+ timeout_ms?: number | undefined;
1743
+ })[];
1744
+ }, {
1745
+ skills: ({
1746
+ name: string;
1747
+ type: "api";
1748
+ id: string;
1749
+ pricing: {
1750
+ credits_per_call: number;
1751
+ credits_per_minute?: number | undefined;
1752
+ free_tier?: number | undefined;
1753
+ };
1754
+ endpoint: string;
1755
+ method: "GET" | "POST" | "PUT" | "DELETE";
1756
+ provider?: string | undefined;
1757
+ auth?: {
1758
+ type: "bearer";
1759
+ token: string;
1760
+ } | {
1761
+ type: "apikey";
1762
+ key: string;
1763
+ header?: string | undefined;
1764
+ } | {
1765
+ type: "basic";
1766
+ username: string;
1767
+ password: string;
1768
+ } | undefined;
1769
+ input_mapping?: Record<string, string> | undefined;
1770
+ output_mapping?: Record<string, string> | undefined;
1771
+ timeout_ms?: number | undefined;
1772
+ retries?: number | undefined;
1773
+ } | {
1774
+ name: string;
1775
+ type: "pipeline";
1776
+ id: string;
1777
+ pricing: {
1778
+ credits_per_call: number;
1779
+ credits_per_minute?: number | undefined;
1780
+ free_tier?: number | undefined;
1781
+ };
1782
+ steps: ({
1783
+ skill_id: string;
1784
+ input_mapping?: Record<string, string> | undefined;
1785
+ } | {
1786
+ command: string;
1787
+ input_mapping?: Record<string, string> | undefined;
1788
+ })[];
1789
+ timeout_ms?: number | undefined;
1790
+ } | {
1791
+ name: string;
1792
+ type: "openclaw";
1793
+ id: string;
1794
+ pricing: {
1795
+ credits_per_call: number;
1796
+ credits_per_minute?: number | undefined;
1797
+ free_tier?: number | undefined;
1798
+ };
1799
+ agent_name: string;
1800
+ channel: "telegram" | "webhook" | "process";
1801
+ timeout_ms?: number | undefined;
1802
+ } | {
1803
+ name: string;
1804
+ type: "command";
1805
+ id: string;
1806
+ pricing: {
1807
+ credits_per_call: number;
1808
+ credits_per_minute?: number | undefined;
1809
+ free_tier?: number | undefined;
1810
+ };
1811
+ command: string;
1812
+ output_type: "text" | "json" | "file";
1813
+ timeout_ms?: number | undefined;
1814
+ allowed_commands?: string[] | undefined;
1815
+ working_dir?: string | undefined;
1816
+ } | {
1817
+ name: string;
1818
+ type: "conductor";
1819
+ id: string;
1820
+ pricing: {
1821
+ credits_per_call: number;
1822
+ credits_per_minute?: number | undefined;
1823
+ free_tier?: number | undefined;
1824
+ };
1825
+ conductor_skill: "orchestrate" | "plan";
1826
+ timeout_ms?: number | undefined;
1827
+ })[];
1828
+ }>;
1829
+ /** TypeScript type for any skill config entry */
1830
+ type SkillConfig = z.infer<typeof SkillConfigSchema>;
1831
+ /** TypeScript type for an API-mode skill config */
1832
+ type ApiSkillConfig = z.infer<typeof ApiSkillConfigSchema>;
1833
+ /** TypeScript type for a pipeline-mode skill config */
1834
+ type PipelineSkillConfig = z.infer<typeof PipelineSkillConfigSchema>;
1835
+ /** TypeScript type for an OpenClaw-mode skill config */
1836
+ type OpenClawSkillConfig = z.infer<typeof OpenClawSkillConfigSchema>;
1837
+ /** TypeScript type for a command-mode skill config */
1838
+ type CommandSkillConfig = z.infer<typeof CommandSkillConfigSchema>;
1839
+ /** TypeScript type for a conductor-mode skill config */
1840
+ type ConductorSkillConfig = z.infer<typeof ConductorSkillConfigSchema>;
1841
+ /**
1842
+ * Expands `${VAR_NAME}` patterns in a string using process.env.
1843
+ *
1844
+ * Only matches env-var-style names: uppercase letters, digits, and underscores
1845
+ * (e.g. `${API_KEY}`, `${MY_TOKEN_123}`). Patterns containing dots or lowercase
1846
+ * letters (e.g. `${params.text}`, `${prev.result}`) are left untouched — those
1847
+ * are runtime interpolation placeholders handled by the interpolation engine.
1848
+ *
1849
+ * @param value - The string potentially containing `${ENV_VAR}` references.
1850
+ * @returns The string with env var references replaced; runtime placeholders preserved.
1851
+ * @throws Error if a referenced env var is not defined.
1852
+ */
1853
+ declare function expandEnvVars(value: string): string;
1854
+ /**
1855
+ * Parses a skills.yaml file content string into a typed SkillConfig array.
1856
+ *
1857
+ * 1. Parses YAML string into a raw object (throws on invalid YAML).
1858
+ * 2. Expands all `${ENV_VAR}` references in string values using process.env.
1859
+ * 3. Validates the result with the SkillsFileSchema Zod schema (throws ZodError on invalid shape).
1860
+ *
1861
+ * @param yamlContent - Raw YAML string (contents of skills.yaml).
1862
+ * @returns Parsed and validated array of SkillConfig objects.
1863
+ * @throws YAMLException if YAML syntax is invalid.
1864
+ * @throws ZodError if schema validation fails.
1865
+ * @throws Error if any referenced environment variable is not defined.
1866
+ */
1867
+ declare function parseSkillsFile(yamlContent: string): SkillConfig[];
1868
+
1869
+ /**
1870
+ * Result returned by SkillExecutor.execute() for every invocation.
1871
+ * Always includes timing data regardless of success or failure.
1872
+ */
1873
+ interface ExecutionResult {
1874
+ /** Whether the skill executed successfully. */
1875
+ success: boolean;
1876
+ /** The output produced by the skill on success. */
1877
+ result?: unknown;
1878
+ /** Error message if success is false. */
1879
+ error?: string;
1880
+ /** Wall-clock execution time in milliseconds. */
1881
+ latency_ms: number;
1882
+ }
1883
+ /**
1884
+ * Interface that all executor mode implementations must satisfy.
1885
+ * Each mode handles one skill type: 'api' | 'pipeline' | 'openclaw' | 'command'.
1886
+ */
1887
+ interface ExecutorMode {
1888
+ /**
1889
+ * Execute a skill with the given config and input parameters.
1890
+ *
1891
+ * @param config - The validated SkillConfig for this skill.
1892
+ * @param params - The input parameters passed by the caller.
1893
+ * @returns A partial ExecutionResult without latency_ms (added by SkillExecutor).
1894
+ */
1895
+ execute(config: SkillConfig, params: Record<string, unknown>): Promise<Omit<ExecutionResult, 'latency_ms'>>;
1896
+ }
1897
+ /**
1898
+ * Central dispatcher that routes skill execution requests to the appropriate
1899
+ * executor mode based on the skill's `type` field.
1900
+ *
1901
+ * Usage:
1902
+ * ```ts
1903
+ * const executor = createSkillExecutor(configs, modes);
1904
+ * const result = await executor.execute('tts-skill', { text: 'hello' });
1905
+ * ```
1906
+ */
1907
+ declare class SkillExecutor {
1908
+ private readonly skillMap;
1909
+ private readonly modeMap;
1910
+ /**
1911
+ * @param configs - Parsed SkillConfig array (from parseSkillsFile).
1912
+ * @param modes - Map from skill type string to its executor implementation.
1913
+ */
1914
+ constructor(configs: SkillConfig[], modes: Map<string, ExecutorMode>);
1915
+ /**
1916
+ * Execute a skill by ID with the given input parameters.
1917
+ *
1918
+ * Dispatch order:
1919
+ * 1. Look up skill config by skillId.
1920
+ * 2. Find executor mode by config.type.
1921
+ * 3. Invoke mode.execute(), wrap with latency timing.
1922
+ * 4. Catch any thrown errors and return as ExecutionResult with success:false.
1923
+ *
1924
+ * @param skillId - The ID of the skill to execute.
1925
+ * @param params - Input parameters for the skill.
1926
+ * @returns ExecutionResult including success, result/error, and latency_ms.
1927
+ */
1928
+ execute(skillId: string, params: Record<string, unknown>): Promise<ExecutionResult>;
1929
+ /**
1930
+ * Returns the IDs of all registered skills.
1931
+ *
1932
+ * @returns Array of skill ID strings.
1933
+ */
1934
+ listSkills(): string[];
1935
+ /**
1936
+ * Returns the SkillConfig for a given skill ID, or undefined if not found.
1937
+ *
1938
+ * @param skillId - The skill ID to look up.
1939
+ * @returns The SkillConfig or undefined.
1940
+ */
1941
+ getSkillConfig(skillId: string): SkillConfig | undefined;
1942
+ }
1943
+ /**
1944
+ * Factory function to create a SkillExecutor with the given configs and mode implementations.
1945
+ *
1946
+ * @param configs - Array of parsed SkillConfig objects.
1947
+ * @param modes - Map from type key to ExecutorMode implementation.
1948
+ * @returns A configured SkillExecutor instance.
1949
+ */
1950
+ declare function createSkillExecutor(configs: SkillConfig[], modes: Map<string, ExecutorMode>): SkillExecutor;
1951
+
1952
+ /**
1953
+ * Options for creating a gateway server.
1954
+ */
1955
+ interface GatewayOptions {
1956
+ /** Port to listen on. Default 7700. */
1957
+ port?: number;
1958
+ /** Open registry database instance. */
1959
+ registryDb: Database.Database;
1960
+ /** Open credit database instance. */
1961
+ creditDb: Database.Database;
1962
+ /** Valid bearer tokens for auth. */
1963
+ tokens: string[];
1964
+ /** URL of the local capability handler. */
1965
+ handlerUrl: string;
1966
+ /** Request timeout in ms. Default 30000. */
1967
+ timeoutMs?: number;
1968
+ /** Disable logging (useful for tests). */
1969
+ silent?: boolean;
1970
+ /**
1971
+ * Optional SkillExecutor instance.
1972
+ * When provided, skill execution is dispatched through SkillExecutor.execute()
1973
+ * instead of forwarding via fetch(handlerUrl).
1974
+ * When absent, the original handlerUrl fetch path is used (backward compat).
1975
+ */
1976
+ skillExecutor?: SkillExecutor;
1977
+ }
1978
+ /**
1979
+ * Creates a Fastify gateway server for agent-to-agent communication.
1980
+ * Registers /health (unauthenticated) and /rpc (token-authenticated) endpoints.
1981
+ * Returns a configured Fastify instance (call .ready() before using inject,
1982
+ * or .listen() to start accepting connections).
1983
+ *
1984
+ * @param opts - Gateway configuration options.
1985
+ * @returns Configured Fastify instance (not yet listening).
1986
+ */
1987
+ declare function createGatewayServer(opts: GatewayOptions): FastifyInstance;
1988
+
1989
+ /**
1990
+ * Extracts a nested value from an object using dot-notation path.
1991
+ * e.g. `extractByPath({ data: { audio: 'abc' } }, 'data.audio')` returns `'abc'`
1992
+ *
1993
+ * When path starts with "response.", the "response" prefix is stripped
1994
+ * (the mapping convention uses "response.xxx" but the actual response body
1995
+ * is the root object passed in).
1996
+ *
1997
+ * @param obj - The object to traverse.
1998
+ * @param dotPath - Dot-separated property path.
1999
+ * @returns The value at the path, or `undefined` if any step is missing.
2000
+ */
2001
+ declare function extractByPath(obj: unknown, dotPath: string): unknown;
2002
+ /**
2003
+ * Builds the Authorization / API-key headers for the configured auth type.
2004
+ *
2005
+ * @param auth - The auth config from ApiSkillConfig.
2006
+ * @returns A plain object of header name → value entries.
2007
+ */
2008
+ declare function buildAuthHeaders(auth: ApiSkillConfig['auth']): Record<string, string>;
2009
+ /**
2010
+ * Routes a set of input parameters to their respective destination buckets
2011
+ * (body, query, path, header) based on the `input_mapping` config.
2012
+ *
2013
+ * @param params - The input parameters passed to execute().
2014
+ * @param mapping - The `input_mapping` record from ApiSkillConfig.
2015
+ * @returns Four buckets: body, query, pathParams, headers.
2016
+ */
2017
+ declare function applyInputMapping(params: Record<string, unknown>, mapping: Record<string, string>): {
2018
+ body: Record<string, unknown>;
2019
+ query: Record<string, string>;
2020
+ pathParams: Record<string, string>;
2021
+ headers: Record<string, string>;
2022
+ };
2023
+ /**
2024
+ * API Executor (Mode A) — config-driven REST API calls.
2025
+ *
2026
+ * Supports:
2027
+ * - All 4 HTTP methods: GET, POST, PUT, DELETE
2028
+ * - Input mapping to body, query string, path params, or request headers
2029
+ * - Auth: bearer token, API key header, HTTP Basic
2030
+ * - Output mapping via dot-notation extraction from JSON response
2031
+ * - Retry with exponential backoff on 429/500/503
2032
+ * - Timeout via AbortController
2033
+ *
2034
+ * Implements {@link ExecutorMode} — registered under the `"api"` type key.
2035
+ */
2036
+ declare class ApiExecutor implements ExecutorMode {
2037
+ /**
2038
+ * Execute an API call described by the given skill config.
2039
+ *
2040
+ * @param config - The validated SkillConfig (must be ApiSkillConfig).
2041
+ * @param params - Input parameters to map to the HTTP request.
2042
+ * @returns Partial ExecutionResult (without latency_ms — added by SkillExecutor).
2043
+ */
2044
+ execute(config: SkillConfig, params: Record<string, unknown>): Promise<Omit<ExecutionResult, 'latency_ms'>>;
2045
+ }
2046
+
2047
+ /**
2048
+ * Executor mode for pipeline-type skills (Mode B).
2049
+ *
2050
+ * Chains multiple skill invocations or shell commands sequentially.
2051
+ * Each step can reference previous step outputs via `${prev.result.*}` or
2052
+ * `${steps[N].result.*}` in its `input_mapping` values.
2053
+ *
2054
+ * Usage:
2055
+ * ```ts
2056
+ * const pipelineExecutor = new PipelineExecutor(skillExecutor);
2057
+ * modes.set('pipeline', pipelineExecutor);
2058
+ * ```
2059
+ */
2060
+ declare class PipelineExecutor implements ExecutorMode {
2061
+ private readonly skillExecutor;
2062
+ /**
2063
+ * @param skillExecutor - The parent SkillExecutor used to dispatch sub-skill calls.
2064
+ */
2065
+ constructor(skillExecutor: SkillExecutor);
2066
+ /**
2067
+ * Execute a pipeline skill config sequentially.
2068
+ *
2069
+ * Algorithm:
2070
+ * 1. Initialise context: { params, steps: [], prev: { result: null } }
2071
+ * 2. For each step:
2072
+ * a. Resolve input_mapping keys against current context via interpolateObject.
2073
+ * b. If step has `skill_id`: dispatch via skillExecutor.execute(). On failure → stop.
2074
+ * c. If step has `command`: interpolate command string, run via exec(). On non-zero exit → stop.
2075
+ * d. Store step result in context.steps[i] and context.prev.
2076
+ * 3. Return success with final step result (or null for empty pipeline).
2077
+ *
2078
+ * @param config - The PipelineSkillConfig for this skill.
2079
+ * @param params - Input parameters from the caller.
2080
+ * @returns Partial ExecutionResult (without latency_ms — added by SkillExecutor wrapper).
2081
+ */
2082
+ execute(config: SkillConfig, params: Record<string, unknown>): Promise<Omit<ExecutionResult, 'latency_ms'>>;
2083
+ }
2084
+
2085
+ /**
2086
+ * OpenClaw Bridge — ExecutorMode C.
2087
+ *
2088
+ * Forwards AgentBnB skill execution requests to an OpenClaw agent via one of
2089
+ * three configurable channels:
2090
+ * - `webhook` — HTTP POST to OpenClaw agent's local webhook endpoint
2091
+ * - `process` — spawn `openclaw run <agent_name>` subprocess
2092
+ * - `telegram` — fire-and-forget POST to Telegram Bot API
2093
+ *
2094
+ * Implements the {@link ExecutorMode} interface so it can be registered into
2095
+ * a {@link SkillExecutor} mode map under the key `'openclaw'`.
2096
+ *
2097
+ * @example
2098
+ * ```ts
2099
+ * const modes = new Map([['openclaw', new OpenClawBridge()]]);
2100
+ * const executor = createSkillExecutor(configs, modes);
2101
+ * ```
2102
+ */
2103
+ declare class OpenClawBridge implements ExecutorMode {
2104
+ /**
2105
+ * Execute a skill with the given config and input parameters.
2106
+ *
2107
+ * @param config - The SkillConfig for this skill (must be type 'openclaw').
2108
+ * @param params - Input parameters passed by the caller.
2109
+ * @returns Partial ExecutionResult without latency_ms.
2110
+ */
2111
+ execute(config: SkillConfig, params: Record<string, unknown>): Promise<Omit<ExecutionResult, 'latency_ms'>>;
2112
+ }
2113
+
2114
+ /**
2115
+ * Implements the Command Executor mode (Mode D) for the SkillExecutor.
2116
+ *
2117
+ * Wraps local shell commands as skills with:
2118
+ * - Parameter substitution via `${params.x}` interpolation
2119
+ * - Three output types: text (raw stdout), json (parsed), file (path from stdout)
2120
+ * - Security allowlist via `allowed_commands` (base command checked against list)
2121
+ * - Configurable timeout and working directory
2122
+ */
2123
+ declare class CommandExecutor implements ExecutorMode {
2124
+ /**
2125
+ * Execute a command skill with the provided parameters.
2126
+ *
2127
+ * Steps:
2128
+ * 1. Security check: base command must be in `allowed_commands` if set.
2129
+ * 2. Interpolate `config.command` using `{ params }` context.
2130
+ * 3. Run via `child_process.exec` with timeout and cwd.
2131
+ * 4. Parse stdout based on `output_type`: text | json | file.
2132
+ *
2133
+ * @param config - Validated CommandSkillConfig.
2134
+ * @param params - Input parameters passed by the caller.
2135
+ * @returns Partial ExecutionResult (without latency_ms).
2136
+ */
2137
+ execute(config: SkillConfig, params: Record<string, unknown>): Promise<Omit<ExecutionResult, 'latency_ms'>>;
2138
+ }
2139
+
2140
+ /**
2141
+ * Resolves a dot-path expression (optionally with array index notation) against an object.
2142
+ *
2143
+ * Examples:
2144
+ * - "name" → obj.name
2145
+ * - "a.b.c" → obj.a.b.c
2146
+ * - "steps[0].result" → obj.steps[0].result
2147
+ *
2148
+ * @param obj - The root object to traverse.
2149
+ * @param path - A dot-separated path string, supporting `[N]` array index notation.
2150
+ * @returns The resolved value, or `undefined` if any segment is missing.
2151
+ */
2152
+ declare function resolvePath(obj: unknown, path: string): unknown;
2153
+ /**
2154
+ * Interpolates `${expression}` placeholders in a template string against a context object.
2155
+ *
2156
+ * - Resolves dot-path and array-index expressions against `context`.
2157
+ * - Object values are JSON.stringify'd.
2158
+ * - Missing paths resolve to empty string.
2159
+ * - Non-string (number, boolean, etc.) values are converted via String().
2160
+ *
2161
+ * @param template - A string containing zero or more `${...}` expressions.
2162
+ * @param context - The object to resolve expressions against.
2163
+ * @returns The interpolated string.
2164
+ */
2165
+ declare function interpolate(template: string, context: Record<string, unknown>): string;
2166
+ /**
2167
+ * Deep-walks an object and interpolates all string leaf values using the given context.
2168
+ *
2169
+ * Handles nested objects and arrays recursively. Non-string leaf values are preserved
2170
+ * unchanged.
2171
+ *
2172
+ * @param obj - The object whose string values should be interpolated.
2173
+ * @param context - The interpolation context (same as `interpolate`).
2174
+ * @returns A new object with all string leaves interpolated.
2175
+ */
2176
+ declare function interpolateObject(obj: Record<string, unknown>, context: Record<string, unknown>): Record<string, unknown>;
2177
+
2178
+ /**
2179
+ * Shared types for the Conductor module — task decomposition, matching, budgeting, and orchestration.
2180
+ */
2181
+ /**
2182
+ * A single sub-task produced by the TaskDecomposer.
2183
+ * Represents one step in a multi-step orchestration plan.
2184
+ */
2185
+ interface SubTask {
2186
+ /** Unique identifier for this sub-task (UUID). */
2187
+ id: string;
2188
+ /** Human-readable description of what this step does. */
2189
+ description: string;
2190
+ /** The capability category required to execute this step (e.g. 'tts', 'text_gen'). */
2191
+ required_capability: string;
2192
+ /** Parameters to pass to the executing agent's skill. */
2193
+ params: Record<string, unknown>;
2194
+ /** IDs of sub-tasks that must complete before this one can start. */
2195
+ depends_on: string[];
2196
+ /** Estimated credit cost for this step. */
2197
+ estimated_credits: number;
2198
+ }
2199
+ /**
2200
+ * Result of matching a SubTask to an available agent/skill.
2201
+ */
2202
+ interface MatchResult {
2203
+ /** ID of the sub-task this match is for. */
2204
+ subtask_id: string;
2205
+ /** Owner/agent ID of the selected peer. */
2206
+ selected_agent: string;
2207
+ /** Skill ID on the selected agent's card. */
2208
+ selected_skill: string;
2209
+ /** Match quality score (0-1). */
2210
+ score: number;
2211
+ /** Negotiated credit cost. */
2212
+ credits: number;
2213
+ /** Alternative matches considered. */
2214
+ alternatives: Array<{
2215
+ agent: string;
2216
+ skill: string;
2217
+ score: number;
2218
+ credits: number;
2219
+ }>;
2220
+ }
2221
+ /**
2222
+ * Budget constraints for an orchestration run.
2223
+ */
2224
+ interface ExecutionBudget {
2225
+ /** Sum of all sub-task estimated_credits. */
2226
+ estimated_total: number;
2227
+ /** Hard ceiling — abort if exceeded. */
2228
+ max_budget: number;
2229
+ /** Credits retained by the Conductor for coordination. */
2230
+ orchestration_fee: number;
2231
+ /** Per-task actual spending tracker. */
2232
+ per_task_spending: Map<string, number>;
2233
+ /** Whether human/agent approval is needed before execution. */
2234
+ requires_approval: boolean;
2235
+ }
2236
+ /**
2237
+ * Final result of a completed orchestration.
2238
+ */
2239
+ interface OrchestrationResult {
2240
+ /** Whether all sub-tasks completed successfully. */
2241
+ success: boolean;
2242
+ /** Per-subtask output data, keyed by sub-task ID. */
2243
+ results: Map<string, unknown>;
2244
+ /** Total credits spent across all sub-tasks + orchestration fee. */
2245
+ total_credits: number;
2246
+ /** Wall-clock time from start to finish. */
2247
+ latency_ms: number;
2248
+ /** Error messages for failed sub-tasks. */
2249
+ errors?: string[];
2250
+ }
2251
+
2252
+ /**
2253
+ * Template step definition used internally to generate SubTask instances.
2254
+ */
2255
+ interface TemplateStep {
2256
+ description: string;
2257
+ required_capability: string;
2258
+ estimated_credits: number;
2259
+ /**
2260
+ * Dependency indices — references to other steps in the same template (0-based).
2261
+ * Converted to UUIDs at decomposition time.
2262
+ */
2263
+ depends_on_indices: number[];
2264
+ }
2265
+ /**
2266
+ * A decomposition template: keyword triggers + ordered steps.
2267
+ */
2268
+ interface Template {
2269
+ keywords: readonly string[];
2270
+ steps: readonly TemplateStep[];
2271
+ }
2272
+ /**
2273
+ * Hardcoded decomposition templates for MVP.
2274
+ *
2275
+ * Each template maps keywords to a DAG of steps.
2276
+ * Future versions will replace this with LLM-driven decomposition.
2277
+ */
2278
+ declare const TEMPLATES: Readonly<Record<string, Template>>;
2279
+ /**
2280
+ * Decomposes a natural-language task description into an ordered array of SubTasks
2281
+ * using hardcoded keyword-matching templates.
2282
+ *
2283
+ * Returns the first matching template's steps as SubTask[], or an empty array
2284
+ * if no template matches.
2285
+ *
2286
+ * @param task - Natural language task description.
2287
+ * @param _availableCapabilities - Reserved for future filtering (unused in MVP).
2288
+ * @returns Array of SubTask objects forming a dependency DAG.
2289
+ */
2290
+ declare function decompose(task: string, _availableCapabilities?: string[]): SubTask[];
2291
+
2292
+ /**
2293
+ * CapabilityMatcher — finds the best agent for each sub-task using registry search + peer scoring.
2294
+ *
2295
+ * Wraps the existing searchCards() for card discovery and scorePeers() for ranked selection
2296
+ * with self-exclusion. Returns alternatives for failover when the primary agent fails.
2297
+ */
2298
+
2299
+ /**
2300
+ * Options for matchSubTasks.
2301
+ */
2302
+ interface MatchOptions {
2303
+ /** Open SQLite database with registry tables. */
2304
+ db: Database.Database;
2305
+ /** Sub-tasks to find agents for. */
2306
+ subtasks: SubTask[];
2307
+ /** Owner ID of the conductor agent — excluded from matches (self-exclusion). */
2308
+ conductorOwner: string;
2309
+ }
2310
+ /**
2311
+ * Finds the best agent for each sub-task using registry FTS search and peer scoring.
2312
+ *
2313
+ * For each sub-task:
2314
+ * 1. Searches cards via FTS5 with `{ online: true }` filter
2315
+ * 2. Builds Candidate[] from both v1.0 (card-level pricing) and v2.0 (skill-level pricing) cards
2316
+ * 3. Scores and ranks candidates via scorePeers() with self-exclusion
2317
+ * 4. Selects the top scorer as the primary agent and up to 2 alternatives
2318
+ *
2319
+ * Sub-tasks with no matching cards return a MatchResult with empty selected_agent and score 0.
2320
+ *
2321
+ * @param opts - Match configuration including database, subtasks, and conductor owner ID.
2322
+ * @returns MatchResult[] in the same order as the input subtasks.
2323
+ */
2324
+ declare function matchSubTasks(opts: MatchOptions): MatchResult[];
2325
+
2326
+ /**
2327
+ * Configuration for credit budget enforcement.
2328
+ * Controls how many credits are kept in reserve and unavailable for auto-spending.
2329
+ */
2330
+ interface BudgetConfig {
2331
+ /** Minimum credits to keep in reserve. Auto-requests cannot reduce balance below this floor. Default: 20. */
2332
+ reserve_credits: number;
2333
+ }
2334
+ /**
2335
+ * Enforces credit reserve floors to prevent auto-request from draining balances to zero.
2336
+ *
2337
+ * Phase 7 auto-request MUST call canSpend() before every escrow hold.
2338
+ * Without reserve enforcement, auto-request can drain credits to zero,
2339
+ * isolating the agent from the network.
2340
+ *
2341
+ * @example
2342
+ * ```typescript
2343
+ * const budget = new BudgetManager(creditDb, config.owner, config.budget);
2344
+ * if (!budget.canSpend(card.pricing.credits_per_call)) {
2345
+ * throw new AgentBnBError('Insufficient credits — reserve floor would be breached');
2346
+ * }
2347
+ * ```
2348
+ */
2349
+ declare class BudgetManager {
2350
+ private readonly creditDb;
2351
+ private readonly owner;
2352
+ private readonly config;
2353
+ /**
2354
+ * Creates a new BudgetManager.
2355
+ *
2356
+ * @param creditDb - The credit SQLite database instance.
2357
+ * @param owner - Agent owner identifier.
2358
+ * @param config - Budget configuration. Defaults to DEFAULT_BUDGET_CONFIG (20 credit reserve).
2359
+ */
2360
+ constructor(creditDb: Database.Database, owner: string, config?: BudgetConfig);
2361
+ /**
2362
+ * Returns the number of credits available for spending.
2363
+ * Computed as: max(0, balance - reserve_credits).
2364
+ * Always returns a non-negative number — never goes below zero.
2365
+ *
2366
+ * @returns Available credits (balance minus reserve, floored at 0).
2367
+ */
2368
+ availableCredits(): number;
2369
+ /**
2370
+ * Returns true if spending `amount` credits is permitted by budget rules.
2371
+ *
2372
+ * Rules:
2373
+ * - Zero-cost calls (amount <= 0) always return true.
2374
+ * - Any positive amount requires availableCredits() >= amount.
2375
+ * - If balance is at or below the reserve floor, all positive-cost calls return false.
2376
+ *
2377
+ * @param amount - Number of credits to spend.
2378
+ * @returns true if the spend is allowed, false if it would breach the reserve floor.
2379
+ */
2380
+ canSpend(amount: number): boolean;
2381
+ }
2382
+
2383
+ /**
2384
+ * BudgetController — pre-calculates orchestration cost and enforces spending limits.
2385
+ *
2386
+ * Extends BudgetManager to add orchestration-specific logic: fee calculation,
2387
+ * approval gating when estimated cost exceeds max budget, and per-task spending tracking.
2388
+ */
2389
+
2390
+ /** Credits retained by the Conductor for coordination overhead. */
2391
+ declare const ORCHESTRATION_FEE = 5;
2392
+ /**
2393
+ * Controls budget enforcement for orchestration runs.
2394
+ *
2395
+ * Wraps BudgetManager and adds:
2396
+ * - Pre-calculation of total cost (sub-task credits + orchestration fee)
2397
+ * - Approval gating when estimated total exceeds max budget
2398
+ * - Reserve floor enforcement via BudgetManager.canSpend()
2399
+ *
2400
+ * @example
2401
+ * ```typescript
2402
+ * const controller = new BudgetController(budgetManager, 100);
2403
+ * const budget = controller.calculateBudget(matchResults);
2404
+ * if (controller.canExecute(budget)) {
2405
+ * // proceed with orchestration
2406
+ * }
2407
+ * ```
2408
+ */
2409
+ declare class BudgetController {
2410
+ private readonly budgetManager;
2411
+ private readonly maxBudget;
2412
+ /**
2413
+ * Creates a new BudgetController.
2414
+ *
2415
+ * @param budgetManager - Underlying BudgetManager for reserve floor enforcement.
2416
+ * @param maxBudget - Hard ceiling for the orchestration run.
2417
+ */
2418
+ constructor(budgetManager: BudgetManager, maxBudget: number);
2419
+ /**
2420
+ * Pre-calculates the total budget for an orchestration run.
2421
+ *
2422
+ * Sums all matched sub-task credits, adds the orchestration fee,
2423
+ * and determines whether approval is required (estimated > max).
2424
+ *
2425
+ * @param matches - MatchResult[] from the CapabilityMatcher.
2426
+ * @returns An ExecutionBudget with cost breakdown and approval status.
2427
+ */
2428
+ calculateBudget(matches: MatchResult[]): ExecutionBudget;
2429
+ /**
2430
+ * Checks whether orchestration can proceed without explicit approval.
2431
+ *
2432
+ * Returns true only when:
2433
+ * 1. The budget does NOT require approval (estimated_total <= max_budget)
2434
+ * 2. The BudgetManager confirms sufficient credits (respecting reserve floor)
2435
+ *
2436
+ * @param budget - ExecutionBudget from calculateBudget().
2437
+ * @returns true if execution can proceed autonomously.
2438
+ */
2439
+ canExecute(budget: ExecutionBudget): boolean;
2440
+ /**
2441
+ * Checks budget after explicit user/agent approval.
2442
+ *
2443
+ * Ignores the requires_approval flag — used when the caller has already
2444
+ * obtained explicit approval for the over-budget orchestration.
2445
+ * Still enforces the reserve floor via BudgetManager.canSpend().
2446
+ *
2447
+ * @param budget - ExecutionBudget from calculateBudget().
2448
+ * @returns true if the agent has sufficient credits (reserve floor check only).
2449
+ */
2450
+ approveAndCheck(budget: ExecutionBudget): boolean;
2451
+ }
2452
+
2453
+ /** Fixed owner identifier for the Conductor agent. */
2454
+ declare const CONDUCTOR_OWNER = "agentbnb-conductor";
2455
+ /**
2456
+ * Builds the Conductor's CapabilityCardV2.
2457
+ *
2458
+ * The Conductor exposes two skills:
2459
+ * - `orchestrate` (5 cr): Decomposes and executes multi-agent tasks
2460
+ * - `plan` (1 cr): Returns an execution plan with cost estimate only
2461
+ *
2462
+ * The returned card is validated against CapabilityCardV2Schema before return.
2463
+ *
2464
+ * @returns A valid CapabilityCardV2 for the Conductor.
2465
+ */
2466
+ declare function buildConductorCard(): CapabilityCardV2;
2467
+ /**
2468
+ * Registers the Conductor card in the given SQLite database.
2469
+ *
2470
+ * Idempotent: uses INSERT OR REPLACE to handle repeated calls gracefully.
2471
+ * Stores the v2.0 card as JSON in the same `capability_cards` table used
2472
+ * by the registry, following the same (id, owner, data, created_at, updated_at) schema.
2473
+ *
2474
+ * @param db - Open better-sqlite3 database instance (with migrations applied).
2475
+ * @returns The registered CapabilityCardV2.
2476
+ */
2477
+ declare function registerConductorCard(db: Database.Database): CapabilityCardV2;
2478
+
2479
+ /**
2480
+ * PipelineOrchestrator — DAG-based remote execution engine for the Conductor.
2481
+ *
2482
+ * Executes sub-tasks across remote agents via the Gateway client,
2483
+ * respecting dependency ordering (parallel waves for independent tasks),
2484
+ * output piping between steps, and retry with alternative agents on failure.
2485
+ *
2486
+ * Budget checking is NOT done here — the caller (ConductorMode) handles that.
2487
+ * This module is pure execution.
2488
+ */
2489
+
2490
+ /**
2491
+ * Options for the orchestrate() function.
2492
+ */
2493
+ interface OrchestrateOptions {
2494
+ /** Ordered list of sub-tasks forming a dependency DAG. */
2495
+ subtasks: SubTask[];
2496
+ /** Match results keyed by subtask ID. */
2497
+ matches: Map<string, MatchResult>;
2498
+ /** Bearer token for authenticating with remote agents. */
2499
+ gatewayToken: string;
2500
+ /** Resolves an agent owner to their gateway URL and card ID. */
2501
+ resolveAgentUrl: (agentOwner: string) => {
2502
+ url: string;
2503
+ cardId: string;
2504
+ };
2505
+ /** Per-task timeout in milliseconds. Default 30000. */
2506
+ timeoutMs?: number;
2507
+ /** Maximum budget in credits. If set, aborts remaining tasks when exceeded. */
2508
+ maxBudget?: number;
2509
+ }
2510
+ /**
2511
+ * Executes a DAG of sub-tasks across remote agents via Gateway.
2512
+ *
2513
+ * Execution flow:
2514
+ * 1. Computes execution waves from dependency graph
2515
+ * 2. For each wave, executes all tasks in parallel via Promise.allSettled
2516
+ * 3. Before each task, interpolates params against completed step outputs
2517
+ * 4. On failure, retries with the first alternative agent from MatchResult
2518
+ * 5. Tracks per-task spending and total credits
2519
+ * 6. Optionally enforces a maxBudget ceiling
2520
+ *
2521
+ * @param opts - Orchestration options.
2522
+ * @returns Aggregated orchestration result.
2523
+ */
2524
+ declare function orchestrate(opts: OrchestrateOptions): Promise<OrchestrationResult>;
2525
+
2526
+ /**
2527
+ * ConductorMode — ExecutorMode implementation for Conductor skills.
2528
+ *
2529
+ * Chains TaskDecomposer -> CapabilityMatcher -> BudgetController -> PipelineOrchestrator
2530
+ * to execute multi-agent orchestration pipelines via the SkillExecutor dispatch system.
2531
+ *
2532
+ * Supports two conductor skills:
2533
+ * - `orchestrate`: Full pipeline — decompose, match, budget check, execute, return results.
2534
+ * - `plan`: Planning only — decompose, match, budget check, return plan without executing.
2535
+ */
2536
+
2537
+ /**
2538
+ * Configuration options for ConductorMode.
2539
+ */
2540
+ interface ConductorModeOptions {
2541
+ /** Registry database for card search (FTS5). */
2542
+ db: Database.Database;
2543
+ /** Credit database for budget checks. */
2544
+ creditDb: Database.Database;
2545
+ /** Owner ID of the conductor agent — used for self-exclusion in matching. */
2546
+ conductorOwner: string;
2547
+ /** Bearer token for authenticating with remote agents. */
2548
+ gatewayToken: string;
2549
+ /** Resolves an agent owner to their gateway URL and card ID. */
2550
+ resolveAgentUrl: (owner: string) => {
2551
+ url: string;
2552
+ cardId: string;
2553
+ };
2554
+ /** Maximum budget in credits for orchestration runs. Default 100. */
2555
+ maxBudget?: number;
2556
+ }
2557
+ /**
2558
+ * ExecutorMode implementation for Conductor skills ('orchestrate' and 'plan').
2559
+ *
2560
+ * Dispatches through the full Conductor pipeline:
2561
+ * 1. TaskDecomposer breaks the task into SubTasks
2562
+ * 2. CapabilityMatcher finds agents for each sub-task
2563
+ * 3. BudgetController validates cost against limits
2564
+ * 4. PipelineOrchestrator executes the DAG (orchestrate only)
2565
+ */
2566
+ declare class ConductorMode implements ExecutorMode {
2567
+ private readonly db;
2568
+ private readonly creditDb;
2569
+ private readonly conductorOwner;
2570
+ private readonly gatewayToken;
2571
+ private readonly resolveAgentUrl;
2572
+ private readonly maxBudget;
2573
+ constructor(opts: ConductorModeOptions);
2574
+ /**
2575
+ * Execute a conductor skill with the given config and params.
2576
+ *
2577
+ * @param config - SkillConfig with type 'conductor' and conductor_skill field.
2578
+ * @param params - Must include `task` string.
2579
+ * @returns Execution result without latency_ms (added by SkillExecutor).
2580
+ */
2581
+ execute(config: SkillConfig, params: Record<string, unknown>): Promise<Omit<ExecutionResult, 'latency_ms'>>;
2582
+ }
2583
+
2584
+ /**
2585
+ * Ed25519 keypair as raw DER-encoded Buffers.
2586
+ */
2587
+ interface KeyPair {
2588
+ publicKey: Buffer;
2589
+ privateKey: Buffer;
2590
+ }
2591
+ /**
2592
+ * Generates a new Ed25519 keypair.
2593
+ * Uses Node.js built-in crypto — no external dependencies.
2594
+ *
2595
+ * @returns Object with publicKey and privateKey as DER-encoded Buffers.
2596
+ */
2597
+ declare function generateKeyPair(): KeyPair;
2598
+ /**
2599
+ * Saves an Ed25519 keypair to disk.
2600
+ * Private key is written with mode 0o600 (owner read/write only).
2601
+ *
2602
+ * @param configDir - Directory to write key files into.
2603
+ * @param keys - The keypair to persist.
2604
+ */
2605
+ declare function saveKeyPair(configDir: string, keys: KeyPair): void;
2606
+ /**
2607
+ * Loads an Ed25519 keypair from disk.
2608
+ *
2609
+ * @param configDir - Directory containing private.key and public.key files.
2610
+ * @returns The loaded keypair.
2611
+ * @throws {AgentBnBError} with code 'KEYPAIR_NOT_FOUND' if either key file is missing.
2612
+ */
2613
+ declare function loadKeyPair(configDir: string): KeyPair;
2614
+ /**
2615
+ * Signs escrow receipt data with an Ed25519 private key.
2616
+ * Data is serialized to canonical JSON (sorted keys) before signing.
2617
+ *
2618
+ * @param data - The receipt data to sign (all fields except 'signature').
2619
+ * @param privateKey - DER-encoded Ed25519 private key.
2620
+ * @returns Base64url-encoded signature string.
2621
+ */
2622
+ declare function signEscrowReceipt(data: Record<string, unknown>, privateKey: Buffer): string;
2623
+ /**
2624
+ * Verifies an Ed25519 signature over escrow receipt data.
2625
+ * Returns false (does not throw) for invalid signatures or wrong keys.
2626
+ *
2627
+ * @param data - The receipt data that was signed (all fields except 'signature').
2628
+ * @param signature - Base64url-encoded signature string.
2629
+ * @param publicKey - DER-encoded Ed25519 public key.
2630
+ * @returns true if signature is valid, false otherwise.
2631
+ */
2632
+ declare function verifyEscrowReceipt(data: Record<string, unknown>, signature: string, publicKey: Buffer): boolean;
2633
+
2634
+ /**
2635
+ * Zod schema for validating EscrowReceipt objects.
2636
+ * Used by providers to validate incoming receipts before verification.
2637
+ */
2638
+ declare const EscrowReceiptSchema: z.ZodObject<{
2639
+ requester_owner: z.ZodString;
2640
+ requester_public_key: z.ZodString;
2641
+ amount: z.ZodNumber;
2642
+ card_id: z.ZodString;
2643
+ skill_id: z.ZodOptional<z.ZodString>;
2644
+ timestamp: z.ZodString;
2645
+ nonce: z.ZodString;
2646
+ signature: z.ZodString;
2647
+ }, "strip", z.ZodTypeAny, {
2648
+ card_id: string;
2649
+ signature: string;
2650
+ requester_owner: string;
2651
+ requester_public_key: string;
2652
+ amount: number;
2653
+ timestamp: string;
2654
+ nonce: string;
2655
+ skill_id?: string | undefined;
2656
+ }, {
2657
+ card_id: string;
2658
+ signature: string;
2659
+ requester_owner: string;
2660
+ requester_public_key: string;
2661
+ amount: number;
2662
+ timestamp: string;
2663
+ nonce: string;
2664
+ skill_id?: string | undefined;
2665
+ }>;
2666
+ /**
2667
+ * Options for creating a signed escrow receipt.
2668
+ */
2669
+ interface CreateReceiptOpts {
2670
+ /** Agent owner identifier (requester). */
2671
+ owner: string;
2672
+ /** Number of credits to commit. */
2673
+ amount: number;
2674
+ /** Capability Card ID being requested. */
2675
+ cardId: string;
2676
+ /** Optional skill ID within the card. */
2677
+ skillId?: string;
2678
+ }
2679
+ /**
2680
+ * Creates a signed escrow receipt by atomically holding credits in the local DB
2681
+ * and producing a cryptographically signed receipt that can be sent to a provider.
2682
+ *
2683
+ * This combines local escrow hold + receipt generation from the requester's perspective.
2684
+ *
2685
+ * @param db - The credit database instance.
2686
+ * @param privateKey - DER-encoded Ed25519 private key for signing.
2687
+ * @param publicKey - DER-encoded Ed25519 public key (included in receipt for verification).
2688
+ * @param opts - Receipt creation options (owner, amount, cardId, skillId).
2689
+ * @returns Object with escrowId (local reference) and signed receipt (for transmission).
2690
+ * @throws {AgentBnBError} with code 'INSUFFICIENT_CREDITS' if balance is too low.
2691
+ */
2692
+ declare function createSignedEscrowReceipt(db: Database.Database, privateKey: Buffer, publicKey: Buffer, opts: CreateReceiptOpts): {
2693
+ escrowId: string;
2694
+ receipt: EscrowReceipt;
2695
+ };
2696
+
2697
+ /**
2698
+ * Provider-side settlement: records earnings from a signed escrow receipt.
2699
+ * The provider calls this after successfully executing a capability.
2700
+ * Credits are recorded in the provider's own local DB.
2701
+ *
2702
+ * @param providerDb - The provider's local credit database.
2703
+ * @param providerOwner - Provider agent identifier.
2704
+ * @param receipt - The signed escrow receipt from the requester.
2705
+ * @returns Object indicating settlement success.
2706
+ */
2707
+ declare function settleProviderEarning(providerDb: Database.Database, providerOwner: string, receipt: EscrowReceipt): {
2708
+ settled: true;
2709
+ };
2710
+ /**
2711
+ * Requester-side settlement: confirms that the escrow debit is permanent.
2712
+ * Called after the requester receives confirmation that the provider
2713
+ * successfully executed the capability. Marks escrow as 'settled' without
2714
+ * crediting anyone (credits stay deducted from requester).
2715
+ *
2716
+ * @param requesterDb - The requester's local credit database.
2717
+ * @param escrowId - The escrow ID to confirm as settled.
2718
+ */
2719
+ declare function settleRequesterEscrow(requesterDb: Database.Database, escrowId: string): void;
2720
+ /**
2721
+ * Requester-side failure handling: releases escrowed credits (refund).
2722
+ * Called when the capability execution fails and the requester needs
2723
+ * their credits back.
2724
+ *
2725
+ * @param requesterDb - The requester's local credit database.
2726
+ * @param escrowId - The escrow ID to release.
2727
+ */
2728
+ declare function releaseRequesterEscrow(requesterDb: Database.Database, escrowId: string): void;
675
2729
 
676
- export { type CapabilityCard, CapabilityCardSchema, createGatewayServer, getBalance, getCard, insertCard, openCreditDb, openDatabase, searchCards };
2730
+ export { ApiExecutor, type ApiSkillConfig, ApiSkillConfigSchema, BudgetController, CONDUCTOR_OWNER, type CapabilityCard, CapabilityCardSchema, CommandExecutor, type CommandSkillConfig, CommandSkillConfigSchema, ConductorMode, type ConductorModeOptions, type ConductorSkillConfig, ConductorSkillConfigSchema, type CreateReceiptOpts, type EscrowReceipt, EscrowReceiptSchema, type ExecutionBudget, type ExecutionResult, type ExecutorMode, type KeyPair, type MatchOptions, type MatchResult, ORCHESTRATION_FEE, OpenClawBridge, type OpenClawSkillConfig, OpenClawSkillConfigSchema, type OrchestrateOptions, type OrchestrationResult, PipelineExecutor, type PipelineSkillConfig, PipelineSkillConfigSchema, type SkillConfig, SkillConfigSchema, SkillExecutor, SkillsFileSchema, type SubTask, TEMPLATES, applyInputMapping, buildAuthHeaders, buildConductorCard, createGatewayServer, createSignedEscrowReceipt, createSkillExecutor, decompose, expandEnvVars, extractByPath, generateKeyPair, getBalance, getCard, insertCard, interpolate, interpolateObject, loadKeyPair, matchSubTasks, openCreditDb, openDatabase, orchestrate, parseSkillsFile, registerConductorCard, releaseRequesterEscrow, resolvePath, saveKeyPair, searchCards, settleProviderEarning, settleRequesterEscrow, signEscrowReceipt, verifyEscrowReceipt };