@hashgraphonline/standards-agent-kit 0.2.136 → 0.2.137

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.
Files changed (53) hide show
  1. package/README.md +3 -4
  2. package/dist/cjs/builders/inscriber/inscriber-builder.d.ts +32 -1
  3. package/dist/cjs/standards-agent-kit.cjs +1 -1
  4. package/dist/cjs/standards-agent-kit.cjs.map +1 -1
  5. package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +2 -2
  6. package/dist/cjs/types/inscription-response.d.ts +8 -0
  7. package/dist/cjs/utils/inscription-utils.d.ts +21 -0
  8. package/dist/es/builders/inscriber/inscriber-builder.d.ts +32 -1
  9. package/dist/es/standards-agent-kit.es3.js +4 -0
  10. package/dist/es/standards-agent-kit.es3.js.map +1 -1
  11. package/dist/es/standards-agent-kit.es34.js +12 -6
  12. package/dist/es/standards-agent-kit.es34.js.map +1 -1
  13. package/dist/es/standards-agent-kit.es35.js +5 -4
  14. package/dist/es/standards-agent-kit.es35.js.map +1 -1
  15. package/dist/es/standards-agent-kit.es36.js +13 -9
  16. package/dist/es/standards-agent-kit.es36.js.map +1 -1
  17. package/dist/es/standards-agent-kit.es37.js +30 -28
  18. package/dist/es/standards-agent-kit.es37.js.map +1 -1
  19. package/dist/es/standards-agent-kit.es38.js +9 -10
  20. package/dist/es/standards-agent-kit.es38.js.map +1 -1
  21. package/dist/es/standards-agent-kit.es47.js +17 -50
  22. package/dist/es/standards-agent-kit.es47.js.map +1 -1
  23. package/dist/es/standards-agent-kit.es48.js +54 -3
  24. package/dist/es/standards-agent-kit.es48.js.map +1 -1
  25. package/dist/es/standards-agent-kit.es49.js +2 -39
  26. package/dist/es/standards-agent-kit.es49.js.map +1 -1
  27. package/dist/es/standards-agent-kit.es50.js +38 -17
  28. package/dist/es/standards-agent-kit.es50.js.map +1 -1
  29. package/dist/es/standards-agent-kit.es51.js +16 -51
  30. package/dist/es/standards-agent-kit.es51.js.map +1 -1
  31. package/dist/es/standards-agent-kit.es52.js +77 -0
  32. package/dist/es/standards-agent-kit.es52.js.map +1 -0
  33. package/dist/es/standards-agent-kit.es6.js +160 -4
  34. package/dist/es/standards-agent-kit.es6.js.map +1 -1
  35. package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +2 -2
  36. package/dist/es/types/inscription-response.d.ts +8 -0
  37. package/dist/es/utils/inscription-utils.d.ts +21 -0
  38. package/dist/umd/builders/inscriber/inscriber-builder.d.ts +32 -1
  39. package/dist/umd/standards-agent-kit.umd.js +1 -1
  40. package/dist/umd/standards-agent-kit.umd.js.map +1 -1
  41. package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +2 -2
  42. package/dist/umd/types/inscription-response.d.ts +8 -0
  43. package/dist/umd/utils/inscription-utils.d.ts +21 -0
  44. package/package.json +9 -4
  45. package/src/builders/hcs10/hcs10-builder.ts +4 -0
  46. package/src/builders/inscriber/inscriber-builder.ts +235 -2
  47. package/src/tools/inscriber/InscribeFromBufferTool.ts +48 -19
  48. package/src/tools/inscriber/InscribeFromFileTool.ts +10 -13
  49. package/src/tools/inscriber/InscribeFromUrlTool.ts +15 -11
  50. package/src/tools/inscriber/InscribeHashinalTool.ts +40 -59
  51. package/src/tools/inscriber/RetrieveInscriptionTool.ts +15 -16
  52. package/src/types/inscription-response.ts +27 -0
  53. package/src/utils/inscription-utils.ts +53 -0
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
1
  import { z } from 'zod';
3
2
  import { BaseInscriberQueryTool } from './base-inscriber-tools';
