@quilltap/plugin-types 1.18.0 → 2.0.1

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
132
234
  *
133
- * @module @quilltap/plugin-types/llm
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.
238
+ *
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 */
@@ -209,6 +294,12 @@ interface LLMParams {
209
294
  temperature?: number;
210
295
  /** Maximum tokens to generate */
211
296
  maxTokens?: number;
297
+ /**
298
+ * When true, the provider MUST respect the exact maxTokens value without
299
+ * applying model-specific overrides (e.g. reasoning model minimums).
300
+ * Used by background tasks (cheap LLM) that need strict output limits.
301
+ */
302
+ strictMaxTokens?: boolean;
212
303
  /** Nucleus sampling parameter */
213
304
  topP?: number;
214
305
  /** Stop sequences */
@@ -236,43 +327,7 @@ interface LLMParams {
236
327
  previousResponseId?: string;
237
328
  }
238
329
  /**
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
330
+ * Response from a text completion
276
331
  */
277
332
  interface LLMResponse {
278
333
  /** Generated content */
@@ -293,7 +348,7 @@ interface LLMResponse {
293
348
  cacheUsage?: CacheUsage;
294
349
  }
295
350
  /**
296
- * Streaming chunk from LLM
351
+ * Streaming chunk from a text completion
297
352
  */
298
353
  interface StreamChunk {
299
354
  /** Content in this chunk */
@@ -313,6 +368,56 @@ interface StreamChunk {
313
368
  /** Cache usage statistics */
314
369
  cacheUsage?: CacheUsage;
315
370
  }
371
+ /**
372
+ * Text completion provider interface — Shape 1: Text -> Text
373
+ *
374
+ * Sends instructions and data to an LLM and receives text responses,
375
+ * either as a complete response or as a stream of chunks.
376
+ *
377
+ * This covers both standard and "cheap" model calls — the difference
378
+ * is in model selection and parameters, not the interface shape.
379
+ */
380
+ interface TextProvider {
381
+ /** Whether this provider supports file attachments */
382
+ readonly supportsFileAttachments: boolean;
383
+ /** Supported MIME types for file attachments */
384
+ readonly supportedMimeTypes: string[];
385
+ /** Whether this provider supports web search */
386
+ readonly supportsWebSearch: boolean;
387
+ /**
388
+ * Send a message and get a complete response
389
+ */
390
+ sendMessage(params: LLMParams, apiKey: string): Promise<LLMResponse>;
391
+ /**
392
+ * Send a message and stream the response
393
+ */
394
+ streamMessage(params: LLMParams, apiKey: string): AsyncGenerator<StreamChunk>;
395
+ /**
396
+ * Validate an API key
397
+ */
398
+ validateApiKey(apiKey: string): Promise<boolean>;
399
+ /**
400
+ * Get available models from the provider
401
+ */
402
+ getAvailableModels(apiKey: string): Promise<string[]>;
403
+ /**
404
+ * Get metadata for a specific model (optional)
405
+ */
406
+ getModelMetadata?(modelId: string): ModelMetadata | undefined;
407
+ /**
408
+ * Get metadata for all models with warnings (optional)
409
+ */
410
+ getModelsWithMetadata?(apiKey: string): Promise<ModelMetadata[]>;
411
+ }
412
+
413
+ /**
414
+ * Image Provider — Shape 2: Text -> Image
415
+ *
416
+ * Send instructions (a prompt) to an image generation model,
417
+ * receive one or more generated images.
418
+ *
419
+ * @module @quilltap/plugin-types/providers/image
420
+ */
316
421
  /**
317
422
  * Image generation parameters
318
423
  */
@@ -369,94 +474,18 @@ interface ImageGenResponse {
369
474
  raw?: unknown;
370
475
  }
371
476
  /**
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
477
+ * Image generation provider interface — Shape 2: Text -> Image
409
478
  *
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
479
+ * Sends a text prompt to an image generation model and receives
480
+ * one or more generated images.
452
481
  */
453
- interface ImageGenProvider {
482
+ interface ImageProvider {
454
483
  /** Provider identifier */
455
484
  readonly provider: string;
456
485
  /** Models supported by this provider */
457
486
  readonly supportedModels: string[];
458
487
  /**
459
- * Generate an image
488
+ * Generate an image from a text prompt
460
489
  */
461
490
  generateImage(params: ImageGenParams, apiKey: string): Promise<ImageGenResponse>;
462
491
  /**
@@ -470,12 +499,12 @@ interface ImageGenProvider {
470
499
  }
471
500
 
472
501
  /**
473
- * Embedding Provider Types for Quilltap plugin development
502
+ * Embedding Provider Shape 3: Text -> Vector
474
503
  *
475
- * Defines interfaces for embedding providers that can be implemented
476
- * by plugins to provide text-to-vector embedding functionality.
504
+ * Send text to an embedding model, receive a numeric vector representation.
505
+ * Used for semantic search, RAG, and similarity matching.
477
506
  *
478
- * @module @quilltap/plugin-types/llm/embeddings
507
+ * @module @quilltap/plugin-types/providers/embedding
479
508
  */
480
509
  /**
481
510
  * Result of an embedding operation
@@ -502,10 +531,10 @@ interface EmbeddingOptions {
502
531
  dimensions?: number;
503
532
  }
504
533
  /**
505
- * Standard embedding provider interface
534
+ * Embedding provider interface — Shape 3: Text -> Vector
506
535
  *
507
- * This is the base interface for all embedding providers that use
508
- * external APIs (OpenAI, Ollama, OpenRouter, etc.)
536
+ * Sends text to an embedding model and receives a numeric vector
537
+ * representation for use in semantic search, RAG, and similarity matching.
509
538
  */
510
539
  interface EmbeddingProvider {
511
540
  /**
@@ -630,4 +659,4 @@ interface LocalEmbeddingProvider extends Omit<EmbeddingProvider, 'generateEmbedd
630
659
  */
631
660
  declare function isLocalEmbeddingProvider(provider: EmbeddingProvider | LocalEmbeddingProvider): provider is LocalEmbeddingProvider;
632
661
 
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 };
662
+ 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 };