@quilltap/plugin-types 1.5.1 → 1.7.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/CHANGELOG.md +14 -0
- package/dist/{index-fPQMtntn.d.ts → index-9cCc5tg5.d.ts} +2 -2
- package/dist/{index-esRx5dOb.d.mts → index-BefqyBNF.d.mts} +2 -2
- package/dist/index.d.mts +508 -4
- package/dist/index.d.ts +508 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/index.d.mts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.7.0] - 2026-01-09
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Added file storage plugin types for building custom storage backend plugins:
|
|
13
|
+
- `FileBackendCapabilities` - Interface describing storage backend features
|
|
14
|
+
- `FileBackendMetadata` - Backend registration metadata
|
|
15
|
+
- `FileMetadata` - Stored file metadata (size, contentType, lastModified)
|
|
16
|
+
- `FileStorageBackend` - Core interface with upload, download, delete, exists, and optional operations
|
|
17
|
+
- `FileStorageConfigField` - Configuration field definitions for plugin setup UI
|
|
18
|
+
- `FileStorageProviderPlugin` - Main plugin interface for storage providers
|
|
19
|
+
- `FileStoragePluginExport` - Standard export type for file storage plugins
|
|
20
|
+
- Added `@types/node` to devDependencies for Node.js type support (Buffer, Readable)
|
|
21
|
+
|
|
8
22
|
## [1.5.1] - 2026-01-05
|
|
9
23
|
|
|
10
24
|
### Added
|
|
@@ -339,11 +339,11 @@ interface ProviderPluginExport {
|
|
|
339
339
|
/**
|
|
340
340
|
* Plugin capability types
|
|
341
341
|
*/
|
|
342
|
-
type PluginCapability = 'LLM_PROVIDER' | 'AUTH_PROVIDER' | 'STORAGE_BACKEND' | 'THEME' | 'ROLEPLAY_TEMPLATE' | 'UTILITY';
|
|
342
|
+
type PluginCapability = 'LLM_PROVIDER' | 'AUTH_PROVIDER' | 'STORAGE_BACKEND' | 'THEME' | 'ROLEPLAY_TEMPLATE' | 'TOOL_PROVIDER' | 'UTILITY';
|
|
343
343
|
/**
|
|
344
344
|
* Plugin category
|
|
345
345
|
*/
|
|
346
|
-
type PluginCategory = 'PROVIDER' | 'AUTH' | 'STORAGE' | 'UI' | 'TEMPLATE' | 'UTILITY';
|
|
346
|
+
type PluginCategory = 'PROVIDER' | 'AUTH' | 'STORAGE' | 'UI' | 'TEMPLATE' | 'TOOLS' | 'UTILITY';
|
|
347
347
|
/**
|
|
348
348
|
* Plugin status
|
|
349
349
|
*/
|
|
@@ -339,11 +339,11 @@ interface ProviderPluginExport {
|
|
|
339
339
|
/**
|
|
340
340
|
* Plugin capability types
|
|
341
341
|
*/
|
|
342
|
-
type PluginCapability = 'LLM_PROVIDER' | 'AUTH_PROVIDER' | 'STORAGE_BACKEND' | 'THEME' | 'ROLEPLAY_TEMPLATE' | 'UTILITY';
|
|
342
|
+
type PluginCapability = 'LLM_PROVIDER' | 'AUTH_PROVIDER' | 'STORAGE_BACKEND' | 'THEME' | 'ROLEPLAY_TEMPLATE' | 'TOOL_PROVIDER' | 'UTILITY';
|
|
343
343
|
/**
|
|
344
344
|
* Plugin category
|
|
345
345
|
*/
|
|
346
|
-
type PluginCategory = 'PROVIDER' | 'AUTH' | 'STORAGE' | 'UI' | 'TEMPLATE' | 'UTILITY';
|
|
346
|
+
type PluginCategory = 'PROVIDER' | 'AUTH' | 'STORAGE' | 'UI' | 'TEMPLATE' | 'TOOLS' | 'UTILITY';
|
|
347
347
|
/**
|
|
348
348
|
* Plugin status
|
|
349
349
|
*/
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,512 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
import { UniversalTool } from './llm/index.mjs';
|
|
2
|
+
export { AnthropicToolDefinition, AttachmentResults, CacheUsage, FileAttachment, GeneratedImage, GoogleToolDefinition, ImageGenParams, ImageGenProvider, ImageGenResponse, JSONSchemaDefinition, LLMMessage, LLMParams, LLMProvider, LLMResponse, ModelMetadata, ModelWarning, ModelWarningLevel, OpenAIToolDefinition, ResponseFormat, StreamChunk, TokenUsage, ToolCall, ToolCallRequest, ToolFormatOptions, ToolResult } from './llm/index.mjs';
|
|
3
|
+
export { A as AttachmentSupport, C as CheapModelConfig, p as ColorPalette, r as Effects, t as EmbeddedFont, E as EmbeddingModelInfo, F as FontDefinition, d as IconProps, I as ImageGenerationModelInfo, c as ImageProviderConstraints, o as InstalledPluginInfo, L as LLMProviderPlugin, f as MessageFormatSupport, M as ModelInfo, j as PluginAuthor, g as PluginCapability, h as PluginCategory, k as PluginCompatibility, n as PluginManifest, m as PluginPermissions, i as PluginStatus, b as ProviderCapabilities, l as ProviderConfig, a as ProviderConfigRequirements, P as ProviderMetadata, e as ProviderPluginExport, R as RoleplayTemplateConfig, x as RoleplayTemplateMetadata, y as RoleplayTemplatePlugin, z as RoleplayTemplatePluginExport, S as Spacing, u as ThemeMetadata, v as ThemePlugin, w as ThemePluginExport, s as ThemeTokens, T as ToolFormatType, q as Typography } from './index-BefqyBNF.mjs';
|
|
4
|
+
import { Readable } from 'stream';
|
|
3
5
|
export { ApiKeyError, AttachmentError, ConfigurationError, LogContext, LogLevel, ModelNotFoundError, PluginError, PluginLogger, ProviderApiError, RateLimitError, ToolExecutionError, createConsoleLogger, createNoopLogger } from './common/index.mjs';
|
|
4
6
|
import 'react';
|
|
5
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Tool Plugin types for Quilltap plugin development
|
|
10
|
+
*
|
|
11
|
+
* Defines the interfaces and types needed to create custom LLM tools
|
|
12
|
+
* as Quilltap plugins.
|
|
13
|
+
*
|
|
14
|
+
* @module @quilltap/plugin-types/plugins/tool
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Tool metadata for UI display and identification
|
|
19
|
+
*/
|
|
20
|
+
interface ToolMetadata {
|
|
21
|
+
/** Internal tool name used in LLM function calls (lowercase with underscores) */
|
|
22
|
+
toolName: string;
|
|
23
|
+
/** Human-readable display name for UI */
|
|
24
|
+
displayName: string;
|
|
25
|
+
/** Description of what the tool does (for UI display) */
|
|
26
|
+
description: string;
|
|
27
|
+
/** Category for organizing tools (optional) */
|
|
28
|
+
category?: string;
|
|
29
|
+
/** Icon name or component (optional) */
|
|
30
|
+
icon?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Context provided to tool execution
|
|
34
|
+
*
|
|
35
|
+
* Contains information about the current chat session and user,
|
|
36
|
+
* allowing tools to make context-aware decisions.
|
|
37
|
+
*/
|
|
38
|
+
interface ToolExecutionContext {
|
|
39
|
+
/** Current user ID */
|
|
40
|
+
userId: string;
|
|
41
|
+
/** Current chat ID */
|
|
42
|
+
chatId: string;
|
|
43
|
+
/** Project ID if in project context (optional) */
|
|
44
|
+
projectId?: string;
|
|
45
|
+
/** Character ID if tool is called by a character (optional) */
|
|
46
|
+
characterId?: string;
|
|
47
|
+
/** Participant ID of who is calling the tool (for {{me}} resolution) */
|
|
48
|
+
callingParticipantId?: string;
|
|
49
|
+
/** User-configured settings for this tool */
|
|
50
|
+
toolConfig: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Result of tool execution
|
|
54
|
+
*/
|
|
55
|
+
interface ToolExecutionResult {
|
|
56
|
+
/** Whether the tool execution succeeded */
|
|
57
|
+
success: boolean;
|
|
58
|
+
/** The result data (format depends on the tool) */
|
|
59
|
+
result?: unknown;
|
|
60
|
+
/** Error message if execution failed */
|
|
61
|
+
error?: string;
|
|
62
|
+
/** Formatted text for LLM consumption (optional, if different from result) */
|
|
63
|
+
formattedText?: string;
|
|
64
|
+
/** Additional metadata about the execution */
|
|
65
|
+
metadata?: Record<string, unknown>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Tool Plugin Interface
|
|
69
|
+
*
|
|
70
|
+
* Plugins implementing this interface can be dynamically loaded and used
|
|
71
|
+
* by Quilltap to provide custom tools for LLM interactions.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* import type { ToolPlugin, UniversalTool, ToolExecutionContext, ToolExecutionResult } from '@quilltap/plugin-types';
|
|
76
|
+
*
|
|
77
|
+
* const curlPlugin: ToolPlugin = {
|
|
78
|
+
* metadata: {
|
|
79
|
+
* toolName: 'curl',
|
|
80
|
+
* displayName: 'curl',
|
|
81
|
+
* description: 'Make HTTP requests to fetch web content',
|
|
82
|
+
* },
|
|
83
|
+
* getToolDefinition: () => ({
|
|
84
|
+
* type: 'function',
|
|
85
|
+
* function: {
|
|
86
|
+
* name: 'curl',
|
|
87
|
+
* description: 'Make HTTP requests...',
|
|
88
|
+
* parameters: { ... }
|
|
89
|
+
* }
|
|
90
|
+
* }),
|
|
91
|
+
* validateInput: (input) => typeof input === 'object' && input !== null && 'url' in input,
|
|
92
|
+
* execute: async (input, context) => {
|
|
93
|
+
* // Implementation
|
|
94
|
+
* return { success: true, result: { ... } };
|
|
95
|
+
* },
|
|
96
|
+
* formatResults: (result) => JSON.stringify(result.result, null, 2),
|
|
97
|
+
* };
|
|
98
|
+
*
|
|
99
|
+
* export const plugin = curlPlugin;
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
interface ToolPlugin {
|
|
103
|
+
/**
|
|
104
|
+
* Tool metadata for UI display and identification
|
|
105
|
+
*/
|
|
106
|
+
metadata: ToolMetadata;
|
|
107
|
+
/**
|
|
108
|
+
* Get the tool definition in universal (OpenAI) format
|
|
109
|
+
*
|
|
110
|
+
* Returns the tool's schema that will be sent to LLMs.
|
|
111
|
+
* This is called when building tool arrays for LLM requests.
|
|
112
|
+
*
|
|
113
|
+
* @returns Tool definition in universal format
|
|
114
|
+
*/
|
|
115
|
+
getToolDefinition: () => UniversalTool;
|
|
116
|
+
/**
|
|
117
|
+
* Validate input arguments before execution
|
|
118
|
+
*
|
|
119
|
+
* Checks whether the provided input matches the expected schema.
|
|
120
|
+
* Called before execute() to ensure valid inputs.
|
|
121
|
+
*
|
|
122
|
+
* @param input The input arguments to validate
|
|
123
|
+
* @returns true if valid, false otherwise
|
|
124
|
+
*/
|
|
125
|
+
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
|
+
/**
|
|
138
|
+
* Format results for LLM consumption
|
|
139
|
+
*
|
|
140
|
+
* Converts the raw result into a string that will be sent back
|
|
141
|
+
* to the LLM as the tool response.
|
|
142
|
+
*
|
|
143
|
+
* @param result The execution result to format
|
|
144
|
+
* @returns Formatted string for LLM consumption
|
|
145
|
+
*/
|
|
146
|
+
formatResults: (result: ToolExecutionResult) => string;
|
|
147
|
+
/**
|
|
148
|
+
* Check if the tool is properly configured (optional)
|
|
149
|
+
*
|
|
150
|
+
* For tools that require user configuration (e.g., API keys, allowlists),
|
|
151
|
+
* this method checks whether the necessary configuration is present.
|
|
152
|
+
*
|
|
153
|
+
* @param config The user's tool configuration
|
|
154
|
+
* @returns true if properly configured, false otherwise
|
|
155
|
+
*/
|
|
156
|
+
isConfigured?: (config: Record<string, unknown>) => boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Get default configuration values (optional)
|
|
159
|
+
*
|
|
160
|
+
* Returns the default configuration for this tool.
|
|
161
|
+
* Used when initializing tool settings.
|
|
162
|
+
*
|
|
163
|
+
* @returns Default configuration object
|
|
164
|
+
*/
|
|
165
|
+
getDefaultConfig?: () => Record<string, unknown>;
|
|
166
|
+
/**
|
|
167
|
+
* Render the tool icon as a React component (optional)
|
|
168
|
+
*
|
|
169
|
+
* Returns a function that renders the tool's icon.
|
|
170
|
+
* Called by the UI to display tool icons in various places.
|
|
171
|
+
*
|
|
172
|
+
* @param props Component props including optional className for styling
|
|
173
|
+
* @returns JSX Element representing the tool icon
|
|
174
|
+
*/
|
|
175
|
+
renderIcon?: (props: {
|
|
176
|
+
className?: string;
|
|
177
|
+
}) => React.ReactNode;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Standard export type for tool plugins
|
|
181
|
+
*
|
|
182
|
+
* This is the expected export structure from tool plugin modules.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* // In plugin-curl/index.ts
|
|
187
|
+
* export const plugin: ToolPlugin = { ... };
|
|
188
|
+
*
|
|
189
|
+
* // Or with the export type:
|
|
190
|
+
* const pluginExport: ToolPluginExport = {
|
|
191
|
+
* plugin: { ... }
|
|
192
|
+
* };
|
|
193
|
+
* export default pluginExport;
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
interface ToolPluginExport {
|
|
197
|
+
/** The tool plugin instance */
|
|
198
|
+
plugin: ToolPlugin;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* File Storage Plugin types for Quilltap plugin development
|
|
203
|
+
*
|
|
204
|
+
* Defines the interfaces and types needed to create custom file storage
|
|
205
|
+
* backend providers as Quilltap plugins.
|
|
206
|
+
*
|
|
207
|
+
* @module @quilltap/plugin-types/plugins/file-storage
|
|
208
|
+
*/
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Describes what features a storage backend supports
|
|
212
|
+
*/
|
|
213
|
+
interface FileBackendCapabilities {
|
|
214
|
+
/** Whether the backend supports presigned URLs for direct access */
|
|
215
|
+
presignedUrls: boolean;
|
|
216
|
+
/** Whether the backend supports public URLs (no authentication required) */
|
|
217
|
+
publicUrls: boolean;
|
|
218
|
+
/** Whether the backend supports streaming uploads */
|
|
219
|
+
streamingUpload: boolean;
|
|
220
|
+
/** Whether the backend supports streaming downloads */
|
|
221
|
+
streamingDownload: boolean;
|
|
222
|
+
/** Whether the backend supports copying files between locations */
|
|
223
|
+
copy: boolean;
|
|
224
|
+
/** Whether the backend supports listing files in a prefix/directory */
|
|
225
|
+
list: boolean;
|
|
226
|
+
/** Whether the backend supports retrieving file metadata */
|
|
227
|
+
metadata: boolean;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Metadata about a file storage backend
|
|
231
|
+
*/
|
|
232
|
+
interface FileBackendMetadata {
|
|
233
|
+
/** Unique identifier for this provider */
|
|
234
|
+
providerId: string;
|
|
235
|
+
/** Human-readable display name for UI */
|
|
236
|
+
displayName: string;
|
|
237
|
+
/** Description of the storage backend */
|
|
238
|
+
description: string;
|
|
239
|
+
/** Capabilities supported by this backend */
|
|
240
|
+
capabilities: FileBackendCapabilities;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Metadata about a stored file
|
|
244
|
+
*/
|
|
245
|
+
interface FileMetadata {
|
|
246
|
+
/** Size in bytes */
|
|
247
|
+
size: number;
|
|
248
|
+
/** MIME type */
|
|
249
|
+
contentType: string;
|
|
250
|
+
/** Last modified timestamp */
|
|
251
|
+
lastModified: Date;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Interface for a file storage backend implementation
|
|
255
|
+
*
|
|
256
|
+
* Plugins implementing this interface can provide custom storage backends
|
|
257
|
+
* such as S3, Google Cloud Storage, Azure Blob Storage, etc.
|
|
258
|
+
*/
|
|
259
|
+
interface FileStorageBackend {
|
|
260
|
+
/**
|
|
261
|
+
* Get metadata about this storage backend
|
|
262
|
+
*
|
|
263
|
+
* @returns Backend metadata including capabilities
|
|
264
|
+
*/
|
|
265
|
+
getMetadata(): FileBackendMetadata;
|
|
266
|
+
/**
|
|
267
|
+
* Test the connection to the storage backend
|
|
268
|
+
*
|
|
269
|
+
* Verifies that the backend is properly configured and accessible.
|
|
270
|
+
* This is called during plugin initialization and setup verification.
|
|
271
|
+
*
|
|
272
|
+
* @returns Promise resolving to connection test result
|
|
273
|
+
*/
|
|
274
|
+
testConnection(): Promise<{
|
|
275
|
+
success: boolean;
|
|
276
|
+
message: string;
|
|
277
|
+
latencyMs?: number;
|
|
278
|
+
}>;
|
|
279
|
+
/**
|
|
280
|
+
* Upload a file to storage
|
|
281
|
+
*
|
|
282
|
+
* @param key The storage key/path for the file
|
|
283
|
+
* @param body The file content as Buffer or Readable stream
|
|
284
|
+
* @param contentType MIME type of the file
|
|
285
|
+
* @param metadata Optional custom metadata to store with the file
|
|
286
|
+
*/
|
|
287
|
+
upload(key: string, body: Buffer | Readable, contentType: string, metadata?: Record<string, string>): Promise<void>;
|
|
288
|
+
/**
|
|
289
|
+
* Download a file from storage
|
|
290
|
+
*
|
|
291
|
+
* @param key The storage key/path of the file
|
|
292
|
+
* @returns Promise resolving to the file content as Buffer
|
|
293
|
+
*/
|
|
294
|
+
download(key: string): Promise<Buffer>;
|
|
295
|
+
/**
|
|
296
|
+
* Delete a file from storage
|
|
297
|
+
*
|
|
298
|
+
* @param key The storage key/path of the file
|
|
299
|
+
*/
|
|
300
|
+
delete(key: string): Promise<void>;
|
|
301
|
+
/**
|
|
302
|
+
* Check if a file exists in storage
|
|
303
|
+
*
|
|
304
|
+
* @param key The storage key/path to check
|
|
305
|
+
* @returns Promise resolving to true if file exists, false otherwise
|
|
306
|
+
*/
|
|
307
|
+
exists(key: string): Promise<boolean>;
|
|
308
|
+
/**
|
|
309
|
+
* Get a URL that can be used to access the file through the application proxy
|
|
310
|
+
*
|
|
311
|
+
* This is the primary URL used by Quilltap to serve files to users.
|
|
312
|
+
* It should point back to the Quilltap application, not directly to the
|
|
313
|
+
* storage provider.
|
|
314
|
+
*
|
|
315
|
+
* @param key The storage key/path of the file
|
|
316
|
+
* @returns The proxy URL for accessing the file
|
|
317
|
+
*/
|
|
318
|
+
getProxyUrl(key: string): string;
|
|
319
|
+
/**
|
|
320
|
+
* Copy a file from one location to another
|
|
321
|
+
*
|
|
322
|
+
* Only required if capabilities.copy is true
|
|
323
|
+
*
|
|
324
|
+
* @param sourceKey The source storage key/path
|
|
325
|
+
* @param destinationKey The destination storage key/path
|
|
326
|
+
*/
|
|
327
|
+
copy?(sourceKey: string, destinationKey: string): Promise<void>;
|
|
328
|
+
/**
|
|
329
|
+
* Get metadata about a stored file
|
|
330
|
+
*
|
|
331
|
+
* Only required if capabilities.metadata is true
|
|
332
|
+
*
|
|
333
|
+
* @param key The storage key/path of the file
|
|
334
|
+
* @returns Promise resolving to file metadata or null if file doesn't exist
|
|
335
|
+
*/
|
|
336
|
+
getFileMetadata?(key: string): Promise<FileMetadata | null>;
|
|
337
|
+
/**
|
|
338
|
+
* List files in a prefix/directory
|
|
339
|
+
*
|
|
340
|
+
* Only required if capabilities.list is true
|
|
341
|
+
*
|
|
342
|
+
* @param prefix The prefix or directory to list
|
|
343
|
+
* @param maxKeys Optional maximum number of keys to return
|
|
344
|
+
* @returns Promise resolving to array of keys
|
|
345
|
+
*/
|
|
346
|
+
list?(prefix: string, maxKeys?: number): Promise<string[]>;
|
|
347
|
+
/**
|
|
348
|
+
* Get a presigned URL for direct access to the file
|
|
349
|
+
*
|
|
350
|
+
* The returned URL can be used by clients to access the file directly
|
|
351
|
+
* without going through the Quilltap application, and will expire
|
|
352
|
+
* after the specified time.
|
|
353
|
+
*
|
|
354
|
+
* Only required if capabilities.presignedUrls is true
|
|
355
|
+
*
|
|
356
|
+
* @param key The storage key/path of the file
|
|
357
|
+
* @param expiresIn Expiration time in seconds (default 3600)
|
|
358
|
+
* @returns Promise resolving to presigned URL
|
|
359
|
+
*/
|
|
360
|
+
getPresignedUrl?(key: string, expiresIn?: number): Promise<string>;
|
|
361
|
+
/**
|
|
362
|
+
* Get a presigned URL for uploading a file directly
|
|
363
|
+
*
|
|
364
|
+
* The returned URL can be used by clients to upload a file directly
|
|
365
|
+
* to storage without going through the Quilltap application.
|
|
366
|
+
*
|
|
367
|
+
* Only required if capabilities.presignedUrls is true
|
|
368
|
+
*
|
|
369
|
+
* @param key The storage key/path where the file will be stored
|
|
370
|
+
* @param contentType The MIME type of the file being uploaded
|
|
371
|
+
* @param expiresIn Expiration time in seconds (default 3600)
|
|
372
|
+
* @returns Promise resolving to presigned upload URL
|
|
373
|
+
*/
|
|
374
|
+
getPresignedUploadUrl?(key: string, contentType: string, expiresIn?: number): Promise<string>;
|
|
375
|
+
/**
|
|
376
|
+
* Get a public URL for the file
|
|
377
|
+
*
|
|
378
|
+
* The returned URL is permanent and requires no authentication.
|
|
379
|
+
* Only call this if the file is intended to be publicly accessible.
|
|
380
|
+
*
|
|
381
|
+
* Only required if capabilities.publicUrls is true
|
|
382
|
+
*
|
|
383
|
+
* @param key The storage key/path of the file
|
|
384
|
+
* @returns Promise resolving to public URL
|
|
385
|
+
*/
|
|
386
|
+
getPublicUrl?(key: string): Promise<string>;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Definition of a configuration field for a file storage plugin
|
|
390
|
+
*
|
|
391
|
+
* Used to generate the UI form for configuring the plugin.
|
|
392
|
+
*/
|
|
393
|
+
interface FileStorageConfigField {
|
|
394
|
+
/** Field name (used as key in config object) */
|
|
395
|
+
name: string;
|
|
396
|
+
/** Label displayed in the UI */
|
|
397
|
+
label: string;
|
|
398
|
+
/** Input type for this field */
|
|
399
|
+
type: 'string' | 'number' | 'boolean' | 'secret';
|
|
400
|
+
/** Whether this field is required */
|
|
401
|
+
required: boolean;
|
|
402
|
+
/** Description or help text for the field */
|
|
403
|
+
description?: string;
|
|
404
|
+
/** Default value for the field */
|
|
405
|
+
defaultValue?: string | number | boolean;
|
|
406
|
+
/** Placeholder text for input fields */
|
|
407
|
+
placeholder?: string;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* File Storage Provider Plugin Interface
|
|
411
|
+
*
|
|
412
|
+
* Plugins implementing this interface can provide custom file storage backends
|
|
413
|
+
* to Quilltap, enabling support for different storage providers.
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* ```typescript
|
|
417
|
+
* import type { FileStorageProviderPlugin, FileStorageBackend } from '@quilltap/plugin-types';
|
|
418
|
+
* import { S3Client } from '@aws-sdk/client-s3';
|
|
419
|
+
*
|
|
420
|
+
* const s3Plugin: FileStorageProviderPlugin = {
|
|
421
|
+
* metadata: {
|
|
422
|
+
* backendId: 's3',
|
|
423
|
+
* displayName: 'Amazon S3',
|
|
424
|
+
* description: 'Store files in Amazon S3',
|
|
425
|
+
* },
|
|
426
|
+
* configSchema: [
|
|
427
|
+
* {
|
|
428
|
+
* name: 'accessKeyId',
|
|
429
|
+
* label: 'Access Key ID',
|
|
430
|
+
* type: 'secret',
|
|
431
|
+
* required: true,
|
|
432
|
+
* },
|
|
433
|
+
* // ... more fields
|
|
434
|
+
* ],
|
|
435
|
+
* createBackend: (config) => {
|
|
436
|
+
* return new S3StorageBackend(config);
|
|
437
|
+
* },
|
|
438
|
+
* validateConfig: async (config) => {
|
|
439
|
+
* // Validate configuration
|
|
440
|
+
* return { valid: true };
|
|
441
|
+
* },
|
|
442
|
+
* };
|
|
443
|
+
*
|
|
444
|
+
* export const plugin = s3Plugin;
|
|
445
|
+
* ```
|
|
446
|
+
*/
|
|
447
|
+
interface FileStorageProviderPlugin {
|
|
448
|
+
/**
|
|
449
|
+
* Metadata identifying this plugin
|
|
450
|
+
*/
|
|
451
|
+
metadata: {
|
|
452
|
+
/** Unique identifier for the backend (e.g., 's3', 'gcs', 'azure') */
|
|
453
|
+
backendId: string;
|
|
454
|
+
/** Human-readable display name for UI */
|
|
455
|
+
displayName: string;
|
|
456
|
+
/** Description of what this plugin provides */
|
|
457
|
+
description: string;
|
|
458
|
+
};
|
|
459
|
+
/**
|
|
460
|
+
* Configuration schema for this plugin
|
|
461
|
+
*
|
|
462
|
+
* Defines the fields that users need to configure to use this storage backend.
|
|
463
|
+
* Used to generate the configuration UI form.
|
|
464
|
+
*/
|
|
465
|
+
configSchema: FileStorageConfigField[];
|
|
466
|
+
/**
|
|
467
|
+
* Create a backend instance with the given configuration
|
|
468
|
+
*
|
|
469
|
+
* @param config Configuration object from user input
|
|
470
|
+
* @returns A new FileStorageBackend instance
|
|
471
|
+
*/
|
|
472
|
+
createBackend(config: Record<string, unknown>): FileStorageBackend;
|
|
473
|
+
/**
|
|
474
|
+
* Validate plugin configuration
|
|
475
|
+
*
|
|
476
|
+
* Checks whether the provided configuration is valid for this plugin.
|
|
477
|
+
* Can perform more thorough validation than what's possible with just
|
|
478
|
+
* the config schema (e.g., connecting to the service to verify credentials).
|
|
479
|
+
*
|
|
480
|
+
* @param config Configuration object to validate
|
|
481
|
+
* @returns Promise resolving to validation result
|
|
482
|
+
*/
|
|
483
|
+
validateConfig(config: Record<string, unknown>): Promise<{
|
|
484
|
+
valid: boolean;
|
|
485
|
+
errors?: string[];
|
|
486
|
+
}>;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Standard export type for file storage plugins
|
|
490
|
+
*
|
|
491
|
+
* This is the expected export structure from file storage plugin modules.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```typescript
|
|
495
|
+
* // In plugin-s3/index.ts
|
|
496
|
+
* export const plugin: FileStorageProviderPlugin = { ... };
|
|
497
|
+
*
|
|
498
|
+
* // Or with the export type:
|
|
499
|
+
* const pluginExport: FileStoragePluginExport = {
|
|
500
|
+
* plugin: { ... }
|
|
501
|
+
* };
|
|
502
|
+
* export default pluginExport;
|
|
503
|
+
* ```
|
|
504
|
+
*/
|
|
505
|
+
interface FileStoragePluginExport {
|
|
506
|
+
/** The file storage plugin instance */
|
|
507
|
+
plugin: FileStorageProviderPlugin;
|
|
508
|
+
}
|
|
509
|
+
|
|
6
510
|
/**
|
|
7
511
|
* @quilltap/plugin-types
|
|
8
512
|
*
|
|
@@ -20,6 +524,6 @@ import 'react';
|
|
|
20
524
|
* Version of the plugin-types package.
|
|
21
525
|
* Can be used at runtime to check compatibility.
|
|
22
526
|
*/
|
|
23
|
-
declare const PLUGIN_TYPES_VERSION = "1.
|
|
527
|
+
declare const PLUGIN_TYPES_VERSION = "1.3.0";
|
|
24
528
|
|
|
25
|
-
export { PLUGIN_TYPES_VERSION };
|
|
529
|
+
export { type FileBackendCapabilities, type FileBackendMetadata, type FileMetadata, type FileStorageBackend, type FileStorageConfigField, type FileStoragePluginExport, type FileStorageProviderPlugin, PLUGIN_TYPES_VERSION, type ToolExecutionContext, type ToolExecutionResult, type ToolMetadata, type ToolPlugin, type ToolPluginExport, UniversalTool };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,512 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
import { UniversalTool } from './llm/index.js';
|
|
2
|
+
export { AnthropicToolDefinition, AttachmentResults, CacheUsage, FileAttachment, GeneratedImage, GoogleToolDefinition, ImageGenParams, ImageGenProvider, ImageGenResponse, JSONSchemaDefinition, LLMMessage, LLMParams, LLMProvider, LLMResponse, ModelMetadata, ModelWarning, ModelWarningLevel, OpenAIToolDefinition, ResponseFormat, StreamChunk, TokenUsage, ToolCall, ToolCallRequest, ToolFormatOptions, ToolResult } from './llm/index.js';
|
|
3
|
+
export { A as AttachmentSupport, C as CheapModelConfig, p as ColorPalette, r as Effects, t as EmbeddedFont, E as EmbeddingModelInfo, F as FontDefinition, d as IconProps, I as ImageGenerationModelInfo, c as ImageProviderConstraints, o as InstalledPluginInfo, L as LLMProviderPlugin, f as MessageFormatSupport, M as ModelInfo, j as PluginAuthor, g as PluginCapability, h as PluginCategory, k as PluginCompatibility, n as PluginManifest, m as PluginPermissions, i as PluginStatus, b as ProviderCapabilities, l as ProviderConfig, a as ProviderConfigRequirements, P as ProviderMetadata, e as ProviderPluginExport, R as RoleplayTemplateConfig, x as RoleplayTemplateMetadata, y as RoleplayTemplatePlugin, z as RoleplayTemplatePluginExport, S as Spacing, u as ThemeMetadata, v as ThemePlugin, w as ThemePluginExport, s as ThemeTokens, T as ToolFormatType, q as Typography } from './index-9cCc5tg5.js';
|
|
4
|
+
import { Readable } from 'stream';
|
|
3
5
|
export { ApiKeyError, AttachmentError, ConfigurationError, LogContext, LogLevel, ModelNotFoundError, PluginError, PluginLogger, ProviderApiError, RateLimitError, ToolExecutionError, createConsoleLogger, createNoopLogger } from './common/index.js';
|
|
4
6
|
import 'react';
|
|
5
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Tool Plugin types for Quilltap plugin development
|
|
10
|
+
*
|
|
11
|
+
* Defines the interfaces and types needed to create custom LLM tools
|
|
12
|
+
* as Quilltap plugins.
|
|
13
|
+
*
|
|
14
|
+
* @module @quilltap/plugin-types/plugins/tool
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Tool metadata for UI display and identification
|
|
19
|
+
*/
|
|
20
|
+
interface ToolMetadata {
|
|
21
|
+
/** Internal tool name used in LLM function calls (lowercase with underscores) */
|
|
22
|
+
toolName: string;
|
|
23
|
+
/** Human-readable display name for UI */
|
|
24
|
+
displayName: string;
|
|
25
|
+
/** Description of what the tool does (for UI display) */
|
|
26
|
+
description: string;
|
|
27
|
+
/** Category for organizing tools (optional) */
|
|
28
|
+
category?: string;
|
|
29
|
+
/** Icon name or component (optional) */
|
|
30
|
+
icon?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Context provided to tool execution
|
|
34
|
+
*
|
|
35
|
+
* Contains information about the current chat session and user,
|
|
36
|
+
* allowing tools to make context-aware decisions.
|
|
37
|
+
*/
|
|
38
|
+
interface ToolExecutionContext {
|
|
39
|
+
/** Current user ID */
|
|
40
|
+
userId: string;
|
|
41
|
+
/** Current chat ID */
|
|
42
|
+
chatId: string;
|
|
43
|
+
/** Project ID if in project context (optional) */
|
|
44
|
+
projectId?: string;
|
|
45
|
+
/** Character ID if tool is called by a character (optional) */
|
|
46
|
+
characterId?: string;
|
|
47
|
+
/** Participant ID of who is calling the tool (for {{me}} resolution) */
|
|
48
|
+
callingParticipantId?: string;
|
|
49
|
+
/** User-configured settings for this tool */
|
|
50
|
+
toolConfig: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Result of tool execution
|
|
54
|
+
*/
|
|
55
|
+
interface ToolExecutionResult {
|
|
56
|
+
/** Whether the tool execution succeeded */
|
|
57
|
+
success: boolean;
|
|
58
|
+
/** The result data (format depends on the tool) */
|
|
59
|
+
result?: unknown;
|
|
60
|
+
/** Error message if execution failed */
|
|
61
|
+
error?: string;
|
|
62
|
+
/** Formatted text for LLM consumption (optional, if different from result) */
|
|
63
|
+
formattedText?: string;
|
|
64
|
+
/** Additional metadata about the execution */
|
|
65
|
+
metadata?: Record<string, unknown>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Tool Plugin Interface
|
|
69
|
+
*
|
|
70
|
+
* Plugins implementing this interface can be dynamically loaded and used
|
|
71
|
+
* by Quilltap to provide custom tools for LLM interactions.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* import type { ToolPlugin, UniversalTool, ToolExecutionContext, ToolExecutionResult } from '@quilltap/plugin-types';
|
|
76
|
+
*
|
|
77
|
+
* const curlPlugin: ToolPlugin = {
|
|
78
|
+
* metadata: {
|
|
79
|
+
* toolName: 'curl',
|
|
80
|
+
* displayName: 'curl',
|
|
81
|
+
* description: 'Make HTTP requests to fetch web content',
|
|
82
|
+
* },
|
|
83
|
+
* getToolDefinition: () => ({
|
|
84
|
+
* type: 'function',
|
|
85
|
+
* function: {
|
|
86
|
+
* name: 'curl',
|
|
87
|
+
* description: 'Make HTTP requests...',
|
|
88
|
+
* parameters: { ... }
|
|
89
|
+
* }
|
|
90
|
+
* }),
|
|
91
|
+
* validateInput: (input) => typeof input === 'object' && input !== null && 'url' in input,
|
|
92
|
+
* execute: async (input, context) => {
|
|
93
|
+
* // Implementation
|
|
94
|
+
* return { success: true, result: { ... } };
|
|
95
|
+
* },
|
|
96
|
+
* formatResults: (result) => JSON.stringify(result.result, null, 2),
|
|
97
|
+
* };
|
|
98
|
+
*
|
|
99
|
+
* export const plugin = curlPlugin;
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
interface ToolPlugin {
|
|
103
|
+
/**
|
|
104
|
+
* Tool metadata for UI display and identification
|
|
105
|
+
*/
|
|
106
|
+
metadata: ToolMetadata;
|
|
107
|
+
/**
|
|
108
|
+
* Get the tool definition in universal (OpenAI) format
|
|
109
|
+
*
|
|
110
|
+
* Returns the tool's schema that will be sent to LLMs.
|
|
111
|
+
* This is called when building tool arrays for LLM requests.
|
|
112
|
+
*
|
|
113
|
+
* @returns Tool definition in universal format
|
|
114
|
+
*/
|
|
115
|
+
getToolDefinition: () => UniversalTool;
|
|
116
|
+
/**
|
|
117
|
+
* Validate input arguments before execution
|
|
118
|
+
*
|
|
119
|
+
* Checks whether the provided input matches the expected schema.
|
|
120
|
+
* Called before execute() to ensure valid inputs.
|
|
121
|
+
*
|
|
122
|
+
* @param input The input arguments to validate
|
|
123
|
+
* @returns true if valid, false otherwise
|
|
124
|
+
*/
|
|
125
|
+
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
|
+
/**
|
|
138
|
+
* Format results for LLM consumption
|
|
139
|
+
*
|
|
140
|
+
* Converts the raw result into a string that will be sent back
|
|
141
|
+
* to the LLM as the tool response.
|
|
142
|
+
*
|
|
143
|
+
* @param result The execution result to format
|
|
144
|
+
* @returns Formatted string for LLM consumption
|
|
145
|
+
*/
|
|
146
|
+
formatResults: (result: ToolExecutionResult) => string;
|
|
147
|
+
/**
|
|
148
|
+
* Check if the tool is properly configured (optional)
|
|
149
|
+
*
|
|
150
|
+
* For tools that require user configuration (e.g., API keys, allowlists),
|
|
151
|
+
* this method checks whether the necessary configuration is present.
|
|
152
|
+
*
|
|
153
|
+
* @param config The user's tool configuration
|
|
154
|
+
* @returns true if properly configured, false otherwise
|
|
155
|
+
*/
|
|
156
|
+
isConfigured?: (config: Record<string, unknown>) => boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Get default configuration values (optional)
|
|
159
|
+
*
|
|
160
|
+
* Returns the default configuration for this tool.
|
|
161
|
+
* Used when initializing tool settings.
|
|
162
|
+
*
|
|
163
|
+
* @returns Default configuration object
|
|
164
|
+
*/
|
|
165
|
+
getDefaultConfig?: () => Record<string, unknown>;
|
|
166
|
+
/**
|
|
167
|
+
* Render the tool icon as a React component (optional)
|
|
168
|
+
*
|
|
169
|
+
* Returns a function that renders the tool's icon.
|
|
170
|
+
* Called by the UI to display tool icons in various places.
|
|
171
|
+
*
|
|
172
|
+
* @param props Component props including optional className for styling
|
|
173
|
+
* @returns JSX Element representing the tool icon
|
|
174
|
+
*/
|
|
175
|
+
renderIcon?: (props: {
|
|
176
|
+
className?: string;
|
|
177
|
+
}) => React.ReactNode;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Standard export type for tool plugins
|
|
181
|
+
*
|
|
182
|
+
* This is the expected export structure from tool plugin modules.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* // In plugin-curl/index.ts
|
|
187
|
+
* export const plugin: ToolPlugin = { ... };
|
|
188
|
+
*
|
|
189
|
+
* // Or with the export type:
|
|
190
|
+
* const pluginExport: ToolPluginExport = {
|
|
191
|
+
* plugin: { ... }
|
|
192
|
+
* };
|
|
193
|
+
* export default pluginExport;
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
interface ToolPluginExport {
|
|
197
|
+
/** The tool plugin instance */
|
|
198
|
+
plugin: ToolPlugin;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* File Storage Plugin types for Quilltap plugin development
|
|
203
|
+
*
|
|
204
|
+
* Defines the interfaces and types needed to create custom file storage
|
|
205
|
+
* backend providers as Quilltap plugins.
|
|
206
|
+
*
|
|
207
|
+
* @module @quilltap/plugin-types/plugins/file-storage
|
|
208
|
+
*/
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Describes what features a storage backend supports
|
|
212
|
+
*/
|
|
213
|
+
interface FileBackendCapabilities {
|
|
214
|
+
/** Whether the backend supports presigned URLs for direct access */
|
|
215
|
+
presignedUrls: boolean;
|
|
216
|
+
/** Whether the backend supports public URLs (no authentication required) */
|
|
217
|
+
publicUrls: boolean;
|
|
218
|
+
/** Whether the backend supports streaming uploads */
|
|
219
|
+
streamingUpload: boolean;
|
|
220
|
+
/** Whether the backend supports streaming downloads */
|
|
221
|
+
streamingDownload: boolean;
|
|
222
|
+
/** Whether the backend supports copying files between locations */
|
|
223
|
+
copy: boolean;
|
|
224
|
+
/** Whether the backend supports listing files in a prefix/directory */
|
|
225
|
+
list: boolean;
|
|
226
|
+
/** Whether the backend supports retrieving file metadata */
|
|
227
|
+
metadata: boolean;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Metadata about a file storage backend
|
|
231
|
+
*/
|
|
232
|
+
interface FileBackendMetadata {
|
|
233
|
+
/** Unique identifier for this provider */
|
|
234
|
+
providerId: string;
|
|
235
|
+
/** Human-readable display name for UI */
|
|
236
|
+
displayName: string;
|
|
237
|
+
/** Description of the storage backend */
|
|
238
|
+
description: string;
|
|
239
|
+
/** Capabilities supported by this backend */
|
|
240
|
+
capabilities: FileBackendCapabilities;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Metadata about a stored file
|
|
244
|
+
*/
|
|
245
|
+
interface FileMetadata {
|
|
246
|
+
/** Size in bytes */
|
|
247
|
+
size: number;
|
|
248
|
+
/** MIME type */
|
|
249
|
+
contentType: string;
|
|
250
|
+
/** Last modified timestamp */
|
|
251
|
+
lastModified: Date;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Interface for a file storage backend implementation
|
|
255
|
+
*
|
|
256
|
+
* Plugins implementing this interface can provide custom storage backends
|
|
257
|
+
* such as S3, Google Cloud Storage, Azure Blob Storage, etc.
|
|
258
|
+
*/
|
|
259
|
+
interface FileStorageBackend {
|
|
260
|
+
/**
|
|
261
|
+
* Get metadata about this storage backend
|
|
262
|
+
*
|
|
263
|
+
* @returns Backend metadata including capabilities
|
|
264
|
+
*/
|
|
265
|
+
getMetadata(): FileBackendMetadata;
|
|
266
|
+
/**
|
|
267
|
+
* Test the connection to the storage backend
|
|
268
|
+
*
|
|
269
|
+
* Verifies that the backend is properly configured and accessible.
|
|
270
|
+
* This is called during plugin initialization and setup verification.
|
|
271
|
+
*
|
|
272
|
+
* @returns Promise resolving to connection test result
|
|
273
|
+
*/
|
|
274
|
+
testConnection(): Promise<{
|
|
275
|
+
success: boolean;
|
|
276
|
+
message: string;
|
|
277
|
+
latencyMs?: number;
|
|
278
|
+
}>;
|
|
279
|
+
/**
|
|
280
|
+
* Upload a file to storage
|
|
281
|
+
*
|
|
282
|
+
* @param key The storage key/path for the file
|
|
283
|
+
* @param body The file content as Buffer or Readable stream
|
|
284
|
+
* @param contentType MIME type of the file
|
|
285
|
+
* @param metadata Optional custom metadata to store with the file
|
|
286
|
+
*/
|
|
287
|
+
upload(key: string, body: Buffer | Readable, contentType: string, metadata?: Record<string, string>): Promise<void>;
|
|
288
|
+
/**
|
|
289
|
+
* Download a file from storage
|
|
290
|
+
*
|
|
291
|
+
* @param key The storage key/path of the file
|
|
292
|
+
* @returns Promise resolving to the file content as Buffer
|
|
293
|
+
*/
|
|
294
|
+
download(key: string): Promise<Buffer>;
|
|
295
|
+
/**
|
|
296
|
+
* Delete a file from storage
|
|
297
|
+
*
|
|
298
|
+
* @param key The storage key/path of the file
|
|
299
|
+
*/
|
|
300
|
+
delete(key: string): Promise<void>;
|
|
301
|
+
/**
|
|
302
|
+
* Check if a file exists in storage
|
|
303
|
+
*
|
|
304
|
+
* @param key The storage key/path to check
|
|
305
|
+
* @returns Promise resolving to true if file exists, false otherwise
|
|
306
|
+
*/
|
|
307
|
+
exists(key: string): Promise<boolean>;
|
|
308
|
+
/**
|
|
309
|
+
* Get a URL that can be used to access the file through the application proxy
|
|
310
|
+
*
|
|
311
|
+
* This is the primary URL used by Quilltap to serve files to users.
|
|
312
|
+
* It should point back to the Quilltap application, not directly to the
|
|
313
|
+
* storage provider.
|
|
314
|
+
*
|
|
315
|
+
* @param key The storage key/path of the file
|
|
316
|
+
* @returns The proxy URL for accessing the file
|
|
317
|
+
*/
|
|
318
|
+
getProxyUrl(key: string): string;
|
|
319
|
+
/**
|
|
320
|
+
* Copy a file from one location to another
|
|
321
|
+
*
|
|
322
|
+
* Only required if capabilities.copy is true
|
|
323
|
+
*
|
|
324
|
+
* @param sourceKey The source storage key/path
|
|
325
|
+
* @param destinationKey The destination storage key/path
|
|
326
|
+
*/
|
|
327
|
+
copy?(sourceKey: string, destinationKey: string): Promise<void>;
|
|
328
|
+
/**
|
|
329
|
+
* Get metadata about a stored file
|
|
330
|
+
*
|
|
331
|
+
* Only required if capabilities.metadata is true
|
|
332
|
+
*
|
|
333
|
+
* @param key The storage key/path of the file
|
|
334
|
+
* @returns Promise resolving to file metadata or null if file doesn't exist
|
|
335
|
+
*/
|
|
336
|
+
getFileMetadata?(key: string): Promise<FileMetadata | null>;
|
|
337
|
+
/**
|
|
338
|
+
* List files in a prefix/directory
|
|
339
|
+
*
|
|
340
|
+
* Only required if capabilities.list is true
|
|
341
|
+
*
|
|
342
|
+
* @param prefix The prefix or directory to list
|
|
343
|
+
* @param maxKeys Optional maximum number of keys to return
|
|
344
|
+
* @returns Promise resolving to array of keys
|
|
345
|
+
*/
|
|
346
|
+
list?(prefix: string, maxKeys?: number): Promise<string[]>;
|
|
347
|
+
/**
|
|
348
|
+
* Get a presigned URL for direct access to the file
|
|
349
|
+
*
|
|
350
|
+
* The returned URL can be used by clients to access the file directly
|
|
351
|
+
* without going through the Quilltap application, and will expire
|
|
352
|
+
* after the specified time.
|
|
353
|
+
*
|
|
354
|
+
* Only required if capabilities.presignedUrls is true
|
|
355
|
+
*
|
|
356
|
+
* @param key The storage key/path of the file
|
|
357
|
+
* @param expiresIn Expiration time in seconds (default 3600)
|
|
358
|
+
* @returns Promise resolving to presigned URL
|
|
359
|
+
*/
|
|
360
|
+
getPresignedUrl?(key: string, expiresIn?: number): Promise<string>;
|
|
361
|
+
/**
|
|
362
|
+
* Get a presigned URL for uploading a file directly
|
|
363
|
+
*
|
|
364
|
+
* The returned URL can be used by clients to upload a file directly
|
|
365
|
+
* to storage without going through the Quilltap application.
|
|
366
|
+
*
|
|
367
|
+
* Only required if capabilities.presignedUrls is true
|
|
368
|
+
*
|
|
369
|
+
* @param key The storage key/path where the file will be stored
|
|
370
|
+
* @param contentType The MIME type of the file being uploaded
|
|
371
|
+
* @param expiresIn Expiration time in seconds (default 3600)
|
|
372
|
+
* @returns Promise resolving to presigned upload URL
|
|
373
|
+
*/
|
|
374
|
+
getPresignedUploadUrl?(key: string, contentType: string, expiresIn?: number): Promise<string>;
|
|
375
|
+
/**
|
|
376
|
+
* Get a public URL for the file
|
|
377
|
+
*
|
|
378
|
+
* The returned URL is permanent and requires no authentication.
|
|
379
|
+
* Only call this if the file is intended to be publicly accessible.
|
|
380
|
+
*
|
|
381
|
+
* Only required if capabilities.publicUrls is true
|
|
382
|
+
*
|
|
383
|
+
* @param key The storage key/path of the file
|
|
384
|
+
* @returns Promise resolving to public URL
|
|
385
|
+
*/
|
|
386
|
+
getPublicUrl?(key: string): Promise<string>;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Definition of a configuration field for a file storage plugin
|
|
390
|
+
*
|
|
391
|
+
* Used to generate the UI form for configuring the plugin.
|
|
392
|
+
*/
|
|
393
|
+
interface FileStorageConfigField {
|
|
394
|
+
/** Field name (used as key in config object) */
|
|
395
|
+
name: string;
|
|
396
|
+
/** Label displayed in the UI */
|
|
397
|
+
label: string;
|
|
398
|
+
/** Input type for this field */
|
|
399
|
+
type: 'string' | 'number' | 'boolean' | 'secret';
|
|
400
|
+
/** Whether this field is required */
|
|
401
|
+
required: boolean;
|
|
402
|
+
/** Description or help text for the field */
|
|
403
|
+
description?: string;
|
|
404
|
+
/** Default value for the field */
|
|
405
|
+
defaultValue?: string | number | boolean;
|
|
406
|
+
/** Placeholder text for input fields */
|
|
407
|
+
placeholder?: string;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* File Storage Provider Plugin Interface
|
|
411
|
+
*
|
|
412
|
+
* Plugins implementing this interface can provide custom file storage backends
|
|
413
|
+
* to Quilltap, enabling support for different storage providers.
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* ```typescript
|
|
417
|
+
* import type { FileStorageProviderPlugin, FileStorageBackend } from '@quilltap/plugin-types';
|
|
418
|
+
* import { S3Client } from '@aws-sdk/client-s3';
|
|
419
|
+
*
|
|
420
|
+
* const s3Plugin: FileStorageProviderPlugin = {
|
|
421
|
+
* metadata: {
|
|
422
|
+
* backendId: 's3',
|
|
423
|
+
* displayName: 'Amazon S3',
|
|
424
|
+
* description: 'Store files in Amazon S3',
|
|
425
|
+
* },
|
|
426
|
+
* configSchema: [
|
|
427
|
+
* {
|
|
428
|
+
* name: 'accessKeyId',
|
|
429
|
+
* label: 'Access Key ID',
|
|
430
|
+
* type: 'secret',
|
|
431
|
+
* required: true,
|
|
432
|
+
* },
|
|
433
|
+
* // ... more fields
|
|
434
|
+
* ],
|
|
435
|
+
* createBackend: (config) => {
|
|
436
|
+
* return new S3StorageBackend(config);
|
|
437
|
+
* },
|
|
438
|
+
* validateConfig: async (config) => {
|
|
439
|
+
* // Validate configuration
|
|
440
|
+
* return { valid: true };
|
|
441
|
+
* },
|
|
442
|
+
* };
|
|
443
|
+
*
|
|
444
|
+
* export const plugin = s3Plugin;
|
|
445
|
+
* ```
|
|
446
|
+
*/
|
|
447
|
+
interface FileStorageProviderPlugin {
|
|
448
|
+
/**
|
|
449
|
+
* Metadata identifying this plugin
|
|
450
|
+
*/
|
|
451
|
+
metadata: {
|
|
452
|
+
/** Unique identifier for the backend (e.g., 's3', 'gcs', 'azure') */
|
|
453
|
+
backendId: string;
|
|
454
|
+
/** Human-readable display name for UI */
|
|
455
|
+
displayName: string;
|
|
456
|
+
/** Description of what this plugin provides */
|
|
457
|
+
description: string;
|
|
458
|
+
};
|
|
459
|
+
/**
|
|
460
|
+
* Configuration schema for this plugin
|
|
461
|
+
*
|
|
462
|
+
* Defines the fields that users need to configure to use this storage backend.
|
|
463
|
+
* Used to generate the configuration UI form.
|
|
464
|
+
*/
|
|
465
|
+
configSchema: FileStorageConfigField[];
|
|
466
|
+
/**
|
|
467
|
+
* Create a backend instance with the given configuration
|
|
468
|
+
*
|
|
469
|
+
* @param config Configuration object from user input
|
|
470
|
+
* @returns A new FileStorageBackend instance
|
|
471
|
+
*/
|
|
472
|
+
createBackend(config: Record<string, unknown>): FileStorageBackend;
|
|
473
|
+
/**
|
|
474
|
+
* Validate plugin configuration
|
|
475
|
+
*
|
|
476
|
+
* Checks whether the provided configuration is valid for this plugin.
|
|
477
|
+
* Can perform more thorough validation than what's possible with just
|
|
478
|
+
* the config schema (e.g., connecting to the service to verify credentials).
|
|
479
|
+
*
|
|
480
|
+
* @param config Configuration object to validate
|
|
481
|
+
* @returns Promise resolving to validation result
|
|
482
|
+
*/
|
|
483
|
+
validateConfig(config: Record<string, unknown>): Promise<{
|
|
484
|
+
valid: boolean;
|
|
485
|
+
errors?: string[];
|
|
486
|
+
}>;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Standard export type for file storage plugins
|
|
490
|
+
*
|
|
491
|
+
* This is the expected export structure from file storage plugin modules.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```typescript
|
|
495
|
+
* // In plugin-s3/index.ts
|
|
496
|
+
* export const plugin: FileStorageProviderPlugin = { ... };
|
|
497
|
+
*
|
|
498
|
+
* // Or with the export type:
|
|
499
|
+
* const pluginExport: FileStoragePluginExport = {
|
|
500
|
+
* plugin: { ... }
|
|
501
|
+
* };
|
|
502
|
+
* export default pluginExport;
|
|
503
|
+
* ```
|
|
504
|
+
*/
|
|
505
|
+
interface FileStoragePluginExport {
|
|
506
|
+
/** The file storage plugin instance */
|
|
507
|
+
plugin: FileStorageProviderPlugin;
|
|
508
|
+
}
|
|
509
|
+
|
|
6
510
|
/**
|
|
7
511
|
* @quilltap/plugin-types
|
|
8
512
|
*
|
|
@@ -20,6 +524,6 @@ import 'react';
|
|
|
20
524
|
* Version of the plugin-types package.
|
|
21
525
|
* Can be used at runtime to check compatibility.
|
|
22
526
|
*/
|
|
23
|
-
declare const PLUGIN_TYPES_VERSION = "1.
|
|
527
|
+
declare const PLUGIN_TYPES_VERSION = "1.3.0";
|
|
24
528
|
|
|
25
|
-
export { PLUGIN_TYPES_VERSION };
|
|
529
|
+
export { type FileBackendCapabilities, type FileBackendMetadata, type FileMetadata, type FileStorageBackend, type FileStorageConfigField, type FileStoragePluginExport, type FileStorageProviderPlugin, PLUGIN_TYPES_VERSION, type ToolExecutionContext, type ToolExecutionResult, type ToolMetadata, type ToolPlugin, type ToolPluginExport, UniversalTool };
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/errors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AE,CAAA;AAAA,MAChE;AAAA,IACF,CAAA;AAAA,IAEA,KAAA,EAAO,CAAC,OAAA,EAAiB,OAAA,EAAsB,KAAA,KAAwB;AACrE,MAAA,IAAI,SAAA,CAAU,OAAO,CAAA,EAAG;AACtB,QAAA,OAAA,CAAQ,KAAA;AAAA,UACN,IAAI,MAAM,CAAA,EAAA,EAAK,OAAO,CAAA,EAAG,aAAA,CAAc,OAAO,CAAC,CAAA,CAAA;AAAA,UAC/C,KAAA,GAAQ;AAAA,EAAK,KAAA,CAAM,KAAA,IAAS,KAAA,CAAM,OAAO,CAAA,CAAA,GAAK;AAAA,SAChD;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF;AAOO,SAAS,gBAAA,GAAiC;AAC/C,EAAA,MAAM,OAAO,MAAY;AAAA,EAAC,CAAA;AAC1B,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,IAAA;AAAA,IACP,IAAA,EAAM,IAAA;AAAA,IACN,IAAA,EAAM,IAAA;AAAA,IACN,KAAA,EAAO;AAAA,GACT;AACF;;;ACcO,IAAM,oBAAA,GAAuB","file":"index.js","sourcesContent":["/**\n * Common error types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/errors\n */\n\n/**\n * Base plugin error\n *\n * All plugin-specific errors should extend this class.\n */\nexport class PluginError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly pluginName?: string\n ) {\n super(message);\n this.name = 'PluginError';\n }\n}\n\n/**\n * API key validation error\n *\n * Thrown when an API key is invalid or has insufficient permissions.\n */\nexport class ApiKeyError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'API_KEY_ERROR', pluginName);\n this.name = 'ApiKeyError';\n }\n}\n\n/**\n * Provider API error\n *\n * Thrown when the provider API returns an error.\n */\nexport class ProviderApiError extends PluginError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly response?: unknown,\n pluginName?: string\n ) {\n super(message, 'PROVIDER_API_ERROR', pluginName);\n this.name = 'ProviderApiError';\n }\n}\n\n/**\n * Rate limit error\n *\n * Thrown when the provider rate limits the request.\n */\nexport class RateLimitError extends ProviderApiError {\n public override readonly code = 'RATE_LIMIT_ERROR';\n\n constructor(\n message: string,\n public readonly retryAfter?: number,\n pluginName?: string\n ) {\n super(message, 429, undefined, pluginName);\n this.name = 'RateLimitError';\n }\n}\n\n/**\n * Configuration error\n *\n * Thrown when plugin configuration is invalid.\n */\nexport class ConfigurationError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'CONFIGURATION_ERROR', pluginName);\n this.name = 'ConfigurationError';\n }\n}\n\n/**\n * Model not found error\n *\n * Thrown when a requested model is not available.\n */\nexport class ModelNotFoundError extends PluginError {\n constructor(\n message: string,\n public readonly modelId?: string,\n pluginName?: string\n ) {\n super(message, 'MODEL_NOT_FOUND', pluginName);\n this.name = 'ModelNotFoundError';\n }\n}\n\n/**\n * Attachment error\n *\n * Thrown when there's an issue processing file attachments.\n */\nexport class AttachmentError extends PluginError {\n constructor(\n message: string,\n public readonly attachmentId?: string,\n pluginName?: string\n ) {\n super(message, 'ATTACHMENT_ERROR', pluginName);\n this.name = 'AttachmentError';\n }\n}\n\n/**\n * Tool execution error\n *\n * Thrown when a tool call fails to execute.\n */\nexport class ToolExecutionError extends PluginError {\n constructor(\n message: string,\n public readonly toolName?: string,\n pluginName?: string\n ) {\n super(message, 'TOOL_EXECUTION_ERROR', pluginName);\n this.name = 'ToolExecutionError';\n }\n}\n","/**\n * Logger types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/logger\n */\n\n/**\n * Log level type\n */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Log context metadata\n */\nexport interface LogContext {\n /** Context identifier (e.g., module name) */\n context?: string;\n /** Additional metadata */\n [key: string]: unknown;\n}\n\n/**\n * Logger interface that plugins can implement or receive\n *\n * This interface is compatible with Quilltap's built-in logger.\n * Plugins can use this interface to accept a logger from the host\n * application or implement their own logging.\n */\nexport interface PluginLogger {\n /**\n * Log a debug message\n * @param message Message to log\n * @param context Optional context metadata\n */\n debug(message: string, context?: LogContext): void;\n\n /**\n * Log an info message\n * @param message Message to log\n * @param context Optional context metadata\n */\n info(message: string, context?: LogContext): void;\n\n /**\n * Log a warning message\n * @param message Message to log\n * @param context Optional context metadata\n */\n warn(message: string, context?: LogContext): void;\n\n /**\n * Log an error message\n * @param message Message to log\n * @param context Optional context metadata\n * @param error Optional error object\n */\n error(message: string, context?: LogContext, error?: Error): void;\n}\n\n/**\n * Simple console-based logger for standalone plugin development\n *\n * This logger writes to the console and is useful for local\n * plugin development and testing.\n *\n * @param prefix Prefix to add to all log messages\n * @param minLevel Minimum log level to output (default: 'info')\n * @returns A PluginLogger instance\n *\n * @example\n * ```typescript\n * const logger = createConsoleLogger('my-plugin', 'debug');\n * logger.debug('Initializing plugin', { version: '1.0.0' });\n * logger.info('Plugin ready');\n * logger.error('Failed to connect', { endpoint: 'api.example.com' }, new Error('Connection refused'));\n * ```\n */\nexport function createConsoleLogger(prefix: string, minLevel: LogLevel = 'info'): PluginLogger {\n const levels: LogLevel[] = ['debug', 'info', 'warn', 'error'];\n const shouldLog = (level: LogLevel): boolean =>\n levels.indexOf(level) >= levels.indexOf(minLevel);\n\n const formatContext = (context?: LogContext): string => {\n if (!context) return '';\n const entries = Object.entries(context)\n .filter(([key]) => key !== 'context')\n .map(([key, value]) => `${key}=${JSON.stringify(value)}`)\n .join(' ');\n return entries ? ` ${entries}` : '';\n };\n\n return {\n debug: (message: string, context?: LogContext): void => {\n if (shouldLog('debug')) {\n console.debug(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n info: (message: string, context?: LogContext): void => {\n if (shouldLog('info')) {\n console.info(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n warn: (message: string, context?: LogContext): void => {\n if (shouldLog('warn')) {\n console.warn(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n error: (message: string, context?: LogContext, error?: Error): void => {\n if (shouldLog('error')) {\n console.error(\n `[${prefix}] ${message}${formatContext(context)}`,\n error ? `\\n${error.stack || error.message}` : ''\n );\n }\n },\n };\n}\n\n/**\n * No-op logger for production or when logging is disabled\n *\n * @returns A PluginLogger that does nothing\n */\nexport function createNoopLogger(): PluginLogger {\n const noop = (): void => {};\n return {\n debug: noop,\n info: noop,\n warn: noop,\n error: noop,\n };\n}\n","/**\n * @quilltap/plugin-types\n *\n * Type definitions for Quilltap plugin development.\n *\n * This package provides TypeScript types and interfaces for building\n * Quilltap plugins, including LLM providers, authentication providers,\n * and utility plugins.\n *\n * @packageDocumentation\n * @module @quilltap/plugin-types\n */\n\n// ============================================================================\n// LLM Types\n// ============================================================================\n\nexport type {\n // Core message types\n FileAttachment,\n LLMMessage,\n JSONSchemaDefinition,\n ResponseFormat,\n LLMParams,\n\n // Response types\n TokenUsage,\n CacheUsage,\n AttachmentResults,\n LLMResponse,\n StreamChunk,\n\n // Image generation types\n ImageGenParams,\n GeneratedImage,\n ImageGenResponse,\n\n // Model metadata\n ModelWarningLevel,\n ModelWarning,\n ModelMetadata,\n\n // Provider interfaces\n LLMProvider,\n ImageGenProvider,\n} from './llm/base';\n\nexport type {\n // Tool definitions\n OpenAIToolDefinition,\n UniversalTool,\n AnthropicToolDefinition,\n GoogleToolDefinition,\n\n // Tool calls\n ToolCall,\n ToolCallRequest,\n ToolResult,\n ToolFormatOptions,\n} from './llm/tools';\n\n// ============================================================================\n// Plugin Types\n// ============================================================================\n\nexport type {\n // Provider plugin types\n ProviderMetadata,\n ProviderConfigRequirements,\n ProviderCapabilities,\n AttachmentSupport,\n ModelInfo,\n EmbeddingModelInfo,\n ImageGenerationModelInfo,\n ImageProviderConstraints,\n IconProps,\n LLMProviderPlugin,\n ProviderPluginExport,\n // Runtime configuration types\n MessageFormatSupport,\n CheapModelConfig,\n ToolFormatType,\n} from './plugins/provider';\n\nexport type {\n // Manifest types\n PluginCapability,\n PluginCategory,\n PluginStatus,\n PluginAuthor,\n PluginCompatibility,\n ProviderConfig,\n PluginPermissions,\n PluginManifest,\n InstalledPluginInfo,\n} from './plugins/manifest';\n\nexport type {\n // Theme plugin types\n ColorPalette,\n Typography,\n Spacing,\n Effects,\n ThemeTokens,\n FontDefinition,\n EmbeddedFont,\n ThemeMetadata,\n ThemePlugin,\n ThemePluginExport,\n} from './plugins/theme';\n\nexport type {\n // Roleplay template plugin types\n RoleplayTemplateConfig,\n RoleplayTemplateMetadata,\n RoleplayTemplatePlugin,\n RoleplayTemplatePluginExport,\n} from './plugins/roleplay-template';\n\n// ============================================================================\n// Common Types\n// ============================================================================\n\nexport type { LogLevel, LogContext, PluginLogger } from './common/logger';\n\n// Error classes (these are values, not just types)\nexport {\n PluginError,\n ApiKeyError,\n ProviderApiError,\n RateLimitError,\n ConfigurationError,\n ModelNotFoundError,\n AttachmentError,\n ToolExecutionError,\n} from './common/errors';\n\n// Logger factories\nexport { createConsoleLogger, createNoopLogger } from './common/logger';\n\n// ============================================================================\n// Version\n// ============================================================================\n\n/**\n * Version of the plugin-types package.\n * Can be used at runtime to check compatibility.\n */\nexport const PLUGIN_TYPES_VERSION = '1.2.0';\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/common/errors.ts","../src/common/logger.ts","../src/index.ts"],"names":[],"mappings":";;;AAWO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EACrC,WAAA,CACE,OAAA,EACgB,IAAA,EACA,UAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAHG,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AAAA,EACd;AACF;AAOO,IAAM,WAAA,GAAN,cAA0B,WAAA,CAAY;AAAA,EAC3C,WAAA,CAAY,SAAiB,UAAA,EAAqB;AAChD,IAAA,KAAA,CAAM,OAAA,EAAS,iBAAiB,UAAU,CAAA;AAC1C,IAAA,IAAA,CAAK,IAAA,GAAO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A;AAC1B,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,IAAA;AAAA,IACP,IAAA,EAAM,IAAA;AAAA,IACN,IAAA,EAAM,IAAA;AAAA,IACN,KAAA,EAAO;AAAA,GACT;AACF;;;ACkCO,IAAM,oBAAA,GAAuB","file":"index.js","sourcesContent":["/**\n * Common error types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/errors\n */\n\n/**\n * Base plugin error\n *\n * All plugin-specific errors should extend this class.\n */\nexport class PluginError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly pluginName?: string\n ) {\n super(message);\n this.name = 'PluginError';\n }\n}\n\n/**\n * API key validation error\n *\n * Thrown when an API key is invalid or has insufficient permissions.\n */\nexport class ApiKeyError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'API_KEY_ERROR', pluginName);\n this.name = 'ApiKeyError';\n }\n}\n\n/**\n * Provider API error\n *\n * Thrown when the provider API returns an error.\n */\nexport class ProviderApiError extends PluginError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly response?: unknown,\n pluginName?: string\n ) {\n super(message, 'PROVIDER_API_ERROR', pluginName);\n this.name = 'ProviderApiError';\n }\n}\n\n/**\n * Rate limit error\n *\n * Thrown when the provider rate limits the request.\n */\nexport class RateLimitError extends ProviderApiError {\n public override readonly code = 'RATE_LIMIT_ERROR';\n\n constructor(\n message: string,\n public readonly retryAfter?: number,\n pluginName?: string\n ) {\n super(message, 429, undefined, pluginName);\n this.name = 'RateLimitError';\n }\n}\n\n/**\n * Configuration error\n *\n * Thrown when plugin configuration is invalid.\n */\nexport class ConfigurationError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'CONFIGURATION_ERROR', pluginName);\n this.name = 'ConfigurationError';\n }\n}\n\n/**\n * Model not found error\n *\n * Thrown when a requested model is not available.\n */\nexport class ModelNotFoundError extends PluginError {\n constructor(\n message: string,\n public readonly modelId?: string,\n pluginName?: string\n ) {\n super(message, 'MODEL_NOT_FOUND', pluginName);\n this.name = 'ModelNotFoundError';\n }\n}\n\n/**\n * Attachment error\n *\n * Thrown when there's an issue processing file attachments.\n */\nexport class AttachmentError extends PluginError {\n constructor(\n message: string,\n public readonly attachmentId?: string,\n pluginName?: string\n ) {\n super(message, 'ATTACHMENT_ERROR', pluginName);\n this.name = 'AttachmentError';\n }\n}\n\n/**\n * Tool execution error\n *\n * Thrown when a tool call fails to execute.\n */\nexport class ToolExecutionError extends PluginError {\n constructor(\n message: string,\n public readonly toolName?: string,\n pluginName?: string\n ) {\n super(message, 'TOOL_EXECUTION_ERROR', pluginName);\n this.name = 'ToolExecutionError';\n }\n}\n","/**\n * Logger types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/logger\n */\n\n/**\n * Log level type\n */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Log context metadata\n */\nexport interface LogContext {\n /** Context identifier (e.g., module name) */\n context?: string;\n /** Additional metadata */\n [key: string]: unknown;\n}\n\n/**\n * Logger interface that plugins can implement or receive\n *\n * This interface is compatible with Quilltap's built-in logger.\n * Plugins can use this interface to accept a logger from the host\n * application or implement their own logging.\n */\nexport interface PluginLogger {\n /**\n * Log a debug message\n * @param message Message to log\n * @param context Optional context metadata\n */\n debug(message: string, context?: LogContext): void;\n\n /**\n * Log an info message\n * @param message Message to log\n * @param context Optional context metadata\n */\n info(message: string, context?: LogContext): void;\n\n /**\n * Log a warning message\n * @param message Message to log\n * @param context Optional context metadata\n */\n warn(message: string, context?: LogContext): void;\n\n /**\n * Log an error message\n * @param message Message to log\n * @param context Optional context metadata\n * @param error Optional error object\n */\n error(message: string, context?: LogContext, error?: Error): void;\n}\n\n/**\n * Simple console-based logger for standalone plugin development\n *\n * This logger writes to the console and is useful for local\n * plugin development and testing.\n *\n * @param prefix Prefix to add to all log messages\n * @param minLevel Minimum log level to output (default: 'info')\n * @returns A PluginLogger instance\n *\n * @example\n * ```typescript\n * const logger = createConsoleLogger('my-plugin', 'debug');\n * logger.debug('Initializing plugin', { version: '1.0.0' });\n * logger.info('Plugin ready');\n * logger.error('Failed to connect', { endpoint: 'api.example.com' }, new Error('Connection refused'));\n * ```\n */\nexport function createConsoleLogger(prefix: string, minLevel: LogLevel = 'info'): PluginLogger {\n const levels: LogLevel[] = ['debug', 'info', 'warn', 'error'];\n const shouldLog = (level: LogLevel): boolean =>\n levels.indexOf(level) >= levels.indexOf(minLevel);\n\n const formatContext = (context?: LogContext): string => {\n if (!context) return '';\n const entries = Object.entries(context)\n .filter(([key]) => key !== 'context')\n .map(([key, value]) => `${key}=${JSON.stringify(value)}`)\n .join(' ');\n return entries ? ` ${entries}` : '';\n };\n\n return {\n debug: (message: string, context?: LogContext): void => {\n if (shouldLog('debug')) {\n console.debug(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n info: (message: string, context?: LogContext): void => {\n if (shouldLog('info')) {\n console.info(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n warn: (message: string, context?: LogContext): void => {\n if (shouldLog('warn')) {\n console.warn(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n error: (message: string, context?: LogContext, error?: Error): void => {\n if (shouldLog('error')) {\n console.error(\n `[${prefix}] ${message}${formatContext(context)}`,\n error ? `\\n${error.stack || error.message}` : ''\n );\n }\n },\n };\n}\n\n/**\n * No-op logger for production or when logging is disabled\n *\n * @returns A PluginLogger that does nothing\n */\nexport function createNoopLogger(): PluginLogger {\n const noop = (): void => {};\n return {\n debug: noop,\n info: noop,\n warn: noop,\n error: noop,\n };\n}\n","/**\n * @quilltap/plugin-types\n *\n * Type definitions for Quilltap plugin development.\n *\n * This package provides TypeScript types and interfaces for building\n * Quilltap plugins, including LLM providers, authentication providers,\n * and utility plugins.\n *\n * @packageDocumentation\n * @module @quilltap/plugin-types\n */\n\n// ============================================================================\n// LLM Types\n// ============================================================================\n\nexport type {\n // Core message types\n FileAttachment,\n LLMMessage,\n JSONSchemaDefinition,\n ResponseFormat,\n LLMParams,\n\n // Response types\n TokenUsage,\n CacheUsage,\n AttachmentResults,\n LLMResponse,\n StreamChunk,\n\n // Image generation types\n ImageGenParams,\n GeneratedImage,\n ImageGenResponse,\n\n // Model metadata\n ModelWarningLevel,\n ModelWarning,\n ModelMetadata,\n\n // Provider interfaces\n LLMProvider,\n ImageGenProvider,\n} from './llm/base';\n\nexport type {\n // Tool definitions\n OpenAIToolDefinition,\n UniversalTool,\n AnthropicToolDefinition,\n GoogleToolDefinition,\n\n // Tool calls\n ToolCall,\n ToolCallRequest,\n ToolResult,\n ToolFormatOptions,\n} from './llm/tools';\n\n// ============================================================================\n// Plugin Types\n// ============================================================================\n\nexport type {\n // Provider plugin types\n ProviderMetadata,\n ProviderConfigRequirements,\n ProviderCapabilities,\n AttachmentSupport,\n ModelInfo,\n EmbeddingModelInfo,\n ImageGenerationModelInfo,\n ImageProviderConstraints,\n IconProps,\n LLMProviderPlugin,\n ProviderPluginExport,\n // Runtime configuration types\n MessageFormatSupport,\n CheapModelConfig,\n ToolFormatType,\n} from './plugins/provider';\n\nexport type {\n // Manifest types\n PluginCapability,\n PluginCategory,\n PluginStatus,\n PluginAuthor,\n PluginCompatibility,\n ProviderConfig,\n PluginPermissions,\n PluginManifest,\n InstalledPluginInfo,\n} from './plugins/manifest';\n\nexport type {\n // Theme plugin types\n ColorPalette,\n Typography,\n Spacing,\n Effects,\n ThemeTokens,\n FontDefinition,\n EmbeddedFont,\n ThemeMetadata,\n ThemePlugin,\n ThemePluginExport,\n} from './plugins/theme';\n\nexport type {\n // Roleplay template plugin types\n RoleplayTemplateConfig,\n RoleplayTemplateMetadata,\n RoleplayTemplatePlugin,\n RoleplayTemplatePluginExport,\n} from './plugins/roleplay-template';\n\nexport type {\n // Tool plugin types\n ToolMetadata,\n ToolExecutionContext,\n ToolExecutionResult,\n ToolPlugin,\n ToolPluginExport,\n} from './plugins/tool';\n\nexport type {\n // File storage plugin types\n FileBackendCapabilities,\n FileBackendMetadata,\n FileMetadata,\n FileStorageBackend,\n FileStorageConfigField,\n FileStorageProviderPlugin,\n FileStoragePluginExport,\n} from './plugins/file-storage';\n\n// ============================================================================\n// Common Types\n// ============================================================================\n\nexport type { LogLevel, LogContext, PluginLogger } from './common/logger';\n\n// Error classes (these are values, not just types)\nexport {\n PluginError,\n ApiKeyError,\n ProviderApiError,\n RateLimitError,\n ConfigurationError,\n ModelNotFoundError,\n AttachmentError,\n ToolExecutionError,\n} from './common/errors';\n\n// Logger factories\nexport { createConsoleLogger, createNoopLogger } from './common/logger';\n\n// ============================================================================\n// Version\n// ============================================================================\n\n/**\n * Version of the plugin-types package.\n * Can be used at runtime to check compatibility.\n */\nexport const PLUGIN_TYPES_VERSION = '1.3.0';\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -105,7 +105,7 @@ function createNoopLogger() {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
// src/index.ts
|
|
108
|
-
var PLUGIN_TYPES_VERSION = "1.
|
|
108
|
+
var PLUGIN_TYPES_VERSION = "1.3.0";
|
|
109
109
|
|
|
110
110
|
export { ApiKeyError, AttachmentError, ConfigurationError, ModelNotFoundError, PLUGIN_TYPES_VERSION, PluginError, ProviderApiError, RateLimitError, ToolExecutionError, createConsoleLogger, createNoopLogger };
|
|
111
111
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/errors.ts","../src/common/logger.ts","../src/index.ts"],"names":[],"mappings":";AAWO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EACrC,WAAA,CACE,OAAA,EACgB,IAAA,EACA,UAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAHG,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AAAA,EACd;AACF;AAOO,IAAM,WAAA,GAAN,cAA0B,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AM,OAAO,CAAA,CAAA,GAAK;AAAA,SAChD;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF;AAOO,SAAS,gBAAA,GAAiC;AAC/C,EAAA,MAAM,OAAO,MAAY;AAAA,EAAC,CAAA;AAC1B,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,IAAA;AAAA,IACP,IAAA,EAAM,IAAA;AAAA,IACN,IAAA,EAAM,IAAA;AAAA,IACN,KAAA,EAAO;AAAA,GACT;AACF;;;ACcO,IAAM,oBAAA,GAAuB","file":"index.mjs","sourcesContent":["/**\n * Common error types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/errors\n */\n\n/**\n * Base plugin error\n *\n * All plugin-specific errors should extend this class.\n */\nexport class PluginError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly pluginName?: string\n ) {\n super(message);\n this.name = 'PluginError';\n }\n}\n\n/**\n * API key validation error\n *\n * Thrown when an API key is invalid or has insufficient permissions.\n */\nexport class ApiKeyError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'API_KEY_ERROR', pluginName);\n this.name = 'ApiKeyError';\n }\n}\n\n/**\n * Provider API error\n *\n * Thrown when the provider API returns an error.\n */\nexport class ProviderApiError extends PluginError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly response?: unknown,\n pluginName?: string\n ) {\n super(message, 'PROVIDER_API_ERROR', pluginName);\n this.name = 'ProviderApiError';\n }\n}\n\n/**\n * Rate limit error\n *\n * Thrown when the provider rate limits the request.\n */\nexport class RateLimitError extends ProviderApiError {\n public override readonly code = 'RATE_LIMIT_ERROR';\n\n constructor(\n message: string,\n public readonly retryAfter?: number,\n pluginName?: string\n ) {\n super(message, 429, undefined, pluginName);\n this.name = 'RateLimitError';\n }\n}\n\n/**\n * Configuration error\n *\n * Thrown when plugin configuration is invalid.\n */\nexport class ConfigurationError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'CONFIGURATION_ERROR', pluginName);\n this.name = 'ConfigurationError';\n }\n}\n\n/**\n * Model not found error\n *\n * Thrown when a requested model is not available.\n */\nexport class ModelNotFoundError extends PluginError {\n constructor(\n message: string,\n public readonly modelId?: string,\n pluginName?: string\n ) {\n super(message, 'MODEL_NOT_FOUND', pluginName);\n this.name = 'ModelNotFoundError';\n }\n}\n\n/**\n * Attachment error\n *\n * Thrown when there's an issue processing file attachments.\n */\nexport class AttachmentError extends PluginError {\n constructor(\n message: string,\n public readonly attachmentId?: string,\n pluginName?: string\n ) {\n super(message, 'ATTACHMENT_ERROR', pluginName);\n this.name = 'AttachmentError';\n }\n}\n\n/**\n * Tool execution error\n *\n * Thrown when a tool call fails to execute.\n */\nexport class ToolExecutionError extends PluginError {\n constructor(\n message: string,\n public readonly toolName?: string,\n pluginName?: string\n ) {\n super(message, 'TOOL_EXECUTION_ERROR', pluginName);\n this.name = 'ToolExecutionError';\n }\n}\n","/**\n * Logger types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/logger\n */\n\n/**\n * Log level type\n */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Log context metadata\n */\nexport interface LogContext {\n /** Context identifier (e.g., module name) */\n context?: string;\n /** Additional metadata */\n [key: string]: unknown;\n}\n\n/**\n * Logger interface that plugins can implement or receive\n *\n * This interface is compatible with Quilltap's built-in logger.\n * Plugins can use this interface to accept a logger from the host\n * application or implement their own logging.\n */\nexport interface PluginLogger {\n /**\n * Log a debug message\n * @param message Message to log\n * @param context Optional context metadata\n */\n debug(message: string, context?: LogContext): void;\n\n /**\n * Log an info message\n * @param message Message to log\n * @param context Optional context metadata\n */\n info(message: string, context?: LogContext): void;\n\n /**\n * Log a warning message\n * @param message Message to log\n * @param context Optional context metadata\n */\n warn(message: string, context?: LogContext): void;\n\n /**\n * Log an error message\n * @param message Message to log\n * @param context Optional context metadata\n * @param error Optional error object\n */\n error(message: string, context?: LogContext, error?: Error): void;\n}\n\n/**\n * Simple console-based logger for standalone plugin development\n *\n * This logger writes to the console and is useful for local\n * plugin development and testing.\n *\n * @param prefix Prefix to add to all log messages\n * @param minLevel Minimum log level to output (default: 'info')\n * @returns A PluginLogger instance\n *\n * @example\n * ```typescript\n * const logger = createConsoleLogger('my-plugin', 'debug');\n * logger.debug('Initializing plugin', { version: '1.0.0' });\n * logger.info('Plugin ready');\n * logger.error('Failed to connect', { endpoint: 'api.example.com' }, new Error('Connection refused'));\n * ```\n */\nexport function createConsoleLogger(prefix: string, minLevel: LogLevel = 'info'): PluginLogger {\n const levels: LogLevel[] = ['debug', 'info', 'warn', 'error'];\n const shouldLog = (level: LogLevel): boolean =>\n levels.indexOf(level) >= levels.indexOf(minLevel);\n\n const formatContext = (context?: LogContext): string => {\n if (!context) return '';\n const entries = Object.entries(context)\n .filter(([key]) => key !== 'context')\n .map(([key, value]) => `${key}=${JSON.stringify(value)}`)\n .join(' ');\n return entries ? ` ${entries}` : '';\n };\n\n return {\n debug: (message: string, context?: LogContext): void => {\n if (shouldLog('debug')) {\n console.debug(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n info: (message: string, context?: LogContext): void => {\n if (shouldLog('info')) {\n console.info(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n warn: (message: string, context?: LogContext): void => {\n if (shouldLog('warn')) {\n console.warn(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n error: (message: string, context?: LogContext, error?: Error): void => {\n if (shouldLog('error')) {\n console.error(\n `[${prefix}] ${message}${formatContext(context)}`,\n error ? `\\n${error.stack || error.message}` : ''\n );\n }\n },\n };\n}\n\n/**\n * No-op logger for production or when logging is disabled\n *\n * @returns A PluginLogger that does nothing\n */\nexport function createNoopLogger(): PluginLogger {\n const noop = (): void => {};\n return {\n debug: noop,\n info: noop,\n warn: noop,\n error: noop,\n };\n}\n","/**\n * @quilltap/plugin-types\n *\n * Type definitions for Quilltap plugin development.\n *\n * This package provides TypeScript types and interfaces for building\n * Quilltap plugins, including LLM providers, authentication providers,\n * and utility plugins.\n *\n * @packageDocumentation\n * @module @quilltap/plugin-types\n */\n\n// ============================================================================\n// LLM Types\n// ============================================================================\n\nexport type {\n // Core message types\n FileAttachment,\n LLMMessage,\n JSONSchemaDefinition,\n ResponseFormat,\n LLMParams,\n\n // Response types\n TokenUsage,\n CacheUsage,\n AttachmentResults,\n LLMResponse,\n StreamChunk,\n\n // Image generation types\n ImageGenParams,\n GeneratedImage,\n ImageGenResponse,\n\n // Model metadata\n ModelWarningLevel,\n ModelWarning,\n ModelMetadata,\n\n // Provider interfaces\n LLMProvider,\n ImageGenProvider,\n} from './llm/base';\n\nexport type {\n // Tool definitions\n OpenAIToolDefinition,\n UniversalTool,\n AnthropicToolDefinition,\n GoogleToolDefinition,\n\n // Tool calls\n ToolCall,\n ToolCallRequest,\n ToolResult,\n ToolFormatOptions,\n} from './llm/tools';\n\n// ============================================================================\n// Plugin Types\n// ============================================================================\n\nexport type {\n // Provider plugin types\n ProviderMetadata,\n ProviderConfigRequirements,\n ProviderCapabilities,\n AttachmentSupport,\n ModelInfo,\n EmbeddingModelInfo,\n ImageGenerationModelInfo,\n ImageProviderConstraints,\n IconProps,\n LLMProviderPlugin,\n ProviderPluginExport,\n // Runtime configuration types\n MessageFormatSupport,\n CheapModelConfig,\n ToolFormatType,\n} from './plugins/provider';\n\nexport type {\n // Manifest types\n PluginCapability,\n PluginCategory,\n PluginStatus,\n PluginAuthor,\n PluginCompatibility,\n ProviderConfig,\n PluginPermissions,\n PluginManifest,\n InstalledPluginInfo,\n} from './plugins/manifest';\n\nexport type {\n // Theme plugin types\n ColorPalette,\n Typography,\n Spacing,\n Effects,\n ThemeTokens,\n FontDefinition,\n EmbeddedFont,\n ThemeMetadata,\n ThemePlugin,\n ThemePluginExport,\n} from './plugins/theme';\n\nexport type {\n // Roleplay template plugin types\n RoleplayTemplateConfig,\n RoleplayTemplateMetadata,\n RoleplayTemplatePlugin,\n RoleplayTemplatePluginExport,\n} from './plugins/roleplay-template';\n\n// ============================================================================\n// Common Types\n// ============================================================================\n\nexport type { LogLevel, LogContext, PluginLogger } from './common/logger';\n\n// Error classes (these are values, not just types)\nexport {\n PluginError,\n ApiKeyError,\n ProviderApiError,\n RateLimitError,\n ConfigurationError,\n ModelNotFoundError,\n AttachmentError,\n ToolExecutionError,\n} from './common/errors';\n\n// Logger factories\nexport { createConsoleLogger, createNoopLogger } from './common/logger';\n\n// ============================================================================\n// Version\n// ============================================================================\n\n/**\n * Version of the plugin-types package.\n * Can be used at runtime to check compatibility.\n */\nexport const PLUGIN_TYPES_VERSION = '1.2.0';\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/common/errors.ts","../src/common/logger.ts","../src/index.ts"],"names":[],"mappings":";AAWO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EACrC,WAAA,CACE,OAAA,EACgB,IAAA,EACA,UAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAHG,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AAAA,EACd;AACF;AAOO,IAAM,WAAA,GAAN,cAA0B,WAAA,CAAY;AAAA,EAC3C,WAAA,CAAY,SAAiB,UAAA,EAAqB;AAChD,IAAA,KAAA,CAAM,OAAA,EAAS,iBAAiB,UAAU,CAAA;AAC1C,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AAAA,EACd;AACF;AAOO,IAAM,gBAAA,GAAN,cAA+B,WAAA,CAAY;AAAA,EAChD,WAAA,CACE,OAAA,EACgB,UAAA,EACA,QAAA,EAChB,UAAA,EACA;AACA,IAAA,KAAA,CAAM,OAAA,EAAS,sBAAsB,UAAU,CAAA;AAJ/B,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AAIhB,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AAAA,EACd;AACF;AAOO,IAAM,cAAA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,QAAA,OAAA,CAAQ,IAAA,CAAK,IAAI,MAAM,CAAA,EAAA,EAAK,OAAO,CAAA,EAAG,aAAA,CAAc,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,MAChE;AAAA,IACF,CAAA;AAAA,IAEA,IAAA,EAAM,CAAC,OAAA,EAAiB,OAAA,KAA+B;AACrD,MAAA,IAAI,SAAA,CAAU,MAAM,CAAA,EAAG;AACrB,QAAA,OAAA,CAAQ,IAAA,CAAK,IAAI,MAAM,CAAA,EAAA,EAAK,OAAO,CAAA,EAAG,aAAA,CAAc,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,MAChE;AAAA,IACF,CAAA;AAAA,IAEA,KAAA,EAAO,CAAC,OAAA,EAAiB,OAAA,EAAsB,KAAA,KAAwB;AACrE,MAAA,IAAI,SAAA,CAAU,OAAO,CAAA,EAAG;AACtB,QAAA,OAAA,CAAQ,KAAA;AAAA,UACN,IAAI,MAAM,CAAA,EAAA,EAAK,OAAO,CAAA,EAAG,aAAA,CAAc,OAAO,CAAC,CAAA,CAAA;AAAA,UAC/C,KAAA,GAAQ;AAAA,EAAK,KAAA,CAAM,KAAA,IAAS,KAAA,CAAM,OAAO,CAAA,CAAA,GAAK;AAAA,SAChD;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF;AAOO,SAAS,gBAAA,GAAiC;AAC/C,EAAA,MAAM,OAAO,MAAY;AAAA,EAAC,CAAA;AAC1B,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,IAAA;AAAA,IACP,IAAA,EAAM,IAAA;AAAA,IACN,IAAA,EAAM,IAAA;AAAA,IACN,KAAA,EAAO;AAAA,GACT;AACF;;;ACkCO,IAAM,oBAAA,GAAuB","file":"index.mjs","sourcesContent":["/**\n * Common error types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/errors\n */\n\n/**\n * Base plugin error\n *\n * All plugin-specific errors should extend this class.\n */\nexport class PluginError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly pluginName?: string\n ) {\n super(message);\n this.name = 'PluginError';\n }\n}\n\n/**\n * API key validation error\n *\n * Thrown when an API key is invalid or has insufficient permissions.\n */\nexport class ApiKeyError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'API_KEY_ERROR', pluginName);\n this.name = 'ApiKeyError';\n }\n}\n\n/**\n * Provider API error\n *\n * Thrown when the provider API returns an error.\n */\nexport class ProviderApiError extends PluginError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly response?: unknown,\n pluginName?: string\n ) {\n super(message, 'PROVIDER_API_ERROR', pluginName);\n this.name = 'ProviderApiError';\n }\n}\n\n/**\n * Rate limit error\n *\n * Thrown when the provider rate limits the request.\n */\nexport class RateLimitError extends ProviderApiError {\n public override readonly code = 'RATE_LIMIT_ERROR';\n\n constructor(\n message: string,\n public readonly retryAfter?: number,\n pluginName?: string\n ) {\n super(message, 429, undefined, pluginName);\n this.name = 'RateLimitError';\n }\n}\n\n/**\n * Configuration error\n *\n * Thrown when plugin configuration is invalid.\n */\nexport class ConfigurationError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'CONFIGURATION_ERROR', pluginName);\n this.name = 'ConfigurationError';\n }\n}\n\n/**\n * Model not found error\n *\n * Thrown when a requested model is not available.\n */\nexport class ModelNotFoundError extends PluginError {\n constructor(\n message: string,\n public readonly modelId?: string,\n pluginName?: string\n ) {\n super(message, 'MODEL_NOT_FOUND', pluginName);\n this.name = 'ModelNotFoundError';\n }\n}\n\n/**\n * Attachment error\n *\n * Thrown when there's an issue processing file attachments.\n */\nexport class AttachmentError extends PluginError {\n constructor(\n message: string,\n public readonly attachmentId?: string,\n pluginName?: string\n ) {\n super(message, 'ATTACHMENT_ERROR', pluginName);\n this.name = 'AttachmentError';\n }\n}\n\n/**\n * Tool execution error\n *\n * Thrown when a tool call fails to execute.\n */\nexport class ToolExecutionError extends PluginError {\n constructor(\n message: string,\n public readonly toolName?: string,\n pluginName?: string\n ) {\n super(message, 'TOOL_EXECUTION_ERROR', pluginName);\n this.name = 'ToolExecutionError';\n }\n}\n","/**\n * Logger types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/logger\n */\n\n/**\n * Log level type\n */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Log context metadata\n */\nexport interface LogContext {\n /** Context identifier (e.g., module name) */\n context?: string;\n /** Additional metadata */\n [key: string]: unknown;\n}\n\n/**\n * Logger interface that plugins can implement or receive\n *\n * This interface is compatible with Quilltap's built-in logger.\n * Plugins can use this interface to accept a logger from the host\n * application or implement their own logging.\n */\nexport interface PluginLogger {\n /**\n * Log a debug message\n * @param message Message to log\n * @param context Optional context metadata\n */\n debug(message: string, context?: LogContext): void;\n\n /**\n * Log an info message\n * @param message Message to log\n * @param context Optional context metadata\n */\n info(message: string, context?: LogContext): void;\n\n /**\n * Log a warning message\n * @param message Message to log\n * @param context Optional context metadata\n */\n warn(message: string, context?: LogContext): void;\n\n /**\n * Log an error message\n * @param message Message to log\n * @param context Optional context metadata\n * @param error Optional error object\n */\n error(message: string, context?: LogContext, error?: Error): void;\n}\n\n/**\n * Simple console-based logger for standalone plugin development\n *\n * This logger writes to the console and is useful for local\n * plugin development and testing.\n *\n * @param prefix Prefix to add to all log messages\n * @param minLevel Minimum log level to output (default: 'info')\n * @returns A PluginLogger instance\n *\n * @example\n * ```typescript\n * const logger = createConsoleLogger('my-plugin', 'debug');\n * logger.debug('Initializing plugin', { version: '1.0.0' });\n * logger.info('Plugin ready');\n * logger.error('Failed to connect', { endpoint: 'api.example.com' }, new Error('Connection refused'));\n * ```\n */\nexport function createConsoleLogger(prefix: string, minLevel: LogLevel = 'info'): PluginLogger {\n const levels: LogLevel[] = ['debug', 'info', 'warn', 'error'];\n const shouldLog = (level: LogLevel): boolean =>\n levels.indexOf(level) >= levels.indexOf(minLevel);\n\n const formatContext = (context?: LogContext): string => {\n if (!context) return '';\n const entries = Object.entries(context)\n .filter(([key]) => key !== 'context')\n .map(([key, value]) => `${key}=${JSON.stringify(value)}`)\n .join(' ');\n return entries ? ` ${entries}` : '';\n };\n\n return {\n debug: (message: string, context?: LogContext): void => {\n if (shouldLog('debug')) {\n console.debug(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n info: (message: string, context?: LogContext): void => {\n if (shouldLog('info')) {\n console.info(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n warn: (message: string, context?: LogContext): void => {\n if (shouldLog('warn')) {\n console.warn(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n error: (message: string, context?: LogContext, error?: Error): void => {\n if (shouldLog('error')) {\n console.error(\n `[${prefix}] ${message}${formatContext(context)}`,\n error ? `\\n${error.stack || error.message}` : ''\n );\n }\n },\n };\n}\n\n/**\n * No-op logger for production or when logging is disabled\n *\n * @returns A PluginLogger that does nothing\n */\nexport function createNoopLogger(): PluginLogger {\n const noop = (): void => {};\n return {\n debug: noop,\n info: noop,\n warn: noop,\n error: noop,\n };\n}\n","/**\n * @quilltap/plugin-types\n *\n * Type definitions for Quilltap plugin development.\n *\n * This package provides TypeScript types and interfaces for building\n * Quilltap plugins, including LLM providers, authentication providers,\n * and utility plugins.\n *\n * @packageDocumentation\n * @module @quilltap/plugin-types\n */\n\n// ============================================================================\n// LLM Types\n// ============================================================================\n\nexport type {\n // Core message types\n FileAttachment,\n LLMMessage,\n JSONSchemaDefinition,\n ResponseFormat,\n LLMParams,\n\n // Response types\n TokenUsage,\n CacheUsage,\n AttachmentResults,\n LLMResponse,\n StreamChunk,\n\n // Image generation types\n ImageGenParams,\n GeneratedImage,\n ImageGenResponse,\n\n // Model metadata\n ModelWarningLevel,\n ModelWarning,\n ModelMetadata,\n\n // Provider interfaces\n LLMProvider,\n ImageGenProvider,\n} from './llm/base';\n\nexport type {\n // Tool definitions\n OpenAIToolDefinition,\n UniversalTool,\n AnthropicToolDefinition,\n GoogleToolDefinition,\n\n // Tool calls\n ToolCall,\n ToolCallRequest,\n ToolResult,\n ToolFormatOptions,\n} from './llm/tools';\n\n// ============================================================================\n// Plugin Types\n// ============================================================================\n\nexport type {\n // Provider plugin types\n ProviderMetadata,\n ProviderConfigRequirements,\n ProviderCapabilities,\n AttachmentSupport,\n ModelInfo,\n EmbeddingModelInfo,\n ImageGenerationModelInfo,\n ImageProviderConstraints,\n IconProps,\n LLMProviderPlugin,\n ProviderPluginExport,\n // Runtime configuration types\n MessageFormatSupport,\n CheapModelConfig,\n ToolFormatType,\n} from './plugins/provider';\n\nexport type {\n // Manifest types\n PluginCapability,\n PluginCategory,\n PluginStatus,\n PluginAuthor,\n PluginCompatibility,\n ProviderConfig,\n PluginPermissions,\n PluginManifest,\n InstalledPluginInfo,\n} from './plugins/manifest';\n\nexport type {\n // Theme plugin types\n ColorPalette,\n Typography,\n Spacing,\n Effects,\n ThemeTokens,\n FontDefinition,\n EmbeddedFont,\n ThemeMetadata,\n ThemePlugin,\n ThemePluginExport,\n} from './plugins/theme';\n\nexport type {\n // Roleplay template plugin types\n RoleplayTemplateConfig,\n RoleplayTemplateMetadata,\n RoleplayTemplatePlugin,\n RoleplayTemplatePluginExport,\n} from './plugins/roleplay-template';\n\nexport type {\n // Tool plugin types\n ToolMetadata,\n ToolExecutionContext,\n ToolExecutionResult,\n ToolPlugin,\n ToolPluginExport,\n} from './plugins/tool';\n\nexport type {\n // File storage plugin types\n FileBackendCapabilities,\n FileBackendMetadata,\n FileMetadata,\n FileStorageBackend,\n FileStorageConfigField,\n FileStorageProviderPlugin,\n FileStoragePluginExport,\n} from './plugins/file-storage';\n\n// ============================================================================\n// Common Types\n// ============================================================================\n\nexport type { LogLevel, LogContext, PluginLogger } from './common/logger';\n\n// Error classes (these are values, not just types)\nexport {\n PluginError,\n ApiKeyError,\n ProviderApiError,\n RateLimitError,\n ConfigurationError,\n ModelNotFoundError,\n AttachmentError,\n ToolExecutionError,\n} from './common/errors';\n\n// Logger factories\nexport { createConsoleLogger, createNoopLogger } from './common/logger';\n\n// ============================================================================\n// Version\n// ============================================================================\n\n/**\n * Version of the plugin-types package.\n * Can be used at runtime to check compatibility.\n */\nexport const PLUGIN_TYPES_VERSION = '1.3.0';\n"]}
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { B as AnnotationButton, A as AttachmentSupport, p as ColorPalette, G as DialogueDetection, r as Effects, t as EmbeddedFont, E as EmbeddingModelInfo, F as FontDefinition, d as IconProps, I as ImageGenerationModelInfo, c as ImageProviderConstraints, o as InstalledPluginInfo, L as LLMProviderPlugin, M as ModelInfo, j as PluginAuthor, g as PluginCapability, h as PluginCategory, k as PluginCompatibility, n as PluginManifest, m as PluginPermissions, i as PluginStatus, b as ProviderCapabilities, l as ProviderConfig, a as ProviderConfigRequirements, P as ProviderMetadata, e as ProviderPluginExport, D as RenderingPattern, R as RoleplayTemplateConfig, x as RoleplayTemplateMetadata, y as RoleplayTemplatePlugin, z as RoleplayTemplatePluginExport, S as Spacing, u as ThemeMetadata, v as ThemePlugin, w as ThemePluginExport, s as ThemeTokens, q as Typography } from '../index-
|
|
1
|
+
export { B as AnnotationButton, A as AttachmentSupport, p as ColorPalette, G as DialogueDetection, r as Effects, t as EmbeddedFont, E as EmbeddingModelInfo, F as FontDefinition, d as IconProps, I as ImageGenerationModelInfo, c as ImageProviderConstraints, o as InstalledPluginInfo, L as LLMProviderPlugin, M as ModelInfo, j as PluginAuthor, g as PluginCapability, h as PluginCategory, k as PluginCompatibility, n as PluginManifest, m as PluginPermissions, i as PluginStatus, b as ProviderCapabilities, l as ProviderConfig, a as ProviderConfigRequirements, P as ProviderMetadata, e as ProviderPluginExport, D as RenderingPattern, R as RoleplayTemplateConfig, x as RoleplayTemplateMetadata, y as RoleplayTemplatePlugin, z as RoleplayTemplatePluginExport, S as Spacing, u as ThemeMetadata, v as ThemePlugin, w as ThemePluginExport, s as ThemeTokens, q as Typography } from '../index-BefqyBNF.mjs';
|
|
2
2
|
import 'react';
|
|
3
3
|
import '../llm/index.mjs';
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { B as AnnotationButton, A as AttachmentSupport, p as ColorPalette, G as DialogueDetection, r as Effects, t as EmbeddedFont, E as EmbeddingModelInfo, F as FontDefinition, d as IconProps, I as ImageGenerationModelInfo, c as ImageProviderConstraints, o as InstalledPluginInfo, L as LLMProviderPlugin, M as ModelInfo, j as PluginAuthor, g as PluginCapability, h as PluginCategory, k as PluginCompatibility, n as PluginManifest, m as PluginPermissions, i as PluginStatus, b as ProviderCapabilities, l as ProviderConfig, a as ProviderConfigRequirements, P as ProviderMetadata, e as ProviderPluginExport, D as RenderingPattern, R as RoleplayTemplateConfig, x as RoleplayTemplateMetadata, y as RoleplayTemplatePlugin, z as RoleplayTemplatePluginExport, S as Spacing, u as ThemeMetadata, v as ThemePlugin, w as ThemePluginExport, s as ThemeTokens, q as Typography } from '../index-
|
|
1
|
+
export { B as AnnotationButton, A as AttachmentSupport, p as ColorPalette, G as DialogueDetection, r as Effects, t as EmbeddedFont, E as EmbeddingModelInfo, F as FontDefinition, d as IconProps, I as ImageGenerationModelInfo, c as ImageProviderConstraints, o as InstalledPluginInfo, L as LLMProviderPlugin, M as ModelInfo, j as PluginAuthor, g as PluginCapability, h as PluginCategory, k as PluginCompatibility, n as PluginManifest, m as PluginPermissions, i as PluginStatus, b as ProviderCapabilities, l as ProviderConfig, a as ProviderConfigRequirements, P as ProviderMetadata, e as ProviderPluginExport, D as RenderingPattern, R as RoleplayTemplateConfig, x as RoleplayTemplateMetadata, y as RoleplayTemplatePlugin, z as RoleplayTemplatePluginExport, S as Spacing, u as ThemeMetadata, v as ThemePlugin, w as ThemePluginExport, s as ThemeTokens, q as Typography } from '../index-9cCc5tg5.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import '../llm/index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quilltap/plugin-types",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Type definitions for Quilltap plugin development",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
+
"@types/node": "^20.0.0",
|
|
50
51
|
"@types/react": "^18.2.0",
|
|
51
52
|
"tsup": "^8.0.0",
|
|
52
53
|
"typescript": "^5.3.0"
|
|
@@ -58,7 +59,8 @@
|
|
|
58
59
|
"typescript",
|
|
59
60
|
"llm",
|
|
60
61
|
"ai",
|
|
61
|
-
"provider"
|
|
62
|
+
"provider",
|
|
63
|
+
"tools"
|
|
62
64
|
],
|
|
63
65
|
"author": {
|
|
64
66
|
"name": "Foundry-9 LLC",
|