4
3
  import {
@@ -6,6 +5,7 @@ import {
6
5
  InscriptionInput,
7
6
  ContentResolverRegistry,
8
7
  Logger,
8
+ InscriptionResult,
9
9
  } from '@hashgraphonline/standards-sdk';
10
10
  import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
11
11
  import { validateHIP412Metadata } from '../../validation/hip412-schemas';
@@ -19,9 +19,14 @@ import {
19
19
  createInscriptionSuccess,
20
20
  createInscriptionQuote,
21
21
  createInscriptionError,
22
+ createInscriptionPending,
22
23
  InscriptionResponse,
23
24
  } from '../../types/inscription-response';
24
25
  import { FormValidatable } from '../../interfaces/FormValidatable';
26
+ import {
27
+ extractTopicIds,
28
+ buildInscriptionLinks,
29
+ } from '../../utils/inscription-utils';
25
30
 
26
31
  /**
27
32
  * Network-specific Hashinal block configuration for HashLink blocks
@@ -46,7 +51,6 @@ const HASHLINK_BLOCK_CONFIG = {
46
51
  * @param network The network type to get configuration for
47
52
  * @returns Network-specific block configuration with blockId, hashLink, and template
48
53
  */
49
- // @ts-ignore - keep untyped to satisfy mixed parser while using runtime narrowing
50
54
  function getHashLinkBlockId(network) {
51
55
  const config =
52
56
  network === 'mainnet'
@@ -58,8 +62,6 @@ function getHashLinkBlockId(network) {
58
62
  return config;
59
63
  }
60
64
 
61
- // Note: Using inline return type annotations to avoid parser issues with interface declarations
62
-
63
65
  /**
64
66
  * Schema for inscribing Hashinal NFT
65
67
  */
@@ -205,7 +207,6 @@ export class InscribeHashinalTool
205
207
  description =
206
208
  'Tool for inscribing Hashinal NFTs. CRITICAL: When user provides content (url/contentRef/base64Data), call with ONLY the content parameters - DO NOT auto-generate name, description, creator, or attributes. A form will be automatically shown to collect metadata from the user. Only include metadata parameters if the user explicitly provided them in their message.';
207
209
 
208
- // Declare entity resolution preferences to preserve user-specified literal fields
209
210
  getEntityResolutionPreferences(): Record<string, string> {
210
211
  return {
211
212
  name: 'literal',
@@ -350,20 +351,17 @@ export class InscribeHashinalTool
350
351
  .describe('Trait name (e.g., "Rarity", "Color", "Style")'),
351
352
  value: z
352
353
  .union([z.string(), z.number()])
353
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
354
354
  .describe('Trait value (e.g., "Epic", "Blue", 85)'),
355
355
  })
356
356
  )
357
357
  )
358
358
  .withRender(renderConfigs.array('NFT Attributes', 'Attribute'))
359
359
  .optional()
360
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
361
360
  .describe('Collectible traits and characteristics.'),
362
361
 
363
362
  type: z
364
363
  .string()
365
364
  .optional()
366
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
367
365
  .describe(
368
366
  'Category or genre of the NFT (e.g., "Digital Art", "Photography", "Collectible Card)'
369
367
  ),
@@ -523,28 +521,26 @@ export class InscribeHashinalTool
523
521
  });
524
522
 
525
523
  result = await Promise.race([
526
- this.inscriberBuilder.inscribe(inscriptionData, options),
524
+ this.inscriberBuilder.inscribeAuto
525
+ ? this.inscriberBuilder.inscribeAuto(inscriptionData, options)
526
+ : this.inscriberBuilder.inscribe(inscriptionData, options),
527
527
  timeoutPromise,
528
528
  ]);
529
529
  } else {
530
- result = await this.inscriberBuilder.inscribe(inscriptionData, options);
530
+ result = this.inscriberBuilder.inscribeAuto
531
+ ? await this.inscriberBuilder.inscribeAuto(inscriptionData, options)
532
+ : await this.inscriberBuilder.inscribe(inscriptionData, options);
531
533
  }
532
534
 
