@hashgraphonline/standards-agent-kit 0.2.134 → 0.2.136

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 (32) hide show
  1. package/dist/cjs/interfaces/FormValidatable.d.ts +4 -13
  2. package/dist/cjs/standards-agent-kit.cjs +1 -1
  3. package/dist/cjs/standards-agent-kit.cjs.map +1 -1
  4. package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +1 -8
  5. package/dist/cjs/tools/inscriber/base-inscriber-tools.d.ts +19 -0
  6. package/dist/es/interfaces/FormValidatable.d.ts +4 -13
  7. package/dist/es/standards-agent-kit.es33.js +12 -0
  8. package/dist/es/standards-agent-kit.es33.js.map +1 -1
  9. package/dist/es/standards-agent-kit.es34.js +2 -2
  10. package/dist/es/standards-agent-kit.es34.js.map +1 -1
  11. package/dist/es/standards-agent-kit.es36.js +2 -2
  12. package/dist/es/standards-agent-kit.es36.js.map +1 -1
  13. package/dist/es/standards-agent-kit.es37.js +25 -26
  14. package/dist/es/standards-agent-kit.es37.js.map +1 -1
  15. package/dist/es/standards-agent-kit.es44.js +1 -1
  16. package/dist/es/standards-agent-kit.es44.js.map +1 -1
  17. package/dist/es/standards-agent-kit.es51.js +2 -2
  18. package/dist/es/standards-agent-kit.es51.js.map +1 -1
  19. package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +1 -8
  20. package/dist/es/tools/inscriber/base-inscriber-tools.d.ts +19 -0
  21. package/dist/umd/interfaces/FormValidatable.d.ts +4 -13
  22. package/dist/umd/standards-agent-kit.umd.js +1 -1
  23. package/dist/umd/standards-agent-kit.umd.js.map +1 -1
  24. package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +1 -8
  25. package/dist/umd/tools/inscriber/base-inscriber-tools.d.ts +19 -0
  26. package/package.json +2 -2
  27. package/src/interfaces/FormValidatable.ts +9 -12
  28. package/src/tools/inscriber/InscribeFromBufferTool.ts +2 -2
  29. package/src/tools/inscriber/InscribeFromUrlTool.ts +2 -2
  30. package/src/tools/inscriber/InscribeHashinalTool.ts +43 -50
  31. package/src/tools/inscriber/base-inscriber-tools.ts +26 -0
  32. package/src/types/inscription-response.ts +2 -2
