@quilltap/plugin-types 1.17.3 → 2.0.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.
@@ -1,3 +1,105 @@
1
+ /**
2
+ * Common types shared across all provider interfaces
3
+ *
4
+ * These types are used by multiple provider shapes (text, image, embedding, scoring)
5
+ * and are extracted here to avoid duplication.
6
+ *
7
+ * @module @quilltap/plugin-types/providers/common
8
+ */
9
+ /**
10
+ * File attachment for multimodal messages
11
+ */
12
+ interface FileAttachment {
13
+ /** Unique identifier for the attachment */
14
+ id: string;
15
+ /** Path to the file on disk (internal use) */
16
+ filepath?: string;
17
+ /** Original filename */
18
+ filename: string;
19
+ /** MIME type of the file */
20
+ mimeType: string;
21
+ /** File size in bytes */
22
+ size: number;
23
+ /** Base64 encoded data (loaded at send time) */
24
+ data?: string;
25
+ /** URL to fetch the file (alternative to data) */
26
+ url?: string;
27
+ /** Additional metadata */
28
+ metadata?: Record<string, unknown>;
29
+ }
30
+ /**
31
+ * Token usage statistics
32
+ */
33
+ interface TokenUsage {
34
+ /** Tokens used for the prompt */
35
+ promptTokens: number;
36
+ /** Tokens used for the completion */
37
+ completionTokens: number;
38
+ /** Total tokens used */
39
+ totalTokens: number;
40
+ }
41
+ /**
42
+ * Cache usage statistics (OpenRouter, Anthropic)
43
+ */
44
+ interface CacheUsage {
45
+ /** Number of cached tokens */
46
+ cachedTokens?: number;
47
+ /** Cache discount amount */
48
+ cacheDiscount?: number;
49
+ /** Tokens used for cache creation */
50
+ cacheCreationInputTokens?: number;
51
+ /** Tokens read from cache */
52
+ cacheReadInputTokens?: number;
53
+ }
54
+ /**
55
+ * Attachment processing results
56
+ */
57
+ interface AttachmentResults {
58
+ /** IDs of attachments sent successfully */
59
+ sent: string[];
60
+ /** Attachments that failed with error details */
61
+ failed: Array<{
62
+ id: string;
63
+ error: string;
64
+ }>;
65
+ }
66
+ /**
67
+ * Model warning level
68
+ */
69
+ type ModelWarningLevel = 'info' | 'warning' | 'error';
70
+ /**
71
+ * Model warning information
72
+ */
73
+ interface ModelWarning {
74
+ /** Warning severity level */
75
+ level: ModelWarningLevel;
76
+ /** Warning message */
77
+ message: string;
78
+ /** Optional link to documentation */
79
+ documentationUrl?: string;
80
+ }
81
+ /**
82
+ * Model metadata with warnings and capabilities
83
+ */
84
+ interface ModelMetadata {
85
+ /** Model identifier */
86
+ id: string;
87
+ /** Human-readable display name */
88
+ displayName?: string;
89
+ /** Warnings or recommendations */
90
+ warnings?: ModelWarning[];
91
+ /** Whether the model is deprecated */
92
+ deprecated?: boolean;
93
+ /** Whether the model is experimental/preview */
94
+ experimental?: boolean;
95
+ /** Capabilities this model lacks */
96
+ missingCapabilities?: string[];
97
+ /** Maximum output tokens */
98
+ maxOutputTokens?: number;
99
+ /** Context window size */
100
+ contextWindow?: number;
101
+ }
102
+
1
103
  /**
2
104
  * Tool/Function calling types for Quilltap plugin development
3
105
  *
@@ -128,32 +230,15 @@ interface ToolFormatOptions {
128
230
  }
129
231
 
130
232
  /**
131
- * Core LLM types for Quilltap plugin development
233
+ * Text Provider Shape 1: Text -> Text
234
+ *
235
+ * Send instructions + data (with optional attachments) to an LLM,
236
+ * receive a text response. This is the fundamental text completion shape,
237
+ * covering both standard and "cheap" model calls.
132
238
  *
133
- * @module @quilltap/plugin-types/llm
239
+ * @module @quilltap/plugin-types/providers/text
134
240
  */
