@quilltap/plugin-types 1.0.1 → 1.0.3

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 CHANGED
@@ -5,13 +5,35 @@ 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.0.1] - 2024-12-30
8
+ ## [1.0.3] - 2025-12-30
9
+
10
+ ### Added
11
+
12
+ - New runtime configuration types for `LLMProviderPlugin`:
13
+ - `MessageFormatSupport` - configures name field support for multi-character chats
14
+ - `CheapModelConfig` - specifies recommended cheap models for background tasks
15
+ - `ToolFormatType` - declares which tool format the provider uses ('openai' | 'anthropic' | 'google')
16
+ - New optional properties on `LLMProviderPlugin`:
17
+ - `messageFormat?: MessageFormatSupport`
18
+ - `charsPerToken?: number` - token estimation multiplier (default: 3.5)
19
+ - `toolFormat?: ToolFormatType` - tool format type
20
+ - `cheapModels?: CheapModelConfig` - cheap model configuration
21
+ - `defaultContextWindow?: number` - fallback context window (default: 8192)
22
+ - Added `pricing?: { input: number; output: number }` to `ModelInfo` interface
23
+
24
+ ## [1.0.2] - 2025-12-30
25
+
26
+ ### Fixed
27
+
28
+ - Removed unused eslint-disable directives
29
+
30
+ ## [1.0.1] - 2025-12-30
9
31
 
10
32
  ### Fixed
11
33
 
12
34
  - Changed `formatTools` and `parseToolCalls` signatures to use `any` instead of `unknown` for backward compatibility with existing plugin implementations
13
35
 
14
- ## [1.0.0] - 2024-12-30
36
+ ## [1.0.0] - 2025-12-30
15
37
 
16
38
  ### Added
17
39
 
