@quilltap/plugin-types 1.8.1 → 1.9.0
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/index.d.mts +52 -52
- package/dist/index.d.ts +52 -52
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -67,6 +67,10 @@ interface ToolExecutionResult {
|
|
|
67
67
|
/**
|
|
68
68
|
* Tool Plugin Interface
|
|
69
69
|
*
|
|
70
|
+
* All tool plugins use the multi-tool pattern, providing an array of tools
|
|
71
|
+
* (even if it's just one tool). This standardized approach makes it easy
|
|
72
|
+
* to extend plugins with additional tools over time.
|
|
73
|
+
*
|
|
70
74
|
* Plugins implementing this interface can be dynamically loaded and used
|
|
71
75
|
* by Quilltap to provide custom tools for LLM interactions.
|
|
72
76
|
*
|
|
@@ -74,22 +78,24 @@ interface ToolExecutionResult {
|
|
|
74
78
|
* ```typescript
|
|
75
79
|
* import type { ToolPlugin, UniversalTool, ToolExecutionContext, ToolExecutionResult } from '@quilltap/plugin-types';
|
|
76
80
|
*
|
|
81
|
+
* const curlToolDefinition: UniversalTool = {
|
|
82
|
+
* type: 'function',
|
|
83
|
+
* function: {
|
|
84
|
+
* name: 'curl',
|
|
85
|
+
* description: 'Make HTTP requests...',
|
|
86
|
+
* parameters: { type: 'object', properties: { url: { type: 'string' } }, required: ['url'] }
|
|
87
|
+
* }
|
|
88
|
+
* };
|
|
89
|
+
*
|
|
77
90
|
* const curlPlugin: ToolPlugin = {
|
|
78
91
|
* metadata: {
|
|
79
92
|
* toolName: 'curl',
|
|
80
93
|
* displayName: 'curl',
|
|
81
94
|
* description: 'Make HTTP requests to fetch web content',
|
|
82
95
|
* },
|
|
83
|
-
*
|
|
84
|
-
* type: 'function',
|
|
85
|
-
* function: {
|
|
86
|
-
* name: 'curl',
|
|
87
|
-
* description: 'Make HTTP requests...',
|
|
88
|
-
* parameters: { ... }
|
|
89
|
-
* }
|
|
90
|
-
* }),
|
|
96
|
+
* getToolDefinitions: async () => [curlToolDefinition],
|
|
91
97
|
* validateInput: (input) => typeof input === 'object' && input !== null && 'url' in input,
|
|
92
|
-
*
|
|
98
|
+
* executeByName: async (toolName, input, context) => {
|
|
93
99
|
* // Implementation
|
|
94
100
|
* return { success: true, result: { ... } };
|
|
95
101
|
* },
|
|
@@ -105,35 +111,40 @@ interface ToolPlugin {
|
|
|
105
111
|
*/
|
|
106
112
|
metadata: ToolMetadata;
|
|
107
113
|
/**
|
|
108
|
-
* Get
|
|
114
|
+
* Get tool definitions in universal (OpenAI) format
|
|
115
|
+
*
|
|
116
|
+
* Returns an array of tool definitions that will be sent to LLMs.
|
|
117
|
+
* Even single-tool plugins return an array (with one element).
|
|
118
|
+
*
|
|
119
|
+
* This method is async to allow plugins to perform initialization
|
|
120
|
+
* or network requests during tool discovery (e.g., MCP servers).
|
|
121
|
+
*
|
|
122
|
+
* @param config User configuration for this plugin
|
|
123
|
+
* @returns Promise resolving to array of tool definitions in universal format
|
|
124
|
+
*/
|
|
125
|
+
getToolDefinitions: (config: Record<string, unknown>) => Promise<UniversalTool[]>;
|
|
126
|
+
/**
|
|
127
|
+
* Execute a tool by name
|
|
109
128
|
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
129
|
+
* The registry routes execution to this method based on the tool name.
|
|
130
|
+
* For single-tool plugins, the toolName will match metadata.toolName.
|
|
112
131
|
*
|
|
113
|
-
* @
|
|
132
|
+
* @param toolName The name of the tool to execute
|
|
133
|
+
* @param input The input arguments from the LLM
|
|
134
|
+
* @param context Execution context with user/chat info and config
|
|
135
|
+
* @returns Promise resolving to the execution result
|
|
114
136
|
*/
|
|
115
|
-
|
|
137
|
+
executeByName: (toolName: string, input: Record<string, unknown>, context: ToolExecutionContext) => Promise<ToolExecutionResult>;
|
|
116
138
|
/**
|
|
117
139
|
* Validate input arguments before execution
|
|
118
140
|
*
|
|
119
141
|
* Checks whether the provided input matches the expected schema.
|
|
120
|
-
* Called before
|
|
142
|
+
* Called before executeByName() to ensure valid inputs.
|
|
121
143
|
*
|
|
122
144
|
* @param input The input arguments to validate
|
|
123
145
|
* @returns true if valid, false otherwise
|
|
124
146
|
*/
|
|
125
147
|
validateInput: (input: unknown) => boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Execute the tool with the given input and context
|
|
128
|
-
*
|
|
129
|
-
* This is the main tool execution logic. It receives the parsed
|
|
130
|
-
* arguments from the LLM and returns the result.
|
|
131
|
-
*
|
|
132
|
-
* @param input The input arguments from the LLM
|
|
133
|
-
* @param context Execution context with user/chat info and config
|
|
134
|
-
* @returns Promise resolving to the execution result
|
|
135
|
-
*/
|
|
136
|
-
execute: (input: Record<string, unknown>, context: ToolExecutionContext) => Promise<ToolExecutionResult>;
|
|
137
148
|
/**
|
|
138
149
|
* Format results for LLM consumption
|
|
139
150
|
*
|
|
@@ -175,32 +186,6 @@ interface ToolPlugin {
|
|
|
175
186
|
renderIcon?: (props: {
|
|
176
187
|
className?: string;
|
|
177
188
|
}) => React.ReactNode;
|
|
178
|
-
/**
|
|
179
|
-
* Get multiple tool definitions (optional)
|
|
180
|
-
*
|
|
181
|
-
* For plugins that provide multiple tools dynamically (e.g., MCP connector).
|
|
182
|
-
* When implemented, the registry will call this at request time (not startup)
|
|
183
|
-
* to get the current list of tools based on configuration.
|
|
184
|
-
*
|
|
185
|
-
* This allows plugins to discover tools dynamically based on user config
|
|
186
|
-
* (e.g., MCP servers to connect to).
|
|
187
|
-
*
|
|
188
|
-
* @param config User configuration for this plugin
|
|
189
|
-
* @returns Array of tool definitions in universal format
|
|
190
|
-
*/
|
|
191
|
-
getMultipleToolDefinitions?: (config: Record<string, unknown>) => UniversalTool[];
|
|
192
|
-
/**
|
|
193
|
-
* Execute a specific tool by name (optional)
|
|
194
|
-
*
|
|
195
|
-
* Required when getMultipleToolDefinitions is implemented.
|
|
196
|
-
* The registry routes execution to this method based on the tool name.
|
|
197
|
-
*
|
|
198
|
-
* @param toolName The name of the tool to execute (as returned by getMultipleToolDefinitions)
|
|
199
|
-
* @param input The input arguments from the LLM
|
|
200
|
-
* @param context Execution context with user/chat info and config
|
|
201
|
-
* @returns Promise resolving to the execution result
|
|
202
|
-
*/
|
|
203
|
-
executeByName?: (toolName: string, input: Record<string, unknown>, context: ToolExecutionContext) => Promise<ToolExecutionResult>;
|
|
204
189
|
/**
|
|
205
190
|
* Called when configuration changes (optional)
|
|
206
191
|
*
|
|
@@ -210,6 +195,21 @@ interface ToolPlugin {
|
|
|
210
195
|
* @param config The updated user configuration
|
|
211
196
|
*/
|
|
212
197
|
onConfigurationChange?: (config: Record<string, unknown>) => Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* @deprecated Use getToolDefinitions instead. This method is for backwards
|
|
200
|
+
* compatibility only and will be removed in a future version.
|
|
201
|
+
*/
|
|
202
|
+
getToolDefinition?: () => UniversalTool;
|
|
203
|
+
/**
|
|
204
|
+
* @deprecated Use executeByName instead. This method is for backwards
|
|
205
|
+
* compatibility only and will be removed in a future version.
|
|
206
|
+
*/
|
|
207
|
+
execute?: (input: Record<string, unknown>, context: ToolExecutionContext) => Promise<ToolExecutionResult>;
|
|
208
|
+
/**
|
|
209
|
+
* @deprecated Use getToolDefinitions instead. This method is for backwards
|
|
210
|
+
* compatibility only and will be removed in a future version.
|
|
211
|
+
*/
|
|
212
|
+
getMultipleToolDefinitions?: (config: Record<string, unknown>) => Promise<UniversalTool[]>;
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
215
|
* Standard export type for tool plugins
|
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,10 @@ interface ToolExecutionResult {
|
|
|
67
67
|
/**
|
|
68
68
|
* Tool Plugin Interface
|
|
69
69
|
*
|
|
70
|
+
* All tool plugins use the multi-tool pattern, providing an array of tools
|
|
71
|
+
* (even if it's just one tool). This standardized approach makes it easy
|
|
72
|
+
* to extend plugins with additional tools over time.
|
|
73
|
+
*
|
|
70
74
|
* Plugins implementing this interface can be dynamically loaded and used
|
|
71
75
|
* by Quilltap to provide custom tools for LLM interactions.
|
|
72
76
|
*
|
|
@@ -74,22 +78,24 @@ interface ToolExecutionResult {
|
|
|
74
78
|
* ```typescript
|
|
75
79
|
* import type { ToolPlugin, UniversalTool, ToolExecutionContext, ToolExecutionResult } from '@quilltap/plugin-types';
|
|
76
80
|
*
|
|
81
|
+
* const curlToolDefinition: UniversalTool = {
|
|
82
|
+
* type: 'function',
|
|
83
|
+
* function: {
|
|
84
|
+
* name: 'curl',
|
|
85
|
+
* description: 'Make HTTP requests...',
|
|
86
|
+
* parameters: { type: 'object', properties: { url: { type: 'string' } }, required: ['url'] }
|
|
87
|
+
* }
|
|
88
|
+
* };
|
|
89
|
+
*
|
|
77
90
|
* const curlPlugin: ToolPlugin = {
|
|
78
91
|
* metadata: {
|
|
79
92
|
* toolName: 'curl',
|
|
80
93
|
* displayName: 'curl',
|
|
81
94
|
* description: 'Make HTTP requests to fetch web content',
|
|
82
95
|
* },
|
|
83
|
-
*
|
|
84
|
-
* type: 'function',
|
|
85
|
-
* function: {
|
|
86
|
-
* name: 'curl',
|
|
87
|
-
* description: 'Make HTTP requests...',
|
|
88
|
-
* parameters: { ... }
|
|
89
|
-
* }
|
|
90
|
-
* }),
|
|
96
|
+
* getToolDefinitions: async () => [curlToolDefinition],
|
|
91
97
|
* validateInput: (input) => typeof input === 'object' && input !== null && 'url' in input,
|
|
92
|
-
*
|
|
98
|
+
* executeByName: async (toolName, input, context) => {
|
|
93
99
|
* // Implementation
|
|
94
100
|
* return { success: true, result: { ... } };
|
|
95
101
|
* },
|
|
@@ -105,35 +111,40 @@ interface ToolPlugin {
|
|
|
105
111
|
*/
|
|
106
112
|
metadata: ToolMetadata;
|
|
107
113
|
/**
|
|
108
|
-
* Get
|
|
114
|
+
* Get tool definitions in universal (OpenAI) format
|
|
115
|
+
*
|
|
116
|
+
* Returns an array of tool definitions that will be sent to LLMs.
|
|
117
|
+
* Even single-tool plugins return an array (with one element).
|
|
118
|
+
*
|
|
119
|
+
* This method is async to allow plugins to perform initialization
|
|
120
|
+
* or network requests during tool discovery (e.g., MCP servers).
|
|
121
|
+
*
|
|
122
|
+
* @param config User configuration for this plugin
|
|
123
|
+
* @returns Promise resolving to array of tool definitions in universal format
|
|
124
|
+
*/
|
|
125
|
+
getToolDefinitions: (config: Record<string, unknown>) => Promise<UniversalTool[]>;
|
|
126
|
+
/**
|
|
127
|
+
* Execute a tool by name
|
|
109
128
|
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
129
|
+
* The registry routes execution to this method based on the tool name.
|
|
130
|
+
* For single-tool plugins, the toolName will match metadata.toolName.
|
|
112
131
|
*
|
|
113
|
-
* @
|
|
132
|
+
* @param toolName The name of the tool to execute
|
|
133
|
+
* @param input The input arguments from the LLM
|
|
134
|
+
* @param context Execution context with user/chat info and config
|
|
135
|
+
* @returns Promise resolving to the execution result
|
|
114
136
|
*/
|
|
115
|
-
|
|
137
|
+
executeByName: (toolName: string, input: Record<string, unknown>, context: ToolExecutionContext) => Promise<ToolExecutionResult>;
|
|
116
138
|
/**
|
|
117
139
|
* Validate input arguments before execution
|
|
118
140
|
*
|
|
119
141
|
* Checks whether the provided input matches the expected schema.
|
|
120
|
-
* Called before
|
|
142
|
+
* Called before executeByName() to ensure valid inputs.
|
|
121
143
|
*
|
|
122
144
|
* @param input The input arguments to validate
|
|
123
145
|
* @returns true if valid, false otherwise
|
|
124
146
|
*/
|
|
125
147
|
validateInput: (input: unknown) => boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Execute the tool with the given input and context
|
|
128
|
-
*
|
|
129
|
-
* This is the main tool execution logic. It receives the parsed
|
|
130
|
-
* arguments from the LLM and returns the result.
|
|
131
|
-
*
|
|
132
|
-
* @param input The input arguments from the LLM
|
|
133
|
-
* @param context Execution context with user/chat info and config
|
|
134
|
-
* @returns Promise resolving to the execution result
|
|
135
|
-
*/
|
|
136
|
-
execute: (input: Record<string, unknown>, context: ToolExecutionContext) => Promise<ToolExecutionResult>;
|
|
137
148
|
/**
|
|
138
149
|
* Format results for LLM consumption
|
|
139
150
|
*
|
|
@@ -175,32 +186,6 @@ interface ToolPlugin {
|
|
|
175
186
|
renderIcon?: (props: {
|
|
176
187
|
className?: string;
|
|
177
188
|
}) => React.ReactNode;
|
|
178
|
-
/**
|
|
179
|
-
* Get multiple tool definitions (optional)
|
|
180
|
-
*
|
|
181
|
-
* For plugins that provide multiple tools dynamically (e.g., MCP connector).
|
|
182
|
-
* When implemented, the registry will call this at request time (not startup)
|
|
183
|
-
* to get the current list of tools based on configuration.
|
|
184
|
-
*
|
|
185
|
-
* This allows plugins to discover tools dynamically based on user config
|
|
186
|
-
* (e.g., MCP servers to connect to).
|
|
187
|
-
*
|
|
188
|
-
* @param config User configuration for this plugin
|
|
189
|
-
* @returns Array of tool definitions in universal format
|
|
190
|
-
*/
|
|
191
|
-
getMultipleToolDefinitions?: (config: Record<string, unknown>) => UniversalTool[];
|
|
192
|
-
/**
|
|
193
|
-
* Execute a specific tool by name (optional)
|
|
194
|
-
*
|
|
195
|
-
* Required when getMultipleToolDefinitions is implemented.
|
|
196
|
-
* The registry routes execution to this method based on the tool name.
|
|
197
|
-
*
|
|
198
|
-
* @param toolName The name of the tool to execute (as returned by getMultipleToolDefinitions)
|
|
199
|
-
* @param input The input arguments from the LLM
|
|
200
|
-
* @param context Execution context with user/chat info and config
|
|
201
|
-
* @returns Promise resolving to the execution result
|
|
202
|
-
*/
|
|
203
|
-
executeByName?: (toolName: string, input: Record<string, unknown>, context: ToolExecutionContext) => Promise<ToolExecutionResult>;
|
|
204
189
|
/**
|
|
205
190
|
* Called when configuration changes (optional)
|
|
206
191
|
*
|
|
@@ -210,6 +195,21 @@ interface ToolPlugin {
|
|
|
210
195
|
* @param config The updated user configuration
|
|
211
196
|
*/
|
|
212
197
|
onConfigurationChange?: (config: Record<string, unknown>) => Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* @deprecated Use getToolDefinitions instead. This method is for backwards
|
|
200
|
+
* compatibility only and will be removed in a future version.
|
|
201
|
+
*/
|
|
202
|
+
getToolDefinition?: () => UniversalTool;
|
|
203
|
+
/**
|
|
204
|
+
* @deprecated Use executeByName instead. This method is for backwards
|
|
205
|
+
* compatibility only and will be removed in a future version.
|
|
206
|
+
*/
|
|
207
|
+
execute?: (input: Record<string, unknown>, context: ToolExecutionContext) => Promise<ToolExecutionResult>;
|
|
208
|
+
/**
|
|
209
|
+
* @deprecated Use getToolDefinitions instead. This method is for backwards
|
|
210
|
+
* compatibility only and will be removed in a future version.
|
|
211
|
+
*/
|
|
212
|
+
getMultipleToolDefinitions?: (config: Record<string, unknown>) => Promise<UniversalTool[]>;
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
215
|
* Standard export type for tool plugins
|