@hashgraphonline/standards-agent-kit 0.2.161 → 0.2.162

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.
@@ -9,7 +9,7 @@ export interface TopicIds {
9
9
  * - Prefers jsonTopicId when present (for CDN linking)
10
10
  * - Collects topic_id/topicId from either inscription or result
11
11
  */
12
- export declare function extractTopicIds(inscription: RetrievedInscriptionResult, result?: unknown): TopicIds;
12
+ export declare function extractTopicIds(inscription: RetrievedInscriptionResult | undefined, result?: unknown): TopicIds;
13
13
  /**
14
14
  * Build HRL/CDN URLs from extracted topic ids.
15
15
  * - HRL prefers jsonTopicId, falls back to topicId
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashgraphonline/standards-agent-kit",
3
- "version": "0.2.161",
3
+ "version": "0.2.162",
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",
@@ -11,6 +11,7 @@ import {
11
11
  HederaClientConfig,
12
12
  NetworkType,
13
13
  getTopicId,
14
+ Logger,
14
15
  } from '@hashgraphonline/standards-sdk';
15
16
  import {
16
17
  InscriptionSDK,
@@ -52,6 +53,25 @@ type InscriptionSDKAuthParams = Parameters<
52
53
  type ClientAuthConfig = Extract<InscriptionSDKAuthParams, { type: 'client' }>;
53
54
  type ServerAuthConfig = Extract<InscriptionSDKAuthParams, { type: 'server' }>;
54
55
 
56
+ export const toDashedTransactionId = (transactionId: string): string => {
57
+ if (transactionId.includes('-')) {
58
+ return transactionId;
59
+ }
60
+
61
+ const [account, timePart] = transactionId.split('@');
62
+ if (!account || !timePart) {
63
+ return transactionId;
64
+ }
65
+
66
+ const [secondsPart, nanosPart] = timePart.split('.');
67
+ if (!secondsPart) {
68
+ return transactionId;
69
+ }
70
+
71
+ const normalizedNanos = (nanosPart ?? '0').padEnd(9, '0').slice(0, 9);
72
+ return `${account}-${secondsPart}-${normalizedNanos}`;
73
+ };
74
+
55
75
  export class InscriberBuilder extends BaseServiceBuilder {
56
76
  protected inscriptionSDK?: InscriptionSDKInstance;
57
77
  private static signerProvider?: () =>
@@ -154,6 +174,10 @@ export class InscriberBuilder extends BaseServiceBuilder {
154
174
  const accountId = this.hederaKit.signer.getAccountId().toString();
155
175
 
156
176
  try {
177
+ this.logger.info('Attempting InscriptionSDK.createWithAuth', {
178
+ accountId,
179
+ network: networkType,
180
+ });
157
181
  const privateKey = this.hederaKit.signer?.getOperatorPrivateKey();
158
182
  if (privateKey) {
159
183
  this.inscriptionSDK = await InscriptionSDK.createWithAuth({
@@ -163,6 +187,9 @@ export class InscriberBuilder extends BaseServiceBuilder {
163
187
  privateKey.toStringRaw() as ServerAuthConfig['privateKey'],
164
188
  network: networkType,
165
189
  });
190
+ this.logger.info('Created InscriptionSDK via createWithAuth', {
191
+ network: networkType,
192
+ });
166
193
  }
167
194
  } catch (error) {
168
195
  this.logger.warn('Failed to create InscriptionSDK with auth', error);
@@ -171,20 +198,29 @@ export class InscriberBuilder extends BaseServiceBuilder {
171
198
 
172
199
  if (!this.inscriptionSDK) {
173
200
  try {
201
+ this.logger.info('Creating fallback InscriptionSDK instance', {
202
+ network: networkType,
203
+ });
174
204
  this.inscriptionSDK = new InscriptionSDK({
175
205
  apiKey: 'public-access',
176
206
  network: networkType,
177
207
  connectionMode: 'http',
178
208
  });
209
+ this.logger.info('Created fallback InscriptionSDK instance', {
210
+ network: networkType,
211
+ });
212
+ return this.inscriptionSDK;
179
213
  } catch (fallbackError) {
180
- this.logger.warn(
214
+ this.logger.error(
181
215
  'Failed to create InscriptionSDK fallback instance',
182
216
  fallbackError
183
217
  );
184
218
  }
185
219
  }
186
220
 
187
- return this.inscriptionSDK || null;
221
+ this.logger.error('failed to setup sdk');
222
+
223
+ return null;
188
224
  }
189
225
 
190
226
  /**
@@ -326,6 +362,14 @@ export class InscriberBuilder extends BaseServiceBuilder {
326
362
  network
327
363
  );
328
364
 
365
+ this.logger.info('inscribeAuto start response', {
366
+ hasTransactionBytes:
367
+ typeof (start as { transactionBytes?: unknown }).transactionBytes ===
368
+ 'string',
369
+ txId: (start as { tx_id?: unknown }).tx_id,
370
+ status: (start as { status?: unknown }).status,
371
+ });
372
+
329
373
  const completedStart = start as CompletedInscriptionResponse;
330
374
  const isCompletedResponse =
331
375
  Boolean(completedStart?.inscription) && completedStart?.confirmed;
@@ -367,29 +411,57 @@ export class InscriberBuilder extends BaseServiceBuilder {
367
411
  );
368
412
  const transactionId = exec?.transactionId || '';
369
413
 
414
+ this.logger.info('inscribeAuto wallet execution', {
415
+ transactionId,
416
+ network,
417
+ });
418
+
370
419
  const shouldWait = options.quoteOnly
371
420
  ? false
372
421
  : options.waitForConfirmation ?? true;
422
+ const canonicalTransactionId = toDashedTransactionId(
423
+ startResponse.tx_id || transactionId
424
+ );
373
425
  if (shouldWait) {
374
- this.logger.debug('Will be retrieving inscription');
375
426
  const maxAttempts =
376
427
  (options as { waitMaxAttempts?: number }).waitMaxAttempts ?? 60;
377
428
  const intervalMs =
378
429
  (options as { waitIntervalMs?: number }).waitIntervalMs ?? 5000;
430
+ const pollId = canonicalTransactionId;
431
+ this.logger.debug('Will be retrieving inscription', pollId);
379
432
 
380
- const pollId = startResponse.tx_id || transactionId;
433
+ let retrieved: RetrievedInscriptionResult | null = null;
381
434
  const sdk = await this.getInscriptionSDK(options);
435
+
436
+ console.log('got an SDK', sdk);
437
+
382
438
  if (sdk) {
383
- const retrieved: RetrievedInscriptionResult =
384
- await sdk.waitForInscription(
439
+ try {
440
+ retrieved = await sdk.waitForInscription(
385
441
  pollId,
386
442
  maxAttempts,
387
443
  intervalMs,
388
444
  true,
389
445
  (progress: RegistrationProgressData) => {
390
- this.logger.info('checking inscription', progress);
446
+ this.logger.debug('checking inscription', progress);
391
447
  }
392
448
  );
449
+ } catch (error) {
450
+ this.logger.warn('Primary inscription wait failed', {
451
+ pollId,
452
+ error: error instanceof Error ? error.message : String(error),
453
+ });
454
+ }
455
+ } else {
456
+ this.logger.warn(
457
+ 'No inscription SDK available, using public client',
458
+ {
459
+ pollId,
460
+ }
461
+ );
462
+ }
463
+
464
+ if (retrieved) {
393
465
  const topicIdFromInscription: string | undefined = getTopicId(
394
466
  retrieved as unknown
395
467
  );
@@ -399,14 +471,14 @@ export class InscriberBuilder extends BaseServiceBuilder {
399
471
  quote: false,
400
472
  confirmed: true,
401
473
  result: {
402
- jobId: startResponse.tx_id || '',
403
- transactionId,
474
+ jobId: toDashedTransactionId(startResponse.tx_id || ''),
475
+ transactionId: canonicalTransactionId,
404
476
  topicId,
405
477
  },
406
478
  inscription: retrieved,
407
479
  } as unknown as InscriptionResponse;
408
480
  this.logger.debug(
409
- 'retrieved inscription',
481
+ 'retrieved inscription confirmed',
410
482
  resultConfirmed,
411
483
  retrieved
412
484
  );
@@ -418,8 +490,8 @@ export class InscriberBuilder extends BaseServiceBuilder {
418
490
  quote: false,
419
491
  confirmed: false,
420
492
  result: {
421
- jobId: startResponse.tx_id || '',
422
- transactionId,
493
+ jobId: toDashedTransactionId(startResponse.tx_id || ''),
494
+ transactionId: canonicalTransactionId,
423
495
  status: startResponse.status,
424
496
  completed: startResponse.completed,
425
497
  },
@@ -19,11 +19,12 @@ function getStringProp(obj: unknown, key: string): string | undefined {
19
19
  * - Collects topic_id/topicId from either inscription or result
20
20
  */
21
21
  export function extractTopicIds(
22
- inscription: RetrievedInscriptionResult,
22
+ inscription: RetrievedInscriptionResult | undefined,
23
23
  result?: unknown
24
24
  ): TopicIds {
25
25
  const jsonTopicId =
26
- inscription.jsonTopicId || getStringProp(inscription, 'json_topic_id');
26
+ (inscription as RetrievedInscriptionResult | undefined)?.jsonTopicId ||
27
+ getStringProp(inscription, 'json_topic_id');
27
28
 
28
29
  const imageTopicId =
29
30
  getStringProp(inscription, 'topic_id') ||