@hashgraphonline/standards-sdk 0.0.16 → 0.0.17
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/es/hcs-10/agent-builder.d.ts +24 -0
- package/dist/es/hcs-10/base-client.d.ts +61 -0
- package/dist/es/hcs-10/browser.d.ts +2 -6
- package/dist/es/hcs-10/index.d.ts +2 -2
- package/dist/es/hcs-10/registrations.d.ts +16 -0
- package/dist/es/hcs-10/sdk.d.ts +30 -51
- package/dist/es/standards-sdk.es.js +23847 -24064
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/utils/index.d.ts +2 -0
- package/dist/es/utils/mirror-node-utils.d.ts +146 -0
- package/dist/es/utils/topic-fee-utils.d.ts +11 -0
- package/dist/umd/hcs-10/agent-builder.d.ts +24 -0
- package/dist/umd/hcs-10/base-client.d.ts +61 -0
- package/dist/umd/hcs-10/browser.d.ts +2 -6
- package/dist/umd/hcs-10/index.d.ts +2 -2
- package/dist/umd/hcs-10/registrations.d.ts +16 -0
- package/dist/umd/hcs-10/sdk.d.ts +30 -51
- package/dist/umd/standards-sdk.umd.js +11 -11
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/dist/umd/utils/index.d.ts +2 -0
- package/dist/umd/utils/mirror-node-utils.d.ts +146 -0
- package/dist/umd/utils/topic-fee-utils.d.ts +11 -0
- package/package.json +5 -3
- package/dist/es/hcs-10/outbound.d.ts +0 -150
- package/dist/es/hcs-10/registration-utils.d.ts +0 -34
- package/dist/umd/hcs-10/outbound.d.ts +0 -150
- package/dist/umd/hcs-10/registration-utils.d.ts +0 -34
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { InboundTopicType, NetworkType, AgentConfiguration, FeeAmount } from './types.d';
|
|
2
|
+
import { AIAgentCapability } from '../hcs-11';
|
|
3
|
+
import { AgentMetadata } from './sdk';
|
|
4
|
+
type SocialPlatform = 'twitter' | 'discord' | 'github' | 'website' | 'x' | 'linkedin' | 'youtube' | 'telegram';
|
|
5
|
+
export declare class AgentBuilder {
|
|
6
|
+
private config;
|
|
7
|
+
setName(name: string): AgentBuilder;
|
|
8
|
+
setDescription(description: string): AgentBuilder;
|
|
9
|
+
setCapabilities(capabilities: AIAgentCapability[]): AgentBuilder;
|
|
10
|
+
setAgentType(type: 'autonomous' | 'manual'): AgentBuilder;
|
|
11
|
+
setModel(model: string): AgentBuilder;
|
|
12
|
+
setCreator(creator: string): AgentBuilder;
|
|
13
|
+
addSocial(platform: SocialPlatform, handle: string): AgentBuilder;
|
|
14
|
+
addProperty(key: string, value: any): AgentBuilder;
|
|
15
|
+
setMetadata(metadata: AgentMetadata): AgentBuilder;
|
|
16
|
+
setProfilePicture(pfpBuffer: Buffer, pfpFileName: string): AgentBuilder;
|
|
17
|
+
setNetwork(network: NetworkType): AgentBuilder;
|
|
18
|
+
setInboundTopicType(inboundTopicType: InboundTopicType): AgentBuilder;
|
|
19
|
+
setFeeConfig(feeAmount: FeeAmount, feeCollectorAccountId: string, exemptAccounts?: string[]): AgentBuilder;
|
|
20
|
+
setConnectionFeeConfig(feeAmount: FeeAmount, feeCollectorAccountId: string, exemptAccounts?: string[]): AgentBuilder;
|
|
21
|
+
setExistingAccount(accountId: string, privateKey: string): AgentBuilder;
|
|
22
|
+
build(): AgentConfiguration;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Logger, LogLevel } from '../utils/logger';
|
|
2
|
+
import { Registration } from './registrations';
|
|
3
|
+
import { HederaMirrorNode, TopicInfo, AccountResponse } from '../utils/mirror-node-utils';
|
|
4
|
+
export interface HCS10Config {
|
|
5
|
+
network: 'mainnet' | 'testnet';
|
|
6
|
+
logLevel?: LogLevel;
|
|
7
|
+
}
|
|
8
|
+
export interface HCSMessage {
|
|
9
|
+
p: 'hcs-10';
|
|
10
|
+
op: 'connection_request' | 'connection_created' | 'message';
|
|
11
|
+
data: string;
|
|
12
|
+
created?: Date;
|
|
13
|
+
consensus_timestamp?: string;
|
|
14
|
+
m?: string;
|
|
15
|
+
payer: string;
|
|
16
|
+
outbound_topic_id?: string;
|
|
17
|
+
connection_request_id?: number;
|
|
18
|
+
confirmed_request_id?: number;
|
|
19
|
+
connection_topic_id?: string;
|
|
20
|
+
connected_account_id?: string;
|
|
21
|
+
requesting_account_id?: string;
|
|
22
|
+
connection_id?: number;
|
|
23
|
+
sequence_number: number;
|
|
24
|
+
operator_id?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare abstract class HCS10BaseClient extends Registration {
|
|
27
|
+
protected network: string;
|
|
28
|
+
protected logger: Logger;
|
|
29
|
+
protected mirrorNode: HederaMirrorNode;
|
|
30
|
+
constructor(config: HCS10Config);
|
|
31
|
+
abstract getAccountAndSigner(): {
|
|
32
|
+
accountId: string;
|
|
33
|
+
signer: any;
|
|
34
|
+
};
|
|
35
|
+
getMessages(topicId: string): Promise<{
|
|
36
|
+
messages: HCSMessage[];
|
|
37
|
+
}>;
|
|
38
|
+
protected checkRegistrationStatus(transactionId: string, network: string, baseUrl: string): Promise<{
|
|
39
|
+
status: 'pending' | 'success' | 'failed';
|
|
40
|
+
}>;
|
|
41
|
+
requestAccount(account: string): Promise<AccountResponse>;
|
|
42
|
+
getAccountMemo(accountId: string): Promise<string | null>;
|
|
43
|
+
protected getTopicInfoFromMemo(memo: string): Promise<TopicInfo | null>;
|
|
44
|
+
getTopicInfo(accountId: string): Promise<TopicInfo | null>;
|
|
45
|
+
retrieveOutboundConnectTopic(accountId: string): Promise<string | null>;
|
|
46
|
+
retrieveOutboundConnectTopicFromNetwork(accountId: string): Promise<TopicInfo>;
|
|
47
|
+
retrieveOutboundMessages(agentAccountId: string): Promise<HCSMessage[]>;
|
|
48
|
+
hasConnectionCreated(agentAccountId: string, connectionId: number): Promise<boolean>;
|
|
49
|
+
clearCache(): void;
|
|
50
|
+
}
|
|
51
|
+
export declare class HCS10Cache {
|
|
52
|
+
private static instance;
|
|
53
|
+
private cache;
|
|
54
|
+
private cacheExpiry;
|
|
55
|
+
private readonly CACHE_TTL;
|
|
56
|
+
private constructor();
|
|
57
|
+
static getInstance(): HCS10Cache;
|
|
58
|
+
set(key: string, value: TopicInfo): void;
|
|
59
|
+
get(key: string): TopicInfo | undefined;
|
|
60
|
+
clear(): void;
|
|
61
|
+
}
|
|
@@ -2,7 +2,7 @@ import { PublicKey, TransactionReceipt } from '@hashgraph/sdk';
|
|
|
2
2
|
import { HashinalsWalletConnectSDK } from '@hashgraphonline/hashinal-wc';
|
|
3
3
|
import { Logger, LogLevel } from '../utils/logger';
|
|
4
4
|
import { RetrievedInscriptionResult } from '@kiloscribe/inscription-sdk';
|
|
5
|
-
import {
|
|
5
|
+
import { HCS10BaseClient } from './base-client';
|
|
6
6
|
import { AgentConfig, NetworkType } from './types.d';
|
|
7
7
|
export type BrowserHCSClientConfig = {
|
|
8
8
|
network: 'mainnet' | 'testnet';
|
|
@@ -28,10 +28,9 @@ interface SocialLinks {
|
|
|
28
28
|
export type BrowserAgentConfig = Omit<AgentConfig<BrowserHCSClient>, 'privateKey'> & {
|
|
29
29
|
client: BrowserHCSClient;
|
|
30
30
|
};
|
|
31
|
-
export declare class BrowserHCSClient extends
|
|
31
|
+
export declare class BrowserHCSClient extends HCS10BaseClient {
|
|
32
32
|
private hwc;
|
|
33
33
|
protected logger: Logger;
|
|
34
|
-
private guardedRegistryTopicId;
|
|
35
34
|
private guardedRegistryBaseUrl;
|
|
36
35
|
private hcs11Client;
|
|
37
36
|
constructor(config: BrowserHCSClientConfig);
|
|
@@ -93,9 +92,6 @@ export declare class BrowserHCSClient extends Outbound {
|
|
|
93
92
|
accountId: string;
|
|
94
93
|
signer: any;
|
|
95
94
|
};
|
|
96
|
-
protected getMessages(topicId: string): Promise<{
|
|
97
|
-
messages: HCSMessage[];
|
|
98
|
-
}>;
|
|
99
95
|
/**
|
|
100
96
|
* Inscribes a profile picture file to the Hedera network
|
|
101
97
|
* @param buffer File buffer to inscribe
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AgentMetadata } from './sdk';
|
|
2
|
+
import { Logger } from '../utils/logger';
|
|
2
3
|
export interface RegistrationSearchOptions {
|
|
3
4
|
tags?: string[];
|
|
4
5
|
accountId?: string;
|
|
@@ -22,6 +23,21 @@ export interface RegistrationSearchResult {
|
|
|
22
23
|
error?: string;
|
|
23
24
|
success: boolean;
|
|
24
25
|
}
|
|
26
|
+
export type RegistrationResult = {
|
|
27
|
+
transaction?: any;
|
|
28
|
+
transactionId?: string;
|
|
29
|
+
success: boolean;
|
|
30
|
+
error?: string;
|
|
31
|
+
validationErrors?: any[];
|
|
32
|
+
};
|
|
25
33
|
export declare abstract class Registration {
|
|
34
|
+
protected checkRegistrationStatus(transactionId: string, network: string, baseUrl: string, logger?: Logger): Promise<{
|
|
35
|
+
status: 'pending' | 'success' | 'failed';
|
|
36
|
+
}>;
|
|
37
|
+
waitForRegistrationConfirmation(transactionId: string, network: string, baseUrl: string, maxAttempts?: number, delayMs?: number, logger?: Logger): Promise<boolean>;
|
|
38
|
+
executeRegistration(accountId: string, inboundTopicId: string, network: string, baseUrl: string, logger?: Logger, metadata?: {
|
|
39
|
+
tags: string[];
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}): Promise<RegistrationResult>;
|
|
26
42
|
findRegistrations(options?: RegistrationSearchOptions, baseUrl?: string): Promise<RegistrationSearchResult>;
|
|
27
43
|
}
|
package/dist/es/hcs-10/sdk.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Client, PrivateKey, TransactionReceipt, PublicKey } from '@hashgraph/sdk';
|
|
1
|
+
import { Client, PrivateKey, KeyList, TransactionReceipt, PublicKey } from '@hashgraph/sdk';
|
|
2
2
|
import { RetrievedInscriptionResult } from '@kiloscribe/inscription-sdk';
|
|
3
3
|
import { Logger } from '../utils/logger';
|
|
4
|
-
import {
|
|
5
|
-
import { HCSClientConfig,
|
|
4
|
+
import { HCS10BaseClient } from './base-client';
|
|
5
|
+
import { HCSClientConfig, AgentConfig, CreateAccountResponse, CreateAgentResponse, InscribePfpResponse, StoreHCS11ProfileResponse, AgentRegistrationResult, HandleConnectionRequestResponse, WaitForConnectionConfirmationResponse, GetAccountAndSignerResponse, InboundTopicType, TopicFeeConfig } from './types.d';
|
|
6
|
+
import { AgentBuilder } from './agent-builder';
|
|
7
|
+
export { InboundTopicType } from './types.d';
|
|
6
8
|
export interface AgentMetadata {
|
|
7
9
|
type: 'autonomous' | 'manual';
|
|
8
10
|
model?: string;
|
|
@@ -19,13 +21,14 @@ export interface AgentMetadata {
|
|
|
19
21
|
creator?: string;
|
|
20
22
|
properties?: Record<string, any>;
|
|
21
23
|
}
|
|
22
|
-
export declare class HCS10Client extends
|
|
24
|
+
export declare class HCS10Client extends HCS10BaseClient {
|
|
23
25
|
private client;
|
|
24
26
|
private operatorPrivateKey;
|
|
25
27
|
protected network: string;
|
|
26
28
|
protected logger: Logger;
|
|
27
29
|
protected guardedRegistryBaseUrl: string;
|
|
28
30
|
private hcs11Client;
|
|
31
|
+
private feeAmount;
|
|
29
32
|
constructor(config: HCSClientConfig);
|
|
30
33
|
getClient(): Client;
|
|
31
34
|
/**
|
|
@@ -33,17 +36,20 @@ export declare class HCS10Client extends Outbound {
|
|
|
33
36
|
* @returns Object with account ID and private key
|
|
34
37
|
*/
|
|
35
38
|
createAccount(): Promise<CreateAccountResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Creates an inbound topic with the specified configuration
|
|
41
|
+
* @param accountId Account ID associated with the topic
|
|
42
|
+
* @param topicType Type of inbound topic (public, controlled, or fee-based)
|
|
43
|
+
* @param feeConfig Optional fee configuration for fee-based topics
|
|
44
|
+
* @returns The topic ID of the created inbound topic
|
|
45
|
+
*/
|
|
46
|
+
createInboundTopic(accountId: string, topicType: InboundTopicType, feeConfig?: TopicFeeConfig): Promise<string>;
|
|
36
47
|
/**
|
|
37
48
|
* Creates a new agent with inbound and outbound topics
|
|
38
|
-
* @param
|
|
39
|
-
* @param pfpFileName Profile picture filename
|
|
40
|
-
* @param agentName Agent name
|
|
41
|
-
* @param agentDescription Agent description
|
|
42
|
-
* @param capabilities Agent capability tags
|
|
43
|
-
* @param metadata Additional agent metadata
|
|
49
|
+
* @param builder The agent builder object
|
|
44
50
|
* @returns Object with topic IDs
|
|
45
51
|
*/
|
|
46
|
-
createAgent(
|
|
52
|
+
createAgent(builder: AgentBuilder): Promise<CreateAgentResponse>;
|
|
47
53
|
/**
|
|
48
54
|
* Inscribes a profile picture to Hedera
|
|
49
55
|
* @param buffer Profile picture buffer
|
|
@@ -64,33 +70,21 @@ export declare class HCS10Client extends Outbound {
|
|
|
64
70
|
* @returns Response with topic IDs and transaction ID
|
|
65
71
|
*/
|
|
66
72
|
storeHCS11Profile(agentName: string, agentDescription: string, inboundTopicId: string, outboundTopicId: string, capabilities: number[], metadata: AgentMetadata, pfpBuffer?: Buffer, pfpFileName?: string): Promise<StoreHCS11ProfileResponse>;
|
|
73
|
+
private setupFees;
|
|
67
74
|
/**
|
|
68
75
|
* Handles a connection request from another account
|
|
69
76
|
* @param inboundTopicId Inbound topic ID
|
|
70
77
|
* @param requestingAccountId Requesting account ID
|
|
71
78
|
* @param connectionRequestId Connection request ID
|
|
79
|
+
* @param connectionFeeConfig Optional fee configuration for the connection topic
|
|
72
80
|
* @returns Response with connection details
|
|
73
81
|
*/
|
|
74
|
-
handleConnectionRequest(inboundTopicId: string, requestingAccountId: string, connectionRequestId: number): Promise<HandleConnectionRequestResponse>;
|
|
82
|
+
handleConnectionRequest(inboundTopicId: string, requestingAccountId: string, connectionRequestId: number, connectionFeeConfig?: TopicFeeConfig): Promise<HandleConnectionRequestResponse>;
|
|
75
83
|
confirmConnection(inboundTopicId: string, connectionTopicId: string, connectedAccountId: string, connectionId: number, operatorId: string, memo: string, submitKey?: PrivateKey): Promise<number>;
|
|
76
84
|
sendMessage(connectionTopicId: string, operatorId: string, data: string, memo?: string, submitKey?: PrivateKey): Promise<void>;
|
|
77
|
-
|
|
78
|
-
* Retrieves the memo field from a Hedera account
|
|
79
|
-
* @param accountId The account ID to fetch the memo for
|
|
80
|
-
* @returns The account memo as a string, or null if not found/error
|
|
81
|
-
*/
|
|
82
|
-
getAccountMemo(accountId: string): Promise<string | null>;
|
|
83
|
-
/**
|
|
84
|
-
* Creates a threshold topic with the operator and requester keys
|
|
85
|
-
* @param memo The memo for the topic
|
|
86
|
-
* @param requesterPublicKey The public key of the requester
|
|
87
|
-
* @returns The topic ID of the created topic
|
|
88
|
-
*/
|
|
89
|
-
createThresholdTopic(memo: string, requesterPublicKey: string): Promise<string>;
|
|
90
|
-
createTopic(memo: string, adminKey?: boolean, submitKey?: boolean): Promise<string>;
|
|
85
|
+
createTopic(memo: string, adminKey?: boolean | PublicKey | KeyList, submitKey?: boolean | PublicKey | KeyList, feeConfig?: TopicFeeConfig): Promise<string>;
|
|
91
86
|
submitMessage(topicId: string, message: string, submitKey?: PrivateKey): Promise<TransactionReceipt>;
|
|
92
87
|
private submitPayload;
|
|
93
|
-
queryTopicMessages(topicId: string): Promise<string[]>;
|
|
94
88
|
submitConnectionRequest(inboundTopicId: string, requestingAccountId: string, operatorId: string, memo: string): Promise<TransactionReceipt>;
|
|
95
89
|
recordOutboundConnectionConfirmation({ outboundTopicId, connectionRequestId, confirmedRequestId, connectionTopicId, operatorId, memo, }: {
|
|
96
90
|
outboundTopicId: string;
|
|
@@ -110,20 +104,12 @@ export declare class HCS10Client extends Outbound {
|
|
|
110
104
|
* @returns Connection confirmation details
|
|
111
105
|
*/
|
|
112
106
|
waitForConnectionConfirmation(inboundTopicId: string, connectionRequestId: number, maxAttempts?: number, delayMs?: number): Promise<WaitForConnectionConfirmationResponse>;
|
|
113
|
-
/**
|
|
114
|
-
* Gets the account ID and signer for the client
|
|
115
|
-
* @returns Account ID and signer
|
|
116
|
-
*/
|
|
117
107
|
getAccountAndSigner(): GetAccountAndSignerResponse;
|
|
118
|
-
|
|
119
|
-
|
|
108
|
+
canSubmitToInboundTopic(topicId: string, userAccountId: string): Promise<{
|
|
109
|
+
canSubmit: boolean;
|
|
110
|
+
requiresFee: boolean;
|
|
111
|
+
reason?: string;
|
|
120
112
|
}>;
|
|
121
|
-
/**
|
|
122
|
-
* Retrieves the public key for a given account ID
|
|
123
|
-
* @param accountId Account ID to retrieve the public key for
|
|
124
|
-
* @returns The public key of the account
|
|
125
|
-
*/
|
|
126
|
-
getPublicKey(accountId: string): Promise<PublicKey>;
|
|
127
113
|
/**
|
|
128
114
|
* Creates and registers an agent with a Guarded registry.
|
|
129
115
|
*
|
|
@@ -133,20 +119,10 @@ export declare class HCS10Client extends Outbound {
|
|
|
133
119
|
* 3. Creates an agent on the client.
|
|
134
120
|
* 4. Registers the agent with the Hashgraph Online Guarded Registry.
|
|
135
121
|
*
|
|
136
|
-
* @param
|
|
137
|
-
* @param description Agent description
|
|
138
|
-
* @param capabilities Agent capability tags
|
|
139
|
-
* @param metadata Additional metadata
|
|
140
|
-
* @param pfpBuffer Profile picture buffer
|
|
141
|
-
* @param pfpFileName Profile picture filename
|
|
142
|
-
* @param network Network type
|
|
143
|
-
* @param existingAccount Optional existing account
|
|
122
|
+
* @param builder The agent builder object
|
|
144
123
|
* @returns Agent configuration
|
|
145
124
|
*/
|
|
146
|
-
createAndRegisterAgent(
|
|
147
|
-
accountId: string;
|
|
148
|
-
privateKey: string;
|
|
149
|
-
}): Promise<AgentConfig<HCS10Client>>;
|
|
125
|
+
createAndRegisterAgent(builder: AgentBuilder): Promise<AgentConfig<HCS10Client>>;
|
|
150
126
|
/**
|
|
151
127
|
* Registers an agent with the guarded registry
|
|
152
128
|
* @param accountId Account ID to register
|
|
@@ -166,4 +142,7 @@ export declare class HCS10Client extends Outbound {
|
|
|
166
142
|
* @param submitKey - The submit key of the agent
|
|
167
143
|
*/
|
|
168
144
|
registerAgent(registryTopicId: string, accountId: string, inboundTopicId: string, memo: string, submitKey?: PrivateKey): Promise<void>;
|
|
145
|
+
getInboundTopicType(topicId: string): Promise<InboundTopicType>;
|
|
146
|
+
getNetwork(): string;
|
|
147
|
+
getLogger(): Logger;
|
|
169
148
|
}
|