@hashgraphonline/standards-agent-kit 0.2.131 → 0.2.134

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 (168) hide show
  1. package/dist/cjs/builders/hcs10/hcs10-builder.d.ts +0 -2
  2. package/dist/cjs/builders/inscriber/inscriber-builder.d.ts +4 -10
  3. package/dist/cjs/index.d.ts +2 -0
  4. package/dist/cjs/interfaces/FormValidatable.d.ts +45 -0
  5. package/dist/cjs/interfaces/index.d.ts +1 -0
  6. package/dist/cjs/lib/index.d.ts +1 -0
  7. package/dist/cjs/lib/zod-render/config-extractor.d.ts +50 -0
  8. package/dist/cjs/lib/zod-render/index.d.ts +6 -0
  9. package/dist/cjs/lib/zod-render/schema-extension.d.ts +94 -0
  10. package/dist/cjs/lib/zod-render/types.d.ts +286 -0
  11. package/dist/cjs/standards-agent-kit.cjs +1 -1
  12. package/dist/cjs/standards-agent-kit.cjs.map +1 -1
  13. package/dist/cjs/tools/hcs10/natural-language-mapper.d.ts +6 -1
  14. package/dist/cjs/tools/hcs2/CreateRegistryTool.d.ts +1 -16
  15. package/dist/cjs/tools/hcs2/DeleteEntryTool.d.ts +1 -13
  16. package/dist/cjs/tools/hcs2/RegisterEntryTool.d.ts +1 -16
  17. package/dist/cjs/tools/hcs2/UpdateEntryTool.d.ts +1 -19
  18. package/dist/cjs/tools/hcs6/CreateDynamicRegistryTool.d.ts +1 -10
  19. package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +82 -132
  20. package/dist/cjs/tools/inscriber/RetrieveInscriptionTool.d.ts +20 -1
  21. package/dist/cjs/types/inscription-response.d.ts +172 -0
  22. package/dist/cjs/validation/hip412-schemas.d.ts +1 -1
  23. package/dist/es/builders/hcs10/hcs10-builder.d.ts +0 -2
  24. package/dist/es/builders/inscriber/inscriber-builder.d.ts +4 -10
  25. package/dist/es/index.d.ts +2 -0
  26. package/dist/es/interfaces/FormValidatable.d.ts +45 -0
  27. package/dist/es/interfaces/index.d.ts +1 -0
  28. package/dist/es/lib/index.d.ts +1 -0
  29. package/dist/es/lib/zod-render/config-extractor.d.ts +50 -0
  30. package/dist/es/lib/zod-render/index.d.ts +6 -0
  31. package/dist/es/lib/zod-render/schema-extension.d.ts +94 -0
  32. package/dist/es/lib/zod-render/types.d.ts +286 -0
  33. package/dist/es/standards-agent-kit.es.js +24 -1
  34. package/dist/es/standards-agent-kit.es.js.map +1 -1
  35. package/dist/es/standards-agent-kit.es10.js +3 -1
  36. package/dist/es/standards-agent-kit.es10.js.map +1 -1
  37. package/dist/es/standards-agent-kit.es14.js +3 -1
  38. package/dist/es/standards-agent-kit.es14.js.map +1 -1
  39. package/dist/es/standards-agent-kit.es20.js +3 -20
  40. package/dist/es/standards-agent-kit.es20.js.map +1 -1
  41. package/dist/es/standards-agent-kit.es22.js.map +1 -1
  42. package/dist/es/standards-agent-kit.es23.js.map +1 -1
  43. package/dist/es/standards-agent-kit.es24.js.map +1 -1
  44. package/dist/es/standards-agent-kit.es25.js.map +1 -1
  45. package/dist/es/standards-agent-kit.es29.js.map +1 -1
  46. package/dist/es/standards-agent-kit.es3.js +0 -4
  47. package/dist/es/standards-agent-kit.es3.js.map +1 -1
  48. package/dist/es/standards-agent-kit.es30.js.map +1 -1
  49. package/dist/es/standards-agent-kit.es31.js.map +1 -1
  50. package/dist/es/standards-agent-kit.es32.js.map +1 -1
  51. package/dist/es/standards-agent-kit.es33.js +0 -4
  52. package/dist/es/standards-agent-kit.es33.js.map +1 -1
  53. package/dist/es/standards-agent-kit.es34.js +13 -17
  54. package/dist/es/standards-agent-kit.es34.js.map +1 -1
  55. package/dist/es/standards-agent-kit.es35.js +2 -8
  56. package/dist/es/standards-agent-kit.es35.js.map +1 -1
  57. package/dist/es/standards-agent-kit.es36.js +2 -2
  58. package/dist/es/standards-agent-kit.es37.js +451 -92
  59. package/dist/es/standards-agent-kit.es37.js.map +1 -1
  60. package/dist/es/standards-agent-kit.es38.js +12 -11
  61. package/dist/es/standards-agent-kit.es38.js.map +1 -1
  62. package/dist/es/standards-agent-kit.es39.js +1 -1
  63. package/dist/es/standards-agent-kit.es39.js.map +1 -1
  64. package/dist/es/standards-agent-kit.es40.js +7 -7
  65. package/dist/es/standards-agent-kit.es40.js.map +1 -1
  66. package/dist/es/standards-agent-kit.es41.js.map +1 -1
  67. package/dist/es/standards-agent-kit.es42.js +423 -24
  68. package/dist/es/standards-agent-kit.es42.js.map +1 -1
  69. package/dist/es/standards-agent-kit.es43.js +185 -3
  70. package/dist/es/standards-agent-kit.es43.js.map +1 -1
  71. package/dist/es/standards-agent-kit.es44.js +3 -53
  72. package/dist/es/standards-agent-kit.es44.js.map +1 -1
  73. package/dist/es/standards-agent-kit.es45.js +25 -3
  74. package/dist/es/standards-agent-kit.es45.js.map +1 -1
  75. package/dist/es/standards-agent-kit.es46.js +3 -39
  76. package/dist/es/standards-agent-kit.es46.js.map +1 -1
  77. package/dist/es/standards-agent-kit.es47.js +51 -9
  78. package/dist/es/standards-agent-kit.es47.js.map +1 -1
  79. package/dist/es/standards-agent-kit.es48.js +6 -0
  80. package/dist/es/standards-agent-kit.es48.js.map +1 -0
  81. package/dist/es/standards-agent-kit.es49.js +43 -0
  82. package/dist/es/standards-agent-kit.es49.js.map +1 -0
  83. package/dist/es/standards-agent-kit.es50.js +22 -0
  84. package/dist/es/standards-agent-kit.es50.js.map +1 -0
  85. package/dist/es/standards-agent-kit.es51.js +57 -0
  86. package/dist/es/standards-agent-kit.es51.js.map +1 -0
  87. package/dist/es/standards-agent-kit.es6.js +1 -1
  88. package/dist/es/standards-agent-kit.es6.js.map +1 -1
  89. package/dist/es/standards-agent-kit.es7.js +1 -1
  90. package/dist/es/standards-agent-kit.es7.js.map +1 -1
  91. package/dist/es/standards-agent-kit.es9.js +6 -2
  92. package/dist/es/standards-agent-kit.es9.js.map +1 -1
  93. package/dist/es/tools/hcs10/natural-language-mapper.d.ts +6 -1
  94. package/dist/es/tools/hcs2/CreateRegistryTool.d.ts +1 -16
  95. package/dist/es/tools/hcs2/DeleteEntryTool.d.ts +1 -13
  96. package/dist/es/tools/hcs2/RegisterEntryTool.d.ts +1 -16
  97. package/dist/es/tools/hcs2/UpdateEntryTool.d.ts +1 -19
  98. package/dist/es/tools/hcs6/CreateDynamicRegistryTool.d.ts +1 -10
  99. package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +82 -132
  100. package/dist/es/tools/inscriber/RetrieveInscriptionTool.d.ts +20 -1
  101. package/dist/es/types/inscription-response.d.ts +172 -0
  102. package/dist/es/validation/hip412-schemas.d.ts +1 -1
  103. package/dist/umd/builders/hcs10/hcs10-builder.d.ts +0 -2
  104. package/dist/umd/builders/inscriber/inscriber-builder.d.ts +4 -10
  105. package/dist/umd/index.d.ts +2 -0
  106. package/dist/umd/interfaces/FormValidatable.d.ts +45 -0
  107. package/dist/umd/interfaces/index.d.ts +1 -0
  108. package/dist/umd/lib/index.d.ts +1 -0
  109. package/dist/umd/lib/zod-render/config-extractor.d.ts +50 -0
  110. package/dist/umd/lib/zod-render/index.d.ts +6 -0
  111. package/dist/umd/lib/zod-render/schema-extension.d.ts +94 -0
  112. package/dist/umd/lib/zod-render/types.d.ts +286 -0
  113. package/dist/umd/standards-agent-kit.umd.js +1 -1
  114. package/dist/umd/standards-agent-kit.umd.js.map +1 -1
  115. package/dist/umd/tools/hcs10/natural-language-mapper.d.ts +6 -1
  116. package/dist/umd/tools/hcs2/CreateRegistryTool.d.ts +1 -16
  117. package/dist/umd/tools/hcs2/DeleteEntryTool.d.ts +1 -13
  118. package/dist/umd/tools/hcs2/RegisterEntryTool.d.ts +1 -16
  119. package/dist/umd/tools/hcs2/UpdateEntryTool.d.ts +1 -19
  120. package/dist/umd/tools/hcs6/CreateDynamicRegistryTool.d.ts +1 -10
  121. package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +82 -132
  122. package/dist/umd/tools/inscriber/RetrieveInscriptionTool.d.ts +20 -1
  123. package/dist/umd/types/inscription-response.d.ts +172 -0
  124. package/dist/umd/validation/hip412-schemas.d.ts +1 -1
  125. package/package.json +5 -4
  126. package/src/builders/hcs10/hcs10-builder.ts +0 -4
  127. package/src/builders/inscriber/inscriber-builder.ts +5 -12
  128. package/src/hcs10/HCS10Client.ts +2 -5
  129. package/src/hcs10/types.ts +1 -15
  130. package/src/index.ts +2 -0
  131. package/src/init/init.ts +7 -10
  132. package/src/interfaces/FormValidatable.ts +57 -0
  133. package/src/interfaces/index.ts +1 -0
  134. package/src/lib/index.ts +1 -0
  135. package/src/lib/zod-render/config-extractor.ts +351 -0
  136. package/src/lib/zod-render/index.ts +36 -0
  137. package/src/lib/zod-render/schema-extension.ts +544 -0
  138. package/src/lib/zod-render/types.ts +333 -0
  139. package/src/plugins/PluginInterface.ts +1 -2
  140. package/src/plugins/PluginRegistry.ts +1 -1
  141. package/src/plugins/hedera/HbarPricePlugin.ts +1 -1
  142. package/src/plugins/weather/index.ts +15 -4
  143. package/src/state/open-convai-state.ts +1 -11
  144. package/src/tools/hcs10/FindRegistrationsTool.ts +1 -1
  145. package/src/tools/hcs10/RegisterAgentTool.ts +3 -3
  146. package/src/tools/hcs10/SendMessageToConnectionTool.ts +4 -1
  147. package/src/tools/hcs10/natural-language-mapper.ts +35 -53
  148. package/src/tools/hcs2/CreateRegistryTool.ts +1 -1
  149. package/src/tools/hcs2/DeleteEntryTool.ts +1 -1
  150. package/src/tools/hcs2/RegisterEntryTool.ts +1 -1
  151. package/src/tools/hcs2/UpdateEntryTool.ts +1 -1
  152. package/src/tools/hcs6/CreateDynamicRegistryTool.ts +2 -2
  153. package/src/tools/hcs6/QueryDynamicRegistryTool.ts +1 -1
  154. package/src/tools/hcs6/RegisterDynamicHashinalTool.ts +1 -1
  155. package/src/tools/hcs6/UpdateDynamicHashinalTool.ts +2 -2
  156. package/src/tools/inscriber/InscribeFromFileTool.ts +2 -11
  157. package/src/tools/inscriber/InscribeFromUrlTool.ts +15 -19
  158. package/src/tools/inscriber/InscribeHashinalTool.ts +681 -153
  159. package/src/tools/inscriber/RetrieveInscriptionTool.ts +34 -12
  160. package/src/tools/inscriber/base-inscriber-tools.ts +2 -24
  161. package/src/types/content-resolver.ts +3 -3
  162. package/src/types/inscription-response.ts +234 -0
  163. package/src/utils/Encryption.ts +1 -1
  164. package/src/utils/HederaClient.ts +1 -2
  165. package/src/utils/metadata-defaults.ts +15 -4
  166. package/src/utils/state-tools.ts +1 -2
  167. package/src/validation/content-ref-schemas.ts +2 -2
  168. package/src/validation/hip412-schemas.ts +1 -1
