@hashgraphonline/standards-agent-kit 0.2.160 → 0.2.161

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashgraphonline/standards-agent-kit",
3
- "version": "0.2.160",
3
+ "version": "0.2.161",
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,11 @@ import {
12
12
  NetworkType,
13
13
  getTopicId,
14
14
  } from '@hashgraphonline/standards-sdk';
15
- import type { InscriptionResult } from '@kiloscribe/inscription-sdk';
15
+ import {
16
+ InscriptionSDK,
17
+ type InscriptionResult,
18
+ type RegistrationProgressData,
19
+ } from '@kiloscribe/inscription-sdk';
16
20
  import type { AgentOperationalMode } from 'hedera-agent-kit';
17
21
 
18
22
  /**
@@ -41,21 +45,10 @@ export interface CompletedInscriptionResponse {
41
45
  /**
42
46
  * Builder for Inscription operations
43
47
  */
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];
48
+ type InscriptionSDKInstance = InstanceType<typeof InscriptionSDK>;
49
+ type InscriptionSDKAuthParams = Parameters<
50
+ typeof InscriptionSDK.createWithAuth
51
+ >[0];
59
52
  type ClientAuthConfig = Extract<InscriptionSDKAuthParams, { type: 'client' }>;
60
53
  type ServerAuthConfig = Extract<InscriptionSDKAuthParams, { type: 'server' }>;
61
54
 
@@ -153,32 +146,23 @@ export class InscriberBuilder extends BaseServiceBuilder {
153
146
  }
154
147
 
155
148
  const network = this.hederaKit.client.network;
156
- const networkType: 'mainnet' | 'testnet' = network.toString().includes('mainnet')
149
+ const networkType: 'mainnet' | 'testnet' = network
150
+ .toString()
151
+ .includes('mainnet')
157
152
  ? 'mainnet'
158
153
  : 'testnet';
159
154
  const accountId = this.hederaKit.signer.getAccountId().toString();
160
155
 
161
156
  try {
162
- const { InscriptionSDK } = await loadInscriptionSdkModule();
163
- const signer = await this.getSigner();
164
-
165
- if (signer) {
157
+ const privateKey = this.hederaKit.signer?.getOperatorPrivateKey();
158
+ if (privateKey) {
166
159
  this.inscriptionSDK = await InscriptionSDK.createWithAuth({
167
- type: 'client',
160
+ type: 'server',
168
161
  accountId,
169
- signer: signer as unknown as ClientAuthConfig['signer'],
162
+ privateKey:
163
+ privateKey.toStringRaw() as ServerAuthConfig['privateKey'],
170
164
  network: networkType,
171
165
  });
172
- } else {
173
- const privateKey = this.hederaKit.signer?.getOperatorPrivateKey();
174
- if (privateKey) {
175
- this.inscriptionSDK = await InscriptionSDK.createWithAuth({
176
- type: 'server',
177
- accountId,
178
- privateKey: privateKey.toStringRaw() as ServerAuthConfig['privateKey'],
179
- network: networkType,
180
- });
181
- }
182
166
  }
183
167
  } catch (error) {
184
168
  this.logger.warn('Failed to create InscriptionSDK with auth', error);
@@ -187,7 +171,6 @@ export class InscriberBuilder extends BaseServiceBuilder {
187
171
 
188
172
  if (!this.inscriptionSDK) {
189
173
  try {
190
- const { InscriptionSDK } = await loadInscriptionSdkModule();
191
174
  this.inscriptionSDK = new InscriptionSDK({
192
175
  apiKey: 'public-access',
193
176
  network: networkType,
@@ -394,14 +377,18 @@ export class InscriberBuilder extends BaseServiceBuilder {
394
377
  const intervalMs =
395
378
  (options as { waitIntervalMs?: number }).waitIntervalMs ?? 5000;
396
379
 
380
+ const pollId = startResponse.tx_id || transactionId;
397
381
  const sdk = await this.getInscriptionSDK(options);
398
382
  if (sdk) {
399
383
  const retrieved: RetrievedInscriptionResult =
400
384
  await sdk.waitForInscription(
401
- transactionId,
385
+ pollId,
402
386
  maxAttempts,
403
387
  intervalMs,
404
- true
388
+ true,
389
+ (progress: RegistrationProgressData) => {
390
+ this.logger.info('checking inscription', progress);
391
+ }
405
392
  );
406
393
  const topicIdFromInscription: string | undefined = getTopicId(
407
394
  retrieved as unknown
@@ -418,7 +405,11 @@ export class InscriberBuilder extends BaseServiceBuilder {
418
405
  },
419
406
  inscription: retrieved,
420
407
  } as unknown as InscriptionResponse;
421
- this.logger.debug('retrieved inscription', resultConfirmed, retrieved);
408
+ this.logger.debug(
409
+ 'retrieved inscription',
410
+ resultConfirmed,
411
+ retrieved
412
+ );
422
413
  return resultConfirmed;
423
414
  }
424
415
  }