@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 };
package/dist/llm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- // src/llm/embeddings.ts
3
+ // src/providers/embedding.ts
4
4
  function isLocalEmbeddingProvider(provider) {
5
5
  return "fitCorpus" in provider && "loadState" in provider && "getState" in provider;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/llm/embeddings.ts"],"names":[],"mappings":";;;AAyLO,SAAS,yBACd,QAAA,EACoC;AACpC,EAAA,OAAO,WAAA,IAAe,QAAA,IAAY,WAAA,IAAe,QAAA,IAAY,UAAA,IAAc,QAAA;AAC7E","file":"index.js","sourcesContent":["/**\n * Embedding Provider Types for Quilltap plugin development\n *\n * Defines interfaces for embedding providers that can be implemented\n * by plugins to provide text-to-vector embedding functionality.\n *\n * @module @quilltap/plugin-types/llm/embeddings\n */\n\n/**\n * Result of an embedding operation\n */\nexport interface EmbeddingResult {\n /** The embedding vector (array of floating point numbers) */\n embedding: number[];\n /** The model used to generate the embedding */\n model: string;\n /** Number of dimensions in the embedding vector */\n dimensions: number;\n /** Token usage information (if available) */\n usage?: {\n promptTokens: number;\n totalTokens: number;\n cost?: number;\n };\n}\n\n/**\n * Options for embedding generation\n */\nexport interface EmbeddingOptions {\n /** Desired dimensions for the embedding (if model supports variable dimensions) */\n dimensions?: number;\n}\n\n/**\n * Standard embedding provider interface\n *\n * This is the base interface for all embedding providers that use\n * external APIs (OpenAI, Ollama, OpenRouter, etc.)\n */\nexport interface EmbeddingProvider {\n /**\n * Generate an embedding for a single text\n *\n * @param text The text to embed\n * @param model The model to use\n * @param apiKey The API key for authentication\n * @param options Optional configuration\n * @returns The embedding result\n */\n generateEmbedding(\n text: string,\n model: string,\n apiKey: string,\n options?: EmbeddingOptions\n ): Promise<EmbeddingResult>;\n\n /**\n * Generate embeddings for multiple texts in a batch\n *\n * @param texts Array of texts to embed\n * @param model The model to use\n * @param apiKey The API key for authentication\n * @param options Optional configuration\n * @returns Array of embedding results\n */\n generateBatchEmbeddings?(\n texts: string[],\n model: string,\n apiKey: string,\n options?: EmbeddingOptions\n ): Promise<EmbeddingResult[]>;\n\n /**\n * Get available embedding models\n *\n * @param apiKey The API key for authentication\n * @returns Array of model IDs\n */\n getAvailableModels?(apiKey: string): Promise<string[]>;\n\n /**\n * Check if the provider is available and properly configured\n *\n * @param apiKey Optional API key to validate\n * @returns True if the provider is ready to use\n */\n isAvailable?(apiKey?: string): Promise<boolean>;\n}\n\n/**\n * Serializable state for local embedding providers\n *\n * Used by providers like TF-IDF that maintain vocabulary state\n */\nexport interface LocalEmbeddingProviderState {\n /** The vocabulary as an array of [term, index] pairs */\n vocabulary: [string, number][];\n /** The IDF (Inverse Document Frequency) weights */\n idf: number[];\n /** Average document length across the corpus */\n avgDocLength: number;\n /** Size of the vocabulary */\n vocabularySize: number;\n /** Whether bigrams are included in the vocabulary */\n includeBigrams: boolean;\n /** Timestamp when the vocabulary was fitted */\n fittedAt: string;\n}\n\n/**\n * Local embedding provider interface\n *\n * Extended interface for local/offline embedding providers that\n * maintain vocabulary state (like TF-IDF). These providers don't\n * require API keys and can work entirely offline.\n */\nexport interface LocalEmbeddingProvider extends Omit<EmbeddingProvider, 'generateEmbedding' | 'generateBatchEmbeddings'> {\n /**\n * Generate an embedding for a single text\n * Local providers don't need apiKey parameter\n *\n * @param text The text to embed\n * @returns The embedding result\n */\n generateEmbedding(text: string): EmbeddingResult;\n\n /**\n * Generate embeddings for multiple texts in a batch\n *\n * @param texts Array of texts to embed\n * @returns Array of embedding results\n */\n generateBatchEmbeddings(texts: string[]): EmbeddingResult[];\n\n /**\n * Fit the vocabulary on a corpus of documents\n *\n * This method analyzes the corpus to build vocabulary, calculate IDF weights,\n * and other statistics needed for embedding generation.\n *\n * @param documents Array of text documents to analyze\n */\n fitCorpus(documents: string[]): void;\n\n /**\n * Check if the vocabulary has been fitted\n *\n * @returns True if fitCorpus has been called with documents\n */\n isFitted(): boolean;\n\n /**\n * Load state from a serialized representation\n *\n * @param state The serialized provider state\n */\n loadState(state: LocalEmbeddingProviderState): void;\n\n /**\n * Get the current state for serialization\n *\n * @returns The provider state, or null if not fitted\n */\n getState(): LocalEmbeddingProviderState | null;\n\n /**\n * Get the vocabulary size\n *\n * @returns Number of terms in the vocabulary\n */\n getVocabularySize(): number;\n\n /**\n * Get the embedding dimensions\n *\n * @returns Number of dimensions in generated embeddings\n */\n getDimensions(): number;\n}\n\n/**\n * Type guard to check if a provider is a local embedding provider\n */\nexport function isLocalEmbeddingProvider(\n provider: EmbeddingProvider | LocalEmbeddingProvider\n): provider is LocalEmbeddingProvider {\n return 'fitCorpus' in provider && 'loadState' in provider && 'getState' in provider;\n}\n"]}
1
+ {"version":3,"sources":["../../src/providers/embedding.ts"],"names":[],"mappings":";;;AAyLO,SAAS,yBACd,QAAA,EACoC;AACpC,EAAA,OAAO,WAAA,IAAe,QAAA,IAAY,WAAA,IAAe,QAAA,IAAY,UAAA,IAAc,QAAA;AAC7E","file":"index.js","sourcesContent":["/**\n * Embedding Provider Shape 3: Text -> Vector\n *\n * Send text to an embedding model, receive a numeric vector representation.\n * Used for semantic search, RAG, and similarity matching.\n *\n * @module @quilltap/plugin-types/providers/embedding\n */\n\n/**\n * Result of an embedding operation\n */\nexport interface EmbeddingResult {\n /** The embedding vector (array of floating point numbers) */\n embedding: number[];\n /** The model used to generate the embedding */\n model: string;\n /** Number of dimensions in the embedding vector */\n dimensions: number;\n /** Token usage information (if available) */\n usage?: {\n promptTokens: number;\n totalTokens: number;\n cost?: number;\n };\n}\n\n/**\n * Options for embedding generation\n */\nexport interface EmbeddingOptions {\n /** Desired dimensions for the embedding (if model supports variable dimensions) */\n dimensions?: number;\n}\n\n/**\n * Embedding provider interface — Shape 3: Text -> Vector\n *\n * Sends text to an embedding model and receives a numeric vector\n * representation for use in semantic search, RAG, and similarity matching.\n */\nexport interface EmbeddingProvider {\n /**\n * Generate an embedding for a single text\n *\n * @param text The text to embed\n * @param model The model to use\n * @param apiKey The API key for authentication\n * @param options Optional configuration\n * @returns The embedding result\n */\n generateEmbedding(\n text: string,\n model: string,\n apiKey: string,\n options?: EmbeddingOptions\n ): Promise<EmbeddingResult>;\n\n /**\n * Generate embeddings for multiple texts in a batch\n *\n * @param texts Array of texts to embed\n * @param model The model to use\n * @param apiKey The API key for authentication\n * @param options Optional configuration\n * @returns Array of embedding results\n */\n generateBatchEmbeddings?(\n texts: string[],\n model: string,\n apiKey: string,\n options?: EmbeddingOptions\n ): Promise<EmbeddingResult[]>;\n\n /**\n * Get available embedding models\n *\n * @param apiKey The API key for authentication\n * @returns Array of model IDs\n */\n getAvailableModels?(apiKey: string): Promise<string[]>;\n\n /**\n * Check if the provider is available and properly configured\n *\n * @param apiKey Optional API key to validate\n * @returns True if the provider is ready to use\n */\n isAvailable?(apiKey?: string): Promise<boolean>;\n}\n\n/**\n * Serializable state for local embedding providers\n *\n * Used by providers like TF-IDF that maintain vocabulary state\n */\nexport interface LocalEmbeddingProviderState {\n /** The vocabulary as an array of [term, index] pairs */\n vocabulary: [string, number][];\n /** The IDF (Inverse Document Frequency) weights */\n idf: number[];\n /** Average document length across the corpus */\n avgDocLength: number;\n /** Size of the vocabulary */\n vocabularySize: number;\n /** Whether bigrams are included in the vocabulary */\n includeBigrams: boolean;\n /** Timestamp when the vocabulary was fitted */\n fittedAt: string;\n}\n\n/**\n * Local embedding provider interface\n *\n * Extended interface for local/offline embedding providers that\n * maintain vocabulary state (like TF-IDF). These providers don't\n * require API keys and can work entirely offline.\n */\nexport interface LocalEmbeddingProvider extends Omit<EmbeddingProvider, 'generateEmbedding' | 'generateBatchEmbeddings'> {\n /**\n * Generate an embedding for a single text\n * Local providers don't need apiKey parameter\n *\n * @param text The text to embed\n * @returns The embedding result\n */\n generateEmbedding(text: string): EmbeddingResult;\n\n /**\n * Generate embeddings for multiple texts in a batch\n *\n * @param texts Array of texts to embed\n * @returns Array of embedding results\n */\n generateBatchEmbeddings(texts: string[]): EmbeddingResult[];\n\n /**\n * Fit the vocabulary on a corpus of documents\n *\n * This method analyzes the corpus to build vocabulary, calculate IDF weights,\n * and other statistics needed for embedding generation.\n *\n * @param documents Array of text documents to analyze\n */\n fitCorpus(documents: string[]): void;\n\n /**\n * Check if the vocabulary has been fitted\n *\n * @returns True if fitCorpus has been called with documents\n */\n isFitted(): boolean;\n\n /**\n * Load state from a serialized representation\n *\n * @param state The serialized provider state\n */\n loadState(state: LocalEmbeddingProviderState): void;\n\n /**\n * Get the current state for serialization\n *\n * @returns The provider state, or null if not fitted\n */\n getState(): LocalEmbeddingProviderState | null;\n\n /**\n * Get the vocabulary size\n *\n * @returns Number of terms in the vocabulary\n */\n getVocabularySize(): number;\n\n /**\n * Get the embedding dimensions\n *\n * @returns Number of dimensions in generated embeddings\n */\n getDimensions(): number;\n}\n\n/**\n * Type guard to check if a provider is a local embedding provider\n */\nexport function isLocalEmbeddingProvider(\n provider: EmbeddingProvider | LocalEmbeddingProvider\n): provider is LocalEmbeddingProvider {\n return 'fitCorpus' in provider && 'loadState' in provider && 'getState' in provider;\n}\n"]}
@@ -1,4 +1,4 @@
1
- // src/llm/embeddings.ts
1
+ // src/providers/embedding.ts
2
2
  function isLocalEmbeddingProvider(provider) {
3
3
  return "fitCorpus" in provider && "loadState" in provider && "getState" in provider;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/llm/embeddings.ts"],"names":[],"mappings":";AAyLO,SAAS,yBACd,QAAA,EACoC;AACpC,EAAA,OAAO,WAAA,IAAe,QAAA,IAAY,WAAA,IAAe,QAAA,IAAY,UAAA,IAAc,QAAA;AAC7E","file":"index.mjs","sourcesContent":["/**\n * Embedding Provider Types for Quilltap plugin development\n *\n * Defines interfaces for embedding providers that can be implemented\n * by plugins to provide text-to-vector embedding functionality.\n *\n * @module @quilltap/plugin-types/llm/embeddings\n */\n\n/**\n * Result of an embedding operation\n */\nexport interface EmbeddingResult {\n /** The embedding vector (array of floating point numbers) */\n embedding: number[];\n /** The model used to generate the embedding */\n model: string;\n /** Number of dimensions in the embedding vector */\n dimensions: number;\n /** Token usage information (if available) */\n usage?: {\n promptTokens: number;\n totalTokens: number;\n cost?: number;\n };\n}\n\n/**\n * Options for embedding generation\n */\nexport interface EmbeddingOptions {\n /** Desired dimensions for the embedding (if model supports variable dimensions) */\n dimensions?: number;\n}\n\n/**\n * Standard embedding provider interface\n *\n * This is the base interface for all embedding providers that use\n * external APIs (OpenAI, Ollama, OpenRouter, etc.)\n */\nexport interface EmbeddingProvider {\n /**\n * Generate an embedding for a single text\n *\n * @param text The text to embed\n * @param model The model to use\n * @param apiKey The API key for authentication\n * @param options Optional configuration\n * @returns The embedding result\n */\n generateEmbedding(\n text: string,\n model: string,\n apiKey: string,\n options?: EmbeddingOptions\n ): Promise<EmbeddingResult>;\n\n /**\n * Generate embeddings for multiple texts in a batch\n *\n * @param texts Array of texts to embed\n * @param model The model to use\n * @param apiKey The API key for authentication\n * @param options Optional configuration\n * @returns Array of embedding results\n */\n generateBatchEmbeddings?(\n texts: string[],\n model: string,\n apiKey: string,\n options?: EmbeddingOptions\n ): Promise<EmbeddingResult[]>;\n\n /**\n * Get available embedding models\n *\n * @param apiKey The API key for authentication\n * @returns Array of model IDs\n */\n getAvailableModels?(apiKey: string): Promise<string[]>;\n\n /**\n * Check if the provider is available and properly configured\n *\n * @param apiKey Optional API key to validate\n * @returns True if the provider is ready to use\n */\n isAvailable?(apiKey?: string): Promise<boolean>;\n}\n\n/**\n * Serializable state for local embedding providers\n *\n * Used by providers like TF-IDF that maintain vocabulary state\n */\nexport interface LocalEmbeddingProviderState {\n /** The vocabulary as an array of [term, index] pairs */\n vocabulary: [string, number][];\n /** The IDF (Inverse Document Frequency) weights */\n idf: number[];\n /** Average document length across the corpus */\n avgDocLength: number;\n /** Size of the vocabulary */\n vocabularySize: number;\n /** Whether bigrams are included in the vocabulary */\n includeBigrams: boolean;\n /** Timestamp when the vocabulary was fitted */\n fittedAt: string;\n}\n\n/**\n * Local embedding provider interface\n *\n * Extended interface for local/offline embedding providers that\n * maintain vocabulary state (like TF-IDF). These providers don't\n * require API keys and can work entirely offline.\n */\nexport interface LocalEmbeddingProvider extends Omit<EmbeddingProvider, 'generateEmbedding' | 'generateBatchEmbeddings'> {\n /**\n * Generate an embedding for a single text\n * Local providers don't need apiKey parameter\n *\n * @param text The text to embed\n * @returns The embedding result\n */\n generateEmbedding(text: string): EmbeddingResult;\n\n /**\n * Generate embeddings for multiple texts in a batch\n *\n * @param texts Array of texts to embed\n * @returns Array of embedding results\n */\n generateBatchEmbeddings(texts: string[]): EmbeddingResult[];\n\n /**\n * Fit the vocabulary on a corpus of documents\n *\n * This method analyzes the corpus to build vocabulary, calculate IDF weights,\n * and other statistics needed for embedding generation.\n *\n * @param documents Array of text documents to analyze\n */\n fitCorpus(documents: string[]): void;\n\n /**\n * Check if the vocabulary has been fitted\n *\n * @returns True if fitCorpus has been called with documents\n */\n isFitted(): boolean;\n\n /**\n * Load state from a serialized representation\n *\n * @param state The serialized provider state\n */\n loadState(state: LocalEmbeddingProviderState): void;\n\n /**\n * Get the current state for serialization\n *\n * @returns The provider state, or null if not fitted\n */\n getState(): LocalEmbeddingProviderState | null;\n\n /**\n * Get the vocabulary size\n *\n * @returns Number of terms in the vocabulary\n */\n getVocabularySize(): number;\n\n /**\n * Get the embedding dimensions\n *\n * @returns Number of dimensions in generated embeddings\n */\n getDimensions(): number;\n}\n\n/**\n * Type guard to check if a provider is a local embedding provider\n */\nexport function isLocalEmbeddingProvider(\n provider: EmbeddingProvider | LocalEmbeddingProvider\n): provider is LocalEmbeddingProvider {\n return 'fitCorpus' in provider && 'loadState' in provider && 'getState' in provider;\n}\n"]}
1
+ {"version":3,"sources":["../../src/providers/embedding.ts"],"names":[],"mappings":";AAyLO,SAAS,yBACd,QAAA,EACoC;AACpC,EAAA,OAAO,WAAA,IAAe,QAAA,IAAY,WAAA,IAAe,QAAA,IAAY,UAAA,IAAc,QAAA;AAC7E","file":"index.mjs","sourcesContent":["/**\n * Embedding Provider Shape 3: Text -> Vector\n *\n * Send text to an embedding model, receive a numeric vector representation.\n * Used for semantic search, RAG, and similarity matching.\n *\n * @module @quilltap/plugin-types/providers/embedding\n */\n\n/**\n * Result of an embedding operation\n */\nexport interface EmbeddingResult {\n /** The embedding vector (array of floating point numbers) */\n embedding: number[];\n /** The model used to generate the embedding */\n model: string;\n /** Number of dimensions in the embedding vector */\n dimensions: number;\n /** Token usage information (if available) */\n usage?: {\n promptTokens: number;\n totalTokens: number;\n cost?: number;\n };\n}\n\n/**\n * Options for embedding generation\n */\nexport interface EmbeddingOptions {\n /** Desired dimensions for the embedding (if model supports variable dimensions) */\n dimensions?: number;\n}\n\n/**\n * Embedding provider interface — Shape 3: Text -> Vector\n *\n * Sends text to an embedding model and receives a numeric vector\n * representation for use in semantic search, RAG, and similarity matching.\n */\nexport interface EmbeddingProvider {\n /**\n * Generate an embedding for a single text\n *\n * @param text The text to embed\n * @param model The model to use\n * @param apiKey The API key for authentication\n * @param options Optional configuration\n * @returns The embedding result\n */\n generateEmbedding(\n text: string,\n model: string,\n apiKey: string,\n options?: EmbeddingOptions\n ): Promise<EmbeddingResult>;\n\n /**\n * Generate embeddings for multiple texts in a batch\n *\n * @param texts Array of texts to embed\n * @param model The model to use\n * @param apiKey The API key for authentication\n * @param options Optional configuration\n * @returns Array of embedding results\n */\n generateBatchEmbeddings?(\n texts: string[],\n model: string,\n apiKey: string,\n options?: EmbeddingOptions\n ): Promise<EmbeddingResult[]>;\n\n /**\n * Get available embedding models\n *\n * @param apiKey The API key for authentication\n * @returns Array of model IDs\n */\n getAvailableModels?(apiKey: string): Promise<string[]>;\n\n /**\n * Check if the provider is available and properly configured\n *\n * @param apiKey Optional API key to validate\n * @returns True if the provider is ready to use\n */\n isAvailable?(apiKey?: string): Promise<boolean>;\n}\n\n/**\n * Serializable state for local embedding providers\n *\n * Used by providers like TF-IDF that maintain vocabulary state\n */\nexport interface LocalEmbeddingProviderState {\n /** The vocabulary as an array of [term, index] pairs */\n vocabulary: [string, number][];\n /** The IDF (Inverse Document Frequency) weights */\n idf: number[];\n /** Average document length across the corpus */\n avgDocLength: number;\n /** Size of the vocabulary */\n vocabularySize: number;\n /** Whether bigrams are included in the vocabulary */\n includeBigrams: boolean;\n /** Timestamp when the vocabulary was fitted */\n fittedAt: string;\n}\n\n/**\n * Local embedding provider interface\n *\n * Extended interface for local/offline embedding providers that\n * maintain vocabulary state (like TF-IDF). These providers don't\n * require API keys and can work entirely offline.\n */\nexport interface LocalEmbeddingProvider extends Omit<EmbeddingProvider, 'generateEmbedding' | 'generateBatchEmbeddings'> {\n /**\n * Generate an embedding for a single text\n * Local providers don't need apiKey parameter\n *\n * @param text The text to embed\n * @returns The embedding result\n */\n generateEmbedding(text: string): EmbeddingResult;\n\n /**\n * Generate embeddings for multiple texts in a batch\n *\n * @param texts Array of texts to embed\n * @returns Array of embedding results\n */\n generateBatchEmbeddings(texts: string[]): EmbeddingResult[];\n\n /**\n * Fit the vocabulary on a corpus of documents\n *\n * This method analyzes the corpus to build vocabulary, calculate IDF weights,\n * and other statistics needed for embedding generation.\n *\n * @param documents Array of text documents to analyze\n */\n fitCorpus(documents: string[]): void;\n\n /**\n * Check if the vocabulary has been fitted\n *\n * @returns True if fitCorpus has been called with documents\n */\n isFitted(): boolean;\n\n /**\n * Load state from a serialized representation\n *\n * @param state The serialized provider state\n */\n loadState(state: LocalEmbeddingProviderState): void;\n\n /**\n * Get the current state for serialization\n *\n * @returns The provider state, or null if not fitted\n */\n getState(): LocalEmbeddingProviderState | null;\n\n /**\n * Get the vocabulary size\n *\n * @returns Number of terms in the vocabulary\n */\n getVocabularySize(): number;\n\n /**\n * Get the embedding dimensions\n *\n * @returns Number of dimensions in generated embeddings\n */\n getDimensions(): number;\n}\n\n/**\n * Type guard to check if a provider is a local embedding provider\n */\nexport function isLocalEmbeddingProvider(\n provider: EmbeddingProvider | LocalEmbeddingProvider\n): provider is LocalEmbeddingProvider {\n return 'fitCorpus' in provider && 'loadState' in provider && 'getState' in provider;\n}\n"]}
@@ -1,2 +1,3 @@
1
- export { $ as AnnotationButton, A as AttachmentSupport, a as ColorPalette, a0 as DialogueDetection, E as Effects, b as EmbeddedFont, c as EmbeddingModelInfo, F as FontDefinition, I as IconProps, d as ImageGenerationModelInfo, e as ImageProviderConstraints, g as InstalledPluginInfo, L as LLMProviderPlugin, h as ModelInfo, i as ModerationCategoryResult, a1 as ModerationProviderConfig, j as ModerationProviderConfigRequirements, k as ModerationProviderMetadata, l as ModerationProviderPlugin, m as ModerationProviderPluginExport, n as ModerationResult, P as PluginAuthor, o as PluginCapability, p as PluginCategory, q as PluginCompatibility, s as PluginManifest, t as PluginPermissions, u as PluginStatus, v as ProviderCapabilities, w as ProviderConfig, x as ProviderConfigRequirements, y as ProviderMetadata, z as ProviderPluginExport, a2 as RenderingPattern, R as RoleplayTemplateConfig, B as RoleplayTemplateMetadata, D as RoleplayTemplatePlugin, G as RoleplayTemplatePluginExport, S as SearchOutput, H as SearchProviderConfig, J as SearchProviderConfigRequirements, K as SearchProviderMetadata, N as SearchProviderPlugin, O as SearchProviderPluginExport, Q as SearchResult, T as Spacing, V as ThemeMetadata, W as ThemePlugin, X as ThemePluginExport, Y as ThemeTokens, _ as Typography } from '../index-QQUNtK0j.mjs';
1
+ export { a4 as AnnotationButton, A as AttachmentSupport, a as ColorPalette, a5 as DialogueDetection, E as Effects, b as EmbeddedFont, c as EmbeddingModelInfo, F as FontDefinition, I as IconProps, d as ImageGenerationModelInfo, e as ImageProviderConstraints, g as InstalledPluginInfo, L as LLMProviderPlugin, h as ModelInfo, i as ModerationCategoryResult, a6 as ModerationProviderConfig, j as ModerationProviderConfigRequirements, k as ModerationProviderMetadata, l as ModerationProviderPlugin, m as ModerationProviderPluginExport, n as ModerationResult, P as PluginAuthor, o as PluginCapability, p as PluginCategory, q as PluginCompatibility, s as PluginManifest, t as PluginPermissions, u as PluginStatus, v as ProviderCapabilities, w as ProviderConfig, x as ProviderConfigRequirements, y as ProviderMetadata, z as ProviderPluginExport, a7 as RenderingPattern, R as RoleplayTemplateConfig, B as RoleplayTemplateMetadata, D as RoleplayTemplatePlugin, G as RoleplayTemplatePluginExport, S as ScoringProviderConfigRequirements, H as ScoringProviderMetadata, J as ScoringProviderPlugin, K as ScoringProviderPluginExport, N as SearchOutput, O as SearchProviderConfig, Q as SearchProviderConfigRequirements, T as SearchProviderMetadata, U as SearchProviderPlugin, V as SearchProviderPluginExport, W as SearchResult, X as Spacing, Z as TextProviderPlugin, _ as ThemeMetadata, $ as ThemePlugin, a0 as ThemePluginExport, a1 as ThemeTokens, a3 as Typography } from '../index-DtW7izgw.mjs';
2
2
  import '../llm/index.mjs';
3
+ import '../providers/index.mjs';
@@ -1,2 +1,3 @@
1
- export { $ as AnnotationButton, A as AttachmentSupport, a as ColorPalette, a0 as DialogueDetection, E as Effects, b as EmbeddedFont, c as EmbeddingModelInfo, F as FontDefinition, I as IconProps, d as ImageGenerationModelInfo, e as ImageProviderConstraints, g as InstalledPluginInfo, L as LLMProviderPlugin, h as ModelInfo, i as ModerationCategoryResult, a1 as ModerationProviderConfig, j as ModerationProviderConfigRequirements, k as ModerationProviderMetadata, l as ModerationProviderPlugin, m as ModerationProviderPluginExport, n as ModerationResult, P as PluginAuthor, o as PluginCapability, p as PluginCategory, q as PluginCompatibility, s as PluginManifest, t as PluginPermissions, u as PluginStatus, v as ProviderCapabilities, w as ProviderConfig, x as ProviderConfigRequirements, y as ProviderMetadata, z as ProviderPluginExport, a2 as RenderingPattern, R as RoleplayTemplateConfig, B as RoleplayTemplateMetadata, D as RoleplayTemplatePlugin, G as RoleplayTemplatePluginExport, S as SearchOutput, H as SearchProviderConfig, J as SearchProviderConfigRequirements, K as SearchProviderMetadata, N as SearchProviderPlugin, O as SearchProviderPluginExport, Q as SearchResult, T as Spacing, V as ThemeMetadata, W as ThemePlugin, X as ThemePluginExport, Y as ThemeTokens, _ as Typography } from '../index-FCJXfnL_.js';
1
+ export { a4 as AnnotationButton, A as AttachmentSupport, a as ColorPalette, a5 as DialogueDetection, E as Effects, b as EmbeddedFont, c as EmbeddingModelInfo, F as FontDefinition, I as IconProps, d as ImageGenerationModelInfo, e as ImageProviderConstraints, g as InstalledPluginInfo, L as LLMProviderPlugin, h as ModelInfo, i as ModerationCategoryResult, a6 as ModerationProviderConfig, j as ModerationProviderConfigRequirements, k as ModerationProviderMetadata, l as ModerationProviderPlugin, m as ModerationProviderPluginExport, n as ModerationResult, P as PluginAuthor, o as PluginCapability, p as PluginCategory, q as PluginCompatibility, s as PluginManifest, t as PluginPermissions, u as PluginStatus, v as ProviderCapabilities, w as ProviderConfig, x as ProviderConfigRequirements, y as ProviderMetadata, z as ProviderPluginExport, a7 as RenderingPattern, R as RoleplayTemplateConfig, B as RoleplayTemplateMetadata, D as RoleplayTemplatePlugin, G as RoleplayTemplatePluginExport, S as ScoringProviderConfigRequirements, H as ScoringProviderMetadata, J as ScoringProviderPlugin, K as ScoringProviderPluginExport, N as SearchOutput, O as SearchProviderConfig, Q as SearchProviderConfigRequirements, T as SearchProviderMetadata, U as SearchProviderPlugin, V as SearchProviderPluginExport, W as SearchResult, X as Spacing, Z as TextProviderPlugin, _ as ThemeMetadata, $ as ThemePlugin, a0 as ThemePluginExport, a1 as ThemeTokens, a3 as Typography } from '../index-BXJLgAuZ.js';
2
2
  import '../llm/index.js';
3
+ import '../providers/index.js';
@@ -0,0 +1,132 @@
1
+ export { AttachmentResults, CacheUsage, EmbeddingOptions, EmbeddingProvider, EmbeddingResult, FileAttachment, GeneratedImage, ImageGenParams, ImageGenResponse, ImageGenProvider as ImageProvider, JSONSchemaDefinition, LLMMessage, LLMParams, LLMResponse, LocalEmbeddingProvider, LocalEmbeddingProviderState, ModelMetadata, ModelWarning, ModelWarningLevel, ResponseFormat, StreamChunk, LLMProvider as TextProvider, TokenUsage, isLocalEmbeddingProvider } from '../llm/index.mjs';
2
+
3
+ /**
4
+ * Scoring Provider — Shape 4: Text + Candidates -> Scores
5
+ *
6
+ * Send content (and optionally candidates or labels) to a scoring model,
7
+ * receive scored categories or ranked results. This generalizes content
8
+ * moderation, reranking, and classification into a single interface shape.
9
+ *
10
+ * ## Supported Tasks
11
+ *
12
+ * ### Moderation (implemented)
13
+ * Score content against safety categories. The provider returns per-category
14
+ * flagged/score pairs (e.g., "violence": 0.95, "hate": 0.02).
15
+ *
16
+ * ```typescript
17
+ * const result = await provider.score({
18
+ * content: 'some user message',
19
+ * task: 'moderation',
20
+ * }, apiKey);
21
+ * // result.flagged = true, result.categories = [{ category: 'violence', flagged: true, score: 0.95 }, ...]
22
+ * ```
23
+ *
24
+ * ### Reranking (future)
25
+ * Given a query and candidate passages, score each passage by relevance.
26
+ * Uses `candidates` field to pass the passages to rank.
27
+ *
28
+ * ```typescript
29
+ * const result = await provider.score({
30
+ * content: 'What is the capital of France?',
31
+ * task: 'reranking',
32
+ * candidates: ['Paris is the capital of France.', 'London is in England.', ...],
33
+ * }, apiKey);
34
+ * // result.categories = [{ category: '0', score: 0.98 }, { category: '1', score: 0.12 }, ...]
35
+ * ```
36
+ *
37
+ * ### Classification (future)
38
+ * Classify content into one or more predefined labels.
39
+ * Uses `labels` field to define the classification categories.
40
+ *
41
+ * ```typescript
42
+ * const result = await provider.score({
43
+ * content: 'I love this product!',
44
+ * task: 'classification',
45
+ * labels: ['positive', 'negative', 'neutral'],
46
+ * }, apiKey);
47
+ * // result.categories = [{ category: 'positive', flagged: true, score: 0.92 }, ...]
48
+ * ```
49
+ *
50
+ * @module @quilltap/plugin-types/providers/scoring
51
+ */
52
+ /**
53
+ * The type of scoring task to perform
54
+ */
55
+ type ScoringTask = 'moderation' | 'reranking' | 'classification';
56
+ /**
57
+ * Input for a scoring operation
58
+ */
59
+ interface ScoringInput {
60
+ /** The primary text to score */
61
+ content: string;
62
+ /** The scoring task type */
63
+ task: ScoringTask;
64
+ /**
65
+ * Candidate passages for reranking.
66
+ * Each candidate is scored against the content (used as query).
67
+ */
68
+ candidates?: string[];
69
+ /**
70
+ * Label set for classification.
71
+ * Content is classified into these categories.
72
+ */
73
+ labels?: string[];
74
+ /** Task-specific options */
75
+ options?: Record<string, unknown>;
76
+ }
77
+ /**
78
+ * A single category/label score
79
+ */
80
+ interface CategoryScore {
81
+ /** Category or label name (e.g., 'violence', 'positive', or candidate index) */
82
+ category: string;
83
+ /** Whether this category was triggered/flagged */
84
+ flagged: boolean;
85
+ /** Confidence score (0-1) */
86
+ score: number;
87
+ }
88
+ /**
89
+ * Result from a scoring operation
90
+ */
91
+ interface ScoringResult {
92
+ /** Overall flagged status (for moderation) or top match (for classification) */
93
+ flagged: boolean;
94
+ /** Per-category/label breakdown with scores */
95
+ categories: CategoryScore[];
96
+ /** Which task produced this result */
97
+ task: ScoringTask;
98
+ }
99
+ /**
100
+ * Scoring provider interface — Shape 4: Text + Candidates -> Scores
101
+ *
102
+ * Sends content to a scoring model and receives scored categories,
103
+ * ranked results, or classification labels. Generalizes moderation,
104
+ * reranking, and classification into a single provider shape.
105
+ */
106
+ interface ScoringProvider {
107
+ /**
108
+ * Score content according to the specified task
109
+ *
110
+ * @param input The scoring input with content, task type, and optional candidates/labels
111
+ * @param apiKey The API key for authentication
112
+ * @param baseUrl Optional base URL for the scoring API
113
+ * @returns Scored results with per-category breakdown
114
+ */
115
+ score(input: ScoringInput, apiKey: string, baseUrl?: string): Promise<ScoringResult>;
116
+ /**
117
+ * Get the scoring tasks this provider supports
118
+ *
119
+ * @returns Array of supported task types
120
+ */
121
+ getSupportedTasks(): ScoringTask[];
122
+ /**
123
+ * Validate an API key for this provider (optional)
124
+ *
125
+ * @param apiKey The API key to validate
126
+ * @param baseUrl Optional base URL
127
+ * @returns True if valid
128
+ */
129
+ validateApiKey?(apiKey: string, baseUrl?: string): Promise<boolean>;
130
+ }
131
+
132
+ export type { CategoryScore, ScoringInput, ScoringProvider, ScoringResult, ScoringTask };