@@ -11,21 +11,14 @@ import {
11
11
  HederaClientConfig,
12
12
  NetworkType,
13
13
  } from '@hashgraphonline/standards-sdk';
14
+ import { InscriptionSDK } from '@kiloscribe/inscription-sdk';
14
15
 
15
16
  /**
16
- * Type definition for DAppSigner since we don't have the actual package
17
+ * Type definition for DAppSigner interface compatible with inscription SDK
17
18
  */
18
19
  interface DAppSigner {
19
20
  getAccountId(): { toString(): string };
20
- }
21
-
22
- /**
23
- * Type definition for InscriptionSDK since we don't have the actual package
24
- */
25
- interface InscriptionSDK {
26
- inscribeAndExecute(request: any, config: any): Promise<any>;
27
- inscribe(request: any, signer: any): Promise<any>;
28
- waitForInscription(txId: string, maxAttempts: number, intervalMs: number, checkCompletion: boolean, progressCallback?: Function): Promise<any>;
21
+ [key: string]: unknown;
29
22
  }
30
23
 
31
24
  /**
@@ -42,7 +35,7 @@ export class InscriberBuilder extends BaseServiceBuilder {
42
35
  * Get or create Inscription SDK - temporarily returns null since we don't have the actual SDK
43
36
  */
