@hashgraphonline/standards-agent-kit 0.2.162 → 0.2.164

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.162",
3
+ "version": "0.2.164",
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",
@@ -63,7 +63,7 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "@hashgraph/sdk": "^2.72.0",
66
- "@hashgraphonline/standards-sdk": "^0.1.110",
66
+ "@hashgraphonline/standards-sdk": "^0.1.111",
67
67
  "@kiloscribe/inscription-sdk": "^1.0.60",
68
68
  "@langchain/community": "^0.3.5",
69
69
  "@langchain/core": "^0.3.71",
@@ -4,6 +4,7 @@ import {
4
4
  inscribe,
5
5
  inscribeWithSigner,
6
6
  retrieveInscription,
7
+ getOrCreateSDK,
7
8
  InscriptionInput,
8
9
  InscriptionOptions,
9
10
  InscriptionResponse,
@@ -13,10 +14,10 @@ import {
13
14
  getTopicId,
14
15
  Logger,
15
16
  } from '@hashgraphonline/standards-sdk';
16
- import {
17
+ import type {
17
18
  InscriptionSDK,
18
- type InscriptionResult,
19
- type RegistrationProgressData,
19
+ InscriptionResult,
20
+ RegistrationProgressData,
20
21
  } from '@kiloscribe/inscription-sdk';
21
22
  import type { AgentOperationalMode } from 'hedera-agent-kit';
22
23
 
@@ -46,12 +47,7 @@ export interface CompletedInscriptionResponse {
46
47
  /**
47
48
  * Builder for Inscription operations
48
49
  */
49
- type InscriptionSDKInstance = InstanceType<typeof InscriptionSDK>;
50
- type InscriptionSDKAuthParams = Parameters<
51
- typeof InscriptionSDK.createWithAuth
52
- >[0];
53
- type ClientAuthConfig = Extract<InscriptionSDKAuthParams, { type: 'client' }>;
54
- type ServerAuthConfig = Extract<InscriptionSDKAuthParams, { type: 'server' }>;
50
+ type InscriptionSDKInstance = InscriptionSDK;
55
51
 
56
52
  export const toDashedTransactionId = (transactionId: string): string => {
57
53
  if (transactionId.includes('-')) {
@@ -159,7 +155,7 @@ export class InscriberBuilder extends BaseServiceBuilder {
159
155
  * Get or create Inscription SDK
160
156
  */
161
157
  protected async getInscriptionSDK(
162
- _options: InscriptionOptions
158
+ options: InscriptionOptions
163
159
  ): Promise<InscriptionSDKInstance | null> {
164
160
  if (this.inscriptionSDK) {
165
161
  return this.inscriptionSDK;
@@ -172,55 +168,37 @@ export class InscriberBuilder extends BaseServiceBuilder {
172
168
  ? 'mainnet'
173
169
  : 'testnet';
174
170
  const accountId = this.hederaKit.signer.getAccountId().toString();
171
+ const operatorKey = this.hederaKit.signer?.getOperatorPrivateKey();
172
+ const baseOptions: InscriptionOptions = {
173
+ ...options,
174
+ network: options.network ?? networkType,
175
+ };
176
+
177
+ const apiKey = baseOptions.apiKey ?? (operatorKey ? undefined : 'public-access');
178
+ const effectiveOptions: InscriptionOptions = apiKey
179
+ ? { ...baseOptions, apiKey }
180
+ : baseOptions;
181
+
182
+ const clientConfig = {
183
+ accountId,
184
+ privateKey: operatorKey?.toStringRaw() ?? apiKey ?? 'public-access',
185
+ network: networkType,
186
+ };
175
187
 
176
188
  try {
177
- this.logger.info('Attempting InscriptionSDK.createWithAuth', {
178
- accountId,
179
- network: networkType,
180
- });
181
- const privateKey = this.hederaKit.signer?.getOperatorPrivateKey();
182
- if (privateKey) {
183
- this.inscriptionSDK = await InscriptionSDK.createWithAuth({
184
- type: 'server',
185
- accountId,
186
- privateKey:
187
- privateKey.toStringRaw() as ServerAuthConfig['privateKey'],
188
- network: networkType,
189
- });
190
- this.logger.info('Created InscriptionSDK via createWithAuth', {
191
- network: networkType,
192
- });
193
- }
189
+ this.inscriptionSDK = await getOrCreateSDK(
190
+ clientConfig,
191
+ effectiveOptions,
192
+ this.inscriptionSDK
193
+ );
194
+ return this.inscriptionSDK;
194
195
  } catch (error) {
195
- this.logger.warn('Failed to create InscriptionSDK with auth', error);
196
+ this.logger.error('failed to setup sdk', {
197
+ error: error instanceof Error ? error.message : String(error),
198
+ });
196
199
  this.inscriptionSDK = undefined;
200
+ return null;
197
201
  }
198
-
199
- if (!this.inscriptionSDK) {
200
- try {
201
- this.logger.info('Creating fallback InscriptionSDK instance', {
202
- network: networkType,
203
- });
204
- this.inscriptionSDK = new InscriptionSDK({
205
- apiKey: 'public-access',
206
- network: networkType,
207
- connectionMode: 'http',
208
- });
209
- this.logger.info('Created fallback InscriptionSDK instance', {
210
- network: networkType,
211
- });
212
- return this.inscriptionSDK;
213
- } catch (fallbackError) {
214
- this.logger.error(
215
- 'Failed to create InscriptionSDK fallback instance',
216
- fallbackError
217
- );
218
- }
219
- }
220
-
221
- this.logger.error('failed to setup sdk');
222
-
223
- return null;
224
202
  }
225
203
 
226
204
  /**
@@ -410,6 +388,8 @@ export class InscriberBuilder extends BaseServiceBuilder {
410
388
  network
411
389
  );
412
390
  const transactionId = exec?.transactionId || '';
391
+ const rawTransactionId = startResponse.tx_id || transactionId;
392
+ const canonicalTransactionId = toDashedTransactionId(rawTransactionId);
413
393
 
414
394
  this.logger.info('inscribeAuto wallet execution', {
415
395
  transactionId,
@@ -419,9 +399,6 @@ export class InscriberBuilder extends BaseServiceBuilder {
419
399
  const shouldWait = options.quoteOnly
420
400
  ? false
421
401
  : options.waitForConfirmation ?? true;
422
- const canonicalTransactionId = toDashedTransactionId(
423
- startResponse.tx_id || transactionId
424
- );
425
402
  if (shouldWait) {
426
403
  const maxAttempts =
427
404
  (options as { waitMaxAttempts?: number }).waitMaxAttempts ?? 60;
@@ -433,8 +410,6 @@ export class InscriberBuilder extends BaseServiceBuilder {
433
410
  let retrieved: RetrievedInscriptionResult | null = null;
434
411
  const sdk = await this.getInscriptionSDK(options);
435
412
 
436
- console.log('got an SDK', sdk);
437
-
438
413
  if (sdk) {
439
414
  try {
440
415
  retrieved = await sdk.waitForInscription(