135
241
 
136
- /**
137
- * File attachment for multimodal messages
138
- */
139
- interface FileAttachment {
140
- /** Unique identifier for the attachment */
141
- id: string;
142
- /** Path to the file on disk (internal use) */
143
- filepath?: string;
144
- /** Original filename */
145
- filename: string;
146
- /** MIME type of the file */
147
- mimeType: string;
148
- /** File size in bytes */
149
- size: number;
150
- /** Base64 encoded data (loaded at send time) */
151
- data?: string;
152
- /** URL to fetch the file (alternative to data) */
153
- url?: string;
154
- /** Additional metadata */
155
- metadata?: Record<string, unknown>;
156
- }
157
242
  /**
158
243
  * Message in a conversation
159
244
  */
@@ -198,7 +283,7 @@ interface ResponseFormat {
198
283
  jsonSchema?: JSONSchemaDefinition;
199
284
  }
200
285
  /**
201
- * Parameters for LLM requests
286
+ * Parameters for text completion requests
202
287
  */
203
288
  interface LLMParams {
204
289
  /** Array of messages in the conversation */
@@ -236,43 +321,7 @@ interface LLMParams {
236
321
  previousResponseId?: string;
237
322
  }
238
323
  /**
239
- * Token usage statistics
240
- */
241
- interface TokenUsage {
242
- /** Tokens used for the prompt */
243
- promptTokens: number;
244
- /** Tokens used for the completion */
245
- completionTokens: number;
246
- /** Total tokens used */
247
- totalTokens: number;
248
- }
249
- /**
250
- * Cache usage statistics (OpenRouter, Anthropic)
251
- */
252
- interface CacheUsage {
253
- /** Number of cached tokens */
254
- cachedTokens?: number;
255
- /** Cache discount amount */
256
- cacheDiscount?: number;
257
- /** Tokens used for cache creation */
258
- cacheCreationInputTokens?: number;
259
- /** Tokens read from cache */
260
- cacheReadInputTokens?: number;
261
- }
262
- /**
263
- * Attachment processing results
264
- */
265
- interface AttachmentResults {
266
- /** IDs of attachments sent successfully */
267
- sent: string[];
268
- /** Attachments that failed with error details */
269
- failed: Array<{
270
- id: string;
271
- error: string;
272
- }>;
273
- }
274
- /**
275
- * Response from LLM
324
+ * Response from a text completion
276
325
  */
277
326
  interface LLMResponse {
278
327
  /** Generated content */
@@ -293,7 +342,7 @@ interface LLMResponse {
293
342
  cacheUsage?: CacheUsage;
294
343
  }
295
344
  /**
296
- * Streaming chunk from LLM
345
+ * Streaming chunk from a text completion
297
346
  */
298
347
  interface StreamChunk {
299
348
  /** Content in this chunk */
@@ -313,6 +362,56 @@ interface StreamChunk {
313
362
  /** Cache usage statistics */
314
363
  cacheUsage?: CacheUsage;
315
364
  }
365
+ /**
366
+ * Text completion provider interface — Shape 1: Text -> Text
367
+ *
368
+ * Sends instructions and data to an LLM and receives text responses,
369
+ * either as a complete response or as a stream of chunks.
370
+ *
371
+ * This covers both standard and "cheap" model calls — the difference
372
+ * is in model selection and parameters, not the interface shape.
373
+ */
374
+ interface TextProvider {
375
+ /** Whether this provider supports file attachments */
376
+ readonly supportsFileAttachments: boolean;
377
+ /** Supported MIME types for file attachments */
378
+ readonly supportedMimeTypes: string[];
379
+ /** Whether this provider supports web search */
380
+ readonly supportsWebSearch: boolean;
381
+ /**
382
+ * Send a message and get a complete response
383
+ */
384
+ sendMessage(params: LLMParams, apiKey: string): Promise<LLMResponse>;
385
+ /**
386
+ * Send a message and stream the response
387
+ */
388
+ streamMessage(params: LLMParams, apiKey: string): AsyncGenerator<StreamChunk>;
389
+ /**
390
+ * Validate an API key
391
+ */
392
+ validateApiKey(apiKey: string): Promise<boolean>;
393
+ /**
394
+ * Get available models from the provider
395
+ */
396
+ getAvailableModels(apiKey: string): Promise<string[]>;
397
+ /**
398
+ * Get metadata for a specific model (optional)
399
+ */
400
+ getModelMetadata?(modelId: string): ModelMetadata | undefined;
401
+ /**
402
+ * Get metadata for all models with warnings (optional)
403
+ */
404
+ getModelsWithMetadata?(apiKey: string): Promise<ModelMetadata[]>;
405
+ }
406
+
407
+ /**
408
+ * Image Provider — Shape 2: Text -> Image
409
+ *
410
+ * Send instructions (a prompt) to an image generation model,
411
+ * receive one or more generated images.
412
+ *
413
+ * @module @quilltap/plugin-types/providers/image
414
+ */
316
415
  /**
317
416
  * Image generation parameters
318
417
  */
@@ -369,94 +468,18 @@ interface ImageGenResponse {
369
468
  raw?: unknown;
370
469
  }
371
470
  /**
372
- * Model warning level
373
- */
374
- type ModelWarningLevel = 'info' | 'warning' | 'error';
375
- /**
376
- * Model warning information
377
- */
378
- interface ModelWarning {
379
- /** Warning severity level */
380
- level: ModelWarningLevel;
381
- /** Warning message */
382
- message: string;
383
- /** Optional link to documentation */
384
- documentationUrl?: string;
385
- }
386
- /**
387
- * Model metadata with warnings and capabilities
388
- */
389
- interface ModelMetadata {
390
- /** Model identifier */
391
- id: string;
392
- /** Human-readable display name */
393
- displayName?: string;
394
- /** Warnings or recommendations */
395
- warnings?: ModelWarning[];
396
- /** Whether the model is deprecated */
397
- deprecated?: boolean;
398
- /** Whether the model is experimental/preview */
399
- experimental?: boolean;
400
- /** Capabilities this model lacks */
401
- missingCapabilities?: string[];
402
- /** Maximum output tokens */
403
- maxOutputTokens?: number;
404
- /** Context window size */
405
- contextWindow?: number;
406
- }
407
- /**
408
- * Core LLM provider interface
471
+ * Image generation provider interface — Shape 2: Text -> Image
409
472
  *
410
- * Plugins can implement this interface to provide LLM functionality.
411
- */
412
- interface LLMProvider {
413
- /** Whether this provider supports file attachments */
414
- readonly supportsFileAttachments: boolean;
415
- /** Supported MIME types for file attachments */
416
- readonly supportedMimeTypes: string[];
417
- /** Whether this provider supports image generation */
418
- readonly supportsImageGeneration: boolean;
419
- /** Whether this provider supports web search */
420
- readonly supportsWebSearch: boolean;
421
- /**
422
- * Send a message and get a complete response
423
- */
424
- sendMessage(params: LLMParams, apiKey: string): Promise<LLMResponse>;
425
- /**
426
- * Send a message and stream the response
427
- */
428
- streamMessage(params: LLMParams, apiKey: string): AsyncGenerator<StreamChunk>;
429
- /**
430
- * Validate an API key
431
- */
432
- validateApiKey(apiKey: string): Promise<boolean>;
433
- /**
434
- * Get available models from the provider
435
- */
436
- getAvailableModels(apiKey: string): Promise<string[]>;
437
- /**
438
- * Generate an image (optional)
439
- */
440
- generateImage?(params: ImageGenParams, apiKey: string): Promise<ImageGenResponse>;
441
- /**
442
- * Get metadata for a specific model (optional)
443
- */
444
- getModelMetadata?(modelId: string): ModelMetadata | undefined;
445
- /**
446
- * Get metadata for all models with warnings (optional)
447
- */
448
- getModelsWithMetadata?(apiKey: string): Promise<ModelMetadata[]>;
449
- }
450
- /**
451
- * Image generation provider interface
473
+ * Sends a text prompt to an image generation model and receives
474
+ * one or more generated images.
452
475
  */
453
- interface ImageGenProvider {
476
+ interface ImageProvider {
454
477
  /** Provider identifier */
455
478
  readonly provider: string;
456
479
  /** Models supported by this provider */
457
480
  readonly supportedModels: string[];
458
481
  /**
459
- * Generate an image
482
+ * Generate an image from a text prompt
460
483
  */
461
484
  generateImage(params: ImageGenParams, apiKey: string): Promise<ImageGenResponse>;
462
485
  /**
@@ -470,12 +493,12 @@ interface ImageGenProvider {
470
493
  }
471
494
 
472
495
  /**
473
- * Embedding Provider Types for Quilltap plugin development
496
+ * Embedding Provider Shape 3: Text -> Vector
474
497
  *
475
- * Defines interfaces for embedding providers that can be implemented
476
- * by plugins to provide text-to-vector embedding functionality.
498
+ * Send text to an embedding model, receive a numeric vector representation.
499
+ * Used for semantic search, RAG, and similarity matching.
477
500
  *
478
- * @module @quilltap/plugin-types/llm/embeddings
501
+ * @module @quilltap/plugin-types/providers/embedding
479
502
  */
480
503
  /**
481
504
  * Result of an embedding operation
@@ -502,10 +525,10 @@ interface EmbeddingOptions {
502
525
  dimensions?: number;
503
526
  }
504
527
  /**
505
- * Standard embedding provider interface
528
+ * Embedding provider interface — Shape 3: Text -> Vector
506
529
  *
507
- * This is the base interface for all embedding providers that use
508
- * external APIs (OpenAI, Ollama, OpenRouter, etc.)
530
+ * Sends text to an embedding model and receives a numeric vector
531
+ * representation for use in semantic search, RAG, and similarity matching.
509
532
  */
510
533
  interface EmbeddingProvider {
511
534
  /**
@@ -630,4 +653,4 @@ interface LocalEmbeddingProvider extends Omit<EmbeddingProvider, 'generateEmbedd
630
653
  */
631
654
  declare function isLocalEmbeddingProvider(provider: EmbeddingProvider | LocalEmbeddingProvider): provider is LocalEmbeddingProvider;
632
655
 
633
- export { type AnthropicToolDefinition, type AttachmentResults, type CacheUsage, type EmbeddingOptions, type EmbeddingProvider, type EmbeddingResult, type FileAttachment, type GeneratedImage, type GoogleToolDefinition, type ImageGenParams, type ImageGenProvider, type ImageGenResponse, type JSONSchemaDefinition, type LLMMessage, type LLMParams, type LLMProvider, type LLMResponse, type LocalEmbeddingProvider, type LocalEmbeddingProviderState, type ModelMetadata, type ModelWarning, type ModelWarningLevel, type OpenAIToolDefinition, type ResponseFormat, type StreamChunk, type TokenUsage, type ToolCall, type ToolCallRequest, type ToolFormatOptions, type ToolResult, type UniversalTool, isLocalEmbeddingProvider };
656
+ export { type AnthropicToolDefinition, type AttachmentResults, type CacheUsage, type EmbeddingOptions, type EmbeddingProvider, type EmbeddingResult, type FileAttachment, type GeneratedImage, type GoogleToolDefinition, type ImageGenParams, type ImageProvider as ImageGenProvider, type ImageGenResponse, type ImageProvider, type JSONSchemaDefinition, type LLMMessage, type LLMParams, type TextProvider as LLMProvider, type LLMResponse, type LocalEmbeddingProvider, type LocalEmbeddingProviderState, type ModelMetadata, type ModelWarning, type ModelWarningLevel, type OpenAIToolDefinition, type ResponseFormat, type StreamChunk, type TextProvider, type TokenUsage, type ToolCall, type ToolCallRequest, type ToolFormatOptions, type ToolResult, type UniversalTool, isLocalEmbeddingProvider };