44
37
  protected async getInscriptionSDK(
45
- options: InscriptionOptions
38
+ _options: InscriptionOptions
46
39
  ): Promise<InscriptionSDK | null> {
47
40
  return null;
48
41
  }
@@ -81,7 +74,7 @@ export class InscriberBuilder extends BaseServiceBuilder {
81
74
  signer: DAppSigner,
82
75
  options: InscriptionOptions
83
76
  ): Promise<InscriptionResponse> {
84
- return await inscribeWithSigner(input, signer as any, options);
77
+ return await inscribeWithSigner(input, signer as unknown as Parameters<typeof inscribeWithSigner>[1], options);
85
78
  }
86
79
 
87
80
  /**
@@ -17,7 +17,6 @@ import { AgentMetadata, AgentChannels } from './types';
17
17
  import { encryptMessage } from '../utils/Encryption';
18
18
  import { IStateManager } from '../state/state-types';
19
19
 
20
- // Keep type alias as they were removed accidentally
21
20
  type StandardHandleConnectionRequest = InstanceType<
22
21
  typeof StandardSDKClient
23
22
  >['handleConnectionRequest'];
@@ -444,13 +443,11 @@ export class HCS10Client {
444
443
  error?: string;
445
444
  }> {
446
445
  try {
447
- // Set up client with provided operator details
446
+
448
447
  this.setClient(options.accountId, options.privateKey);
449
448
 
450
- // Check if we can retrieve the operator ID
451
449
  const operatorId = this.getOperatorId();
452
450
 
453
- // If we got this far, basic validation passed
454
451
  return {
455
452
  isValid: true,
456
453
  operator: { accountId: operatorId },
@@ -472,7 +469,7 @@ export class HCS10Client {
472
469
  const validationResult = await this.validateOperator(options);
473
470
 
474
471
  if (validationResult.isValid) {
475
- // If we have access to the state manager, initialize its connections manager
472
+
476
473
  if (options.stateManager) {
477
474
  options.stateManager.initializeConnectionsManager(this.standardClient);
478
475
  }
@@ -1,4 +1,3 @@
1
- // src/hcs10/types.ts
2
1
 
3
2
  import { FeeConfigBuilderInterface } from '@hashgraphonline/standards-sdk';
4
3
 
@@ -25,7 +24,7 @@ export interface AgentMetadata {
25
24
  export interface AgentChannels {
26
25
  inboundTopicId: string;
27
26
  outboundTopicId: string;
28
- // Future: additional connection topics can be added.
27
+
29
28
  }
30
29
 
31
30
  /**
@@ -39,16 +38,3 @@ export interface HCS10Message {
39
38
  messageId: string;
40
39
  metadata?: Record<string, unknown>;
41
40
  }
42
-
43
- // export interface AgentRegistration {
44
- // id: string;
45
- // name: string;
46
- // capabilities: string[];
47
- // createdAt: number;
48
- // publicKey: string;
49
- // }
50
-
51
- // export interface HCS10Config {
52
- // topicId: string;
53
- // network: 'mainnet' | 'testnet' | 'previewnet';
54
- // }
package/src/index.ts CHANGED
@@ -2,6 +2,8 @@ export * from './tools';
2
2
  export * from './state';
3
3
  export * from './init';
4
4
  export * from './plugins';
5
+ export * from './lib';
6
+ export * from './interfaces';
5
7
  export { HCS10Builder, HCS2Builder, HCS6Builder, InscriberBuilder } from './builders';
6
8
  export type { ExecuteResult } from './builders';
7
9
  export { HCS10Client } from './hcs10';
package/src/init/init.ts CHANGED
@@ -73,13 +73,19 @@ export const initializeStandardsAgentKit = async (
73
73
 
74
74
  const networkEnv = config.network || process.env.HEDERA_NETWORK || 'testnet';
75
75
 
76
+ const shouldSilence = process.env.DISABLE_LOGGING === 'true';
77
+ const logger = Logger.getInstance({
78
+ level: config.logLevel || 'info',
79
+ silent: shouldSilence,
80
+ });
81
+
76
82
  let network: 'mainnet' | 'testnet';
77
83
  if (networkEnv === 'mainnet') {
78
84
  network = 'mainnet';
79
85
  } else if (networkEnv === 'testnet') {
80
86
  network = 'testnet';
81
87
  } else {
82
- console.warn(
88
+ logger.warn(
83
89
  `Unsupported network specified: '${networkEnv}'. Defaulting to 'testnet'.`
84
90
  );
85
91
  network = 'testnet';
@@ -91,12 +97,6 @@ export const initializeStandardsAgentKit = async (
91
97
  );
92
98
  }
93
99
 
94
- const shouldSilence = process.env.DISABLE_LOGGING === 'true';
95
- const logger = Logger.getInstance({
96
- level: config.logLevel || 'info',
97
- silent: shouldSilence,
98
- });
99
-
100
100
  const stateManager =
101
101
  options?.stateManager ||
102
102
  new OpenConvaiState({
@@ -105,13 +105,11 @@ export const initializeStandardsAgentKit = async (
105
105
  });
106
106
  logger.info('State manager initialized');
107
107
 
108
- // Create HederaAgentKit
109
108
  const signer = new ServerSigner(operatorId, operatorPrivateKey, network);
110
109
  const hederaKit = new HederaAgentKit(signer);
111
110
  await hederaKit.initialize();
112
111
  logger.info(`HederaAgentKit initialized for ${operatorId} on ${network}`);
113
112
 
114
- // Create HCS10Builder
115
113
  const hcs10Builder = new HCS10Builder(hederaKit, stateManager, {
116
114
  useEncryption: config.useEncryption,
117
115
  registryUrl: config.registryUrl,
@@ -135,7 +133,6 @@ export const initializeStandardsAgentKit = async (
135
133
 
136
134
  const tools: Partial<HCS10Tools> = {};
137
135
 
138
- // Always create RegisterAgentTool
139
136
  tools.registerAgentTool = new RegisterAgentTool({
140
137
  hederaKit,
141
138
  hcs10Builder,
@@ -0,0 +1,57 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Interface for tools that can provide custom form validation logic
5
+ */
6
+ export interface FormValidatable {
7
+ /**
8
+ * Determines if a form should be generated for the given input
9
+ * @param input The input data to validate
10
+ * @returns true if a form should be generated, false if the tool can execute
11
+ */
12
+ shouldGenerateForm(input: unknown): boolean;
13
+
14
+ /**
15
+ * Returns the schema to use for form generation
16
+ * This allows tools to provide a focused schema for forms
17
+ * @returns The schema to use for generating forms
18
+ */
19
+ getFormSchema(): z.ZodSchema;
20
+
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
30
+ * Essential fields are always shown in forms even if marked as optional
31
+ * @returns Array of field names that are essential for user experience
32
+ */
33
+ getEssentialFields?(): string[];
34
+
35
+ /**
36
+ * Optional method to determine if a field value should be considered empty
37
+ * Allows tools to define custom empty logic for their specific data types
38
+ * @param fieldName The name of the field
39
+ * @param value The value to check
40
+ * @returns true if the field should be considered empty
41
+ */
42
+ isFieldEmpty?(fieldName: string, value: unknown): boolean;
43
+ }
44
+
45
+ /**
46
+ * Type guard to check if a tool implements FormValidatable
47
+ */
48
+ export function isFormValidatable(tool: unknown): tool is FormValidatable {
49
+ return (
50
+ tool !== null &&
51
+ typeof tool === 'object' &&
52
+ 'shouldGenerateForm' in tool &&
53
+ 'getFormSchema' in tool &&
54
+ typeof (tool as FormValidatable).shouldGenerateForm === 'function' &&
55
+ typeof (tool as FormValidatable).getFormSchema === 'function'
56
+ );
57
+ }
@@ -0,0 +1 @@
1
+ export * from './FormValidatable';
@@ -0,0 +1 @@
1
+ export * from './zod-render';
@@ -0,0 +1,351 @@
1
+ import { ZodType } from 'zod';
2
+
3
+ /**
4
+ * Type definitions for Zod internal structures
5
+ */
6
+ interface ZodDef {
7
+ typeName: string;
8
+ type?: ZodType<unknown>;
9
+ }
10
+
11
+ /**
12
+ * Type definition for Zod object schema with shape property
13
+ */
14
+ interface ZodObjectSchema {
15
+ _def: ZodDef;
16
+ shape: Record<string, ZodType<unknown>>;
17
+ }
18
+
19
+ /**
20
+ * Type definition for Zod array schema with element type
21
+ */
22
+ interface ZodArraySchema {
23
+ _def: ZodDef & {
24
+ type: ZodType<unknown>;
25
+ };
26
+ }
27
+
28
+ /**
29
+ * Type definition for field config map entries
30
+ */
31
+ interface FieldConfigMapEntry {
32
+ renderConfig: RenderConfigSchema;
33
+ metadata: FieldMetadata;
34
+ path: string[];
35
+ }
36
+
37
+
38
+ /**
39
+ * Type definition for simple field configuration
40
+ */
41
+ interface SimpleFieldConfig {
42
+ name: string;
43
+ type: FormFieldType;
44
+ label: string;
45
+ required: boolean;
46
+ placeholder?: string;
47
+ options?: Array<{ value: unknown; label: string }>;
48
+ }
49
+ import {
50
+ RenderConfigSchema,
51
+ ExtractedRenderConfig,
52
+ FieldMetadata,
53
+ FormFieldType
54
+ } from './types';
55
+ import {
56
+ hasRenderConfig,
57
+ getRenderConfig,
58
+ extractFieldMetadata,
59
+ getInnerSchema
60
+ } from './schema-extension';
61
+
62
+ /**
63
+ * Extracts render configurations from a Zod schema and all nested schemas
64
+ */
65
+ export function extractRenderConfigs(schema: ZodType<unknown>): ExtractedRenderConfig {
66
+ const fields: Record<string, RenderConfigSchema> = {};
67
+ const groups: Record<string, string[]> = {};
68
+ const order: string[] = [];
69
+ const metadata: Record<string, FieldMetadata> = {};
70
+
71
+ extractFromSchema(schema, '', fields, groups, order, metadata);
72
+
73
+ return {
74
+ fields,
75
+ groups: organizeFieldGroups(groups),
76
+ order: orderFields(order, fields),
77
+ metadata
78
+ };
79
+ }
80
+
81
+ /**
82
+ * Recursively extracts render configurations from schema and nested schemas
83
+ */
84
+ function extractFromSchema(
85
+ schema: ZodType<unknown>,
86
+ pathPrefix: string,
87
+ fields: Record<string, RenderConfigSchema>,
88
+ groups: Record<string, string[]>,
89
+ order: string[],
90
+ metadata: Record<string, FieldMetadata>
91
+ ): void {
92
+ const innerSchema = getInnerSchema(schema);
93
+ const typeName = (innerSchema._def as ZodDef)?.typeName;
94
+
95
+ if (typeName === 'ZodObject') {
96
+ extractFromObjectSchema(innerSchema as unknown as ZodObjectSchema, pathPrefix, fields, groups, order, metadata);
97
+ } else if (typeName === 'ZodArray') {
98
+ extractFromArraySchema(innerSchema as unknown as ZodArraySchema, pathPrefix, fields, groups, order, metadata);
99
+ } else {
100
+ extractFromPrimitiveSchema(schema, pathPrefix, fields, groups, order, metadata);
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Extracts configurations from ZodObject schemas
106
+ */
107
+ function extractFromObjectSchema(
108
+ schema: ZodObjectSchema,
109
+ pathPrefix: string,
110
+ fields: Record<string, RenderConfigSchema>,
111
+ groups: Record<string, string[]>,
112
+ order: string[],
113
+ metadata: Record<string, FieldMetadata>
114
+ ): void {
115
+ const shape = schema.shape;
116
+
117
+ if (hasRenderConfig(schema)) {
118
+ const config = getRenderConfig(schema);
119
+ if (config && pathPrefix) {
120
+ fields[pathPrefix] = config;
121
+ addToGroup(groups, config.ui?.group || 'default', pathPrefix);
122
+ addToOrder(order, pathPrefix, config.ui?.order);
123
+ }
124
+ }
125
+
126
+ for (const [key, fieldSchema] of Object.entries(shape)) {
127
+ const fieldPath = pathPrefix ? `${pathPrefix}.${key}` : key;
128
+ extractFromSchema(fieldSchema as ZodType<unknown>, fieldPath, fields, groups, order, metadata);
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Extracts configurations from ZodArray schemas
134
+ */
135
+ function extractFromArraySchema(
136
+ schema: ZodArraySchema,
137
+ pathPrefix: string,
138
+ fields: Record<string, RenderConfigSchema>,
139
+ groups: Record<string, string[]>,
140
+ order: string[],
141
+ metadata: Record<string, FieldMetadata>
142
+ ): void {
143
+ if (hasRenderConfig(schema)) {
144
+ const config = getRenderConfig(schema);
145
+ if (config) {
146
+ fields[pathPrefix] = config;
147
+ addToGroup(groups, config.ui?.group || 'default', pathPrefix);
148
+ addToOrder(order, pathPrefix, config.ui?.order);
149
+ metadata[pathPrefix] = extractFieldMetadata(schema);
150
+ }
151
+ }
152
+
153
+ const elementSchema = schema._def.type;
154
+ if (elementSchema) {
155
+ const itemPath = `${pathPrefix}[]`;
156
+ extractFromSchema(elementSchema, itemPath, fields, groups, order, metadata);
157
+ }
158
+ }
159
+
160
+ /**
161
+ * Extracts configurations from primitive schemas
162
+ */
163
+ function extractFromPrimitiveSchema(
164
+ schema: ZodType<unknown>,
165
+ pathPrefix: string,
166
+ fields: Record<string, RenderConfigSchema>,
167
+ groups: Record<string, string[]>,
168
+ order: string[],
169
+ metadata: Record<string, FieldMetadata>
170
+ ): void {
171
+ if (hasRenderConfig(schema)) {
172
+ const config = getRenderConfig(schema);
173
+ if (config) {
174
+ fields[pathPrefix] = config;
175
+ addToGroup(groups, config.ui?.group || 'default', pathPrefix);
176
+ addToOrder(order, pathPrefix, config.ui?.order);
177
+ }
178
+ }
179
+
180
+ metadata[pathPrefix] = extractFieldMetadata(schema);
181
+ }
182
+
183
+ /**
184
+ * Adds a field to a group
185
+ */
186
+ function addToGroup(groups: Record<string, string[]>, groupName: string, fieldPath: string): void {
187
+ if (!groups[groupName]) {
188
+ groups[groupName] = [];
189
+ }
190
+ groups[groupName].push(fieldPath);
191
+ }
192
+
193
+ /**
194
+ * Adds a field to the order array considering explicit order values
195
+ */
196
+ function addToOrder(order: string[], fieldPath: string, explicitOrder?: number): void {
197
+ if (explicitOrder !== undefined) {
198
+ order.splice(explicitOrder, 0, fieldPath);
199
+ } else {
200
+ order.push(fieldPath);
201
+ }
202
+ }
203
+
204
+ /**
205
+ * Organizes field groups with proper ordering
206
+ */
207
+ function organizeFieldGroups(groups: Record<string, string[]>): Record<string, string[]> {
208
+ const organized: Record<string, string[]> = {};
209
+ const groupPriority = ['default', 'Keys & Security', 'Token Settings', 'Custom Fees'];
210
+
211
+ for (const groupName of groupPriority) {
212
+ if (groups[groupName]) {
213
+ organized[groupName] = groups[groupName];
214
+ }
215
+ }
216
+
217
+ for (const [groupName, fields] of Object.entries(groups)) {
218
+ if (!groupPriority.includes(groupName)) {
219
+ organized[groupName] = fields;
220
+ }
221
+ }
222
+
223
+ return organized;
224
+ }
225
+
226
+ /**
227
+ * Orders fields based on explicit order values and logical grouping
228
+ */
229
+ function orderFields(order: string[], fields: Record<string, RenderConfigSchema>): string[] {
230
+ const fieldPriority: Record<string, number> = {
231
+ 'tokenName': 1,
232
+ 'tokenSymbol': 2,
233
+ 'maxSupply': 3,
234
+ 'supplyType': 4,
235
+ 'treasuryAccountId': 5,
236
+ 'memo': 6,
237
+ };
238
+
239
+ return order.sort((a, b) => {
240
+ const aConfig = fields[a];
241
+ const bConfig = fields[b];
242
+
243
+ if (aConfig?.ui?.order !== undefined && bConfig?.ui?.order !== undefined) {
244
+ return aConfig.ui.order - bConfig.ui.order;
245
+ }
246
+
247
+ if (aConfig?.ui?.order !== undefined) {
248
+ return -1;
249
+ }
250
+ if (bConfig?.ui?.order !== undefined) {
251
+ return 1;
252
+ }
253
+
254
+ const aPriority = fieldPriority[a] || 1000;
255
+ const bPriority = fieldPriority[b] || 1000;
256
+
257
+ if (aPriority !== bPriority) {
258
+ return aPriority - bPriority;
259
+ }
260
+
261
+ return a.localeCompare(b);
262
+ });
263
+ }
264
+
265
+ /**
266
+ * Generates field ordering metadata for complex forms
267
+ */
268
+ export function generateFieldOrdering(schema: ZodType<unknown>): {
269
+ sections: Record<string, { title: string; fields: string[]; order: number }>;
270
+ fieldOrder: string[];
271
+ } {
272
+ const extracted = extractRenderConfigs(schema);
273
+ const sections: Record<string, { title: string; fields: string[]; order: number }> = {};
274
+
275
+ const sectionOrder: Record<string, number> = {
276
+ 'default': 0,
277
+ 'Basic Information': 1,
278
+ 'Token Settings': 2,
279
+ 'Keys & Security': 3,
280
+ 'Custom Fees': 4,
281
+ 'Advanced Settings': 5
282
+ };
283
+
284
+ for (const [groupName, fields] of Object.entries(extracted.groups)) {
285
+ const displayName = groupName === 'default' ? 'Basic Information' : groupName;
286
+ sections[displayName] = {
287
+ title: displayName,
288
+ fields,
289
+ order: sectionOrder[displayName] || 10
290
+ };
291
+ }
292
+
293
+ return {
294
+ sections,
295
+ fieldOrder: extracted.order
296
+ };
297
+ }
298
+
299
+ /**
300
+ * Creates a field configuration map for form builders
301
+ */
302
+ export function createFieldConfigMap(schema: ZodType<unknown>): Record<string, FieldConfigMapEntry> {
303
+ const extracted = extractRenderConfigs(schema);
304
+ const configMap: Record<string, FieldConfigMapEntry> = {};
305
+
306
+ for (const [fieldPath, renderConfig] of Object.entries(extracted.fields)) {
307
+ const metadata = extracted.metadata[fieldPath];
308
+ const path = fieldPath.split('.');
309
+
310
+ configMap[fieldPath] = {
311
+ renderConfig,
312
+ metadata,
313
+ path
314
+ };
315
+ }
316
+
317
+ return configMap;
318
+ }
319
+
320
+
321
+
322
+
323
+ /**
324
+ * Creates a simplified configuration for basic form rendering
325
+ */
326
+ export function createSimpleConfig(schema: ZodType<unknown>): {
327
+ fields: Array<SimpleFieldConfig>;
328
+ } {
329
+ const extracted = extractRenderConfigs(schema);
330
+ const fields = [];
331
+
332
+ for (const fieldPath of extracted.order) {
333
+ const renderConfig = extracted.fields[fieldPath];
334
+ const metadata = extracted.metadata[fieldPath];
335
+
336
+ if (!renderConfig || !metadata) {
337
+ continue;
338
+ }
339
+
340
+ fields.push({
341
+ name: fieldPath,
342
+ type: metadata.type,
343
+ label: renderConfig.ui?.label || fieldPath,
344
+ required: metadata.required,
345
+ placeholder: renderConfig.ui?.placeholder,
346
+ options: renderConfig.options || metadata.options
347
+ });
348
+ }
349
+
350
+ return { fields };
351
+ }
@@ -0,0 +1,36 @@
1
+ export * from './types';
2
+ export * from './schema-extension';
3
+ export * from './config-extractor';
4
+
5
+ export {
6
+ extendZodSchema,
7
+ hasRenderConfig,
8
+ getRenderConfig,
9
+ renderConfigs
10
+ } from './schema-extension';
11
+
12
+ export {
13
+ extractRenderConfigs,
14
+ generateFieldOrdering,
15
+ createFieldConfigMap,
16
+ createSimpleConfig
17
+ } from './config-extractor';
18
+
19
+ export type {
20
+ FormFieldType,
21
+ RenderContext,
22
+ RenderFunction,
23
+ RenderConfigSchema,
24
+ ZodSchemaWithRender,
25
+ FormGenerationOptions,
26
+ ValidationError,
27
+ FormState,
28
+ FormActions,
29
+ UseFormReturn,
30
+ ComponentRegistry,
31
+ FieldComponentProps,
32
+ SelectOption,
33
+ FileUploadResult,
34
+ FieldMetadata,
35
+ ExtractedRenderConfig
36
+ } from './types';