@@ -37,6 +37,7 @@ declare const inscribeHashinalSchema: import('../..').ZodSchemaWithRender<{
37
37
  export declare class InscribeHashinalTool extends BaseInscriberQueryTool implements FormValidatable {
38
38
  name: string;
39
39
  description: string;
40
+ getEntityResolutionPreferences(): Record<string, string>;
40
41
  get specificInputSchema(): z.ZodObject<z.ZodRawShape>;
41
42
  private _schemaWithRenderConfig?;
42
43
  get schema(): z.ZodObject<z.ZodRawShape>;
@@ -50,14 +51,6 @@ export declare class InscribeHashinalTool extends BaseInscriberQueryTool impleme
50
51
  * Returns the focused schema for form generation
51
52
  */
52
53
  getFormSchema(): z.ZodObject<z.ZodRawShape>;
53
- /**
54
- * Implementation of FormValidatable interface
55
- * Validates metadata quality and provides detailed feedback
56
- */
57
- validateMetadataQuality(input: unknown): {
58
- needsForm: boolean;
59
- reason: string;
60
- };
61
54
  protected executeQuery(params: z.infer<typeof inscribeHashinalSchema>, _runManager?: CallbackManagerForToolRun): Promise<InscriptionResponse>;
62
55
  /**
63
56
  * Creates HashLink block configuration for Hashinal inscriptions.
@@ -4,12 +4,22 @@ import { InscriberTransactionToolParams, InscriberQueryToolParams } from './insc
4
4
  import { ContentResolverInterface } from '../../types/content-resolver';
5
5
  import { InscriptionInput, InscriptionOptions, QuoteResult } from '@hashgraphonline/standards-sdk';
6
6
  import { z } from 'zod';
7
+ /**
8
+ * Event emitted when an entity is created during inscription
9
+ */
10
+ export interface EntityCreationEvent {
11
+ entityId: string;
12
+ entityName: string;
13
+ entityType: string;
14
+ transactionId?: string;
15
+ }
7
16
  /**
8
17
  * Base class for Inscriber transaction tools
9
18
  */
10
19
  export declare abstract class BaseInscriberTransactionTool<T extends z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny> = z.ZodObject<z.ZodRawShape>> extends BaseHederaTransactionTool<T> {
11
20
  protected inscriberBuilder: InscriberBuilder;
12
21
  protected contentResolver: ContentResolverInterface | null;
22
+ protected onEntityCreated?: (event: EntityCreationEvent) => void;
13
23
  namespace: "inscriber";
14
24
  constructor(params: InscriberTransactionToolParams);
15
25
  /**
@@ -20,6 +30,10 @@ export declare abstract class BaseInscriberTransactionTool<T extends z.ZodObject
20
30
  * Get content resolver with fallback to registry
21
31
  */
22
32
  protected getContentResolver(): ContentResolverInterface | null;
33
+ /**
34
+ * Set entity creation handler for automatic entity storage
35
+ */
36
+ setEntityCreationHandler(handler: (event: EntityCreationEvent) => void): void;
23
37
  /**
24
38
  * Generate a quote for an inscription without executing it
25
39
  * @param input - The inscription input data
@@ -34,6 +48,7 @@ export declare abstract class BaseInscriberTransactionTool<T extends z.ZodObject
34
48
  export declare abstract class BaseInscriberQueryTool<T extends z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny> = z.ZodObject<z.ZodRawShape>> extends BaseHederaQueryTool<T> {
35
49
  protected inscriberBuilder: InscriberBuilder;
36
50
  protected contentResolver: ContentResolverInterface | null;
51
+ protected onEntityCreated?: (event: EntityCreationEvent) => void;
37
52
  namespace: "inscriber";
38
53
  constructor(params: InscriberQueryToolParams);
39
54
  /**
@@ -44,6 +59,10 @@ export declare abstract class BaseInscriberQueryTool<T extends z.ZodObject<z.Zod
44
59
  * Get content resolver with fallback to registry
45
60
  */
46
61
  protected getContentResolver(): ContentResolverInterface | null;
62
+ /**
63
+ * Set entity creation handler for automatic entity storage
64
+ */
65
+ setEntityCreationHandler(handler: (event: EntityCreationEvent) => void): void;
47
66
  /**
48
67
  * Generate a quote for an inscription without executing it
49
68
  * @param input - The inscription input data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashgraphonline/standards-agent-kit",
3
- "version": "0.2.134",
3
+ "version": "0.2.136",
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",
@@ -90,7 +90,7 @@
90
90
  },
91
91
  "dependencies": {
92
92
  "@hashgraph/sdk": "^2.69.0",
93
- "@hashgraphonline/standards-sdk": "0.0.183",
93
+ "@hashgraphonline/standards-sdk": "0.0.187",
94
94
  "@kiloscribe/inscription-sdk": "^1.0.59",
95
95
  "@langchain/community": "^0.3.5",
96
96
  "@langchain/core": "^0.3.71",
@@ -19,27 +19,20 @@ export interface FormValidatable {
19
19
  getFormSchema(): z.ZodSchema;
20
20
 
21
21
  /**
22
- * Optional method to validate metadata quality and provide detailed feedback
23
- * @param input The input data to analyze
24
- * @returns Object indicating if form is needed and the reason
25
- */
26
- validateMetadataQuality?(input: unknown): { needsForm: boolean; reason: string };
27
-
28
- /**
29
- * Optional method to define which fields are essential for this tool
22
+ * Defines which fields are essential for this tool
30
23
  * Essential fields are always shown in forms even if marked as optional
31
24
  * @returns Array of field names that are essential for user experience
32
25
  */
33
- getEssentialFields?(): string[];
26
+ getEssentialFields(): string[];
34
27
 
35
28
  /**
36
- * Optional method to determine if a field value should be considered empty
29
+ * Determines if a field value should be considered empty
37
30
  * Allows tools to define custom empty logic for their specific data types
38
31
  * @param fieldName The name of the field
39
32
  * @param value The value to check
40
33
  * @returns true if the field should be considered empty
41
34
  */
42
- isFieldEmpty?(fieldName: string, value: unknown): boolean;
35
+ isFieldEmpty(fieldName: string, value: unknown): boolean;
43
36
  }
44
37
 
45
38
  /**
@@ -51,7 +44,11 @@ export function isFormValidatable(tool: unknown): tool is FormValidatable {
51
44
  typeof tool === 'object' &&
52
45
  'shouldGenerateForm' in tool &&
53
46
  'getFormSchema' in tool &&
47
+ 'getEssentialFields' in tool &&
48
+ 'isFieldEmpty' in tool &&
54
49
  typeof (tool as FormValidatable).shouldGenerateForm === 'function' &&
55
- typeof (tool as FormValidatable).getFormSchema === 'function'
50
+ typeof (tool as FormValidatable).getFormSchema === 'function' &&
51
+ typeof (tool as FormValidatable).getEssentialFields === 'function' &&
52
+ typeof (tool as FormValidatable).isFieldEmpty === 'function'
56
53
  );
57
54
  }
@@ -59,8 +59,8 @@ export class InscribeFromBufferTool extends BaseInscriberQueryTool<
59
59
  waitForConfirmation: params.quoteOnly
60
60
  ? false
61
61
  : params.waitForConfirmation ?? true,
62
- waitMaxAttempts: 10,
63
- waitIntervalMs: 3000,
62
+ waitMaxAttempts: 60,
63
+ waitIntervalMs: 5000,
64
64
  apiKey: params.apiKey,
65
65
  network: this.inscriberBuilder['hederaKit'].client.network
66
66
  .toString()
@@ -242,8 +242,8 @@ export class InscribeFromUrlTool extends BaseInscriberQueryTool<
242
242
  waitForConfirmation: params.quoteOnly
243
243
  ? false
244
244
  : params.waitForConfirmation ?? true,
245
- waitMaxAttempts: 10,
246
- waitIntervalMs: 3000,
245
+ waitMaxAttempts: 60,
246
+ waitIntervalMs: 5000,
247
247
  apiKey: params.apiKey,
248
248
  network: this.inscriberBuilder['hederaKit'].client.network
249
249
  .toString()
@@ -15,7 +15,6 @@ import {
15
15
  extendZodSchema,
16
16
  renderConfigs,
17
17
  } from '../../lib/zod-render/schema-extension';
18
- import type { EnhancedRenderConfig } from '../../lib/zod-render/types';
19
18
  import {
20
19
  createInscriptionSuccess,
21
20
  createInscriptionQuote,
@@ -38,7 +37,7 @@ const HASHLINK_BLOCK_CONFIG = {
38
37
  hashLink: 'hcs://12/0.0.TBD',
39
38
  template: '0.0.TBD',
40
39
  },
41
- } as const;
40
+ };
42
41
 
43
42
  /**
44
43
  * Gets the appropriate HashLink block configuration for the specified network.
@@ -47,23 +46,19 @@ const HASHLINK_BLOCK_CONFIG = {
47
46
  * @param network The network type to get configuration for
48
47
  * @returns Network-specific block configuration with blockId, hashLink, and template
49
48
  */
50
- function getHashLinkBlockId(network: 'mainnet' | 'testnet') {
51
- const config = HASHLINK_BLOCK_CONFIG[network];
49
+ // @ts-ignore - keep untyped to satisfy mixed parser while using runtime narrowing
50
+ function getHashLinkBlockId(network) {
51
+ const config =
52
+ network === 'mainnet'
53
+ ? HASHLINK_BLOCK_CONFIG.mainnet
54
+ : HASHLINK_BLOCK_CONFIG.testnet;
52
55
  if (!config || config.blockId === '0.0.TBD') {
53
56
  return HASHLINK_BLOCK_CONFIG.testnet;
54
57
  }
55
58
  return config;
56
59
  }
57
60
 
58
- /**
59
- * Result of HCS-12 block lookup
60
- */
61
- interface HCS12BlockResult {
62
- blockId: string;
63
- hashLink: string;
64
- template: string;
65
- attributes: Record<string, unknown>;
66
- }
61
+ // Note: Using inline return type annotations to avoid parser issues with interface declarations
67
62
 
68
63
  /**
69
64
  * Schema for inscribing Hashinal NFT
@@ -210,6 +205,17 @@ export class InscribeHashinalTool
210
205
  description =
211
206
  '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.';
212
207
 
208
+ // Declare entity resolution preferences to preserve user-specified literal fields
209
+ getEntityResolutionPreferences(): Record<string, string> {
210
+ return {
211
+ name: 'literal',
212
+ description: 'literal',
213
+ creator: 'literal',
214
+ attributes: 'literal',
215
+ properties: 'literal',
216
+ };
217
+ }
218
+
213
219
  get specificInputSchema(): z.ZodObject<z.ZodRawShape> {
214
220
  const baseSchema =
215
221
  (inscribeHashinalSchema as z.ZodType & { _def?: { schema?: z.ZodType } })
@@ -349,12 +355,7 @@ export class InscribeHashinalTool
349
355
  })
350
356
  )
351
357
  )
352
- .withRender(
353
- renderConfigs.array(
354
- 'NFT Attributes',
355
- 'Attribute'
356
- ) as EnhancedRenderConfig
357
- )
358
+ .withRender(renderConfigs.array('NFT Attributes', 'Attribute'))
358
359
  .optional()
359
360
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
360
361
  .describe('Collectible traits and characteristics.'),
@@ -378,35 +379,6 @@ export class InscribeHashinalTool
378
379
  return focusedSchema as unknown as z.ZodObject<z.ZodRawShape>;
379
380
  }
380
381
 
381
- /**
382
- * Implementation of FormValidatable interface
383
- * Validates metadata quality and provides detailed feedback
384
- */
385
- validateMetadataQuality(input: unknown): {
386
- needsForm: boolean;
387
- reason: string;
388
- } {
389
- const inputObj = input as Record<string, unknown>;
390
- const hasRequiredMetadata = !!(
391
- inputObj.name &&
392
- inputObj.description &&
393
- inputObj.creator
394
- );
395
-
396
- if (!hasRequiredMetadata) {
397
- return {
398
- needsForm: true,
399
- reason:
400
- 'Missing essential metadata (name, description, creator) for NFT creation',
401
- };
402
- }
403
-
404
- return {
405
- needsForm: false,
406
- reason: 'All required metadata fields present',
407
- };
408
- }
409
-
410
382
  protected async executeQuery(
411
383
  params: z.infer<typeof inscribeHashinalSchema>,
412
384
  _runManager?: CallbackManagerForToolRun
@@ -470,7 +442,7 @@ export class InscribeHashinalTool
470
442
  waitForConfirmation: params.quoteOnly
471
443
  ? false
472
444
  : params.waitForConfirmation ?? true,
473
- waitMaxAttempts: 30,
445
+ waitMaxAttempts: 60,
474
446
  waitIntervalMs: 5000,
475
447
  network: this.inscriberBuilder['hederaKit'].client.network
476
448
  .toString()
@@ -602,6 +574,14 @@ export class InscribeHashinalTool
602
574
  },
603
575
  });
604
576
 
577
+ this.onEntityCreated?.({
578
+ entityId: jsonTopicId || imageTopicId || 'unknown',
579
+ entityName: params.name || 'Unnamed Inscription',
580
+ entityType: 'topicId',
581
+ transactionId: (result.result as { transactionId?: string })
582
+ ?.transactionId,
583
+ });
584
+
605
585
  if (params.withHashLinkBlocks) {
606
586
  try {
607
587
  const blockData = await this.createHashLinkBlock(
@@ -659,6 +639,14 @@ export class InscribeHashinalTool
659
639
  },
660
640
  });
661
641
 
642
+ this.onEntityCreated?.({
643
+ entityId: jsonTopicId || imageTopicId || 'unknown',
644
+ entityName: params.name || 'Unnamed Inscription',
645
+ entityType: 'topicId',
646
+ transactionId: (result.result as { transactionId?: string })
647
+ ?.transactionId,
648
+ });
649
+
662
650
  if (params.withHashLinkBlocks) {
663
651
  try {
664
652
  const blockData = await this.createHashLinkBlock(
@@ -768,7 +756,12 @@ export class InscribeHashinalTool
768
756
  private async createHashLinkBlock(
769
757
  response: ReturnType<typeof createInscriptionSuccess>,
770
758
  _mimeType?: string
771
- ): Promise<HCS12BlockResult> {
759
+ ): Promise<{
760
+ blockId: string;
761
+ hashLink: string;
762
+ template: string;
763
+ attributes: Record<string, unknown>;
764
+ }> {
772
765
  const clientNetwork = this.inscriberBuilder['hederaKit'].client.network
773
766
  .toString()
774
767
  .includes('mainnet')
@@ -16,6 +16,16 @@ import {
16
16
  } from '@hashgraphonline/standards-sdk';
17
17
  import { z } from 'zod';
18
18
 
19
+ /**
20
+ * Event emitted when an entity is created during inscription
21
+ */
22
+ export interface EntityCreationEvent {
23
+ entityId: string;
24
+ entityName: string;
25
+ entityType: string;
26
+ transactionId?: string;
27
+ }
28
+
19
29
  /**
20
30
  * Base class for Inscriber transaction tools
21
31
  */
@@ -28,6 +38,7 @@ export abstract class BaseInscriberTransactionTool<
28
38
  > extends BaseHederaTransactionTool<T> {
29
39
  protected inscriberBuilder: InscriberBuilder;
30
40
  protected contentResolver: ContentResolverInterface | null;
41
+ protected onEntityCreated?: (event: EntityCreationEvent) => void;
31
42
  namespace = 'inscriber' as const;
32
43
 
33
44
  constructor(params: InscriberTransactionToolParams) {
@@ -50,6 +61,13 @@ export abstract class BaseInscriberTransactionTool<
50
61
  return this.contentResolver;
51
62
  }
52
63
 
64
+ /**
65
+ * Set entity creation handler for automatic entity storage
66
+ */
67
+ setEntityCreationHandler(handler: (event: EntityCreationEvent) => void): void {
68
+ this.onEntityCreated = handler;
69
+ }
70
+
53
71
  /**
54
72
  * Generate a quote for an inscription without executing it
55
73
  * @param input - The inscription input data
@@ -93,6 +111,7 @@ export abstract class BaseInscriberQueryTool<
93
111
  > extends BaseHederaQueryTool<T> {
94
112
  protected inscriberBuilder: InscriberBuilder;
95
113
  protected contentResolver: ContentResolverInterface | null;
114
+ protected onEntityCreated?: (event: EntityCreationEvent) => void;
96
115
  namespace = 'inscriber' as const;
97
116
 
98
117
  constructor(params: InscriberQueryToolParams) {
@@ -115,6 +134,13 @@ export abstract class BaseInscriberQueryTool<
115
134
  return this.contentResolver;
116
135
  }
117
136
 
137
+ /**
138
+ * Set entity creation handler for automatic entity storage
139
+ */
140
+ setEntityCreationHandler(handler: (event: EntityCreationEvent) => void): void {
141
+ this.onEntityCreated = handler;
142
+ }
143
+
118
144
  /**
119
145
  * Generate a quote for an inscription without executing it
120
146
  * @param input - The inscription input data
@@ -131,9 +131,9 @@ export function createInscriptionSuccess(params: {
131
131
  },
132
132
  metadata,
133
133
  nextSteps: {
134
- primary: 'Use the HRL below as metadata when minting your NFT',
134
+ primary: 'CRITICAL: When minting NFTs, use ONLY the mintingMetadata value as a single string in the metadata array. Do NOT create JSON objects.',
135
135
  context:
136
- 'The HRL (Hedera Resource Locator) is the standardized way to reference your inscribed content in NFT metadata.',
136
+ 'The metadata parameter for minting should be exactly: ["' + hrl + '"] - just the HRL string in an array, nothing else.',
137
137
  mintingMetadata: hrl,
138
138
  },
139
139
  };