agentbnb 3.0.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{card-P5C36VBD.js → card-EWIXC377.js} +1 -1
- package/dist/{chunk-V7M6GIJZ.js → chunk-2ETVQXP7.js} +13 -193
- package/dist/chunk-3Y36WQDV.js +70 -0
- package/dist/{chunk-TQMI73LL.js → chunk-7RU5INZI.js} +1 -0
- package/dist/chunk-MGHI67GR.js +257 -0
- package/dist/chunk-MZCNJ5PY.js +192 -0
- package/dist/{chunk-PJSYSVKN.js → chunk-QAY6XTT7.js} +4 -6
- package/dist/{chunk-EZB4RUIG.js → chunk-VCW7IDJM.js} +1 -1
- package/dist/cli/index.js +1176 -470
- package/dist/{conduct-JZJS2ZHA.js → conduct-5T3LGXMF.js} +10 -8
- package/dist/{conductor-mode-DJ3RIJ5T.js → conductor-mode-GPLAM2XO.js} +4 -3
- package/dist/execute-NZXTSSVV.js +9 -0
- package/dist/index.d.ts +1052 -10
- package/dist/index.js +1488 -249
- package/dist/websocket-client-5TIQDYQ4.js +275 -0
- package/package.json +16 -1
package/dist/index.d.ts
CHANGED
|
@@ -686,8 +686,8 @@ declare const ApiSkillConfigSchema: z.ZodObject<{
|
|
|
686
686
|
key: z.ZodString;
|
|
687
687
|
}, "strip", z.ZodTypeAny, {
|
|
688
688
|
type: "apikey";
|
|
689
|
-
key: string;
|
|
690
689
|
header: string;
|
|
690
|
+
key: string;
|
|
691
691
|
}, {
|
|
692
692
|
type: "apikey";
|
|
693
693
|
key: string;
|
|
@@ -744,8 +744,8 @@ declare const ApiSkillConfigSchema: z.ZodObject<{
|
|
|
744
744
|
token: string;
|
|
745
745
|
} | {
|
|
746
746
|
type: "apikey";
|
|
747
|
-
key: string;
|
|
748
747
|
header: string;
|
|
748
|
+
key: string;
|
|
749
749
|
} | {
|
|
750
750
|
type: "basic";
|
|
751
751
|
username: string;
|
|
@@ -1031,8 +1031,8 @@ declare const SkillConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1031
1031
|
key: z.ZodString;
|
|
1032
1032
|
}, "strip", z.ZodTypeAny, {
|
|
1033
1033
|
type: "apikey";
|
|
1034
|
-
key: string;
|
|
1035
1034
|
header: string;
|
|
1035
|
+
key: string;
|
|
1036
1036
|
}, {
|
|
1037
1037
|
type: "apikey";
|
|
1038
1038
|
key: string;
|
|
@@ -1089,8 +1089,8 @@ declare const SkillConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1089
1089
|
token: string;
|
|
1090
1090
|
} | {
|
|
1091
1091
|
type: "apikey";
|
|
1092
|
-
key: string;
|
|
1093
1092
|
header: string;
|
|
1093
|
+
key: string;
|
|
1094
1094
|
} | {
|
|
1095
1095
|
type: "basic";
|
|
1096
1096
|
username: string;
|
|
@@ -1357,8 +1357,8 @@ declare const SkillsFileSchema: z.ZodObject<{
|
|
|
1357
1357
|
key: z.ZodString;
|
|
1358
1358
|
}, "strip", z.ZodTypeAny, {
|
|
1359
1359
|
type: "apikey";
|
|
1360
|
-
key: string;
|
|
1361
1360
|
header: string;
|
|
1361
|
+
key: string;
|
|
1362
1362
|
}, {
|
|
1363
1363
|
type: "apikey";
|
|
1364
1364
|
key: string;
|
|
@@ -1415,8 +1415,8 @@ declare const SkillsFileSchema: z.ZodObject<{
|
|
|
1415
1415
|
token: string;
|
|
1416
1416
|
} | {
|
|
1417
1417
|
type: "apikey";
|
|
1418
|
-
key: string;
|
|
1419
1418
|
header: string;
|
|
1419
|
+
key: string;
|
|
1420
1420
|
} | {
|
|
1421
1421
|
type: "basic";
|
|
1422
1422
|
username: string;
|
|
@@ -1679,8 +1679,8 @@ declare const SkillsFileSchema: z.ZodObject<{
|
|
|
1679
1679
|
token: string;
|
|
1680
1680
|
} | {
|
|
1681
1681
|
type: "apikey";
|
|
1682
|
-
key: string;
|
|
1683
1682
|
header: string;
|
|
1683
|
+
key: string;
|
|
1684
1684
|
} | {
|
|
1685
1685
|
type: "basic";
|
|
1686
1686
|
username: string;
|
|
@@ -2645,20 +2645,20 @@ declare const EscrowReceiptSchema: z.ZodObject<{
|
|
|
2645
2645
|
nonce: z.ZodString;
|
|
2646
2646
|
signature: z.ZodString;
|
|
2647
2647
|
}, "strip", z.ZodTypeAny, {
|
|
2648
|
-
card_id: string;
|
|
2649
2648
|
signature: string;
|
|
2650
2649
|
requester_owner: string;
|
|
2651
2650
|
requester_public_key: string;
|
|
2652
2651
|
amount: number;
|
|
2652
|
+
card_id: string;
|
|
2653
2653
|
timestamp: string;
|
|
2654
2654
|
nonce: string;
|
|
2655
2655
|
skill_id?: string | undefined;
|
|
2656
2656
|
}, {
|
|
2657
|
-
card_id: string;
|
|
2658
2657
|
signature: string;
|
|
2659
2658
|
requester_owner: string;
|
|
2660
2659
|
requester_public_key: string;
|
|
2661
2660
|
amount: number;
|
|
2661
|
+
card_id: string;
|
|
2662
2662
|
timestamp: string;
|
|
2663
2663
|
nonce: string;
|
|
2664
2664
|
skill_id?: string | undefined;
|
|
@@ -2727,4 +2727,1046 @@ declare function settleRequesterEscrow(requesterDb: Database.Database, escrowId:
|
|
|
2727
2727
|
*/
|
|
2728
2728
|
declare function releaseRequesterEscrow(requesterDb: Database.Database, escrowId: string): void;
|
|
2729
2729
|
|
|
2730
|
-
|
|
2730
|
+
/**
|
|
2731
|
+
* Agent Identity — the unified identity record for an AgentBnB agent.
|
|
2732
|
+
* Stored at ~/.agentbnb/identity.json.
|
|
2733
|
+
*/
|
|
2734
|
+
declare const AgentIdentitySchema: z.ZodObject<{
|
|
2735
|
+
/** Deterministic ID derived from public key: sha256(hex).slice(0, 16). */
|
|
2736
|
+
agent_id: z.ZodString;
|
|
2737
|
+
/** Human-readable owner name (from config or init). */
|
|
2738
|
+
owner: z.ZodString;
|
|
2739
|
+
/** Hex-encoded Ed25519 public key. */
|
|
2740
|
+
public_key: z.ZodString;
|
|
2741
|
+
/** ISO 8601 timestamp of identity creation. */
|
|
2742
|
+
created_at: z.ZodString;
|
|
2743
|
+
/** Optional guarantor info if linked to a human. */
|
|
2744
|
+
guarantor: z.ZodOptional<z.ZodObject<{
|
|
2745
|
+
github_login: z.ZodString;
|
|
2746
|
+
verified_at: z.ZodString;
|
|
2747
|
+
}, "strip", z.ZodTypeAny, {
|
|
2748
|
+
github_login: string;
|
|
2749
|
+
verified_at: string;
|
|
2750
|
+
}, {
|
|
2751
|
+
github_login: string;
|
|
2752
|
+
verified_at: string;
|
|
2753
|
+
}>>;
|
|
2754
|
+
}, "strip", z.ZodTypeAny, {
|
|
2755
|
+
owner: string;
|
|
2756
|
+
created_at: string;
|
|
2757
|
+
agent_id: string;
|
|
2758
|
+
public_key: string;
|
|
2759
|
+
guarantor?: {
|
|
2760
|
+
github_login: string;
|
|
2761
|
+
verified_at: string;
|
|
2762
|
+
} | undefined;
|
|
2763
|
+
}, {
|
|
2764
|
+
owner: string;
|
|
2765
|
+
created_at: string;
|
|
2766
|
+
agent_id: string;
|
|
2767
|
+
public_key: string;
|
|
2768
|
+
guarantor?: {
|
|
2769
|
+
github_login: string;
|
|
2770
|
+
verified_at: string;
|
|
2771
|
+
} | undefined;
|
|
2772
|
+
}>;
|
|
2773
|
+
type AgentIdentity = z.infer<typeof AgentIdentitySchema>;
|
|
2774
|
+
/**
|
|
2775
|
+
* Agent Certificate — a self-signed attestation of agent identity.
|
|
2776
|
+
* Used for P2P identity verification without a shared auth server.
|
|
2777
|
+
*/
|
|
2778
|
+
declare const AgentCertificateSchema: z.ZodObject<{
|
|
2779
|
+
identity: z.ZodObject<{
|
|
2780
|
+
/** Deterministic ID derived from public key: sha256(hex).slice(0, 16). */
|
|
2781
|
+
agent_id: z.ZodString;
|
|
2782
|
+
/** Human-readable owner name (from config or init). */
|
|
2783
|
+
owner: z.ZodString;
|
|
2784
|
+
/** Hex-encoded Ed25519 public key. */
|
|
2785
|
+
public_key: z.ZodString;
|
|
2786
|
+
/** ISO 8601 timestamp of identity creation. */
|
|
2787
|
+
created_at: z.ZodString;
|
|
2788
|
+
/** Optional guarantor info if linked to a human. */
|
|
2789
|
+
guarantor: z.ZodOptional<z.ZodObject<{
|
|
2790
|
+
github_login: z.ZodString;
|
|
2791
|
+
verified_at: z.ZodString;
|
|
2792
|
+
}, "strip", z.ZodTypeAny, {
|
|
2793
|
+
github_login: string;
|
|
2794
|
+
verified_at: string;
|
|
2795
|
+
}, {
|
|
2796
|
+
github_login: string;
|
|
2797
|
+
verified_at: string;
|
|
2798
|
+
}>>;
|
|
2799
|
+
}, "strip", z.ZodTypeAny, {
|
|
2800
|
+
owner: string;
|
|
2801
|
+
created_at: string;
|
|
2802
|
+
agent_id: string;
|
|
2803
|
+
public_key: string;
|
|
2804
|
+
guarantor?: {
|
|
2805
|
+
github_login: string;
|
|
2806
|
+
verified_at: string;
|
|
2807
|
+
} | undefined;
|
|
2808
|
+
}, {
|
|
2809
|
+
owner: string;
|
|
2810
|
+
created_at: string;
|
|
2811
|
+
agent_id: string;
|
|
2812
|
+
public_key: string;
|
|
2813
|
+
guarantor?: {
|
|
2814
|
+
github_login: string;
|
|
2815
|
+
verified_at: string;
|
|
2816
|
+
} | undefined;
|
|
2817
|
+
}>;
|
|
2818
|
+
/** ISO 8601 timestamp of certificate issuance. */
|
|
2819
|
+
issued_at: z.ZodString;
|
|
2820
|
+
/** ISO 8601 timestamp of certificate expiry. */
|
|
2821
|
+
expires_at: z.ZodString;
|
|
2822
|
+
/** Hex-encoded public key of the issuer (same as identity for self-signed). */
|
|
2823
|
+
issuer_public_key: z.ZodString;
|
|
2824
|
+
/** Base64url Ed25519 signature over { identity, issued_at, expires_at, issuer_public_key }. */
|
|
2825
|
+
signature: z.ZodString;
|
|
2826
|
+
}, "strip", z.ZodTypeAny, {
|
|
2827
|
+
signature: string;
|
|
2828
|
+
identity: {
|
|
2829
|
+
owner: string;
|
|
2830
|
+
created_at: string;
|
|
2831
|
+
agent_id: string;
|
|
2832
|
+
public_key: string;
|
|
2833
|
+
guarantor?: {
|
|
2834
|
+
github_login: string;
|
|
2835
|
+
verified_at: string;
|
|
2836
|
+
} | undefined;
|
|
2837
|
+
};
|
|
2838
|
+
issued_at: string;
|
|
2839
|
+
expires_at: string;
|
|
2840
|
+
issuer_public_key: string;
|
|
2841
|
+
}, {
|
|
2842
|
+
signature: string;
|
|
2843
|
+
identity: {
|
|
2844
|
+
owner: string;
|
|
2845
|
+
created_at: string;
|
|
2846
|
+
agent_id: string;
|
|
2847
|
+
public_key: string;
|
|
2848
|
+
guarantor?: {
|
|
2849
|
+
github_login: string;
|
|
2850
|
+
verified_at: string;
|
|
2851
|
+
} | undefined;
|
|
2852
|
+
};
|
|
2853
|
+
issued_at: string;
|
|
2854
|
+
expires_at: string;
|
|
2855
|
+
issuer_public_key: string;
|
|
2856
|
+
}>;
|
|
2857
|
+
type AgentCertificate = z.infer<typeof AgentCertificateSchema>;
|
|
2858
|
+
/**
|
|
2859
|
+
* Derives a deterministic agent_id from a hex-encoded public key.
|
|
2860
|
+
* Uses first 16 chars of SHA-256 hash.
|
|
2861
|
+
*/
|
|
2862
|
+
declare function deriveAgentId(publicKeyHex: string): string;
|
|
2863
|
+
/**
|
|
2864
|
+
* Creates a new agent identity. Generates an Ed25519 keypair if one does not
|
|
2865
|
+
* already exist. Writes identity.json to the config directory.
|
|
2866
|
+
*
|
|
2867
|
+
* @param configDir - Directory to write identity.json into (e.g. ~/.agentbnb).
|
|
2868
|
+
* @param owner - Human-readable agent owner name.
|
|
2869
|
+
* @returns The newly created AgentIdentity.
|
|
2870
|
+
*/
|
|
2871
|
+
declare function createIdentity(configDir: string, owner: string): AgentIdentity;
|
|
2872
|
+
/**
|
|
2873
|
+
* Loads an existing agent identity from disk.
|
|
2874
|
+
*
|
|
2875
|
+
* @param configDir - Directory containing identity.json.
|
|
2876
|
+
* @returns Parsed AgentIdentity or null if file does not exist.
|
|
2877
|
+
*/
|
|
2878
|
+
declare function loadIdentity(configDir: string): AgentIdentity | null;
|
|
2879
|
+
/**
|
|
2880
|
+
* Persists an agent identity to disk.
|
|
2881
|
+
*
|
|
2882
|
+
* @param configDir - Directory to write identity.json into.
|
|
2883
|
+
* @param identity - The identity to save.
|
|
2884
|
+
*/
|
|
2885
|
+
declare function saveIdentity(configDir: string, identity: AgentIdentity): void;
|
|
2886
|
+
/**
|
|
2887
|
+
* Issues a self-signed Agent Certificate. Valid for 365 days.
|
|
2888
|
+
*
|
|
2889
|
+
* @param identity - The agent identity to certify.
|
|
2890
|
+
* @param privateKey - DER-encoded Ed25519 private key.
|
|
2891
|
+
* @returns A signed AgentCertificate.
|
|
2892
|
+
*/
|
|
2893
|
+
declare function issueAgentCertificate(identity: AgentIdentity, privateKey: Buffer): AgentCertificate;
|
|
2894
|
+
/**
|
|
2895
|
+
* Verifies an Agent Certificate's signature and expiry.
|
|
2896
|
+
*
|
|
2897
|
+
* @param cert - The certificate to verify.
|
|
2898
|
+
* @returns true if signature is valid and certificate has not expired.
|
|
2899
|
+
*/
|
|
2900
|
+
declare function verifyAgentCertificate(cert: AgentCertificate): boolean;
|
|
2901
|
+
/**
|
|
2902
|
+
* Ensures an identity exists for the given config directory.
|
|
2903
|
+
* If identity.json already exists, returns it. Otherwise creates a new one.
|
|
2904
|
+
*
|
|
2905
|
+
* @param configDir - Config directory path.
|
|
2906
|
+
* @param owner - Owner name to use if creating new identity.
|
|
2907
|
+
* @returns The loaded or newly created AgentIdentity.
|
|
2908
|
+
*/
|
|
2909
|
+
declare function ensureIdentity(configDir: string, owner: string): AgentIdentity;
|
|
2910
|
+
|
|
2911
|
+
/**
|
|
2912
|
+
* Options for constructing an AgentBnBConsumer.
|
|
2913
|
+
*/
|
|
2914
|
+
interface ConsumerOptions {
|
|
2915
|
+
/** Override the config directory (default: ~/.agentbnb or AGENTBNB_DIR). */
|
|
2916
|
+
configDir?: string;
|
|
2917
|
+
}
|
|
2918
|
+
/**
|
|
2919
|
+
* Options for requesting a capability.
|
|
2920
|
+
*/
|
|
2921
|
+
interface ConsumerRequestOptions {
|
|
2922
|
+
/** Gateway URL of the target agent. */
|
|
2923
|
+
gatewayUrl: string;
|
|
2924
|
+
/** Bearer token for the target agent's gateway. */
|
|
2925
|
+
token: string;
|
|
2926
|
+
/** Capability Card ID to execute. */
|
|
2927
|
+
cardId: string;
|
|
2928
|
+
/** Optional skill ID within the card. */
|
|
2929
|
+
skillId?: string;
|
|
2930
|
+
/** Input parameters for the capability. */
|
|
2931
|
+
params?: Record<string, unknown>;
|
|
2932
|
+
/** Credit amount to commit (escrow). */
|
|
2933
|
+
credits: number;
|
|
2934
|
+
/** Timeout in milliseconds. Default 30000. */
|
|
2935
|
+
timeoutMs?: number;
|
|
2936
|
+
}
|
|
2937
|
+
/**
|
|
2938
|
+
* AgentBnBConsumer — high-level SDK class for agents consuming capabilities.
|
|
2939
|
+
*
|
|
2940
|
+
* Encapsulates the full request lifecycle: identity loading, escrow creation,
|
|
2941
|
+
* capability request, and settlement/release.
|
|
2942
|
+
*
|
|
2943
|
+
* @example
|
|
2944
|
+
* ```typescript
|
|
2945
|
+
* const consumer = new AgentBnBConsumer();
|
|
2946
|
+
* consumer.authenticate();
|
|
2947
|
+
* const result = await consumer.request({
|
|
2948
|
+
* gatewayUrl: 'http://peer:7700',
|
|
2949
|
+
* token: 'peer-token',
|
|
2950
|
+
* cardId: 'uuid-of-card',
|
|
2951
|
+
* credits: 5,
|
|
2952
|
+
* });
|
|
2953
|
+
* ```
|
|
2954
|
+
*/
|
|
2955
|
+
declare class AgentBnBConsumer {
|
|
2956
|
+
private configDir;
|
|
2957
|
+
private identity;
|
|
2958
|
+
private keys;
|
|
2959
|
+
private creditDb;
|
|
2960
|
+
constructor(opts?: ConsumerOptions);
|
|
2961
|
+
/**
|
|
2962
|
+
* Loads agent identity and keypair from disk.
|
|
2963
|
+
* Creates identity if none exists (uses owner from config.json or generates one).
|
|
2964
|
+
*
|
|
2965
|
+
* @returns The loaded AgentIdentity.
|
|
2966
|
+
* @throws {AgentBnBError} if keypair is missing and cannot be created.
|
|
2967
|
+
*/
|
|
2968
|
+
authenticate(): AgentIdentity;
|
|
2969
|
+
/**
|
|
2970
|
+
* Returns the cached identity. Throws if not yet authenticated.
|
|
2971
|
+
*/
|
|
2972
|
+
getIdentity(): AgentIdentity;
|
|
2973
|
+
/**
|
|
2974
|
+
* Requests a capability from a remote agent with full escrow lifecycle.
|
|
2975
|
+
*
|
|
2976
|
+
* 1. Creates a signed escrow receipt (holds credits locally)
|
|
2977
|
+
* 2. Sends the request to the target gateway
|
|
2978
|
+
* 3. Settles escrow on success, releases on failure
|
|
2979
|
+
*
|
|
2980
|
+
* @param opts - Request options including target, card, credits, and params.
|
|
2981
|
+
* @returns The result from the capability execution.
|
|
2982
|
+
* @throws {AgentBnBError} on insufficient credits, network error, or RPC error.
|
|
2983
|
+
*/
|
|
2984
|
+
request(opts: ConsumerRequestOptions): Promise<unknown>;
|
|
2985
|
+
/**
|
|
2986
|
+
* Returns the current credit balance for this agent.
|
|
2987
|
+
*/
|
|
2988
|
+
getBalance(): number;
|
|
2989
|
+
/**
|
|
2990
|
+
* Returns basic reputation data from the local credit database.
|
|
2991
|
+
* Note: success_rate is computed from local request history only.
|
|
2992
|
+
*/
|
|
2993
|
+
getReputation(): {
|
|
2994
|
+
success_rate: number;
|
|
2995
|
+
total_requests: number;
|
|
2996
|
+
};
|
|
2997
|
+
/**
|
|
2998
|
+
* Closes the credit database connection. Call when done.
|
|
2999
|
+
*/
|
|
3000
|
+
close(): void;
|
|
3001
|
+
/** Lazily opens and caches the credit database. */
|
|
3002
|
+
private getCreditDb;
|
|
3003
|
+
}
|
|
3004
|
+
|
|
3005
|
+
/**
|
|
3006
|
+
* Options for constructing an AgentBnBProvider.
|
|
3007
|
+
*/
|
|
3008
|
+
interface ProviderOptions {
|
|
3009
|
+
/** Override the config directory (default: ~/.agentbnb or AGENTBNB_DIR). */
|
|
3010
|
+
configDir?: string;
|
|
3011
|
+
}
|
|
3012
|
+
/**
|
|
3013
|
+
* Options for starting the sharing gateway.
|
|
3014
|
+
*/
|
|
3015
|
+
interface StartSharingOptions {
|
|
3016
|
+
/** Port to listen on (default: from config or 7700). */
|
|
3017
|
+
port?: number;
|
|
3018
|
+
/** Host to bind to (default: '0.0.0.0'). */
|
|
3019
|
+
host?: string;
|
|
3020
|
+
}
|
|
3021
|
+
/**
|
|
3022
|
+
* Context returned after sharing starts.
|
|
3023
|
+
*/
|
|
3024
|
+
interface SharingContext {
|
|
3025
|
+
/** The Fastify gateway server instance. */
|
|
3026
|
+
gateway: FastifyInstance;
|
|
3027
|
+
/** Port the gateway is listening on. */
|
|
3028
|
+
port: number;
|
|
3029
|
+
}
|
|
3030
|
+
/**
|
|
3031
|
+
* AgentBnBProvider — high-level SDK class for agents providing capabilities.
|
|
3032
|
+
*
|
|
3033
|
+
* Manages identity, gateway lifecycle, and capability listing.
|
|
3034
|
+
*
|
|
3035
|
+
* @example
|
|
3036
|
+
* ```typescript
|
|
3037
|
+
* const provider = new AgentBnBProvider();
|
|
3038
|
+
* provider.authenticate();
|
|
3039
|
+
* const ctx = await provider.startSharing({ port: 7700 });
|
|
3040
|
+
* console.log(provider.listCapabilities());
|
|
3041
|
+
* await provider.stopSharing();
|
|
3042
|
+
* ```
|
|
3043
|
+
*/
|
|
3044
|
+
declare class AgentBnBProvider {
|
|
3045
|
+
private configDir;
|
|
3046
|
+
private identity;
|
|
3047
|
+
private registryDb;
|
|
3048
|
+
private creditDb;
|
|
3049
|
+
private gateway;
|
|
3050
|
+
constructor(opts?: ProviderOptions);
|
|
3051
|
+
/**
|
|
3052
|
+
* Loads agent identity from disk.
|
|
3053
|
+
* Creates identity if none exists.
|
|
3054
|
+
*
|
|
3055
|
+
* @returns The loaded AgentIdentity.
|
|
3056
|
+
*/
|
|
3057
|
+
authenticate(): AgentIdentity;
|
|
3058
|
+
/**
|
|
3059
|
+
* Returns the cached identity. Throws if not yet authenticated.
|
|
3060
|
+
*/
|
|
3061
|
+
getIdentity(): AgentIdentity;
|
|
3062
|
+
/**
|
|
3063
|
+
* Starts the gateway server to share capabilities.
|
|
3064
|
+
*
|
|
3065
|
+
* @param opts - Optional port and host configuration.
|
|
3066
|
+
* @returns Context with the gateway server and port.
|
|
3067
|
+
*/
|
|
3068
|
+
startSharing(opts?: StartSharingOptions): Promise<SharingContext>;
|
|
3069
|
+
/**
|
|
3070
|
+
* Stops the gateway server.
|
|
3071
|
+
*/
|
|
3072
|
+
stopSharing(): Promise<void>;
|
|
3073
|
+
/**
|
|
3074
|
+
* Returns all capability cards owned by this agent.
|
|
3075
|
+
*/
|
|
3076
|
+
listCapabilities(): CapabilityCard[];
|
|
3077
|
+
/**
|
|
3078
|
+
* Returns the current credit balance for this agent.
|
|
3079
|
+
*/
|
|
3080
|
+
getBalance(): number;
|
|
3081
|
+
/**
|
|
3082
|
+
* Closes all database connections and stops the gateway. Call when done.
|
|
3083
|
+
*/
|
|
3084
|
+
close(): Promise<void>;
|
|
3085
|
+
/** Lazily opens and caches the registry database. */
|
|
3086
|
+
private getRegistryDb;
|
|
3087
|
+
/** Lazily opens and caches the credit database. */
|
|
3088
|
+
private getCreditDb;
|
|
3089
|
+
}
|
|
3090
|
+
|
|
3091
|
+
/** Maximum agents a single human guarantor can back. */
|
|
3092
|
+
declare const MAX_AGENTS_PER_GUARANTOR = 10;
|
|
3093
|
+
/** Free credits granted per human guarantor registration. */
|
|
3094
|
+
declare const GUARANTOR_CREDIT_POOL = 50;
|
|
3095
|
+
/**
|
|
3096
|
+
* A Human Guarantor — a real person backing one or more agents.
|
|
3097
|
+
* Provides initial trust and credit pool for the agent network.
|
|
3098
|
+
*/
|
|
3099
|
+
declare const GuarantorRecordSchema: z.ZodObject<{
|
|
3100
|
+
id: z.ZodString;
|
|
3101
|
+
github_login: z.ZodString;
|
|
3102
|
+
agent_count: z.ZodNumber;
|
|
3103
|
+
credit_pool: z.ZodNumber;
|
|
3104
|
+
created_at: z.ZodString;
|
|
3105
|
+
}, "strip", z.ZodTypeAny, {
|
|
3106
|
+
id: string;
|
|
3107
|
+
created_at: string;
|
|
3108
|
+
github_login: string;
|
|
3109
|
+
agent_count: number;
|
|
3110
|
+
credit_pool: number;
|
|
3111
|
+
}, {
|
|
3112
|
+
id: string;
|
|
3113
|
+
created_at: string;
|
|
3114
|
+
github_login: string;
|
|
3115
|
+
agent_count: number;
|
|
3116
|
+
credit_pool: number;
|
|
3117
|
+
}>;
|
|
3118
|
+
type GuarantorRecord = z.infer<typeof GuarantorRecordSchema>;
|
|
3119
|
+
/**
|
|
3120
|
+
* Registers a new human guarantor via GitHub login.
|
|
3121
|
+
* Grants GUARANTOR_CREDIT_POOL (50) credits to be distributed among linked agents.
|
|
3122
|
+
*
|
|
3123
|
+
* @param db - The credit database instance.
|
|
3124
|
+
* @param githubLogin - GitHub username of the guarantor.
|
|
3125
|
+
* @returns The created GuarantorRecord.
|
|
3126
|
+
* @throws {AgentBnBError} with code 'GUARANTOR_EXISTS' if login already registered.
|
|
3127
|
+
*/
|
|
3128
|
+
declare function registerGuarantor(db: Database.Database, githubLogin: string): GuarantorRecord;
|
|
3129
|
+
/**
|
|
3130
|
+
* Links an agent to a human guarantor.
|
|
3131
|
+
* Enforces the MAX_AGENTS_PER_GUARANTOR limit (10).
|
|
3132
|
+
*
|
|
3133
|
+
* @param db - The credit database instance.
|
|
3134
|
+
* @param agentId - The agent_id to link.
|
|
3135
|
+
* @param githubLogin - The guarantor's GitHub login.
|
|
3136
|
+
* @returns Updated GuarantorRecord.
|
|
3137
|
+
* @throws {AgentBnBError} with code 'GUARANTOR_NOT_FOUND' if login not registered.
|
|
3138
|
+
* @throws {AgentBnBError} with code 'MAX_AGENTS_EXCEEDED' if limit reached.
|
|
3139
|
+
* @throws {AgentBnBError} with code 'AGENT_ALREADY_LINKED' if agent already has a guarantor.
|
|
3140
|
+
*/
|
|
3141
|
+
declare function linkAgentToGuarantor(db: Database.Database, agentId: string, githubLogin: string): GuarantorRecord;
|
|
3142
|
+
/**
|
|
3143
|
+
* Retrieves a guarantor record by GitHub login.
|
|
3144
|
+
*
|
|
3145
|
+
* @param db - The credit database instance.
|
|
3146
|
+
* @param githubLogin - The GitHub username to look up.
|
|
3147
|
+
* @returns GuarantorRecord or null if not found.
|
|
3148
|
+
*/
|
|
3149
|
+
declare function getGuarantor(db: Database.Database, githubLogin: string): GuarantorRecord | null;
|
|
3150
|
+
/**
|
|
3151
|
+
* Gets the guarantor linked to an agent, if any.
|
|
3152
|
+
*
|
|
3153
|
+
* @param db - The credit database instance.
|
|
3154
|
+
* @param agentId - The agent_id to look up.
|
|
3155
|
+
* @returns GuarantorRecord or null if agent has no guarantor.
|
|
3156
|
+
*/
|
|
3157
|
+
declare function getAgentGuarantor(db: Database.Database, agentId: string): GuarantorRecord | null;
|
|
3158
|
+
/**
|
|
3159
|
+
* Initiates a GitHub OAuth flow for guarantor verification.
|
|
3160
|
+
* This is a STUB — returns placeholder values. Actual OAuth implementation
|
|
3161
|
+
* is deferred to a future version.
|
|
3162
|
+
*
|
|
3163
|
+
* @returns Object with auth_url and state for the OAuth flow.
|
|
3164
|
+
*/
|
|
3165
|
+
declare function initiateGithubAuth(): {
|
|
3166
|
+
auth_url: string;
|
|
3167
|
+
state: string;
|
|
3168
|
+
};
|
|
3169
|
+
|
|
3170
|
+
/**
|
|
3171
|
+
* WebSocket relay message types for agent-to-registry communication.
|
|
3172
|
+
* All messages are JSON-encoded with a discriminating `type` field.
|
|
3173
|
+
*/
|
|
3174
|
+
/** Agent → Registry: Register agent and card on connect */
|
|
3175
|
+
declare const RegisterMessageSchema: z.ZodObject<{
|
|
3176
|
+
type: z.ZodLiteral<"register">;
|
|
3177
|
+
owner: z.ZodString;
|
|
3178
|
+
token: z.ZodString;
|
|
3179
|
+
card: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
3180
|
+
}, "strip", z.ZodTypeAny, {
|
|
3181
|
+
type: "register";
|
|
3182
|
+
owner: string;
|
|
3183
|
+
token: string;
|
|
3184
|
+
card: Record<string, unknown>;
|
|
3185
|
+
}, {
|
|
3186
|
+
type: "register";
|
|
3187
|
+
owner: string;
|
|
3188
|
+
token: string;
|
|
3189
|
+
card: Record<string, unknown>;
|
|
3190
|
+
}>;
|
|
3191
|
+
/** Registry → Agent: Acknowledge registration */
|
|
3192
|
+
declare const RegisteredMessageSchema: z.ZodObject<{
|
|
3193
|
+
type: z.ZodLiteral<"registered">;
|
|
3194
|
+
agent_id: z.ZodString;
|
|
3195
|
+
}, "strip", z.ZodTypeAny, {
|
|
3196
|
+
type: "registered";
|
|
3197
|
+
agent_id: string;
|
|
3198
|
+
}, {
|
|
3199
|
+
type: "registered";
|
|
3200
|
+
agent_id: string;
|
|
3201
|
+
}>;
|
|
3202
|
+
/** Agent A → Registry: Request relay to another agent */
|
|
3203
|
+
declare const RelayRequestMessageSchema: z.ZodObject<{
|
|
3204
|
+
type: z.ZodLiteral<"relay_request">;
|
|
3205
|
+
id: z.ZodString;
|
|
3206
|
+
target_owner: z.ZodString;
|
|
3207
|
+
card_id: z.ZodString;
|
|
3208
|
+
skill_id: z.ZodOptional<z.ZodString>;
|
|
3209
|
+
params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3210
|
+
requester: z.ZodOptional<z.ZodString>;
|
|
3211
|
+
escrow_receipt: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3212
|
+
}, "strip", z.ZodTypeAny, {
|
|
3213
|
+
type: "relay_request";
|
|
3214
|
+
params: Record<string, unknown>;
|
|
3215
|
+
id: string;
|
|
3216
|
+
card_id: string;
|
|
3217
|
+
target_owner: string;
|
|
3218
|
+
skill_id?: string | undefined;
|
|
3219
|
+
requester?: string | undefined;
|
|
3220
|
+
escrow_receipt?: Record<string, unknown> | undefined;
|
|
3221
|
+
}, {
|
|
3222
|
+
type: "relay_request";
|
|
3223
|
+
id: string;
|
|
3224
|
+
card_id: string;
|
|
3225
|
+
target_owner: string;
|
|
3226
|
+
params?: Record<string, unknown> | undefined;
|
|
3227
|
+
skill_id?: string | undefined;
|
|
3228
|
+
requester?: string | undefined;
|
|
3229
|
+
escrow_receipt?: Record<string, unknown> | undefined;
|
|
3230
|
+
}>;
|
|
3231
|
+
/** Registry → Agent B: Incoming request forwarded from Agent A */
|
|
3232
|
+
declare const IncomingRequestMessageSchema: z.ZodObject<{
|
|
3233
|
+
type: z.ZodLiteral<"incoming_request">;
|
|
3234
|
+
id: z.ZodString;
|
|
3235
|
+
from_owner: z.ZodString;
|
|
3236
|
+
card_id: z.ZodString;
|
|
3237
|
+
skill_id: z.ZodOptional<z.ZodString>;
|
|
3238
|
+
params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3239
|
+
requester: z.ZodOptional<z.ZodString>;
|
|
3240
|
+
escrow_receipt: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3241
|
+
}, "strip", z.ZodTypeAny, {
|
|
3242
|
+
type: "incoming_request";
|
|
3243
|
+
params: Record<string, unknown>;
|
|
3244
|
+
id: string;
|
|
3245
|
+
card_id: string;
|
|
3246
|
+
from_owner: string;
|
|
3247
|
+
skill_id?: string | undefined;
|
|
3248
|
+
requester?: string | undefined;
|
|
3249
|
+
escrow_receipt?: Record<string, unknown> | undefined;
|
|
3250
|
+
}, {
|
|
3251
|
+
type: "incoming_request";
|
|
3252
|
+
id: string;
|
|
3253
|
+
card_id: string;
|
|
3254
|
+
from_owner: string;
|
|
3255
|
+
params?: Record<string, unknown> | undefined;
|
|
3256
|
+
skill_id?: string | undefined;
|
|
3257
|
+
requester?: string | undefined;
|
|
3258
|
+
escrow_receipt?: Record<string, unknown> | undefined;
|
|
3259
|
+
}>;
|
|
3260
|
+
/** Agent B → Registry: Response to a relayed request */
|
|
3261
|
+
declare const RelayResponseMessageSchema: z.ZodObject<{
|
|
3262
|
+
type: z.ZodLiteral<"relay_response">;
|
|
3263
|
+
id: z.ZodString;
|
|
3264
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
3265
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
3266
|
+
code: z.ZodNumber;
|
|
3267
|
+
message: z.ZodString;
|
|
3268
|
+
}, "strip", z.ZodTypeAny, {
|
|
3269
|
+
code: number;
|
|
3270
|
+
message: string;
|
|
3271
|
+
}, {
|
|
3272
|
+
code: number;
|
|
3273
|
+
message: string;
|
|
3274
|
+
}>>;
|
|
3275
|
+
}, "strip", z.ZodTypeAny, {
|
|
3276
|
+
type: "relay_response";
|
|
3277
|
+
id: string;
|
|
3278
|
+
result?: unknown;
|
|
3279
|
+
error?: {
|
|
3280
|
+
code: number;
|
|
3281
|
+
message: string;
|
|
3282
|
+
} | undefined;
|
|
3283
|
+
}, {
|
|
3284
|
+
type: "relay_response";
|
|
3285
|
+
id: string;
|
|
3286
|
+
result?: unknown;
|
|
3287
|
+
error?: {
|
|
3288
|
+
code: number;
|
|
3289
|
+
message: string;
|
|
3290
|
+
} | undefined;
|
|
3291
|
+
}>;
|
|
3292
|
+
/** Registry → Agent A: Forwarded response from Agent B */
|
|
3293
|
+
declare const ResponseMessageSchema: z.ZodObject<{
|
|
3294
|
+
type: z.ZodLiteral<"response">;
|
|
3295
|
+
id: z.ZodString;
|
|
3296
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
3297
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
3298
|
+
code: z.ZodNumber;
|
|
3299
|
+
message: z.ZodString;
|
|
3300
|
+
}, "strip", z.ZodTypeAny, {
|
|
3301
|
+
code: number;
|
|
3302
|
+
message: string;
|
|
3303
|
+
}, {
|
|
3304
|
+
code: number;
|
|
3305
|
+
message: string;
|
|
3306
|
+
}>>;
|
|
3307
|
+
}, "strip", z.ZodTypeAny, {
|
|
3308
|
+
type: "response";
|
|
3309
|
+
id: string;
|
|
3310
|
+
result?: unknown;
|
|
3311
|
+
error?: {
|
|
3312
|
+
code: number;
|
|
3313
|
+
message: string;
|
|
3314
|
+
} | undefined;
|
|
3315
|
+
}, {
|
|
3316
|
+
type: "response";
|
|
3317
|
+
id: string;
|
|
3318
|
+
result?: unknown;
|
|
3319
|
+
error?: {
|
|
3320
|
+
code: number;
|
|
3321
|
+
message: string;
|
|
3322
|
+
} | undefined;
|
|
3323
|
+
}>;
|
|
3324
|
+
/** Error message (either direction) */
|
|
3325
|
+
declare const ErrorMessageSchema: z.ZodObject<{
|
|
3326
|
+
type: z.ZodLiteral<"error">;
|
|
3327
|
+
code: z.ZodString;
|
|
3328
|
+
message: z.ZodString;
|
|
3329
|
+
request_id: z.ZodOptional<z.ZodString>;
|
|
3330
|
+
}, "strip", z.ZodTypeAny, {
|
|
3331
|
+
type: "error";
|
|
3332
|
+
code: string;
|
|
3333
|
+
message: string;
|
|
3334
|
+
request_id?: string | undefined;
|
|
3335
|
+
}, {
|
|
3336
|
+
type: "error";
|
|
3337
|
+
code: string;
|
|
3338
|
+
message: string;
|
|
3339
|
+
request_id?: string | undefined;
|
|
3340
|
+
}>;
|
|
3341
|
+
/** Discriminated union of all relay messages */
|
|
3342
|
+
declare const RelayMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
3343
|
+
type: z.ZodLiteral<"register">;
|
|
3344
|
+
owner: z.ZodString;
|
|
3345
|
+
token: z.ZodString;
|
|
3346
|
+
card: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
3347
|
+
}, "strip", z.ZodTypeAny, {
|
|
3348
|
+
type: "register";
|
|
3349
|
+
owner: string;
|
|
3350
|
+
token: string;
|
|
3351
|
+
card: Record<string, unknown>;
|
|
3352
|
+
}, {
|
|
3353
|
+
type: "register";
|
|
3354
|
+
owner: string;
|
|
3355
|
+
token: string;
|
|
3356
|
+
card: Record<string, unknown>;
|
|
3357
|
+
}>, z.ZodObject<{
|
|
3358
|
+
type: z.ZodLiteral<"registered">;
|
|
3359
|
+
agent_id: z.ZodString;
|
|
3360
|
+
}, "strip", z.ZodTypeAny, {
|
|
3361
|
+
type: "registered";
|
|
3362
|
+
agent_id: string;
|
|
3363
|
+
}, {
|
|
3364
|
+
type: "registered";
|
|
3365
|
+
agent_id: string;
|
|
3366
|
+
}>, z.ZodObject<{
|
|
3367
|
+
type: z.ZodLiteral<"relay_request">;
|
|
3368
|
+
id: z.ZodString;
|
|
3369
|
+
target_owner: z.ZodString;
|
|
3370
|
+
card_id: z.ZodString;
|
|
3371
|
+
skill_id: z.ZodOptional<z.ZodString>;
|
|
3372
|
+
params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3373
|
+
requester: z.ZodOptional<z.ZodString>;
|
|
3374
|
+
escrow_receipt: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3375
|
+
}, "strip", z.ZodTypeAny, {
|
|
3376
|
+
type: "relay_request";
|
|
3377
|
+
params: Record<string, unknown>;
|
|
3378
|
+
id: string;
|
|
3379
|
+
card_id: string;
|
|
3380
|
+
target_owner: string;
|
|
3381
|
+
skill_id?: string | undefined;
|
|
3382
|
+
requester?: string | undefined;
|
|
3383
|
+
escrow_receipt?: Record<string, unknown> | undefined;
|
|
3384
|
+
}, {
|
|
3385
|
+
type: "relay_request";
|
|
3386
|
+
id: string;
|
|
3387
|
+
card_id: string;
|
|
3388
|
+
target_owner: string;
|
|
3389
|
+
params?: Record<string, unknown> | undefined;
|
|
3390
|
+
skill_id?: string | undefined;
|
|
3391
|
+
requester?: string | undefined;
|
|
3392
|
+
escrow_receipt?: Record<string, unknown> | undefined;
|
|
3393
|
+
}>, z.ZodObject<{
|
|
3394
|
+
type: z.ZodLiteral<"incoming_request">;
|
|
3395
|
+
id: z.ZodString;
|
|
3396
|
+
from_owner: z.ZodString;
|
|
3397
|
+
card_id: z.ZodString;
|
|
3398
|
+
skill_id: z.ZodOptional<z.ZodString>;
|
|
3399
|
+
params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3400
|
+
requester: z.ZodOptional<z.ZodString>;
|
|
3401
|
+
escrow_receipt: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3402
|
+
}, "strip", z.ZodTypeAny, {
|
|
3403
|
+
type: "incoming_request";
|
|
3404
|
+
params: Record<string, unknown>;
|
|
3405
|
+
id: string;
|
|
3406
|
+
card_id: string;
|
|
3407
|
+
from_owner: string;
|
|
3408
|
+
skill_id?: string | undefined;
|
|
3409
|
+
requester?: string | undefined;
|
|
3410
|
+
escrow_receipt?: Record<string, unknown> | undefined;
|
|
3411
|
+
}, {
|
|
3412
|
+
type: "incoming_request";
|
|
3413
|
+
id: string;
|
|
3414
|
+
card_id: string;
|
|
3415
|
+
from_owner: string;
|
|
3416
|
+
params?: Record<string, unknown> | undefined;
|
|
3417
|
+
skill_id?: string | undefined;
|
|
3418
|
+
requester?: string | undefined;
|
|
3419
|
+
escrow_receipt?: Record<string, unknown> | undefined;
|
|
3420
|
+
}>, z.ZodObject<{
|
|
3421
|
+
type: z.ZodLiteral<"relay_response">;
|
|
3422
|
+
id: z.ZodString;
|
|
3423
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
3424
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
3425
|
+
code: z.ZodNumber;
|
|
3426
|
+
message: z.ZodString;
|
|
3427
|
+
}, "strip", z.ZodTypeAny, {
|
|
3428
|
+
code: number;
|
|
3429
|
+
message: string;
|
|
3430
|
+
}, {
|
|
3431
|
+
code: number;
|
|
3432
|
+
message: string;
|
|
3433
|
+
}>>;
|
|
3434
|
+
}, "strip", z.ZodTypeAny, {
|
|
3435
|
+
type: "relay_response";
|
|
3436
|
+
id: string;
|
|
3437
|
+
result?: unknown;
|
|
3438
|
+
error?: {
|
|
3439
|
+
code: number;
|
|
3440
|
+
message: string;
|
|
3441
|
+
} | undefined;
|
|
3442
|
+
}, {
|
|
3443
|
+
type: "relay_response";
|
|
3444
|
+
id: string;
|
|
3445
|
+
result?: unknown;
|
|
3446
|
+
error?: {
|
|
3447
|
+
code: number;
|
|
3448
|
+
message: string;
|
|
3449
|
+
} | undefined;
|
|
3450
|
+
}>, z.ZodObject<{
|
|
3451
|
+
type: z.ZodLiteral<"response">;
|
|
3452
|
+
id: z.ZodString;
|
|
3453
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
3454
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
3455
|
+
code: z.ZodNumber;
|
|
3456
|
+
message: z.ZodString;
|
|
3457
|
+
}, "strip", z.ZodTypeAny, {
|
|
3458
|
+
code: number;
|
|
3459
|
+
message: string;
|
|
3460
|
+
}, {
|
|
3461
|
+
code: number;
|
|
3462
|
+
message: string;
|
|
3463
|
+
}>>;
|
|
3464
|
+
}, "strip", z.ZodTypeAny, {
|
|
3465
|
+
type: "response";
|
|
3466
|
+
id: string;
|
|
3467
|
+
result?: unknown;
|
|
3468
|
+
error?: {
|
|
3469
|
+
code: number;
|
|
3470
|
+
message: string;
|
|
3471
|
+
} | undefined;
|
|
3472
|
+
}, {
|
|
3473
|
+
type: "response";
|
|
3474
|
+
id: string;
|
|
3475
|
+
result?: unknown;
|
|
3476
|
+
error?: {
|
|
3477
|
+
code: number;
|
|
3478
|
+
message: string;
|
|
3479
|
+
} | undefined;
|
|
3480
|
+
}>, z.ZodObject<{
|
|
3481
|
+
type: z.ZodLiteral<"error">;
|
|
3482
|
+
code: z.ZodString;
|
|
3483
|
+
message: z.ZodString;
|
|
3484
|
+
request_id: z.ZodOptional<z.ZodString>;
|
|
3485
|
+
}, "strip", z.ZodTypeAny, {
|
|
3486
|
+
type: "error";
|
|
3487
|
+
code: string;
|
|
3488
|
+
message: string;
|
|
3489
|
+
request_id?: string | undefined;
|
|
3490
|
+
}, {
|
|
3491
|
+
type: "error";
|
|
3492
|
+
code: string;
|
|
3493
|
+
message: string;
|
|
3494
|
+
request_id?: string | undefined;
|
|
3495
|
+
}>]>;
|
|
3496
|
+
type RegisterMessage = z.infer<typeof RegisterMessageSchema>;
|
|
3497
|
+
type RegisteredMessage = z.infer<typeof RegisteredMessageSchema>;
|
|
3498
|
+
type RelayRequestMessage = z.infer<typeof RelayRequestMessageSchema>;
|
|
3499
|
+
type IncomingRequestMessage = z.infer<typeof IncomingRequestMessageSchema>;
|
|
3500
|
+
type RelayResponseMessage = z.infer<typeof RelayResponseMessageSchema>;
|
|
3501
|
+
type ResponseMessage = z.infer<typeof ResponseMessageSchema>;
|
|
3502
|
+
type ErrorMessage = z.infer<typeof ErrorMessageSchema>;
|
|
3503
|
+
type RelayMessage = z.infer<typeof RelayMessageSchema>;
|
|
3504
|
+
/** Relay server state returned from registerWebSocketRelay */
|
|
3505
|
+
interface RelayState {
|
|
3506
|
+
/** Number of currently connected agents */
|
|
3507
|
+
getOnlineCount(): number;
|
|
3508
|
+
/** List of connected agent owners */
|
|
3509
|
+
getOnlineOwners(): string[];
|
|
3510
|
+
/** Graceful shutdown — close all connections */
|
|
3511
|
+
shutdown(): void;
|
|
3512
|
+
}
|
|
3513
|
+
|
|
3514
|
+
/**
|
|
3515
|
+
* Registers WebSocket relay on an existing Fastify instance.
|
|
3516
|
+
* Adds a `/ws` route that upgrades HTTP to WebSocket for agent relay.
|
|
3517
|
+
*
|
|
3518
|
+
* @param server - Fastify instance with @fastify/websocket already registered.
|
|
3519
|
+
* @param db - Registry database instance.
|
|
3520
|
+
* @returns RelayState for monitoring and graceful shutdown.
|
|
3521
|
+
*/
|
|
3522
|
+
declare function registerWebSocketRelay(server: FastifyInstance, db: Database.Database): RelayState;
|
|
3523
|
+
|
|
3524
|
+
/** Result of handling an incoming relay request */
|
|
3525
|
+
interface RelayHandlerResult {
|
|
3526
|
+
result?: unknown;
|
|
3527
|
+
error?: {
|
|
3528
|
+
code: number;
|
|
3529
|
+
message: string;
|
|
3530
|
+
};
|
|
3531
|
+
}
|
|
3532
|
+
/** Options for the RelayClient constructor */
|
|
3533
|
+
interface RelayClientOptions {
|
|
3534
|
+
/** Registry WebSocket URL (e.g., "wss://hub.agentbnb.dev/ws") */
|
|
3535
|
+
registryUrl: string;
|
|
3536
|
+
/** Agent owner identifier */
|
|
3537
|
+
owner: string;
|
|
3538
|
+
/** Authentication token */
|
|
3539
|
+
token: string;
|
|
3540
|
+
/** Capability card data to register */
|
|
3541
|
+
card: Record<string, unknown>;
|
|
3542
|
+
/** Handler for incoming relay requests from other agents */
|
|
3543
|
+
onRequest: (req: IncomingRequestMessage) => Promise<RelayHandlerResult>;
|
|
3544
|
+
/** Suppress logging. Default false. */
|
|
3545
|
+
silent?: boolean;
|
|
3546
|
+
}
|
|
3547
|
+
/** Options for making a relay request to another agent */
|
|
3548
|
+
interface RelayRequestOptions$1 {
|
|
3549
|
+
targetOwner: string;
|
|
3550
|
+
cardId: string;
|
|
3551
|
+
skillId?: string;
|
|
3552
|
+
params: Record<string, unknown>;
|
|
3553
|
+
requester?: string;
|
|
3554
|
+
escrowReceipt?: Record<string, unknown>;
|
|
3555
|
+
timeoutMs?: number;
|
|
3556
|
+
}
|
|
3557
|
+
/**
|
|
3558
|
+
* WebSocket client for connecting to an AgentBnB registry relay.
|
|
3559
|
+
* Handles registration, auto-reconnect, incoming requests, and outbound relay requests.
|
|
3560
|
+
*/
|
|
3561
|
+
declare class RelayClient {
|
|
3562
|
+
private ws;
|
|
3563
|
+
private readonly opts;
|
|
3564
|
+
private readonly pendingRequests;
|
|
3565
|
+
private reconnectAttempts;
|
|
3566
|
+
private reconnectTimer;
|
|
3567
|
+
private intentionalClose;
|
|
3568
|
+
private registered;
|
|
3569
|
+
private pongTimeout;
|
|
3570
|
+
private pingInterval;
|
|
3571
|
+
constructor(opts: RelayClientOptions);
|
|
3572
|
+
/**
|
|
3573
|
+
* Connect to the registry relay and register.
|
|
3574
|
+
* Resolves when registration is acknowledged.
|
|
3575
|
+
*/
|
|
3576
|
+
connect(): Promise<void>;
|
|
3577
|
+
/**
|
|
3578
|
+
* Disconnect from the registry relay.
|
|
3579
|
+
*/
|
|
3580
|
+
disconnect(): void;
|
|
3581
|
+
/**
|
|
3582
|
+
* Send a relay request to another agent via the registry.
|
|
3583
|
+
* @returns The result from the target agent.
|
|
3584
|
+
*/
|
|
3585
|
+
request(opts: RelayRequestOptions$1): Promise<unknown>;
|
|
3586
|
+
/** Whether the client is connected and registered */
|
|
3587
|
+
get isConnected(): boolean;
|
|
3588
|
+
private buildWsUrl;
|
|
3589
|
+
private handleMessage;
|
|
3590
|
+
private handleIncomingRequest;
|
|
3591
|
+
private handleResponse;
|
|
3592
|
+
private handleError;
|
|
3593
|
+
private send;
|
|
3594
|
+
private startPingInterval;
|
|
3595
|
+
private stopPingInterval;
|
|
3596
|
+
private cleanup;
|
|
3597
|
+
private scheduleReconnect;
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3600
|
+
/**
|
|
3601
|
+
* Options for executing a capability request.
|
|
3602
|
+
* Used by both the HTTP /rpc handler and WebSocket relay.
|
|
3603
|
+
*/
|
|
3604
|
+
interface ExecuteRequestOptions {
|
|
3605
|
+
registryDb: Database.Database;
|
|
3606
|
+
creditDb: Database.Database;
|
|
3607
|
+
cardId: string;
|
|
3608
|
+
skillId?: string;
|
|
3609
|
+
params: Record<string, unknown>;
|
|
3610
|
+
requester: string;
|
|
3611
|
+
escrowReceipt?: EscrowReceipt;
|
|
3612
|
+
skillExecutor?: SkillExecutor;
|
|
3613
|
+
handlerUrl?: string;
|
|
3614
|
+
timeoutMs?: number;
|
|
3615
|
+
}
|
|
3616
|
+
/**
|
|
3617
|
+
* Result of a capability execution.
|
|
3618
|
+
*/
|
|
3619
|
+
type ExecuteResult = {
|
|
3620
|
+
success: true;
|
|
3621
|
+
result: unknown;
|
|
3622
|
+
} | {
|
|
3623
|
+
success: false;
|
|
3624
|
+
error: {
|
|
3625
|
+
code: number;
|
|
3626
|
+
message: string;
|
|
3627
|
+
data?: Record<string, unknown>;
|
|
3628
|
+
};
|
|
3629
|
+
};
|
|
3630
|
+
/**
|
|
3631
|
+
* Executes a capability request with full escrow, reputation, and logging.
|
|
3632
|
+
* Shared between HTTP gateway (/rpc) and WebSocket relay paths.
|
|
3633
|
+
*
|
|
3634
|
+
* @param opts - Execution options including DB handles, card/skill IDs, and executor.
|
|
3635
|
+
* @returns Success with result, or failure with error details.
|
|
3636
|
+
*/
|
|
3637
|
+
declare function executeCapabilityRequest(opts: ExecuteRequestOptions): Promise<ExecuteResult>;
|
|
3638
|
+
|
|
3639
|
+
/**
|
|
3640
|
+
* Options for requesting a capability via WebSocket relay.
|
|
3641
|
+
*/
|
|
3642
|
+
interface RelayRequestOptions {
|
|
3643
|
+
/** Target agent owner to relay the request to. */
|
|
3644
|
+
targetOwner: string;
|
|
3645
|
+
/** Capability Card ID to execute. */
|
|
3646
|
+
cardId: string;
|
|
3647
|
+
/** Optional skill ID within the card. */
|
|
3648
|
+
skillId?: string;
|
|
3649
|
+
/** Input parameters for the capability. */
|
|
3650
|
+
params?: Record<string, unknown>;
|
|
3651
|
+
/** Signed escrow receipt for cross-machine credit verification. */
|
|
3652
|
+
escrowReceipt?: EscrowReceipt;
|
|
3653
|
+
/** Timeout in milliseconds. Default 30000. */
|
|
3654
|
+
timeoutMs?: number;
|
|
3655
|
+
}
|
|
3656
|
+
/**
|
|
3657
|
+
* Sends a capability request to another agent via the WebSocket relay.
|
|
3658
|
+
*
|
|
3659
|
+
* @param relay - Connected RelayClient instance.
|
|
3660
|
+
* @param opts - Relay request options.
|
|
3661
|
+
* @returns The result from the capability execution.
|
|
3662
|
+
* @throws {AgentBnBError} on relay error, timeout, or target agent offline.
|
|
3663
|
+
*/
|
|
3664
|
+
declare function requestViaRelay(relay: RelayClient, opts: RelayRequestOptions): Promise<unknown>;
|
|
3665
|
+
|
|
3666
|
+
/**
|
|
3667
|
+
* Capability detection patterns and templates for smart onboarding.
|
|
3668
|
+
*
|
|
3669
|
+
* Pure data — regex patterns to detect known APIs/tools in markdown files,
|
|
3670
|
+
* and pre-built templates for the interactive fallback menu.
|
|
3671
|
+
*/
|
|
3672
|
+
/**
|
|
3673
|
+
* A detected capability from doc scanning or template selection.
|
|
3674
|
+
* Lightweight — converted to a full Skill via capabilitiesToV2Card().
|
|
3675
|
+
*/
|
|
3676
|
+
interface DetectedCapability {
|
|
3677
|
+
/** Unique key for deduplication, e.g. 'openai', 'elevenlabs' */
|
|
3678
|
+
key: string;
|
|
3679
|
+
/** Human-readable name, e.g. 'OpenAI Text Generation' */
|
|
3680
|
+
name: string;
|
|
3681
|
+
/** Category label, e.g. 'Text Gen', 'TTS' */
|
|
3682
|
+
category: string;
|
|
3683
|
+
/** Default credits per call */
|
|
3684
|
+
credits_per_call: number;
|
|
3685
|
+
/** Metadata tags for FTS indexing */
|
|
3686
|
+
tags: string[];
|
|
3687
|
+
}
|
|
3688
|
+
/**
|
|
3689
|
+
* A regex pattern entry mapping a pattern to a DetectedCapability.
|
|
3690
|
+
*/
|
|
3691
|
+
interface PatternEntry {
|
|
3692
|
+
/** Regex to test against document content */
|
|
3693
|
+
pattern: RegExp;
|
|
3694
|
+
/** The capability to return if the pattern matches */
|
|
3695
|
+
capability: DetectedCapability;
|
|
3696
|
+
}
|
|
3697
|
+
/**
|
|
3698
|
+
* Regex patterns for detecting known APIs and tools in markdown documentation.
|
|
3699
|
+
* Each pattern maps to a DetectedCapability with sensible defaults.
|
|
3700
|
+
*/
|
|
3701
|
+
declare const API_PATTERNS: PatternEntry[];
|
|
3702
|
+
/**
|
|
3703
|
+
* Pre-built templates for the interactive onboarding fallback menu.
|
|
3704
|
+
* Shown when no capabilities are auto-detected.
|
|
3705
|
+
*/
|
|
3706
|
+
declare const INTERACTIVE_TEMPLATES: DetectedCapability[];
|
|
3707
|
+
|
|
3708
|
+
/**
|
|
3709
|
+
* Scans markdown content for known API/tool patterns and returns detected capabilities.
|
|
3710
|
+
*
|
|
3711
|
+
* - Tests each API_PATTERNS regex against the full content
|
|
3712
|
+
* - Deduplicates by capability key (first match wins)
|
|
3713
|
+
* - Returns empty array if nothing is detected
|
|
3714
|
+
*
|
|
3715
|
+
* @param content - Markdown file content to scan
|
|
3716
|
+
* @returns Array of detected capabilities (may be empty)
|
|
3717
|
+
*/
|
|
3718
|
+
declare function detectFromDocs(content: string): DetectedCapability[];
|
|
3719
|
+
|
|
3720
|
+
/**
|
|
3721
|
+
* Result of the capability detection chain.
|
|
3722
|
+
* The `source` field indicates which detection method succeeded.
|
|
3723
|
+
*/
|
|
3724
|
+
interface DetectionResult {
|
|
3725
|
+
/** Which detection method produced results */
|
|
3726
|
+
source: 'soul' | 'docs' | 'env' | 'none';
|
|
3727
|
+
/** Detected capabilities (for 'docs' source) */
|
|
3728
|
+
capabilities: DetectedCapability[];
|
|
3729
|
+
/** Raw SOUL.md content (for 'soul' source — caller passes to publishFromSoulV2) */
|
|
3730
|
+
soulContent?: string;
|
|
3731
|
+
/** Detected env var names (for 'env' source — caller passes to buildDraftCard) */
|
|
3732
|
+
envKeys?: string[];
|
|
3733
|
+
/** Which file was used for detection */
|
|
3734
|
+
sourceFile?: string;
|
|
3735
|
+
}
|
|
3736
|
+
/**
|
|
3737
|
+
* Options for the detection chain.
|
|
3738
|
+
*/
|
|
3739
|
+
interface DetectOptions {
|
|
3740
|
+
/** Explicit file to parse (--from flag) */
|
|
3741
|
+
fromFile?: string;
|
|
3742
|
+
/** Working directory to search for doc files (default: process.cwd()) */
|
|
3743
|
+
cwd?: string;
|
|
3744
|
+
}
|
|
3745
|
+
/**
|
|
3746
|
+
* Runs the capability detection priority chain.
|
|
3747
|
+
*
|
|
3748
|
+
* Checks sources in order and stops at the first one that produces results:
|
|
3749
|
+
* 1. --from <file> → detectFromDocs()
|
|
3750
|
+
* 2. SOUL.md → returns raw content for publishFromSoulV2()
|
|
3751
|
+
* 3. CLAUDE.md / AGENTS.md / README.md → detectFromDocs()
|
|
3752
|
+
* 4. Environment variables → detectApiKeys()
|
|
3753
|
+
* 5. Returns { source: 'none' } if nothing found
|
|
3754
|
+
*
|
|
3755
|
+
* @param opts - Detection options (fromFile, cwd)
|
|
3756
|
+
* @returns Detection result with source indicator and data
|
|
3757
|
+
*/
|
|
3758
|
+
declare function detectCapabilities(opts?: DetectOptions): DetectionResult;
|
|
3759
|
+
/**
|
|
3760
|
+
* Converts detected capabilities into a v2.0 CapabilityCard with skills.
|
|
3761
|
+
*
|
|
3762
|
+
* Each DetectedCapability becomes a Skill on the card. The card is validated
|
|
3763
|
+
* via CapabilityCardV2Schema before returning.
|
|
3764
|
+
*
|
|
3765
|
+
* @param capabilities - Detected capabilities to convert
|
|
3766
|
+
* @param owner - Agent owner name
|
|
3767
|
+
* @param agentName - Optional agent display name (defaults to owner)
|
|
3768
|
+
* @returns A valid v2.0 CapabilityCard
|
|
3769
|
+
*/
|
|
3770
|
+
declare function capabilitiesToV2Card(capabilities: DetectedCapability[], owner: string, agentName?: string): CapabilityCardV2;
|
|
3771
|
+
|
|
3772
|
+
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 };
|