@hashgraphonline/conversational-agent 0.1.215 → 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/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/form-generator.d.ts +39 -2
- package/dist/cjs/forms/types.d.ts +21 -2
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +3 -4
- package/dist/cjs/langchain/FormAwareAgentExecutor.d.ts +53 -4
- package/dist/cjs/langchain/FormValidatingToolWrapper.d.ts +43 -6
- package/dist/cjs/langchain-agent.d.ts +49 -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 +2 -6
- 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 +292 -150
- package/dist/esm/index18.js.map +1 -1
- package/dist/esm/index19.js +158 -65
- package/dist/esm/index19.js.map +1 -1
- package/dist/esm/index20.js +94 -270
- package/dist/esm/index20.js.map +1 -1
- package/dist/esm/index21.js +1 -1
- package/dist/esm/index23.js +14 -0
- package/dist/esm/index23.js.map +1 -1
- package/dist/esm/index24.js +508 -12
- package/dist/esm/index24.js.map +1 -1
- package/dist/esm/index25.js +1 -1
- package/dist/esm/index25.js.map +1 -1
- package/dist/esm/index26.js +1 -1
- package/dist/esm/index26.js.map +1 -1
- package/dist/esm/index27.js +189 -128
- package/dist/esm/index27.js.map +1 -1
- package/dist/esm/index28.js +164 -45
- package/dist/esm/index28.js.map +1 -1
- package/dist/esm/index29.js +302 -24
- package/dist/esm/index29.js.map +1 -1
- package/dist/esm/index30.js +144 -80
- package/dist/esm/index30.js.map +1 -1
- package/dist/esm/index31.js +63 -7
- package/dist/esm/index31.js.map +1 -1
- package/dist/esm/index32.js +24 -236
- package/dist/esm/index32.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/index6.js +61 -22
- package/dist/esm/index6.js.map +1 -1
- package/dist/esm/index8.js +653 -131
- package/dist/esm/index8.js.map +1 -1
- 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/form-generator.d.ts +39 -2
- package/dist/types/forms/types.d.ts +21 -2
- package/dist/types/index.d.ts +3 -4
- package/dist/types/langchain/FormAwareAgentExecutor.d.ts +53 -4
- package/dist/types/langchain/FormValidatingToolWrapper.d.ts +43 -6
- package/dist/types/langchain-agent.d.ts +49 -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 +13 -10
- package/src/config/system-message.ts +14 -0
- package/src/context/ReferenceContextManager.ts +1 -1
- package/src/conversational-agent.ts +91 -36
- 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 +1 -13
- package/src/forms/form-generator.ts +394 -237
- package/src/forms/types.ts +20 -3
- package/src/index.ts +6 -10
- package/src/langchain/FormAwareAgentExecutor.ts +653 -22
- package/src/langchain/FormValidatingToolWrapper.ts +216 -93
- package/src/langchain-agent.ts +924 -185
- 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 +3 -12
- package/src/scripts/test-hedera-kit-wrapper.ts +6 -22
- package/src/scripts/test-inscribe-form-generation.ts +24 -42
- package/src/scripts/test-inscribe-wrapper-verification.ts +1 -7
- 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/dist/cjs/examples/external-tool-wrapper-example.d.ts +0 -131
- package/dist/cjs/langchain/ContentAwareAgentExecutor.d.ts +0 -14
- package/dist/cjs/langchain/external-tool-wrapper.d.ts +0 -179
- package/dist/cjs/scripts/test-external-tool-wrapper.d.ts +0 -5
- package/dist/cjs/scripts/test-hedera-kit-wrapper.d.ts +0 -36
- package/dist/cjs/scripts/test-inscribe-form-generation.d.ts +0 -15
- package/dist/cjs/scripts/test-inscribe-wrapper-verification.d.ts +0 -13
- package/dist/types/examples/external-tool-wrapper-example.d.ts +0 -131
- package/dist/types/langchain/ContentAwareAgentExecutor.d.ts +0 -14
- package/dist/types/langchain/external-tool-wrapper.d.ts +0 -179
- package/dist/types/scripts/test-external-tool-wrapper.d.ts +0 -5
- package/dist/types/scripts/test-hedera-kit-wrapper.d.ts +0 -36
- package/dist/types/scripts/test-inscribe-form-generation.d.ts +0 -15
- package/dist/types/scripts/test-inscribe-wrapper-verification.d.ts +0 -13
- package/src/examples/external-tool-wrapper-example.ts +0 -227
- package/src/langchain/ContentAwareAgentExecutor.ts +0 -19
- package/src/langchain/external-tool-wrapper.ts +0 -486
|
@@ -10,6 +10,7 @@ import { IStateManager } from '@hashgraphonline/standards-agent-kit';
|
|
|
10
10
|
import { MCPServerConfig, MCPConnectionStatus } from './mcp/types';
|
|
11
11
|
import { ContentStoreManager } from './services/ContentStoreManager';
|
|
12
12
|
import { SmartMemoryManager, SmartMemoryConfig } from './memory';
|
|
13
|
+
import { FormSubmission } from './forms/types';
|
|
13
14
|
|
|
14
15
|
export type ToolDescriptor = {
|
|
15
16
|
name: string;
|
|
@@ -107,6 +108,13 @@ export declare class ConversationalAgent {
|
|
|
107
108
|
* @throws {Error} If agent is not initialized
|
|
108
109
|
*/
|
|
109
110
|
processMessage(message: string, chatHistory?: ChatHistoryItem[]): Promise<ChatResponse>;
|
|
111
|
+
/**
|
|
112
|
+
* Process form submission through the conversational agent
|
|
113
|
+
* @param {FormSubmission} submission - The form submission data
|
|
114
|
+
* @returns {Promise<ChatResponse>} The agent's response after processing the form
|
|
115
|
+
* @throws {Error} If agent is not initialized or doesn't support form processing
|
|
116
|
+
*/
|
|
117
|
+
processFormSubmission(submission: FormSubmission): Promise<ChatResponse>;
|
|
110
118
|
/**
|
|
111
119
|
* Validates initialization options and throws if required fields are missing.
|
|
112
120
|
*
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { StructuredTool } from '@langchain/core/tools';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Logger } from '@hashgraphonline/standards-sdk';
|
|
4
|
+
import { FormValidatingToolWrapper } from '../langchain/FormValidatingToolWrapper';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Tool capabilities configuration for registry entries
|
|
8
|
+
*/
|
|
9
|
+
export interface ToolCapabilities {
|
|
10
|
+
supportsFormValidation: boolean;
|
|
11
|
+
requiresWrapper: boolean;
|
|
12
|
+
priority: 'low' | 'medium' | 'high' | 'critical';
|
|
13
|
+
category: 'core' | 'extension' | 'mcp';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Tool metadata for comprehensive tool information
|
|
17
|
+
*/
|
|
18
|
+
export interface ToolMetadata {
|
|
19
|
+
name: string;
|
|
20
|
+
version: string;
|
|
21
|
+
category: ToolCapabilities['category'];
|
|
22
|
+
description: string;
|
|
23
|
+
capabilities: ToolCapabilities;
|
|
24
|
+
dependencies: string[];
|
|
25
|
+
schema: unknown;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Registry entry containing tool instance and metadata
|
|
29
|
+
*/
|
|
30
|
+
export interface ToolRegistryEntry {
|
|
31
|
+
tool: StructuredTool;
|
|
32
|
+
metadata: ToolMetadata;
|
|
33
|
+
wrapper?: FormValidatingToolWrapper<z.ZodObject<z.ZodRawShape>> | undefined;
|
|
34
|
+
originalTool: StructuredTool;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Options for tool registration
|
|
38
|
+
*/
|
|
39
|
+
export interface ToolRegistrationOptions {
|
|
40
|
+
forceWrapper?: boolean;
|
|
41
|
+
skipWrapper?: boolean;
|
|
42
|
+
wrapperConfig?: {
|
|
43
|
+
requireAllFields?: boolean;
|
|
44
|
+
skipFields?: string[];
|
|
45
|
+
};
|
|
46
|
+
metadata?: Partial<ToolMetadata>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Query interface for finding tools
|
|
50
|
+
*/
|
|
51
|
+
export interface ToolQuery {
|
|
52
|
+
name?: string;
|
|
53
|
+
category?: ToolMetadata['category'];
|
|
54
|
+
capabilities?: Partial<ToolCapabilities>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Centralized tool registry for managing tool lifecycle
|
|
58
|
+
*/
|
|
59
|
+
export declare class ToolRegistry {
|
|
60
|
+
private tools;
|
|
61
|
+
private formGenerator;
|
|
62
|
+
private logger;
|
|
63
|
+
constructor(logger?: Logger);
|
|
64
|
+
/**
|
|
65
|
+
* Register a tool with the registry
|
|
66
|
+
*/
|
|
67
|
+
registerTool(tool: StructuredTool, options?: ToolRegistrationOptions): void;
|
|
68
|
+
/**
|
|
69
|
+
* Get a tool by name
|
|
70
|
+
*/
|
|
71
|
+
getTool(name: string): ToolRegistryEntry | null;
|
|
72
|
+
/**
|
|
73
|
+
* Get tools by capability
|
|
74
|
+
*/
|
|
75
|
+
getToolsByCapability(capability: keyof ToolCapabilities, value?: unknown): ToolRegistryEntry[];
|
|
76
|
+
/**
|
|
77
|
+
* Get tools by query
|
|
78
|
+
*/
|
|
79
|
+
getToolsByQuery(query: ToolQuery): ToolRegistryEntry[];
|
|
80
|
+
/**
|
|
81
|
+
* Get all registered tools
|
|
82
|
+
*/
|
|
83
|
+
getAllTools(): StructuredTool[];
|
|
84
|
+
/**
|
|
85
|
+
* Get all registry entries
|
|
86
|
+
*/
|
|
87
|
+
getAllRegistryEntries(): ToolRegistryEntry[];
|
|
88
|
+
/**
|
|
89
|
+
* Get all tool names
|
|
90
|
+
*/
|
|
91
|
+
getToolNames(): string[];
|
|
92
|
+
/**
|
|
93
|
+
* Check if a tool is registered
|
|
94
|
+
*/
|
|
95
|
+
hasTool(name: string): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Unregister a tool
|
|
98
|
+
*/
|
|
99
|
+
unregisterTool(name: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Clear all tools
|
|
102
|
+
*/
|
|
103
|
+
clear(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Analyze tool capabilities
|
|
106
|
+
*/
|
|
107
|
+
private analyzeToolCapabilities;
|
|
108
|
+
/**
|
|
109
|
+
* Check if tool has render configuration
|
|
110
|
+
*/
|
|
111
|
+
private hasRenderConfig;
|
|
112
|
+
/**
|
|
113
|
+
* Determine if tool should be wrapped
|
|
114
|
+
*/
|
|
115
|
+
private shouldWrapTool;
|
|
116
|
+
/**
|
|
117
|
+
* Check if schema is ZodObject-like
|
|
118
|
+
*/
|
|
119
|
+
private isZodObjectLike;
|
|
120
|
+
/**
|
|
121
|
+
* Get statistics about the registry
|
|
122
|
+
*/
|
|
123
|
+
getStatistics(): {
|
|
124
|
+
totalTools: number;
|
|
125
|
+
wrappedTools: number;
|
|
126
|
+
unwrappedTools: number;
|
|
127
|
+
categoryCounts: Record<ToolCapabilities['category'], number>;
|
|
128
|
+
priorityCounts: Record<ToolCapabilities['priority'], number>;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Logger } from '@hashgraphonline/standards-sdk';
|
|
2
|
+
import { SmartMemoryManager } from '../memory/SmartMemoryManager';
|
|
3
|
+
import { FormEngine, ToolExecutionResult } from '../forms/FormEngine';
|
|
4
|
+
import { ToolRegistry, ToolRegistryEntry } from '../core/ToolRegistry';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Session context for tool execution
|
|
8
|
+
*/
|
|
9
|
+
export interface SessionContext {
|
|
10
|
+
sessionId: string;
|
|
11
|
+
userId?: string;
|
|
12
|
+
timestamp: number;
|
|
13
|
+
conversationId?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Context passed through execution pipeline
|
|
17
|
+
*/
|
|
18
|
+
export interface ExecutionContext {
|
|
19
|
+
toolName: string;
|
|
20
|
+
input: unknown;
|
|
21
|
+
session: SessionContext;
|
|
22
|
+
memory: SmartMemoryManager;
|
|
23
|
+
traceId: string;
|
|
24
|
+
toolEntry: ToolRegistryEntry;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result of tool execution with metadata
|
|
28
|
+
*/
|
|
29
|
+
export interface ExecutionResult extends ToolExecutionResult {
|
|
30
|
+
traceId: string;
|
|
31
|
+
executionTime: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* ExecutionPipeline handles tool execution coordination
|
|
35
|
+
*/
|
|
36
|
+
export declare class ExecutionPipeline {
|
|
37
|
+
private logger;
|
|
38
|
+
private toolRegistry;
|
|
39
|
+
private formEngine;
|
|
40
|
+
private memory;
|
|
41
|
+
constructor(toolRegistry: ToolRegistry, formEngine: FormEngine, memory: SmartMemoryManager, logger?: Logger);
|
|
42
|
+
/**
|
|
43
|
+
* Execute a tool through the pipeline
|
|
44
|
+
*/
|
|
45
|
+
execute(toolName: string, input: unknown, sessionContext?: SessionContext): Promise<ExecutionResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Execute tool with validation
|
|
48
|
+
*/
|
|
49
|
+
executeWithValidation(toolName: string, input: unknown, sessionContext?: SessionContext): Promise<ExecutionResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Process form submission
|
|
52
|
+
*/
|
|
53
|
+
processFormSubmission(toolName: string, formId: string, parameters: Record<string, unknown>, sessionContext?: SessionContext): Promise<ExecutionResult>;
|
|
54
|
+
/**
|
|
55
|
+
* Check if form generation is required
|
|
56
|
+
*/
|
|
57
|
+
private checkFormGeneration;
|
|
58
|
+
/**
|
|
59
|
+
* Execute tool directly
|
|
60
|
+
*/
|
|
61
|
+
private executeToolDirect;
|
|
62
|
+
/**
|
|
63
|
+
* Execute wrapped tool
|
|
64
|
+
*/
|
|
65
|
+
private executeWrappedTool;
|
|
66
|
+
/**
|
|
67
|
+
* Handle execution error
|
|
68
|
+
*/
|
|
69
|
+
private handleExecutionError;
|
|
70
|
+
/**
|
|
71
|
+
* Build default session context
|
|
72
|
+
*/
|
|
73
|
+
private buildDefaultSession;
|
|
74
|
+
/**
|
|
75
|
+
* Get statistics about the pipeline
|
|
76
|
+
*/
|
|
77
|
+
getStatistics(): {
|
|
78
|
+
totalMiddleware: number;
|
|
79
|
+
registeredMiddleware: string[];
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -21,12 +21,13 @@ export declare class FormGenerator {
|
|
|
21
21
|
* @param schema The Zod schema to generate a form from
|
|
22
22
|
* @param partialInput Any partial input already provided
|
|
23
23
|
* @param context Additional context about the tool
|
|
24
|
+
* @param preCalculatedMissingFields Optional pre-calculated missing fields set. If undefined, includes all fields from schema.
|
|
24
25
|
* @returns FormMessage to send to the chat UI
|
|
25
26
|
*/
|
|
26
|
-
generateFormFromSchema(schema: z.ZodSchema, partialInput:
|
|
27
|
+
generateFormFromSchema(schema: z.ZodSchema, partialInput: unknown, context: {
|
|
27
28
|
toolName: string;
|
|
28
29
|
toolDescription?: string;
|
|
29
|
-
}): Promise<FormMessage>;
|
|
30
|
+
}, preCalculatedMissingFields?: Set<string>): Promise<FormMessage>;
|
|
30
31
|
/**
|
|
31
32
|
* Extracts validation errors from ZodError
|
|
32
33
|
*/
|
|
@@ -47,6 +48,22 @@ export declare class FormGenerator {
|
|
|
47
48
|
* Safely generates field ordering from schema
|
|
48
49
|
*/
|
|
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;
|
|
50
67
|
/**
|
|
51
68
|
* Generates form fields from schema and validation errors
|
|
52
69
|
*/
|
|
@@ -67,6 +84,10 @@ export declare class FormGenerator {
|
|
|
67
84
|
* Generates a title for the form
|
|
68
85
|
*/
|
|
69
86
|
private generateFormTitle;
|
|
87
|
+
/**
|
|
88
|
+
* Safely extracts ZodObject from a schema, returns null if not an object schema
|
|
89
|
+
*/
|
|
90
|
+
private extractZodObject;
|
|
70
91
|
/**
|
|
71
92
|
* Extracts field names from Zod schema structure
|
|
72
93
|
*/
|
|
@@ -83,4 +104,20 @@ export declare class FormGenerator {
|
|
|
83
104
|
* Generates a description for the form
|
|
84
105
|
*/
|
|
85
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
|
+
};
|
|
86
123
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { RenderConfigSchema } from '@hashgraphonline/standards-agent-kit';
|
|
2
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>;
|
|
3
11
|
/**
|
|
4
12
|
* Represents a form message that can be sent to the chat UI
|
|
5
13
|
*/
|
|
@@ -10,7 +18,9 @@ export interface FormMessage {
|
|
|
10
18
|
originalPrompt: string;
|
|
11
19
|
toolName: string;
|
|
12
20
|
validationErrors?: ValidationError[];
|
|
13
|
-
partialInput?:
|
|
21
|
+
partialInput?: unknown;
|
|
22
|
+
jsonSchema?: JSONSchemaDefinition;
|
|
23
|
+
uiSchema?: UISchemaDefinition;
|
|
14
24
|
}
|
|
15
25
|
/**
|
|
16
26
|
* Configuration for generating a form from Zod schema
|
|
@@ -75,8 +85,17 @@ export interface ValidationError {
|
|
|
75
85
|
*/
|
|
76
86
|
export interface FormSubmission {
|
|
77
87
|
formId: string;
|
|
78
|
-
|
|
88
|
+
toolName: string;
|
|
89
|
+
parameters: Record<string, unknown>;
|
|
79
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
|
+
};
|
|
80
99
|
}
|
|
81
100
|
/**
|
|
82
101
|
* Response after form submission
|