@hashgraphonline/standards-agent-kit 0.2.158 → 0.2.160
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/cjs/builders/inscriber/inscriber-builder.d.ts +6 -6
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/es/builders/inscriber/inscriber-builder.d.ts +6 -6
- package/dist/es/standards-agent-kit.es48.js +7 -3
- package/dist/es/standards-agent-kit.es48.js.map +1 -1
- package/dist/es/standards-agent-kit.es49.js +3 -7
- package/dist/es/standards-agent-kit.es49.js.map +1 -1
- package/dist/es/standards-agent-kit.es6.js +1 -1
- package/dist/es/standards-agent-kit.es7.js +1 -1
- package/dist/es/standards-agent-kit.es8.js +27 -4
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +1 -1
- package/dist/umd/builders/inscriber/inscriber-builder.d.ts +6 -6
- package/dist/umd/standards-agent-kit.umd.js +30 -30
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/builders/inscriber/inscriber-builder.ts +47 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashgraphonline/standards-agent-kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.160",
|
|
4
4
|
"description": "A modular SDK for building on-chain autonomous agents using Hashgraph Online Standards, including HCS-10 for agent discovery and communication.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/standards-agent-kit.cjs",
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
NetworkType,
|
|
13
13
|
getTopicId,
|
|
14
14
|
} from '@hashgraphonline/standards-sdk';
|
|
15
|
-
import { InscriptionResult
|
|
15
|
+
import type { InscriptionResult } from '@kiloscribe/inscription-sdk';
|
|
16
16
|
import type { AgentOperationalMode } from 'hedera-agent-kit';
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -41,8 +41,26 @@ export interface CompletedInscriptionResponse {
|
|
|
41
41
|
/**
|
|
42
42
|
* Builder for Inscription operations
|
|
43
43
|
*/
|
|
44
|
+
let cachedInscriptionSdkModule: typeof import('@kiloscribe/inscription-sdk') | null = null;
|
|
45
|
+
const loadInscriptionSdkModule = async () => {
|
|
46
|
+
if (!cachedInscriptionSdkModule) {
|
|
47
|
+
cachedInscriptionSdkModule = (await import(
|
|
48
|
+
'@kiloscribe/inscription-sdk'
|
|
49
|
+
)) as typeof import('@kiloscribe/inscription-sdk');
|
|
50
|
+
}
|
|
51
|
+
return cachedInscriptionSdkModule;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type InscriptionSDKType = Awaited<
|
|
55
|
+
ReturnType<typeof loadInscriptionSdkModule>
|
|
56
|
+
>['InscriptionSDK'];
|
|
57
|
+
type InscriptionSDKInstance = InstanceType<InscriptionSDKType>;
|
|
58
|
+
type InscriptionSDKAuthParams = Parameters<InscriptionSDKType['createWithAuth']>[0];
|
|
59
|
+
type ClientAuthConfig = Extract<InscriptionSDKAuthParams, { type: 'client' }>;
|
|
60
|
+
type ServerAuthConfig = Extract<InscriptionSDKAuthParams, { type: 'server' }>;
|
|
61
|
+
|
|
44
62
|
export class InscriberBuilder extends BaseServiceBuilder {
|
|
45
|
-
protected inscriptionSDK?:
|
|
63
|
+
protected inscriptionSDK?: InscriptionSDKInstance;
|
|
46
64
|
private static signerProvider?: () =>
|
|
47
65
|
| Promise<DAppSigner | null>
|
|
48
66
|
| DAppSigner
|
|
@@ -129,25 +147,26 @@ export class InscriberBuilder extends BaseServiceBuilder {
|
|
|
129
147
|
*/
|
|
130
148
|
protected async getInscriptionSDK(
|
|
131
149
|
_options: InscriptionOptions
|
|
132
|
-
): Promise<
|
|
150
|
+
): Promise<InscriptionSDKInstance | null> {
|
|
133
151
|
if (this.inscriptionSDK) {
|
|
134
152
|
return this.inscriptionSDK;
|
|
135
153
|
}
|
|
136
154
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
155
|
+
const network = this.hederaKit.client.network;
|
|
156
|
+
const networkType: 'mainnet' | 'testnet' = network.toString().includes('mainnet')
|
|
157
|
+
? 'mainnet'
|
|
158
|
+
: 'testnet';
|
|
159
|
+
const accountId = this.hederaKit.signer.getAccountId().toString();
|
|
142
160
|
|
|
161
|
+
try {
|
|
162
|
+
const { InscriptionSDK } = await loadInscriptionSdkModule();
|
|
143
163
|
const signer = await this.getSigner();
|
|
144
|
-
const accountId = this.hederaKit.signer.getAccountId().toString();
|
|
145
164
|
|
|
146
165
|
if (signer) {
|
|
147
166
|
this.inscriptionSDK = await InscriptionSDK.createWithAuth({
|
|
148
167
|
type: 'client',
|
|
149
168
|
accountId,
|
|
150
|
-
signer: signer as
|
|
169
|
+
signer: signer as unknown as ClientAuthConfig['signer'],
|
|
151
170
|
network: networkType,
|
|
152
171
|
});
|
|
153
172
|
} else {
|
|
@@ -156,13 +175,30 @@ export class InscriberBuilder extends BaseServiceBuilder {
|
|
|
156
175
|
this.inscriptionSDK = await InscriptionSDK.createWithAuth({
|
|
157
176
|
type: 'server',
|
|
158
177
|
accountId,
|
|
159
|
-
privateKey: privateKey.toStringRaw(),
|
|
178
|
+
privateKey: privateKey.toStringRaw() as ServerAuthConfig['privateKey'],
|
|
160
179
|
network: networkType,
|
|
161
180
|
});
|
|
162
181
|
}
|
|
163
182
|
}
|
|
164
183
|
} catch (error) {
|
|
165
184
|
this.logger.warn('Failed to create InscriptionSDK with auth', error);
|
|
185
|
+
this.inscriptionSDK = undefined;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (!this.inscriptionSDK) {
|
|
189
|
+
try {
|
|
190
|
+
const { InscriptionSDK } = await loadInscriptionSdkModule();
|
|
191
|
+
this.inscriptionSDK = new InscriptionSDK({
|
|
192
|
+
apiKey: 'public-access',
|
|
193
|
+
network: networkType,
|
|
194
|
+
connectionMode: 'http',
|
|
195
|
+
});
|
|
196
|
+
} catch (fallbackError) {
|
|
197
|
+
this.logger.warn(
|
|
198
|
+
'Failed to create InscriptionSDK fallback instance',
|
|
199
|
+
fallbackError
|
|
200
|
+
);
|
|
201
|
+
}
|
|
166
202
|
}
|
|
167
203
|
|
|
168
204
|
return this.inscriptionSDK || null;
|