@hashgraphonline/conversational-agent 0.1.214 → 0.1.217
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/cli/dist/CLIApp.d.ts +9 -0
- package/cli/dist/CLIApp.js +127 -0
- package/cli/dist/LocalConversationalAgent.d.ts +37 -0
- package/cli/dist/LocalConversationalAgent.js +58 -0
- package/cli/dist/app.d.ts +16 -0
- package/cli/dist/app.js +13 -0
- package/cli/dist/cli.d.ts +2 -0
- package/cli/dist/cli.js +51 -0
- package/cli/dist/components/AppContainer.d.ts +16 -0
- package/cli/dist/components/AppContainer.js +24 -0
- package/cli/dist/components/AppScreens.d.ts +2 -0
- package/cli/dist/components/AppScreens.js +259 -0
- package/cli/dist/components/ChatScreen.d.ts +15 -0
- package/cli/dist/components/ChatScreen.js +39 -0
- package/cli/dist/components/DebugLoadingScreen.d.ts +5 -0
- package/cli/dist/components/DebugLoadingScreen.js +31 -0
- package/cli/dist/components/LoadingScreen.d.ts +2 -0
- package/cli/dist/components/LoadingScreen.js +16 -0
- package/cli/dist/components/LoadingScreenDebug.d.ts +5 -0
- package/cli/dist/components/LoadingScreenDebug.js +27 -0
- package/cli/dist/components/MCPConfigScreen.d.ts +28 -0
- package/cli/dist/components/MCPConfigScreen.js +168 -0
- package/cli/dist/components/ScreenRouter.d.ts +12 -0
- package/cli/dist/components/ScreenRouter.js +22 -0
- package/cli/dist/components/SetupScreen.d.ts +15 -0
- package/cli/dist/components/SetupScreen.js +65 -0
- package/cli/dist/components/SingleLoadingScreen.d.ts +5 -0
- package/cli/dist/components/SingleLoadingScreen.js +27 -0
- package/cli/dist/components/StatusBadge.d.ts +7 -0
- package/cli/dist/components/StatusBadge.js +28 -0
- package/cli/dist/components/TerminalWindow.d.ts +8 -0
- package/cli/dist/components/TerminalWindow.js +24 -0
- package/cli/dist/components/WelcomeScreen.d.ts +11 -0
- package/cli/dist/components/WelcomeScreen.js +47 -0
- package/cli/dist/context/AppContext.d.ts +68 -0
- package/cli/dist/context/AppContext.js +363 -0
- package/cli/dist/hooks/useInitializeAgent.d.ts +19 -0
- package/cli/dist/hooks/useInitializeAgent.js +28 -0
- package/cli/dist/hooks/useStableState.d.ts +38 -0
- package/cli/dist/hooks/useStableState.js +68 -0
- package/cli/dist/managers/AgentManager.d.ts +57 -0
- package/cli/dist/managers/AgentManager.js +119 -0
- package/cli/dist/managers/ConfigManager.d.ts +53 -0
- package/cli/dist/managers/ConfigManager.js +173 -0
- package/cli/dist/types.d.ts +31 -0
- package/cli/dist/types.js +19 -0
- package/dist/cjs/base-agent.d.ts +2 -0
- package/dist/cjs/conversational-agent.d.ts +8 -0
- package/dist/cjs/core/ToolRegistry.d.ts +130 -0
- package/dist/cjs/execution/ExecutionPipeline.d.ts +81 -0
- package/dist/cjs/forms/FormEngine.d.ts +121 -0
- package/dist/cjs/forms/field-type-registry.d.ts +51 -0
- package/dist/cjs/forms/form-generator.d.ts +123 -0
- package/dist/cjs/forms/index.d.ts +2 -0
- package/dist/cjs/forms/types.d.ts +108 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/langchain/FormAwareAgentExecutor.d.ts +108 -0
- package/dist/cjs/langchain/FormValidatingToolWrapper.d.ts +81 -0
- package/dist/cjs/langchain-agent.d.ts +65 -0
- package/dist/cjs/memory/ContentStorage.d.ts +7 -0
- package/dist/cjs/memory/SmartMemoryManager.d.ts +1 -0
- package/dist/cjs/services/ContentStoreManager.d.ts +11 -1
- package/dist/cjs/utils/ResponseFormatter.d.ts +26 -0
- package/dist/esm/index.js +8 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index12.js +1 -1
- package/dist/esm/index12.js.map +1 -1
- package/dist/esm/index14.js +23 -5
- package/dist/esm/index14.js.map +1 -1
- package/dist/esm/index15.js +25 -4
- package/dist/esm/index15.js.map +1 -1
- package/dist/esm/index16.js +4 -2
- package/dist/esm/index16.js.map +1 -1
- package/dist/esm/index17.js +2 -7
- package/dist/esm/index17.js.map +1 -1
- package/dist/esm/index18.js +609 -36
- package/dist/esm/index18.js.map +1 -1
- package/dist/esm/index19.js +229 -84
- package/dist/esm/index19.js.map +1 -1
- package/dist/esm/index20.js +111 -17
- package/dist/esm/index20.js.map +1 -1
- package/dist/esm/index21.js +44 -7
- package/dist/esm/index21.js.map +1 -1
- package/dist/esm/index22.js +86 -157
- package/dist/esm/index22.js.map +1 -1
- package/dist/esm/index23.js +32 -150
- package/dist/esm/index23.js.map +1 -1
- package/dist/esm/index24.js +746 -80
- package/dist/esm/index24.js.map +1 -1
- package/dist/esm/index25.js +154 -45
- package/dist/esm/index25.js.map +1 -1
- package/dist/esm/index26.js +149 -24
- package/dist/esm/index26.js.map +1 -1
- package/dist/esm/index27.js +196 -217
- package/dist/esm/index27.js.map +1 -1
- package/dist/esm/index28.js +187 -0
- package/dist/esm/index28.js.map +1 -0
- package/dist/esm/index29.js +308 -0
- package/dist/esm/index29.js.map +1 -0
- package/dist/esm/index30.js +159 -0
- package/dist/esm/index30.js.map +1 -0
- package/dist/esm/index31.js +68 -0
- package/dist/esm/index31.js.map +1 -0
- package/dist/esm/index32.js +30 -0
- package/dist/esm/index32.js.map +1 -0
- package/dist/esm/index33.js +95 -0
- package/dist/esm/index33.js.map +1 -0
- package/dist/esm/index34.js +245 -0
- package/dist/esm/index34.js.map +1 -0
- package/dist/esm/index5.js +2 -2
- package/dist/esm/index5.js.map +1 -1
- package/dist/esm/index6.js +68 -25
- package/dist/esm/index6.js.map +1 -1
- package/dist/esm/index7.js.map +1 -1
- package/dist/esm/index8.js +744 -70
- package/dist/esm/index8.js.map +1 -1
- package/dist/types/base-agent.d.ts +2 -0
- package/dist/types/conversational-agent.d.ts +8 -0
- package/dist/types/core/ToolRegistry.d.ts +130 -0
- package/dist/types/execution/ExecutionPipeline.d.ts +81 -0
- package/dist/types/forms/FormEngine.d.ts +121 -0
- package/dist/types/forms/field-type-registry.d.ts +51 -0
- package/dist/types/forms/form-generator.d.ts +123 -0
- package/dist/types/forms/index.d.ts +2 -0
- package/dist/types/forms/types.d.ts +108 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/langchain/FormAwareAgentExecutor.d.ts +108 -0
- package/dist/types/langchain/FormValidatingToolWrapper.d.ts +81 -0
- package/dist/types/langchain-agent.d.ts +65 -0
- package/dist/types/memory/ContentStorage.d.ts +7 -0
- package/dist/types/memory/SmartMemoryManager.d.ts +1 -0
- package/dist/types/services/ContentStoreManager.d.ts +11 -1
- package/dist/types/utils/ResponseFormatter.d.ts +26 -0
- package/package.json +35 -34
- package/src/base-agent.ts +2 -0
- package/src/config/system-message.ts +14 -0
- package/src/context/ReferenceContextManager.ts +1 -1
- package/src/conversational-agent.ts +95 -38
- package/src/core/ToolRegistry.ts +358 -0
- package/src/execution/ExecutionPipeline.ts +301 -0
- package/src/forms/FormEngine.ts +443 -0
- package/src/forms/field-type-registry.ts +203 -0
- package/src/forms/form-generator.ts +841 -0
- package/src/forms/index.ts +2 -0
- package/src/forms/types.ts +125 -0
- package/src/index.ts +9 -0
- package/src/langchain/FormAwareAgentExecutor.ts +971 -0
- package/src/langchain/FormValidatingToolWrapper.ts +355 -0
- package/src/langchain-agent.ts +1034 -87
- package/src/mcp/ContentProcessor.ts +20 -4
- package/src/mcp/MCPClientManager.ts +1 -1
- package/src/mcp/adapters/langchain.ts +1 -1
- package/src/memory/ContentStorage.ts +25 -5
- package/src/memory/SmartMemoryManager.ts +27 -4
- package/src/memory/TokenCounter.ts +1 -1
- package/src/plugins/hbar/HbarPlugin.ts +0 -1
- package/src/scripts/test-external-tool-wrapper.ts +103 -0
- package/src/scripts/test-hedera-kit-wrapper.ts +265 -0
- package/src/scripts/test-inscribe-form-generation.ts +494 -0
- package/src/scripts/test-inscribe-wrapper-verification.ts +220 -0
- package/src/services/ContentStoreManager.ts +23 -9
- package/src/services/EntityResolver.ts +2 -9
- package/src/tools/EntityResolverTool.ts +5 -8
- package/src/utils/ResponseFormatter.ts +146 -0
- package/cli/readme.md +0 -181
- package/dist/cjs/langchain/ContentAwareAgentExecutor.d.ts +0 -14
- package/dist/types/langchain/ContentAwareAgentExecutor.d.ts +0 -14
- package/src/langchain/ContentAwareAgentExecutor.ts +0 -19
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { StructuredTool } from '@langchain/core/tools';
|
|
2
|
+
import { ZodError, z } from 'zod';
|
|
3
|
+
import { Logger } from '@hashgraphonline/standards-sdk';
|
|
4
|
+
import { FormMessage, FormSubmission } from './types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Tool execution result with optional form requirement
|
|
8
|
+
*/
|
|
9
|
+
export interface ToolExecutionResult {
|
|
10
|
+
success: boolean;
|
|
11
|
+
output: string;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
requiresForm?: boolean;
|
|
14
|
+
formMessage?: FormMessage;
|
|
15
|
+
error?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Context for form generation operations
|
|
19
|
+
*/
|
|
20
|
+
export interface FormGenerationContext {
|
|
21
|
+
tool: StructuredTool;
|
|
22
|
+
input: unknown;
|
|
23
|
+
sessionId?: string;
|
|
24
|
+
userId?: string;
|
|
25
|
+
missingFields?: Set<string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* FormEngine handles all form generation and validation logic
|
|
29
|
+
*/
|
|
30
|
+
export declare class FormEngine {
|
|
31
|
+
private formGenerator;
|
|
32
|
+
private logger;
|
|
33
|
+
constructor(logger?: Logger);
|
|
34
|
+
/**
|
|
35
|
+
* Generate a form for a tool with the given input
|
|
36
|
+
*/
|
|
37
|
+
generateForm(toolName: string, tool: StructuredTool, input: unknown, context?: Partial<FormGenerationContext>): Promise<FormMessage | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Process a form submission
|
|
40
|
+
*/
|
|
41
|
+
processSubmission(submission: FormSubmission, context?: {
|
|
42
|
+
originalInput?: Record<string, unknown>;
|
|
43
|
+
schema?: unknown;
|
|
44
|
+
}): Promise<Record<string, unknown>>;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a tool requires form generation based on input
|
|
47
|
+
*/
|
|
48
|
+
shouldGenerateForm(tool: StructuredTool, input: unknown): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Generate form from error context
|
|
51
|
+
*/
|
|
52
|
+
generateFormFromError(error: ZodError, toolName: string, toolSchema: z.ZodSchema, originalPrompt: string): Promise<FormMessage>;
|
|
53
|
+
/**
|
|
54
|
+
* Generate form for FormValidatable tools
|
|
55
|
+
*/
|
|
56
|
+
private generateFormValidatableForm;
|
|
57
|
+
/**
|
|
58
|
+
* Generate form based on schema validation
|
|
59
|
+
*/
|
|
60
|
+
private generateSchemaBasedForm;
|
|
61
|
+
/**
|
|
62
|
+
* Generate form based on render config
|
|
63
|
+
*/
|
|
64
|
+
private generateRenderConfigForm;
|
|
65
|
+
/**
|
|
66
|
+
* Generate form from Zod validation error
|
|
67
|
+
*/
|
|
68
|
+
private generateErrorBasedForm;
|
|
69
|
+
/**
|
|
70
|
+
* Validate input against tool schema
|
|
71
|
+
*/
|
|
72
|
+
private validateInput;
|
|
73
|
+
/**
|
|
74
|
+
* Check if schema is ZodObject
|
|
75
|
+
*/
|
|
76
|
+
private isZodObject;
|
|
77
|
+
/**
|
|
78
|
+
* Check if tool has render configuration
|
|
79
|
+
*/
|
|
80
|
+
private hasRenderConfig;
|
|
81
|
+
/**
|
|
82
|
+
* Extract render configuration from tool
|
|
83
|
+
*/
|
|
84
|
+
private extractRenderConfig;
|
|
85
|
+
/**
|
|
86
|
+
* Resolve form schema for FormValidatable tools
|
|
87
|
+
*/
|
|
88
|
+
private resolveFormSchema;
|
|
89
|
+
/**
|
|
90
|
+
* Determine missing fields for form generation
|
|
91
|
+
*/
|
|
92
|
+
private determineMissingFields;
|
|
93
|
+
/**
|
|
94
|
+
* Generate form with resolved schema
|
|
95
|
+
*/
|
|
96
|
+
private generateFormWithSchema;
|
|
97
|
+
/**
|
|
98
|
+
* Validate form submission
|
|
99
|
+
*/
|
|
100
|
+
private validateSubmission;
|
|
101
|
+
/**
|
|
102
|
+
* Extract base tool input from context
|
|
103
|
+
*/
|
|
104
|
+
private extractBaseToolInput;
|
|
105
|
+
/**
|
|
106
|
+
* Extract submission data
|
|
107
|
+
*/
|
|
108
|
+
private extractSubmissionData;
|
|
109
|
+
/**
|
|
110
|
+
* Merge input data
|
|
111
|
+
*/
|
|
112
|
+
private mergeInputData;
|
|
113
|
+
/**
|
|
114
|
+
* Get registered strategies
|
|
115
|
+
*/
|
|
116
|
+
getRegisteredStrategies(): string[];
|
|
117
|
+
/**
|
|
118
|
+
* Get registered middleware
|
|
119
|
+
*/
|
|
120
|
+
getRegisteredMiddleware(): string[];
|
|
121
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FormFieldType } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pattern-based field type detection rule
|
|
5
|
+
*/
|
|
6
|
+
export interface FieldTypePattern {
|
|
7
|
+
pattern: RegExp | string[];
|
|
8
|
+
type: FormFieldType;
|
|
9
|
+
priority?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Registry for managing field type detection patterns
|
|
13
|
+
*/
|
|
14
|
+
export declare class FieldTypeRegistry {
|
|
15
|
+
private static instance;
|
|
16
|
+
private patterns;
|
|
17
|
+
private constructor();
|
|
18
|
+
/**
|
|
19
|
+
* Get singleton instance
|
|
20
|
+
*/
|
|
21
|
+
static getInstance(): FieldTypeRegistry;
|
|
22
|
+
/**
|
|
23
|
+
* Initialize default field type patterns
|
|
24
|
+
*/
|
|
25
|
+
private initializeDefaultPatterns;
|
|
26
|
+
/**
|
|
27
|
+
* Register a field type pattern
|
|
28
|
+
*/
|
|
29
|
+
register(key: string, pattern: FieldTypePattern): void;
|
|
30
|
+
/**
|
|
31
|
+
* Unregister a field type pattern
|
|
32
|
+
*/
|
|
33
|
+
unregister(key: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Detect field type based on field name
|
|
36
|
+
*/
|
|
37
|
+
detectType(fieldName: string): FormFieldType | null;
|
|
38
|
+
/**
|
|
39
|
+
* Get all registered patterns
|
|
40
|
+
*/
|
|
41
|
+
getPatterns(): Map<string, FieldTypePattern>;
|
|
42
|
+
/**
|
|
43
|
+
* Clear all patterns
|
|
44
|
+
*/
|
|
45
|
+
clear(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Reset to default patterns
|
|
48
|
+
*/
|
|
49
|
+
reset(): void;
|
|
50
|
+
}
|
|
51
|
+
export declare const fieldTypeRegistry: FieldTypeRegistry;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { z, ZodError } from 'zod';
|
|
2
|
+
import { FormMessage } from './types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generates forms from Zod validation failures
|
|
6
|
+
*/
|
|
7
|
+
export declare class FormGenerator {
|
|
8
|
+
private logger;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Creates a form message from a Zod validation error
|
|
12
|
+
* @param error The Zod validation error
|
|
13
|
+
* @param schema The original Zod schema
|
|
14
|
+
* @param toolName Name of the tool that failed validation
|
|
15
|
+
* @param originalPrompt The user's original request
|
|
16
|
+
* @returns FormMessage to send to the chat UI
|
|
17
|
+
*/
|
|
18
|
+
generateFormFromError(error: ZodError, schema: z.ZodSchema, toolName: string, originalPrompt: string): FormMessage;
|
|
19
|
+
/**
|
|
20
|
+
* Generates a form from a schema and partial input
|
|
21
|
+
* @param schema The Zod schema to generate a form from
|
|
22
|
+
* @param partialInput Any partial input already provided
|
|
23
|
+
* @param context Additional context about the tool
|
|
24
|
+
* @param preCalculatedMissingFields Optional pre-calculated missing fields set. If undefined, includes all fields from schema.
|
|
25
|
+
* @returns FormMessage to send to the chat UI
|
|
26
|
+
*/
|
|
27
|
+
generateFormFromSchema(schema: z.ZodSchema, partialInput: unknown, context: {
|
|
28
|
+
toolName: string;
|
|
29
|
+
toolDescription?: string;
|
|
30
|
+
}, preCalculatedMissingFields?: Set<string>): Promise<FormMessage>;
|
|
31
|
+
/**
|
|
32
|
+
* Extracts validation errors from ZodError
|
|
33
|
+
*/
|
|
34
|
+
private extractValidationErrors;
|
|
35
|
+
/**
|
|
36
|
+
* Identifies which fields are missing or invalid from validation errors
|
|
37
|
+
*/
|
|
38
|
+
private identifyMissingFields;
|
|
39
|
+
/**
|
|
40
|
+
* Creates form configuration from schema
|
|
41
|
+
*/
|
|
42
|
+
private createFormConfig;
|
|
43
|
+
/**
|
|
44
|
+
* Safely extracts render configs from schema
|
|
45
|
+
*/
|
|
46
|
+
private extractRenderConfigsSafely;
|
|
47
|
+
/**
|
|
48
|
+
* Safely generates field ordering from schema
|
|
49
|
+
*/
|
|
50
|
+
private generateFieldOrderingSafely;
|
|
51
|
+
/**
|
|
52
|
+
* Determines field priority for progressive disclosure
|
|
53
|
+
*/
|
|
54
|
+
private getFieldPriority;
|
|
55
|
+
/**
|
|
56
|
+
* Determines which fields should be included in the form
|
|
57
|
+
*/
|
|
58
|
+
private determineFieldsToInclude;
|
|
59
|
+
/**
|
|
60
|
+
* Includes required fields that are missing
|
|
61
|
+
*/
|
|
62
|
+
private includeRequiredMissingFields;
|
|
63
|
+
/**
|
|
64
|
+
* Creates form fields from ordered field names
|
|
65
|
+
*/
|
|
66
|
+
private createOrderedFields;
|
|
67
|
+
/**
|
|
68
|
+
* Generates form fields from schema and validation errors
|
|
69
|
+
*/
|
|
70
|
+
private generateFormFields;
|
|
71
|
+
/**
|
|
72
|
+
* Creates a single form field
|
|
73
|
+
*/
|
|
74
|
+
private createFormField;
|
|
75
|
+
/**
|
|
76
|
+
* Maps render config field type to form field type with fallback inference
|
|
77
|
+
*/
|
|
78
|
+
private mapFieldType;
|
|
79
|
+
/**
|
|
80
|
+
* Converts field name to human-readable label
|
|
81
|
+
*/
|
|
82
|
+
private humanizeFieldName;
|
|
83
|
+
/**
|
|
84
|
+
* Generates a title for the form
|
|
85
|
+
*/
|
|
86
|
+
private generateFormTitle;
|
|
87
|
+
/**
|
|
88
|
+
* Safely extracts ZodObject from a schema, returns null if not an object schema
|
|
89
|
+
*/
|
|
90
|
+
private extractZodObject;
|
|
91
|
+
/**
|
|
92
|
+
* Extracts field names from Zod schema structure
|
|
93
|
+
*/
|
|
94
|
+
private extractFieldsFromSchema;
|
|
95
|
+
/**
|
|
96
|
+
* Infers field type from Zod schema
|
|
97
|
+
*/
|
|
98
|
+
private inferTypeFromSchema;
|
|
99
|
+
/**
|
|
100
|
+
* Determines if a field is required based on the Zod schema
|
|
101
|
+
*/
|
|
102
|
+
private isFieldRequired;
|
|
103
|
+
/**
|
|
104
|
+
* Generates a description for the form
|
|
105
|
+
*/
|
|
106
|
+
private generateFormDescription;
|
|
107
|
+
/**
|
|
108
|
+
* Generates JSON Schema and uiSchema from a Zod schema for use with @rjsf/core
|
|
109
|
+
* @param zodSchema The Zod schema to convert
|
|
110
|
+
* @param partialInput Existing input data to filter out fields that already have values
|
|
111
|
+
* @param missingFields Set of fields that are missing and should be shown
|
|
112
|
+
* @returns Object containing jsonSchema and uiSchema
|
|
113
|
+
*/
|
|
114
|
+
generateJsonSchemaForm(zodSchema: z.ZodObject<z.ZodRawShape>, partialInput?: Record<string, unknown>, missingFields?: Set<string>): {
|
|
115
|
+
jsonSchema: import('zod-to-json-schema').JsonSchema7Type & {
|
|
116
|
+
$schema?: string | undefined;
|
|
117
|
+
definitions?: {
|
|
118
|
+
[key: string]: import('zod-to-json-schema').JsonSchema7Type;
|
|
119
|
+
} | undefined;
|
|
120
|
+
};
|
|
121
|
+
uiSchema: Record<string, Record<string, unknown>>;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { RenderConfigSchema } from '@hashgraphonline/standards-agent-kit';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* JSON Schema definition for form rendering
|
|
5
|
+
*/
|
|
6
|
+
export type JSONSchemaDefinition = Record<string, unknown>;
|
|
7
|
+
/**
|
|
8
|
+
* UI Schema configuration for form rendering customization
|
|
9
|
+
*/
|
|
10
|
+
export type UISchemaDefinition = Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Represents a form message that can be sent to the chat UI
|
|
13
|
+
*/
|
|
14
|
+
export interface FormMessage {
|
|
15
|
+
type: 'form';
|
|
16
|
+
id: string;
|
|
17
|
+
formConfig: FormConfig;
|
|
18
|
+
originalPrompt: string;
|
|
19
|
+
toolName: string;
|
|
20
|
+
validationErrors?: ValidationError[];
|
|
21
|
+
partialInput?: unknown;
|
|
22
|
+
jsonSchema?: JSONSchemaDefinition;
|
|
23
|
+
uiSchema?: UISchemaDefinition;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for generating a form from Zod schema
|
|
27
|
+
*/
|
|
28
|
+
export interface FormConfig {
|
|
29
|
+
title: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
fields: FormField[];
|
|
32
|
+
submitLabel?: string;
|
|
33
|
+
cancelLabel?: string;
|
|
34
|
+
metadata?: Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Individual form field configuration
|
|
38
|
+
*/
|
|
39
|
+
export interface FormField {
|
|
40
|
+
name: string;
|
|
41
|
+
label: string;
|
|
42
|
+
type: FormFieldType;
|
|
43
|
+
required: boolean;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
helpText?: string;
|
|
46
|
+
defaultValue?: unknown;
|
|
47
|
+
validation?: FieldValidation;
|
|
48
|
+
options?: FieldOption[];
|
|
49
|
+
renderConfig?: RenderConfigSchema;
|
|
50
|
+
priority?: 'essential' | 'common' | 'advanced' | 'expert';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Form field types supported by the UI
|
|
54
|
+
*/
|
|
55
|
+
export type FormFieldType = 'text' | 'number' | 'select' | 'checkbox' | 'textarea' | 'file' | 'array' | 'object' | 'currency' | 'percentage';
|
|
56
|
+
/**
|
|
57
|
+
* Field validation rules
|
|
58
|
+
*/
|
|
59
|
+
export interface FieldValidation {
|
|
60
|
+
min?: number;
|
|
61
|
+
max?: number;
|
|
62
|
+
minLength?: number;
|
|
63
|
+
maxLength?: number;
|
|
64
|
+
pattern?: string;
|
|
65
|
+
custom?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Option for select/radio fields
|
|
69
|
+
*/
|
|
70
|
+
export interface FieldOption {
|
|
71
|
+
value: string;
|
|
72
|
+
label: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Validation error from Zod
|
|
77
|
+
*/
|
|
78
|
+
export interface ValidationError {
|
|
79
|
+
path: string[];
|
|
80
|
+
message: string;
|
|
81
|
+
code: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Form submission data
|
|
85
|
+
*/
|
|
86
|
+
export interface FormSubmission {
|
|
87
|
+
formId: string;
|
|
88
|
+
toolName: string;
|
|
89
|
+
parameters: Record<string, unknown>;
|
|
90
|
+
timestamp: number;
|
|
91
|
+
context?: {
|
|
92
|
+
originalPrompt?: string;
|
|
93
|
+
partialInput?: Record<string, unknown>;
|
|
94
|
+
chatHistory?: Array<{
|
|
95
|
+
type: 'human' | 'ai';
|
|
96
|
+
content: string;
|
|
97
|
+
}>;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Response after form submission
|
|
102
|
+
*/
|
|
103
|
+
export interface FormResponse {
|
|
104
|
+
success: boolean;
|
|
105
|
+
message?: string;
|
|
106
|
+
data?: unknown;
|
|
107
|
+
error?: string;
|
|
108
|
+
}
|