533
535
  if (result.confirmed && !result.quote) {
534
- const imageTopicId = (
535
- result.inscription as { topic_id?: string; jsonTopicId?: string }
536
- )?.topic_id;
537
- const jsonTopicId = (
538
- result.inscription as { topic_id?: string; jsonTopicId?: string }
539
- )?.jsonTopicId;
536
+ const ids = extractTopicIds(result.inscription, result.result);
540
537
  const network = options.network || 'testnet';
541
-
542
- const cdnUrl = jsonTopicId
543
- ? `https://kiloscribe.com/api/inscription-cdn/${jsonTopicId}?network=${network}`
544
- : null;
545
-
546
538
  const fileStandard = params.fileStandard || '1';
547
- const hrl = jsonTopicId ? `hcs://${fileStandard}/${jsonTopicId}` : null;
539
+ const { hrl, cdnUrl, topicId } = buildInscriptionLinks(
540
+ ids,
541
+ network,
542
+ fileStandard
543
+ );
548
544
  const standardType = fileStandard === '6' ? 'Dynamic' : 'Static';
549
545
 
550
546
  if (!hrl) {
@@ -560,11 +556,10 @@ export class InscribeHashinalTool
560
556
 
561
557
  const inscriptionResponse = createInscriptionSuccess({
562
558
  hrl,
563
- topicId: jsonTopicId || imageTopicId || 'unknown',
559
+ topicId: topicId || 'unknown',
564
560
  standard: standardType as 'Static' | 'Dynamic',
565
561
  cdnUrl: cdnUrl || undefined,
566
- transactionId: (result.result as { transactionId?: string })
567
- ?.transactionId,
562
+ transactionId: (result.result as InscriptionResult)?.transactionId,
568
563
  metadata: {
569
564
  name: params.name,
570
565
  creator: params.creator,
@@ -575,11 +570,10 @@ export class InscribeHashinalTool
575
570
  });
576
571
 
577
572
  this.onEntityCreated?.({
578
- entityId: jsonTopicId || imageTopicId || 'unknown',
573
+ entityId: topicId || 'unknown',
579
574
  entityName: params.name || 'Unnamed Inscription',
580
575
  entityType: 'topicId',
581
- transactionId: (result.result as { transactionId?: string })
582
- ?.transactionId,
576
+ transactionId: (result.result as InscriptionResult)?.transactionId,
583
577
  });
584
578
 
585
579
  if (params.withHashLinkBlocks) {
@@ -593,7 +587,6 @@ export class InscribeHashinalTool
593
587
 
594
588
  inscriptionResponse.hashLinkBlock = blockData;
595
589
  } catch (blockError) {
596
- // Log error but don't fail the inscription
597
590
  const logger = new Logger({ module: 'InscribeHashinalTool' });
598
591
  logger.error('Failed to create HashLink block', {
599
592
  error: blockError,
@@ -603,32 +596,24 @@ export class InscribeHashinalTool
603
596
 
604
597
  return inscriptionResponse;
605
598
  } else if (!result.quote && !result.confirmed) {
606
- const imageTopicId = (
607
- result.inscription as { topic_id?: string; jsonTopicId?: string }
608
- )?.topic_id;
609
- const jsonTopicId = (
610
- result.inscription as { topic_id?: string; jsonTopicId?: string }
611
- )?.jsonTopicId;
612
-
613
- if (jsonTopicId || imageTopicId) {
599
+ const ids = extractTopicIds(result.inscription, result.result);
600
+ if (ids.jsonTopicId || ids.topicId) {
614
601
  const network = options.network || 'testnet';
615
- const cdnUrl = jsonTopicId
616
- ? `https://kiloscribe.com/api/inscription-cdn/${jsonTopicId}?network=${network}`
617
- : null;
618
-
619
602
  const fileStandard = params.fileStandard || '1';
620
- const hrl = jsonTopicId
621
- ? `hcs://${fileStandard}/${jsonTopicId}`
622
- : null;
603
+ const { hrl, cdnUrl, topicId } = buildInscriptionLinks(
604
+ ids,
605
+ network,
606
+ fileStandard
607
+ );
623
608
  const standardType = fileStandard === '6' ? 'Dynamic' : 'Static';
624
609
 
625
610
  if (hrl) {
626
611
  const inscriptionResponse = createInscriptionSuccess({
627
612
  hrl,
628
- topicId: jsonTopicId || imageTopicId || 'unknown',
613
+ topicId: topicId || 'unknown',
629
614
  standard: standardType as 'Static' | 'Dynamic',
630
615
  cdnUrl: cdnUrl || undefined,
631
- transactionId: (result.result as { transactionId?: string })
616
+ transactionId: (result.result as InscriptionResult)
632
617
  ?.transactionId,
633
618
  metadata: {
634
619
  name: params.name,
@@ -640,10 +625,10 @@ export class InscribeHashinalTool
640
625
  });
641
626
 
642
627
  this.onEntityCreated?.({
643
- entityId: jsonTopicId || imageTopicId || 'unknown',
628
+ entityId: topicId || 'unknown',
644
629
  entityName: params.name || 'Unnamed Inscription',
645
630
  entityType: 'topicId',
646
- transactionId: (result.result as { transactionId?: string })
631
+ transactionId: (result.result as InscriptionResult)
647
632
  ?.transactionId,
648
633
  });
649
634
 
@@ -658,7 +643,6 @@ export class InscribeHashinalTool
658
643
 
659
644
  inscriptionResponse.hashLinkBlock = blockData;
660
645
  } catch (blockError) {
661
- // Log error but don't fail the inscription
662
646
  const logger = new Logger({ module: 'InscribeHashinalTool' });
663
647
  logger.error('Failed to create HashLink block', {
664
648
  error: blockError,
@@ -671,17 +655,14 @@ export class InscribeHashinalTool
671
655
  }
672
656
 
673
657
  const transactionId =
674
- (result.result as { transactionId?: string })?.transactionId ||
675
- 'unknown';
676
- return createInscriptionError({
677
- code: 'INSCRIPTION_PENDING',
678
- details: `Inscription submitted but not yet confirmed. Transaction ID: ${transactionId}`,
679
- suggestions: [
680
- 'Wait a few moments for confirmation',
681
- 'Check the transaction status on a Hedera explorer',
682
- "Try the inscription again if it doesn't confirm within 5 minutes",
683
- ],
658
+ (result.result as InscriptionResult)?.transactionId || 'unknown';
659
+ const pending = createInscriptionPending({
660
+ transactionId,
684
661
  });
662
+ return {
663
+ ...pending,
664
+ metadata: { transactionId },
665
+ } as unknown as InscriptionResponse;
685
666
  } else {
686
667
  return createInscriptionError({
687
668
  code: 'UNKNOWN_STATE',
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseInscriberQueryTool } from './base-inscriber-tools';
3
3
  import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
4
+ import type { RetrievedInscriptionResult } from '@hashgraphonline/standards-sdk';
4
5
 
5
6
  /**
6
7
  * Schema for retrieving inscription
@@ -51,7 +52,7 @@ export class RetrieveInscriptionTool extends BaseInscriberQueryTool<typeof retri
51
52
  params: z.infer<typeof retrieveInscriptionSchema>,
52
53
  _runManager?: CallbackManagerForToolRun
53
54
  ): Promise<InscriptionRetrievalResult> {
54
- const result = await this.inscriberBuilder.retrieveInscription(
55
+ const result: RetrievedInscriptionResult = await this.inscriberBuilder.retrieveInscription(
55
56
  params.transactionId,
56
57
  {
57
58
  apiKey: params.apiKey,
@@ -59,23 +60,21 @@ export class RetrieveInscriptionTool extends BaseInscriberQueryTool<typeof retri
59
60
  }
60
61
  );
61
62
 
62
- const typedResult = result as unknown as Record<string, unknown>;
63
-
64
63
  return {
65
- inscriptionId: typedResult.inscriptionId as string | undefined,
66
- transactionId: result.transactionId || 'unknown',
67
- topicId: typedResult.topic_id as string | undefined,
68
- status: result.status || 'unknown',
69
- holderId: typedResult.holderId as string | undefined,
64
+ inscriptionId: (result as unknown as { inscriptionId?: string }).inscriptionId,
65
+ transactionId: (result as unknown as { transactionId?: string }).transactionId || 'unknown',
66
+ topicId: (result as unknown as { topic_id?: string; topicId?: string }).topic_id || (result as unknown as { topicId?: string }).topicId,
67
+ status: (result as unknown as { status?: string }).status || 'unknown',
68
+ holderId: (result as unknown as { holderId?: string }).holderId,
70
69
  metadata: result.metadata,
71
- tags: typedResult.tags,
72
- mode: result.mode,
73
- chunks: typedResult.chunks,
74
- createdAt: typedResult.createdAt as string | undefined,
75
- completedAt: (typedResult.completed || typedResult.completedAt) as string | undefined,
76
- fileUrl: result.fileUrl,
77
- mimeType: typedResult.mimeType as string | undefined,
78
- fileSize: typedResult.fileSize as number | undefined,
70
+ tags: (result as unknown as { tags?: unknown }).tags,
71
+ mode: (result as unknown as { mode?: string }).mode,
72
+ chunks: (result as unknown as { chunks?: unknown }).chunks,
73
+ createdAt: (result as unknown as { createdAt?: string }).createdAt,
74
+ completedAt: (result as unknown as { completed?: string; completedAt?: string }).completed || (result as unknown as { completedAt?: string }).completedAt,
75
+ fileUrl: (result as unknown as { fileUrl?: string }).fileUrl,
76
+ mimeType: (result as unknown as { mimeType?: string }).mimeType,
77
+ fileSize: (result as unknown as { fileSize?: number }).fileSize,
79
78
  };
80
79
  }
81
80
  }
@@ -232,3 +232,30 @@ export function createInscriptionError(params: {
232
232
  },
233
233
  };
234
234
  }
235
+
236
+ /**
237
+ * Helper for pending inscription state (submitted but not yet confirmed)
238
+ */
239
+ export function createInscriptionPending(params: {
240
+ transactionId: string;
241
+ details?: string;
242
+ suggestions?: string[];
243
+ }): InscriptionErrorResponse {
244
+ const { transactionId, details, suggestions } = params;
245
+ const d = details || `Inscription submitted but not yet confirmed. Transaction ID: ${transactionId}`;
246
+ return {
247
+ success: false,
248
+ type: 'error',
249
+ title: 'Inscription Submitted (Pending)',
250
+ message: d,
251
+ error: {
252
+ code: 'INSCRIPTION_PENDING',
253
+ details: d,
254
+ suggestions: suggestions || [
255
+ 'Wait a few moments for confirmation',
256
+ 'Check the transaction status on a Hedera explorer',
257
+ "Try the inscription again if it doesn't confirm within 5 minutes",
258
+ ],
259
+ },
260
+ };
261
+ }
@@ -0,0 +1,53 @@
1
+ export type NetworkType = 'mainnet' | 'testnet';
2
+
3
+ export interface TopicIds {
4
+ jsonTopicId?: string;
5
+ topicId?: string;
6
+ }
7
+
8
+ function getStringProp(obj: unknown, key: string): string | undefined {
9
+ if (!obj || typeof obj !== 'object') return undefined;
10
+ const val = (obj as Record<string, unknown>)[key];
11
+ return typeof val === 'string' && val.trim() ? val : undefined;
12
+ }
13
+
14
+ /**
15
+ * Extract topic ids from an inscription and/or result object without using any.
16
+ * - Prefers jsonTopicId when present (for CDN linking)
17
+ * - Collects topic_id/topicId from either inscription or result
18
+ */
19
+ export function extractTopicIds(
20
+ inscription: unknown,
21
+ result?: unknown
22
+ ): TopicIds {
23
+ const jsonTopicId = getStringProp(inscription, 'jsonTopicId');
24
+
25
+ const imageTopicId =
26
+ getStringProp(inscription, 'topic_id') ||
27
+ getStringProp(inscription, 'topicId') ||
28
+ getStringProp(result, 'topicId') ||
29
+ getStringProp(result, 'topic_id');
30
+
31
+ return {
32
+ jsonTopicId: jsonTopicId,
33
+ topicId: imageTopicId,
34
+ };
35
+ }
36
+
37
+ /**
38
+ * Build HRL/CDN URLs from extracted topic ids.
39
+ * - HRL prefers jsonTopicId, falls back to topicId
40
+ * - CDN URL only provided when jsonTopicId is present
41
+ */
42
+ export function buildInscriptionLinks(
43
+ ids: TopicIds,
44
+ network: NetworkType,
45
+ fileStandard: string = '1'
46
+ ): { hrl?: string; cdnUrl?: string; topicId?: string } {
47
+ const chosen = ids.jsonTopicId || ids.topicId;
48
+ const hrl = chosen ? `hcs://${fileStandard}/${chosen}` : undefined;
49
+ const cdnUrl = ids.jsonTopicId
50
+ ? `https://kiloscribe.com/api/inscription-cdn/${ids.jsonTopicId}?network=${network}`
51
+ : undefined;
52
+ return { hrl, cdnUrl, topicId: chosen };
53
+ }