@@ -0,0 +1,496 @@
1
+ import { ReactNode } from 'react';
2
+ import { LLMProvider, ImageGenProvider, ToolFormatOptions, ToolCallRequest } from './llm/index.mjs';
3
+
4
+ /**
5
+ * Provider Plugin Interface types for Quilltap plugin development
6
+ *
7
+ * @module @quilltap/plugin-types/plugins/provider
8
+ */
9
+
10
+ /**
11
+ * Provider metadata for UI display and identification
12
+ */
13
+ interface ProviderMetadata {
14
+ /** Internal identifier for the provider (e.g., 'OPENAI', 'ANTHROPIC') */
15
+ providerName: string;
16
+ /** Human-readable display name for UI (e.g., 'OpenAI', 'Anthropic') */
17
+ displayName: string;
18
+ /** Short description of the provider */
19
+ description: string;
20
+ /** Short abbreviation for icon display (e.g., 'OAI', 'ANT') */
21
+ abbreviation: string;
22
+ /** Tailwind CSS color classes for UI styling */
23
+ colors: {
24
+ /** Background color class (e.g., 'bg-green-100') */
25
+ bg: string;
26
+ /** Text color class (e.g., 'text-green-800') */
27
+ text: string;
28
+ /** Icon color class (e.g., 'text-green-600') */
29
+ icon: string;
30
+ };
31
+ }
32
+ /**
33
+ * Configuration requirements for the provider
34
+ */
35
+ interface ProviderConfigRequirements {
36
+ /** Whether this provider requires an API key */
37
+ requiresApiKey: boolean;
38
+ /** Whether this provider requires a custom base URL */
39
+ requiresBaseUrl: boolean;
40
+ /** Label text for API key input field */
41
+ apiKeyLabel?: string;
42
+ /** Label text for base URL input field */
43
+ baseUrlLabel?: string;
44
+ /** Placeholder text for base URL input */
45
+ baseUrlPlaceholder?: string;
46
+ /** Default value for base URL */
47
+ baseUrlDefault?: string;
48
+ /** Deprecated: use baseUrlDefault instead */
49
+ defaultBaseUrl?: string;
50
+ }
51
+ /**
52
+ * Provider capability flags
53
+ */
54
+ interface ProviderCapabilities {
55
+ /** Whether the provider supports chat completions */
56
+ chat: boolean;
57
+ /** Whether the provider supports image generation */
58
+ imageGeneration: boolean;
59
+ /** Whether the provider supports text embeddings */
60
+ embeddings: boolean;
61
+ /** Whether the provider supports web search functionality */
62
+ webSearch: boolean;
63
+ }
64
+ /**
65
+ * Attachment/file support configuration
66
+ */
67
+ interface AttachmentSupport {
68
+ /** Whether this provider supports file attachments */
69
+ supportsAttachments: boolean;
70
+ /** Array of MIME types supported for attachments */
71
+ supportedMimeTypes: string[];
72
+ /** Human-readable description of attachment support */
73
+ description: string;
74
+ /** Additional notes about attachment support or limitations */
75
+ notes?: string;
76
+ /** Maximum file size in bytes */
77
+ maxFileSize?: number;
78
+ /** Maximum number of files per request */
79
+ maxFiles?: number;
80
+ }
81
+ /**
82
+ * Information about a specific model
83
+ */
84
+ interface ModelInfo {
85
+ /** Unique identifier for the model */
86
+ id: string;
87
+ /** Human-readable name of the model */
88
+ name: string;
89
+ /** Context window size (tokens) */
90
+ contextWindow?: number;
91
+ /** Maximum output tokens for this model */
92
+ maxOutputTokens?: number;
93
+ /** Whether this model supports image attachments */
94
+ supportsImages?: boolean;
95
+ /** Whether this model supports tool/function calling */
96
+ supportsTools?: boolean;
97
+ /** Description of the model */
98
+ description?: string;
99
+ /** Pricing information */
100
+ pricing?: {
101
+ /** Price per 1M input tokens */
102
+ input: number;
103
+ /** Price per 1M output tokens */
104
+ output: number;
105
+ };
106
+ }
107
+ /**
108
+ * Information about an embedding model
109
+ */
110
+ interface EmbeddingModelInfo {
111
+ /** Unique identifier for the embedding model */
112
+ id: string;
113
+ /** Human-readable name of the model */
114
+ name: string;
115
+ /** Dimensions of the embedding vector output */
116
+ dimensions?: number;
117
+ /** Description of the model's characteristics */
118
+ description?: string;
119
+ }
120
+ /**
121
+ * Information about an image generation model
122
+ */
123
+ interface ImageGenerationModelInfo {
124
+ /** Unique identifier for the model */
125
+ id: string;
126
+ /** Human-readable name of the model */
127
+ name: string;
128
+ /** Supported aspect ratios (e.g., ['1:1', '16:9']) */
129
+ supportedAspectRatios?: string[];
130
+ /** Supported image sizes (e.g., ['1024x1024', '512x512']) */
131
+ supportedSizes?: string[];
132
+ /** Description of the model */
133
+ description?: string;
134
+ }
135
+ /**
136
+ * Constraints for image generation
137
+ */
138
+ interface ImageProviderConstraints {
139
+ /** Maximum bytes allowed for image generation prompt */
140
+ maxPromptBytes?: number;
141
+ /** Warning message about prompt constraints */
142
+ promptConstraintWarning?: string;
143
+ /** Maximum images per request */
144
+ maxImagesPerRequest?: number;
145
+ /** Supported aspect ratios */
146
+ supportedAspectRatios?: string[];
147
+ /** Supported image sizes */
148
+ supportedSizes?: string[];
149
+ }
150
+ /**
151
+ * Icon component props
152
+ */
153
+ interface IconProps {
154
+ /** CSS class for styling */
155
+ className?: string;
156
+ }
157
+ /**
158
+ * Message format support for multi-character chats
159
+ * Defines how the provider handles the 'name' field in messages
160
+ */
161
+ interface MessageFormatSupport {
162
+ /** Whether the provider supports a name field on messages */
163
+ supportsNameField: boolean;
164
+ /** Which roles support the name field */
165
+ supportedRoles: ('user' | 'assistant')[];
166
+ /** Maximum length for name field (if limited) */
167
+ maxNameLength?: number;
168
+ }
169
+ /**
170
+ * Cheap model configuration for background tasks
171
+ * Used for memory extraction, summarization, titling, etc.
172
+ */
173
+ interface CheapModelConfig {
174
+ /** The default cheap model for this provider */
175
+ defaultModel: string;
176
+ /** List of recommended cheap models */
177
+ recommendedModels: string[];
178
+ }
179
+ /**
180
+ * Tool format type for this provider
181
+ * Determines how tools are formatted for API calls
182
+ */
183
+ type ToolFormatType = 'openai' | 'anthropic' | 'google';
184
+ /**
185
+ * Main LLM Provider Plugin Interface
186
+ *
187
+ * Plugins implementing this interface can be dynamically loaded
188
+ * by Quilltap to provide LLM functionality from various providers.
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * import type { LLMProviderPlugin } from '@quilltap/plugin-types';
193
+ *
194
+ * export const plugin: LLMProviderPlugin = {
195
+ * metadata: {
196
+ * providerName: 'MY_PROVIDER',
197
+ * displayName: 'My Provider',
198
+ * description: 'Custom LLM provider',
199
+ * abbreviation: 'MYP',
200
+ * colors: { bg: 'bg-blue-100', text: 'text-blue-800', icon: 'text-blue-600' },
201
+ * },
202
+ * config: {
203
+ * requiresApiKey: true,
204
+ * requiresBaseUrl: false,
205
+ * apiKeyLabel: 'API Key',
206
+ * },
207
+ * capabilities: {
208
+ * chat: true,
209
+ * imageGeneration: false,
210
+ * embeddings: false,
211
+ * webSearch: false,
212
+ * },
213
+ * attachmentSupport: {
214
+ * supportsAttachments: false,
215
+ * supportedMimeTypes: [],
216
+ * description: 'No file attachments supported',
217
+ * },
218
+ * createProvider: () => new MyProvider(),
219
+ * getAvailableModels: async (apiKey) => [...],
220
+ * validateApiKey: async (apiKey) => {...},
221
+ * renderIcon: ({ className }) => <MyIcon className={className} />,
222
+ * };
223
+ * ```
224
+ */
225
+ interface LLMProviderPlugin {
226
+ /** Provider metadata for UI display and identification */
227
+ metadata: ProviderMetadata;
228
+ /** Configuration requirements for this provider */
229
+ config: ProviderConfigRequirements;
230
+ /** Supported capabilities for this provider */
231
+ capabilities: ProviderCapabilities;
232
+ /** File attachment support information */
233
+ attachmentSupport: AttachmentSupport;
234
+ /**
235
+ * Factory method to create an LLMProvider instance
236
+ * @param baseUrl Optional base URL for the provider
237
+ */
238
+ createProvider: (baseUrl?: string) => LLMProvider;
239
+ /**
240
+ * Factory method to create an ImageGenProvider instance (optional)
241
+ * Only required if capabilities.imageGeneration is true
242
+ * @param baseUrl Optional base URL for the provider
243
+ */
244
+ createImageProvider?: (baseUrl?: string) => ImageGenProvider;
245
+ /**
246
+ * Factory method to create an embedding provider (optional)
247
+ * Only required if capabilities.embeddings is true
248
+ * @param baseUrl Optional base URL for the provider
249
+ */
250
+ createEmbeddingProvider?: (baseUrl?: string) => unknown;
251
+ /**
252
+ * Get list of available models for this provider
253
+ * @param apiKey API key for authentication
254
+ * @param baseUrl Optional base URL
255
+ */
256
+ getAvailableModels: (apiKey: string, baseUrl?: string) => Promise<string[]>;
257
+ /**
258
+ * Get static model information without API calls
259
+ */
260
+ getModelInfo?: () => ModelInfo[];
261
+ /**
262
+ * Get embedding models supported by this provider
263
+ */
264
+ getEmbeddingModels?: () => EmbeddingModelInfo[];
265
+ /**
266
+ * Get image generation models supported by this provider
267
+ */
268
+ getImageGenerationModels?: () => ImageGenerationModelInfo[];
269
+ /**
270
+ * Validate an API key for this provider
271
+ * @param apiKey API key to validate
272
+ * @param baseUrl Optional base URL
273
+ */
274
+ validateApiKey: (apiKey: string, baseUrl?: string) => Promise<boolean>;
275
+ /**
276
+ * Render the provider icon as a React component
277
+ * @param props Icon component props
278
+ */
279
+ renderIcon: (props: IconProps) => ReactNode;
280
+ /**
281
+ * Convert universal tool format to provider-specific format (optional)
282
+ * @param tool Tools in OpenAI format or generic objects
283
+ * @param options Formatting options
284
+ */
285
+ formatTools?: (tool: any, options?: ToolFormatOptions) => any;
286
+ /**
287
+ * Parse provider-specific tool calls from response (optional)
288
+ * @param response Raw API response
289
+ */
290
+ parseToolCalls?: (response: any) => ToolCallRequest[];
291
+ /**
292
+ * Get image provider constraints (optional)
293
+ * Only applicable for providers with imageGeneration capability
294
+ */
295
+ getImageProviderConstraints?: () => ImageProviderConstraints;
296
+ /**
297
+ * Message format support for multi-character contexts (optional)
298
+ * If not provided, defaults to no name field support
299
+ */
300
+ messageFormat?: MessageFormatSupport;
301
+ /**
302
+ * Token estimation multiplier (optional)
303
+ * Characters per token for this provider's tokenizer
304
+ * @default 3.5
305
+ */
306
+ charsPerToken?: number;
307
+ /**
308
+ * Tool format type for this provider (optional)
309
+ * Used for quick format detection without calling formatTools()
310
+ * @default 'openai'
311
+ */
312
+ toolFormat?: ToolFormatType;
313
+ /**
314
+ * Cheap model configuration for background tasks (optional)
315
+ * Used for memory extraction, summarization, titling, etc.
316
+ */
317
+ cheapModels?: CheapModelConfig;
318
+ /**
319
+ * Default context window when model is unknown (optional)
320
+ * Falls back to 8192 if not specified
321
+ */
322
+ defaultContextWindow?: number;
323
+ }
324
+ /**
325
+ * Standard export type for provider plugins
326
+ */
327
+ interface ProviderPluginExport {
328
+ /** The provider plugin instance */
329
+ plugin: LLMProviderPlugin;
330
+ }
331
+
332
+ /**
333
+ * Plugin Manifest types for Quilltap plugin development
334
+ *
335
+ * @module @quilltap/plugin-types/plugins/manifest
336
+ */
337
+ /**
338
+ * Plugin capability types
339
+ */
340
+ type PluginCapability = 'LLM_PROVIDER' | 'AUTH_PROVIDER' | 'STORAGE_BACKEND' | 'THEME' | 'UTILITY';
341
+ /**
342
+ * Plugin category
343
+ */
344
+ type PluginCategory = 'PROVIDER' | 'AUTH' | 'STORAGE' | 'UI' | 'UTILITY';
345
+ /**
346
+ * Plugin status
347
+ */
348
+ type PluginStatus = 'STABLE' | 'BETA' | 'EXPERIMENTAL' | 'DEPRECATED';
349
+ /**
350
+ * Author information
351
+ */
352
+ interface PluginAuthor {
353
+ /** Author name */
354
+ name: string;
355
+ /** Author email */
356
+ email?: string;
357
+ /** Author website or profile URL */
358
+ url?: string;
359
+ }
360
+ /**
361
+ * Compatibility requirements
362
+ */
363
+ interface PluginCompatibility {
364
+ /** Minimum Quilltap version (semver range) */
365
+ quilltapVersion: string;
366
+ /** Minimum Node.js version (semver range) */
367
+ nodeVersion?: string;
368
+ }
369
+ /**
370
+ * Provider-specific configuration (for LLM_PROVIDER plugins)
371
+ */
372
+ interface ProviderConfig {
373
+ /** Internal provider name */
374
+ providerName: string;
375
+ /** Human-readable display name */
376
+ displayName: string;
377
+ /** Provider description */
378
+ description: string;
379
+ /** Short abbreviation */
380
+ abbreviation: string;
381
+ /** UI color configuration */
382
+ colors: {
383
+ bg: string;
384
+ text: string;
385
+ icon: string;
386
+ };
387
+ /** Whether the provider requires an API key */
388
+ requiresApiKey: boolean;
389
+ /** Whether the provider requires a base URL */
390
+ requiresBaseUrl: boolean;
391
+ /** Label for API key input */
392
+ apiKeyLabel?: string;
393
+ /** Provider capabilities */
394
+ capabilities: {
395
+ chat: boolean;
396
+ imageGeneration: boolean;
397
+ embeddings: boolean;
398
+ webSearch: boolean;
399
+ };
400
+ /** Attachment support configuration */
401
+ attachmentSupport: {
402
+ supported: boolean;
403
+ mimeTypes: string[];
404
+ description: string;
405
+ };
406
+ }
407
+ /**
408
+ * Required permissions for the plugin
409
+ */
410
+ interface PluginPermissions {
411
+ /** Network domains the plugin may access */
412
+ network?: string[];
413
+ /** Whether the plugin accesses user data */
414
+ userData?: boolean;
415
+ /** Whether the plugin accesses the database */
416
+ database?: boolean;
417
+ /** Whether the plugin accesses the file system */
418
+ fileSystem?: boolean;
419
+ }
420
+ /**
421
+ * Plugin manifest schema
422
+ *
423
+ * This is the structure of the quilltap-manifest.json file
424
+ * that every Quilltap plugin must include.
425
+ */
426
+ interface PluginManifest {
427
+ /** JSON schema reference */
428
+ $schema?: string;
429
+ /** Package name (must start with qtap-plugin-) */
430
+ name: string;
431
+ /** Human-readable title */
432
+ title: string;
433
+ /** Plugin description */
434
+ description: string;
435
+ /** Semantic version */
436
+ version: string;
437
+ /** Author information */
438
+ author: PluginAuthor;
439
+ /** License identifier (SPDX) */
440
+ license: string;
441
+ /** Compatibility requirements */
442
+ compatibility: PluginCompatibility;
443
+ /** Plugin capabilities */
444
+ capabilities: PluginCapability[];
445
+ /** Plugin category */
446
+ category: PluginCategory;
447
+ /** Main entry point (relative path) */
448
+ main: string;
449
+ /** Whether TypeScript source is available */
450
+ typescript?: boolean;
451
+ /** Frontend framework used */
452
+ frontend?: 'REACT' | 'NONE';
453
+ /** Styling approach used */
454
+ styling?: 'TAILWIND' | 'CSS' | 'NONE';
455
+ /** Whether to enable by default when installed */
456
+ enabledByDefault?: boolean;
457
+ /** Plugin status */
458
+ status: PluginStatus;
459
+ /** Search keywords */
460
+ keywords?: string[];
461
+ /** Provider-specific configuration (for LLM_PROVIDER plugins) */
462
+ providerConfig?: ProviderConfig;
463
+ /** Required permissions */
464
+ permissions?: PluginPermissions;
465
+ /** Repository URL */
466
+ repository?: string | {
467
+ type: string;
468
+ url: string;
469
+ directory?: string;
470
+ };
471
+ /** Homepage URL */
472
+ homepage?: string;
473
+ /** Bug tracker URL */
474
+ bugs?: string | {
475
+ url: string;
476
+ email?: string;
477
+ };
478
+ }
479
+ /**
480
+ * Installed plugin metadata
481
+ * Extended manifest with installation-specific information
482
+ */
483
+ interface InstalledPluginInfo extends PluginManifest {
484
+ /** Whether the plugin is currently enabled */
485
+ enabled: boolean;
486
+ /** Installation timestamp */
487
+ installedAt?: string;
488
+ /** Last update timestamp */
489
+ updatedAt?: string;
490
+ /** Installation scope */
491
+ scope?: 'site' | 'user';
492
+ /** Path to installed plugin */
493
+ installPath?: string;
494
+ }
495
+
496
+ export type { AttachmentSupport as A, CheapModelConfig as C, EmbeddingModelInfo as E, ImageGenerationModelInfo as I, LLMProviderPlugin as L, ModelInfo as M, ProviderMetadata as P, ToolFormatType as T, ProviderConfigRequirements as a, ProviderCapabilities as b, ImageProviderConstraints as c, IconProps as d, ProviderPluginExport as e, MessageFormatSupport as f, PluginCapability as g, PluginCategory as h, PluginStatus as i, PluginAuthor as j, PluginCompatibility as k, ProviderConfig as l, PluginPermissions as m, PluginManifest as n, InstalledPluginInfo as o };