@quilltap/plugin-types 1.9.3 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,40 @@ 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.10.0] - 2026-02-01
9
+
10
+ ### Added
11
+
12
+ - `PluginIconData` interface for providing SVG icon data without React dependency:
13
+ - `svg?: string` - Raw SVG string (complete `<svg>` element)
14
+ - `viewBox?: string` - SVG viewBox attribute
15
+ - `paths?: Array<{...}>` - SVG path elements with d, fill, stroke, etc.
16
+ - `circles?: Array<{...}>` - SVG circle elements
17
+ - `text?: {...}` - SVG text element for abbreviation or label
18
+ - `icon?: PluginIconData` property on `LLMProviderPlugin` interface
19
+ - Preferred approach for providing provider icons
20
+ - Quilltap renders the SVG data, removing React dependency from plugins
21
+
22
+ ### Changed
23
+
24
+ - `renderIcon` method on `LLMProviderPlugin` is now optional and deprecated
25
+ - Falls back to `icon` property or generates default icon from abbreviation
26
+ - Kept for backwards compatibility with existing external plugins
27
+
28
+ ## [1.9.4] - 2026-01-30
29
+
30
+ ### Added
31
+
32
+ - New embedding provider types for building embedding plugins:
33
+ - `EmbeddingResult` - Result of an embedding operation (vector, model, dimensions, usage)
34
+ - `EmbeddingOptions` - Options for embedding generation (dimensions)
35
+ - `EmbeddingProvider` - Interface for API-based embedding providers (OpenAI, Ollama, etc.)
36
+ - `LocalEmbeddingProvider` - Extended interface for local/offline providers like TF-IDF
37
+ - `LocalEmbeddingProviderState` - Serializable state for local providers (vocabulary, IDF, etc.)
38
+ - `isLocalEmbeddingProvider` - Type guard function to detect local providers
39
+ - Updated `createEmbeddingProvider` method on `LLMProviderPlugin` to return proper typed interface
40
+ - Now returns `EmbeddingProvider | LocalEmbeddingProvider` instead of `unknown`
41
+
8
42
  ## [1.9.2] - 2026-01-27
9
43
 
10
44
  ### Changed
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { LLMProvider, ImageGenProvider, ToolFormatOptions, ToolCallRequest } from './llm/index.mjs';
2
+ import { LLMProvider, ImageGenProvider, EmbeddingProvider, LocalEmbeddingProvider, ToolFormatOptions, ToolCallRequest } from './llm/index.mjs';
3
3
 
4
4
  /**
5
5
  * Provider Plugin Interface types for Quilltap plugin development
@@ -7,6 +7,63 @@ import { LLMProvider, ImageGenProvider, ToolFormatOptions, ToolCallRequest } fro
7
7
  * @module @quilltap/plugin-types/plugins/provider
8
8
  */
9
9
 
10
+ /**
11
+ * SVG icon data that can be provided by plugins without React dependency
12
+ *
13
+ * Plugins can provide icon data in one of two formats:
14
+ * 1. Raw SVG string: Complete `<svg>` element as a string
15
+ * 2. Structured data: viewBox with paths, circles, and/or text elements
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // Option 1: Raw SVG string
20
+ * icon: {
21
+ * svg: '<svg viewBox="0 0 24 24"><path d="M12 2..." fill="currentColor"/></svg>'
22
+ * }
23
+ *
24
+ * // Option 2: Structured data
25
+ * icon: {
26
+ * viewBox: '0 0 24 24',
27
+ * paths: [
28
+ * { d: 'M12 2L2 7l10 5 10-5-10-5z', fill: 'currentColor' }
29
+ * ]
30
+ * }
31
+ * ```
32
+ */
33
+ interface PluginIconData {
34
+ /** Raw SVG string (complete <svg> element) */
35
+ svg?: string;
36
+ /** SVG viewBox attribute (e.g., '0 0 24 24') */
37
+ viewBox?: string;
38
+ /** SVG path elements */
39
+ paths?: Array<{
40
+ d: string;
41
+ fill?: string;
42
+ stroke?: string;
43
+ strokeWidth?: string;
44
+ opacity?: string;
45
+ fillRule?: 'nonzero' | 'evenodd';
46
+ }>;
47
+ /** SVG circle elements */
48
+ circles?: Array<{
49
+ cx: string | number;
50
+ cy: string | number;
51
+ r: string | number;
52
+ fill?: string;
53
+ stroke?: string;
54
+ strokeWidth?: string;
55
+ opacity?: string;
56
+ }>;
57
+ /** SVG text element for abbreviation or label */
58
+ text?: {
59
+ content: string;
60
+ x?: string;
61
+ y?: string;
62
+ fontSize?: string;
63
+ fontWeight?: string;
64
+ fill?: string;
65
+ };
66
+ }
10
67
  /**
11
68
  * Provider metadata for UI display and identification
12
69
  */
@@ -226,7 +283,10 @@ type ToolFormatType = 'openai' | 'anthropic' | 'google';
226
283
  * createProvider: () => new MyProvider(),
227
284
  * getAvailableModels: async (apiKey) => [...],
228
285
  * validateApiKey: async (apiKey) => {...},
229
- * renderIcon: ({ className }) => <MyIcon className={className} />,
286
+ * icon: {
287
+ * viewBox: '0 0 24 24',
288
+ * paths: [{ d: 'M12 2L2 7l10 5 10-5-10-5z', fill: 'currentColor' }]
289
+ * },
230
290
  * };
231
291
  * ```
232
292
  */
@@ -254,8 +314,9 @@ interface LLMProviderPlugin {
254
314
  * Factory method to create an embedding provider (optional)
255
315
  * Only required if capabilities.embeddings is true
256
316
  * @param baseUrl Optional base URL for the provider
317
+ * @returns EmbeddingProvider for API-based providers, LocalEmbeddingProvider for local providers
257
318
  */
258
- createEmbeddingProvider?: (baseUrl?: string) => unknown;
319
+ createEmbeddingProvider?: (baseUrl?: string) => EmbeddingProvider | LocalEmbeddingProvider;
259
320
  /**
260
321
  * Get list of available models for this provider
261
322
  * @param apiKey API key for authentication
@@ -280,11 +341,31 @@ interface LLMProviderPlugin {
280
341
  * @param baseUrl Optional base URL
281
342
  */
282
343
  validateApiKey: (apiKey: string, baseUrl?: string) => Promise<boolean>;
344
+ /**
345
+ * Provider icon as SVG data (RECOMMENDED)
346
+ *
347
+ * Provides the icon as raw SVG data that Quilltap will render.
348
+ * This is the preferred approach as it doesn't require React in the plugin.
349
+ *
350
+ * If not provided, falls back to `renderIcon` (deprecated) or generates
351
+ * a default icon from the provider's abbreviation.
352
+ *
353
+ * @example
354
+ * ```typescript
355
+ * icon: {
356
+ * viewBox: '0 0 24 24',
357
+ * paths: [{ d: 'M12 2L2 7l10 5 10-5-10-5z', fill: 'currentColor' }]
358
+ * }
359
+ * ```
360
+ */
361
+ icon?: PluginIconData;
283
362
  /**
284
363
  * Render the provider icon as a React component
364
+ * @deprecated Use the `icon` property instead, which doesn't require React.
365
+ * This is kept for backwards compatibility with existing external plugins.
285
366
  * @param props Icon component props
286
367
  */
287
- renderIcon: (props: IconProps) => ReactNode;
368
+ renderIcon?: (props: IconProps) => ReactNode;
288
369
  /**
289
370
  * Convert universal tool format to provider-specific format (optional)
290
371
  * @param tool Tools in OpenAI format or generic objects
@@ -1096,4 +1177,4 @@ interface RoleplayTemplatePluginExport {
1096
1177
  plugin: RoleplayTemplatePlugin;
1097
1178
  }
1098
1179
 
1099
- export type { AttachmentSupport as A, AnnotationButton as B, CheapModelConfig as C, RenderingPattern as D, EmbeddingModelInfo as E, FontDefinition as F, DialogueDetection as G, ImageGenerationModelInfo as I, LLMProviderPlugin as L, ModelInfo as M, ProviderMetadata as P, RoleplayTemplateConfig as R, Spacing as S, 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, ColorPalette as p, Typography as q, Effects as r, ThemeTokens as s, EmbeddedFont as t, ThemeMetadata as u, ThemePlugin as v, ThemePluginExport as w, RoleplayTemplateMetadata as x, RoleplayTemplatePlugin as y, RoleplayTemplatePluginExport as z };
1180
+ export type { AttachmentSupport as A, Typography as B, CheapModelConfig as C, AnnotationButton as D, Effects as E, FontDefinition as F, DialogueDetection as G, RenderingPattern as H, IconProps as I, LLMProviderPlugin as L, MessageFormatSupport as M, PluginAuthor as P, RoleplayTemplateConfig as R, Spacing as S, ThemeMetadata as T, ColorPalette as a, EmbeddedFont as b, EmbeddingModelInfo as c, ImageGenerationModelInfo as d, ImageProviderConstraints as e, InstalledPluginInfo as f, ModelInfo as g, PluginCapability as h, PluginCategory as i, PluginCompatibility as j, PluginIconData as k, PluginManifest as l, PluginPermissions as m, PluginStatus as n, ProviderCapabilities as o, ProviderConfig as p, ProviderConfigRequirements as q, ProviderMetadata as r, ProviderPluginExport as s, RoleplayTemplateMetadata as t, RoleplayTemplatePlugin as u, RoleplayTemplatePluginExport as v, ThemePlugin as w, ThemePluginExport as x, ThemeTokens as y, ToolFormatType as z };
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { LLMProvider, ImageGenProvider, ToolFormatOptions, ToolCallRequest } from './llm/index.js';
2
+ import { LLMProvider, ImageGenProvider, EmbeddingProvider, LocalEmbeddingProvider, ToolFormatOptions, ToolCallRequest } from './llm/index.js';
3
3
 
4
4
  /**
5
5
  * Provider Plugin Interface types for Quilltap plugin development
@@ -7,6 +7,63 @@ import { LLMProvider, ImageGenProvider, ToolFormatOptions, ToolCallRequest } fro
7
7
  * @module @quilltap/plugin-types/plugins/provider
8
8
  */
9
9
 
10
+ /**
11
+ * SVG icon data that can be provided by plugins without React dependency
12
+ *
13
+ * Plugins can provide icon data in one of two formats:
14
+ * 1. Raw SVG string: Complete `<svg>` element as a string
15
+ * 2. Structured data: viewBox with paths, circles, and/or text elements
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // Option 1: Raw SVG string
20
+ * icon: {
21
+ * svg: '<svg viewBox="0 0 24 24"><path d="M12 2..." fill="currentColor"/></svg>'
22
+ * }
23
+ *
24
+ * // Option 2: Structured data
25
+ * icon: {
26
+ * viewBox: '0 0 24 24',
27
+ * paths: [
28
+ * { d: 'M12 2L2 7l10 5 10-5-10-5z', fill: 'currentColor' }
29
+ * ]
30
+ * }
31
+ * ```
32
+ */
33
+ interface PluginIconData {
34
+ /** Raw SVG string (complete <svg> element) */
35
+ svg?: string;
36
+ /** SVG viewBox attribute (e.g., '0 0 24 24') */
37
+ viewBox?: string;
38
+ /** SVG path elements */
39
+ paths?: Array<{
40
+ d: string;
41
+ fill?: string;
42
+ stroke?: string;
43
+ strokeWidth?: string;
44
+ opacity?: string;
45
+ fillRule?: 'nonzero' | 'evenodd';
46
+ }>;
47
+ /** SVG circle elements */
48
+ circles?: Array<{
49
+ cx: string | number;
50
+ cy: string | number;
51
+ r: string | number;
52
+ fill?: string;
53
+ stroke?: string;
54
+ strokeWidth?: string;
55
+ opacity?: string;
56
+ }>;
57
+ /** SVG text element for abbreviation or label */
58
+ text?: {
59
+ content: string;
60
+ x?: string;
61
+ y?: string;
62
+ fontSize?: string;
63
+ fontWeight?: string;
64
+ fill?: string;
65
+ };
66
+ }
10
67
  /**
11
68
  * Provider metadata for UI display and identification
12
69
  */
@@ -226,7 +283,10 @@ type ToolFormatType = 'openai' | 'anthropic' | 'google';
226
283
  * createProvider: () => new MyProvider(),
227
284
  * getAvailableModels: async (apiKey) => [...],
228
285
  * validateApiKey: async (apiKey) => {...},
229
- * renderIcon: ({ className }) => <MyIcon className={className} />,
286
+ * icon: {
287
+ * viewBox: '0 0 24 24',
288
+ * paths: [{ d: 'M12 2L2 7l10 5 10-5-10-5z', fill: 'currentColor' }]
289
+ * },
230
290
  * };
231
291
  * ```
232
292
  */
@@ -254,8 +314,9 @@ interface LLMProviderPlugin {
254
314
  * Factory method to create an embedding provider (optional)
255
315
  * Only required if capabilities.embeddings is true
256
316
  * @param baseUrl Optional base URL for the provider
317
+ * @returns EmbeddingProvider for API-based providers, LocalEmbeddingProvider for local providers
257
318
  */
258
- createEmbeddingProvider?: (baseUrl?: string) => unknown;
319
+ createEmbeddingProvider?: (baseUrl?: string) => EmbeddingProvider | LocalEmbeddingProvider;
259
320
  /**
260
321
  * Get list of available models for this provider
261
322
  * @param apiKey API key for authentication
@@ -280,11 +341,31 @@ interface LLMProviderPlugin {
280
341
  * @param baseUrl Optional base URL
281
342
  */
282
343
  validateApiKey: (apiKey: string, baseUrl?: string) => Promise<boolean>;
344
+ /**
345
+ * Provider icon as SVG data (RECOMMENDED)
346
+ *
347
+ * Provides the icon as raw SVG data that Quilltap will render.
348
+ * This is the preferred approach as it doesn't require React in the plugin.
349
+ *
350
+ * If not provided, falls back to `renderIcon` (deprecated) or generates
351
+ * a default icon from the provider's abbreviation.
352
+ *
353
+ * @example
354
+ * ```typescript
355
+ * icon: {
356
+ * viewBox: '0 0 24 24',
357
+ * paths: [{ d: 'M12 2L2 7l10 5 10-5-10-5z', fill: 'currentColor' }]
358
+ * }
359
+ * ```
360
+ */
361
+ icon?: PluginIconData;
283
362
  /**
284
363
  * Render the provider icon as a React component
364
+ * @deprecated Use the `icon` property instead, which doesn't require React.
365
+ * This is kept for backwards compatibility with existing external plugins.
285
366
  * @param props Icon component props
286
367
  */
287
- renderIcon: (props: IconProps) => ReactNode;
368
+ renderIcon?: (props: IconProps) => ReactNode;
288
369
  /**
289
370
  * Convert universal tool format to provider-specific format (optional)
290
371
  * @param tool Tools in OpenAI format or generic objects
@@ -1096,4 +1177,4 @@ interface RoleplayTemplatePluginExport {
1096
1177
  plugin: RoleplayTemplatePlugin;
1097
1178
  }
1098
1179
 
1099
- export type { AttachmentSupport as A, AnnotationButton as B, CheapModelConfig as C, RenderingPattern as D, EmbeddingModelInfo as E, FontDefinition as F, DialogueDetection as G, ImageGenerationModelInfo as I, LLMProviderPlugin as L, ModelInfo as M, ProviderMetadata as P, RoleplayTemplateConfig as R, Spacing as S, 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, ColorPalette as p, Typography as q, Effects as r, ThemeTokens as s, EmbeddedFont as t, ThemeMetadata as u, ThemePlugin as v, ThemePluginExport as w, RoleplayTemplateMetadata as x, RoleplayTemplatePlugin as y, RoleplayTemplatePluginExport as z };
1180
+ export type { AttachmentSupport as A, Typography as B, CheapModelConfig as C, AnnotationButton as D, Effects as E, FontDefinition as F, DialogueDetection as G, RenderingPattern as H, IconProps as I, LLMProviderPlugin as L, MessageFormatSupport as M, PluginAuthor as P, RoleplayTemplateConfig as R, Spacing as S, ThemeMetadata as T, ColorPalette as a, EmbeddedFont as b, EmbeddingModelInfo as c, ImageGenerationModelInfo as d, ImageProviderConstraints as e, InstalledPluginInfo as f, ModelInfo as g, PluginCapability as h, PluginCategory as i, PluginCompatibility as j, PluginIconData as k, PluginManifest as l, PluginPermissions as m, PluginStatus as n, ProviderCapabilities as o, ProviderConfig as p, ProviderConfigRequirements as q, ProviderMetadata as r, ProviderPluginExport as s, RoleplayTemplateMetadata as t, RoleplayTemplatePlugin as u, RoleplayTemplatePluginExport as v, ThemePlugin as w, ThemePluginExport as x, ThemeTokens as y, ToolFormatType as z };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { UniversalTool } from './llm/index.mjs';
2
- export { AnthropicToolDefinition, AttachmentResults, CacheUsage, FileAttachment, GeneratedImage, GoogleToolDefinition, ImageGenParams, ImageGenProvider, ImageGenResponse, JSONSchemaDefinition, LLMMessage, LLMParams, LLMProvider, LLMResponse, ModelMetadata, ModelWarning, ModelWarningLevel, OpenAIToolDefinition, ResponseFormat, StreamChunk, TokenUsage, ToolCall, ToolCallRequest, ToolFormatOptions, ToolResult } from './llm/index.mjs';
3
- export { A as AttachmentSupport, C as CheapModelConfig, p as ColorPalette, r as Effects, t as EmbeddedFont, E as EmbeddingModelInfo, F as FontDefinition, d as IconProps, I as ImageGenerationModelInfo, c as ImageProviderConstraints, o as InstalledPluginInfo, L as LLMProviderPlugin, f as MessageFormatSupport, M as ModelInfo, j as PluginAuthor, g as PluginCapability, h as PluginCategory, k as PluginCompatibility, n as PluginManifest, m as PluginPermissions, i as PluginStatus, b as ProviderCapabilities, l as ProviderConfig, a as ProviderConfigRequirements, P as ProviderMetadata, e as ProviderPluginExport, R as RoleplayTemplateConfig, x as RoleplayTemplateMetadata, y as RoleplayTemplatePlugin, z as RoleplayTemplatePluginExport, S as Spacing, u as ThemeMetadata, v as ThemePlugin, w as ThemePluginExport, s as ThemeTokens, T as ToolFormatType, q as Typography } from './index-DtgwAg2x.mjs';
2
+ export { AnthropicToolDefinition, AttachmentResults, CacheUsage, EmbeddingOptions, EmbeddingProvider, EmbeddingResult, FileAttachment, GeneratedImage, GoogleToolDefinition, ImageGenParams, ImageGenProvider, ImageGenResponse, JSONSchemaDefinition, LLMMessage, LLMParams, LLMProvider, LLMResponse, LocalEmbeddingProvider, LocalEmbeddingProviderState, ModelMetadata, ModelWarning, ModelWarningLevel, OpenAIToolDefinition, ResponseFormat, StreamChunk, TokenUsage, ToolCall, ToolCallRequest, ToolFormatOptions, ToolResult, isLocalEmbeddingProvider } from './llm/index.mjs';
3
+ export { A as AttachmentSupport, C as CheapModelConfig, a as ColorPalette, E as Effects, b as EmbeddedFont, c as EmbeddingModelInfo, F as FontDefinition, I as IconProps, d as ImageGenerationModelInfo, e as ImageProviderConstraints, f as InstalledPluginInfo, L as LLMProviderPlugin, M as MessageFormatSupport, g as ModelInfo, P as PluginAuthor, h as PluginCapability, i as PluginCategory, j as PluginCompatibility, k as PluginIconData, l as PluginManifest, m as PluginPermissions, n as PluginStatus, o as ProviderCapabilities, p as ProviderConfig, q as ProviderConfigRequirements, r as ProviderMetadata, s as ProviderPluginExport, R as RoleplayTemplateConfig, t as RoleplayTemplateMetadata, u as RoleplayTemplatePlugin, v as RoleplayTemplatePluginExport, S as Spacing, T as ThemeMetadata, w as ThemePlugin, x as ThemePluginExport, y as ThemeTokens, z as ToolFormatType, B as Typography } from './index-CGx4cDk2.mjs';
4
4
  import { Readable } from 'stream';
5
5
  export { ApiKeyError, AttachmentError, ConfigurationError, LogContext, LogLevel, ModelNotFoundError, PluginError, PluginLogger, ProviderApiError, RateLimitError, ToolExecutionError, createConsoleLogger, createNoopLogger } from './common/index.mjs';
6
6
  import 'react';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { UniversalTool } from './llm/index.js';
2
- export { AnthropicToolDefinition, AttachmentResults, CacheUsage, FileAttachment, GeneratedImage, GoogleToolDefinition, ImageGenParams, ImageGenProvider, ImageGenResponse, JSONSchemaDefinition, LLMMessage, LLMParams, LLMProvider, LLMResponse, ModelMetadata, ModelWarning, ModelWarningLevel, OpenAIToolDefinition, ResponseFormat, StreamChunk, TokenUsage, ToolCall, ToolCallRequest, ToolFormatOptions, ToolResult } from './llm/index.js';
3
- export { A as AttachmentSupport, C as CheapModelConfig, p as ColorPalette, r as Effects, t as EmbeddedFont, E as EmbeddingModelInfo, F as FontDefinition, d as IconProps, I as ImageGenerationModelInfo, c as ImageProviderConstraints, o as InstalledPluginInfo, L as LLMProviderPlugin, f as MessageFormatSupport, M as ModelInfo, j as PluginAuthor, g as PluginCapability, h as PluginCategory, k as PluginCompatibility, n as PluginManifest, m as PluginPermissions, i as PluginStatus, b as ProviderCapabilities, l as ProviderConfig, a as ProviderConfigRequirements, P as ProviderMetadata, e as ProviderPluginExport, R as RoleplayTemplateConfig, x as RoleplayTemplateMetadata, y as RoleplayTemplatePlugin, z as RoleplayTemplatePluginExport, S as Spacing, u as ThemeMetadata, v as ThemePlugin, w as ThemePluginExport, s as ThemeTokens, T as ToolFormatType, q as Typography } from './index-3BT4ld_f.js';
2
+ export { AnthropicToolDefinition, AttachmentResults, CacheUsage, EmbeddingOptions, EmbeddingProvider, EmbeddingResult, FileAttachment, GeneratedImage, GoogleToolDefinition, ImageGenParams, ImageGenProvider, ImageGenResponse, JSONSchemaDefinition, LLMMessage, LLMParams, LLMProvider, LLMResponse, LocalEmbeddingProvider, LocalEmbeddingProviderState, ModelMetadata, ModelWarning, ModelWarningLevel, OpenAIToolDefinition, ResponseFormat, StreamChunk, TokenUsage, ToolCall, ToolCallRequest, ToolFormatOptions, ToolResult, isLocalEmbeddingProvider } from './llm/index.js';
3
+ export { A as AttachmentSupport, C as CheapModelConfig, a as ColorPalette, E as Effects, b as EmbeddedFont, c as EmbeddingModelInfo, F as FontDefinition, I as IconProps, d as ImageGenerationModelInfo, e as ImageProviderConstraints, f as InstalledPluginInfo, L as LLMProviderPlugin, M as MessageFormatSupport, g as ModelInfo, P as PluginAuthor, h as PluginCapability, i as PluginCategory, j as PluginCompatibility, k as PluginIconData, l as PluginManifest, m as PluginPermissions, n as PluginStatus, o as ProviderCapabilities, p as ProviderConfig, q as ProviderConfigRequirements, r as ProviderMetadata, s as ProviderPluginExport, R as RoleplayTemplateConfig, t as RoleplayTemplateMetadata, u as RoleplayTemplatePlugin, v as RoleplayTemplatePluginExport, S as Spacing, T as ThemeMetadata, w as ThemePlugin, x as ThemePluginExport, y as ThemeTokens, z as ToolFormatType, B as Typography } from './index-Dtz0bUL8.js';
4
4
  import { Readable } from 'stream';
5
5
  export { ApiKeyError, AttachmentError, ConfigurationError, LogContext, LogLevel, ModelNotFoundError, PluginError, PluginLogger, ProviderApiError, RateLimitError, ToolExecutionError, createConsoleLogger, createNoopLogger } from './common/index.js';
6
6
  import 'react';
package/dist/index.js CHANGED
@@ -1,5 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ // src/llm/embeddings.ts
4
+ function isLocalEmbeddingProvider(provider) {
5
+ return "fitCorpus" in provider && "loadState" in provider && "getState" in provider;
6
+ }
7
+
3
8
  // src/common/errors.ts
4
9
  var PluginError = class extends Error {
5
10
  constructor(message, code, pluginName) {
@@ -120,5 +125,6 @@ exports.RateLimitError = RateLimitError;
120
125
  exports.ToolExecutionError = ToolExecutionError;
121
126
  exports.createConsoleLogger = createConsoleLogger;
122
127
  exports.createNoopLogger = createNoopLogger;
128
+ exports.isLocalEmbeddingProvider = isLocalEmbeddingProvider;
123
129
  //# sourceMappingURL=index.js.map
124
130
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common/errors.ts","../src/common/logger.ts","../src/index.ts"],"names":[],"mappings":";;;AAWO,IA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AA,EAAO,CAAC,OAAA,EAAiB,OAAA,EAAsB,KAAA,KAAwB;AACrE,MAAA,IAAI,SAAA,CAAU,OAAO,CAAA,EAAG;AACtB,QAAA,OAAA,CAAQ,KAAA;AAAA,UACN,IAAI,MAAM,CAAA,EAAA,EAAK,OAAO,CAAA,EAAG,aAAA,CAAc,OAAO,CAAC,CAAA,CAAA;AAAA,UAC/C,KAAA,GAAQ;AAAA,EAAK,KAAA,CAAM,KAAA,IAAS,KAAA,CAAM,OAAO,CAAA,CAAA,GAAK;AAAA,SAChD;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF;AAOO,SAAS,gBAAA,GAAiC;AAC/C,EAAA,MAAM,OAAO,MAAY;AAAA,EAAC,CAAA;AAC1B,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,IAAA;AAAA,IACP,IAAA,EAAM,IAAA;AAAA,IACN,IAAA,EAAM,IAAA;AAAA,IACN,KAAA,EAAO;AAAA,GACT;AACF;;;ACmCO,IAAM,oBAAA,GAAuB","file":"index.js","sourcesContent":["/**\n * Common error types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/errors\n */\n\n/**\n * Base plugin error\n *\n * All plugin-specific errors should extend this class.\n */\nexport class PluginError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly pluginName?: string\n ) {\n super(message);\n this.name = 'PluginError';\n }\n}\n\n/**\n * API key validation error\n *\n * Thrown when an API key is invalid or has insufficient permissions.\n */\nexport class ApiKeyError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'API_KEY_ERROR', pluginName);\n this.name = 'ApiKeyError';\n }\n}\n\n/**\n * Provider API error\n *\n * Thrown when the provider API returns an error.\n */\nexport class ProviderApiError extends PluginError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly response?: unknown,\n pluginName?: string\n ) {\n super(message, 'PROVIDER_API_ERROR', pluginName);\n this.name = 'ProviderApiError';\n }\n}\n\n/**\n * Rate limit error\n *\n * Thrown when the provider rate limits the request.\n */\nexport class RateLimitError extends ProviderApiError {\n public override readonly code = 'RATE_LIMIT_ERROR';\n\n constructor(\n message: string,\n public readonly retryAfter?: number,\n pluginName?: string\n ) {\n super(message, 429, undefined, pluginName);\n this.name = 'RateLimitError';\n }\n}\n\n/**\n * Configuration error\n *\n * Thrown when plugin configuration is invalid.\n */\nexport class ConfigurationError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'CONFIGURATION_ERROR', pluginName);\n this.name = 'ConfigurationError';\n }\n}\n\n/**\n * Model not found error\n *\n * Thrown when a requested model is not available.\n */\nexport class ModelNotFoundError extends PluginError {\n constructor(\n message: string,\n public readonly modelId?: string,\n pluginName?: string\n ) {\n super(message, 'MODEL_NOT_FOUND', pluginName);\n this.name = 'ModelNotFoundError';\n }\n}\n\n/**\n * Attachment error\n *\n * Thrown when there's an issue processing file attachments.\n */\nexport class AttachmentError extends PluginError {\n constructor(\n message: string,\n public readonly attachmentId?: string,\n pluginName?: string\n ) {\n super(message, 'ATTACHMENT_ERROR', pluginName);\n this.name = 'AttachmentError';\n }\n}\n\n/**\n * Tool execution error\n *\n * Thrown when a tool call fails to execute.\n */\nexport class ToolExecutionError extends PluginError {\n constructor(\n message: string,\n public readonly toolName?: string,\n pluginName?: string\n ) {\n super(message, 'TOOL_EXECUTION_ERROR', pluginName);\n this.name = 'ToolExecutionError';\n }\n}\n","/**\n * Logger types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/logger\n */\n\n/**\n * Log level type\n */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Log context metadata\n */\nexport interface LogContext {\n /** Context identifier (e.g., module name) */\n context?: string;\n /** Additional metadata */\n [key: string]: unknown;\n}\n\n/**\n * Logger interface that plugins can implement or receive\n *\n * This interface is compatible with Quilltap's built-in logger.\n * Plugins can use this interface to accept a logger from the host\n * application or implement their own logging.\n */\nexport interface PluginLogger {\n /**\n * Log a debug message\n * @param message Message to log\n * @param context Optional context metadata\n */\n debug(message: string, context?: LogContext): void;\n\n /**\n * Log an info message\n * @param message Message to log\n * @param context Optional context metadata\n */\n info(message: string, context?: LogContext): void;\n\n /**\n * Log a warning message\n * @param message Message to log\n * @param context Optional context metadata\n */\n warn(message: string, context?: LogContext): void;\n\n /**\n * Log an error message\n * @param message Message to log\n * @param context Optional context metadata\n * @param error Optional error object\n */\n error(message: string, context?: LogContext, error?: Error): void;\n}\n\n/**\n * Simple console-based logger for standalone plugin development\n *\n * This logger writes to the console and is useful for local\n * plugin development and testing.\n *\n * @param prefix Prefix to add to all log messages\n * @param minLevel Minimum log level to output (default: 'info')\n * @returns A PluginLogger instance\n *\n * @example\n * ```typescript\n * const logger = createConsoleLogger('my-plugin', 'debug');\n * logger.debug('Initializing plugin', { version: '1.0.0' });\n * logger.info('Plugin ready');\n * logger.error('Failed to connect', { endpoint: 'api.example.com' }, new Error('Connection refused'));\n * ```\n */\nexport function createConsoleLogger(prefix: string, minLevel: LogLevel = 'info'): PluginLogger {\n const levels: LogLevel[] = ['debug', 'info', 'warn', 'error'];\n const shouldLog = (level: LogLevel): boolean =>\n levels.indexOf(level) >= levels.indexOf(minLevel);\n\n const formatContext = (context?: LogContext): string => {\n if (!context) return '';\n const entries = Object.entries(context)\n .filter(([key]) => key !== 'context')\n .map(([key, value]) => `${key}=${JSON.stringify(value)}`)\n .join(' ');\n return entries ? ` ${entries}` : '';\n };\n\n return {\n debug: (message: string, context?: LogContext): void => {\n if (shouldLog('debug')) {\n console.debug(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n info: (message: string, context?: LogContext): void => {\n if (shouldLog('info')) {\n console.info(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n warn: (message: string, context?: LogContext): void => {\n if (shouldLog('warn')) {\n console.warn(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n error: (message: string, context?: LogContext, error?: Error): void => {\n if (shouldLog('error')) {\n console.error(\n `[${prefix}] ${message}${formatContext(context)}`,\n error ? `\\n${error.stack || error.message}` : ''\n );\n }\n },\n };\n}\n\n/**\n * No-op logger for production or when logging is disabled\n *\n * @returns A PluginLogger that does nothing\n */\nexport function createNoopLogger(): PluginLogger {\n const noop = (): void => {};\n return {\n debug: noop,\n info: noop,\n warn: noop,\n error: noop,\n };\n}\n","/**\n * @quilltap/plugin-types\n *\n * Type definitions for Quilltap plugin development.\n *\n * This package provides TypeScript types and interfaces for building\n * Quilltap plugins, including LLM providers, authentication providers,\n * and utility plugins.\n *\n * @packageDocumentation\n * @module @quilltap/plugin-types\n */\n\n// ============================================================================\n// LLM Types\n// ============================================================================\n\nexport type {\n // Core message types\n FileAttachment,\n LLMMessage,\n JSONSchemaDefinition,\n ResponseFormat,\n LLMParams,\n\n // Response types\n TokenUsage,\n CacheUsage,\n AttachmentResults,\n LLMResponse,\n StreamChunk,\n\n // Image generation types\n ImageGenParams,\n GeneratedImage,\n ImageGenResponse,\n\n // Model metadata\n ModelWarningLevel,\n ModelWarning,\n ModelMetadata,\n\n // Provider interfaces\n LLMProvider,\n ImageGenProvider,\n} from './llm/base';\n\nexport type {\n // Tool definitions\n OpenAIToolDefinition,\n UniversalTool,\n AnthropicToolDefinition,\n GoogleToolDefinition,\n\n // Tool calls\n ToolCall,\n ToolCallRequest,\n ToolResult,\n ToolFormatOptions,\n} from './llm/tools';\n\n// ============================================================================\n// Plugin Types\n// ============================================================================\n\nexport type {\n // Provider plugin types\n ProviderMetadata,\n ProviderConfigRequirements,\n ProviderCapabilities,\n AttachmentSupport,\n ModelInfo,\n EmbeddingModelInfo,\n ImageGenerationModelInfo,\n ImageProviderConstraints,\n IconProps,\n LLMProviderPlugin,\n ProviderPluginExport,\n // Runtime configuration types\n MessageFormatSupport,\n CheapModelConfig,\n ToolFormatType,\n} from './plugins/provider';\n\nexport type {\n // Manifest types\n PluginCapability,\n PluginCategory,\n PluginStatus,\n PluginAuthor,\n PluginCompatibility,\n ProviderConfig,\n PluginPermissions,\n PluginManifest,\n InstalledPluginInfo,\n} from './plugins/manifest';\n\nexport type {\n // Theme plugin types\n ColorPalette,\n Typography,\n Spacing,\n Effects,\n ThemeTokens,\n FontDefinition,\n EmbeddedFont,\n ThemeMetadata,\n ThemePlugin,\n ThemePluginExport,\n} from './plugins/theme';\n\nexport type {\n // Roleplay template plugin types\n RoleplayTemplateConfig,\n RoleplayTemplateMetadata,\n RoleplayTemplatePlugin,\n RoleplayTemplatePluginExport,\n} from './plugins/roleplay-template';\n\nexport type {\n // Tool plugin types\n ToolMetadata,\n ToolHierarchyInfo,\n ToolExecutionContext,\n ToolExecutionResult,\n ToolPlugin,\n ToolPluginExport,\n} from './plugins/tool';\n\nexport type {\n // File storage plugin types\n FileBackendCapabilities,\n FileBackendMetadata,\n FileMetadata,\n FileStorageBackend,\n FileStorageConfigField,\n FileStorageProviderPlugin,\n FileStoragePluginExport,\n} from './plugins/file-storage';\n\n// ============================================================================\n// Common Types\n// ============================================================================\n\nexport type { LogLevel, LogContext, PluginLogger } from './common/logger';\n\n// Error classes (these are values, not just types)\nexport {\n PluginError,\n ApiKeyError,\n ProviderApiError,\n RateLimitError,\n ConfigurationError,\n ModelNotFoundError,\n AttachmentError,\n ToolExecutionError,\n} from './common/errors';\n\n// Logger factories\nexport { createConsoleLogger, createNoopLogger } from './common/logger';\n\n// ============================================================================\n// Version\n// ============================================================================\n\n/**\n * Version of the plugin-types package.\n * Can be used at runtime to check compatibility.\n */\nexport const PLUGIN_TYPES_VERSION = '1.3.0';\n"]}
1
+ {"version":3,"sources":["../src/llm/embeddings.ts","../src/common/errors.ts","../src/common/logger.ts","../src/index.ts"],"names":[],"mappings":";;;AAyLO,SAAS,yBACd,QAAA,EACoC;AACpC,EAAA,OAAO,WAAA,IAAe,QAAA,IAAY,WAAA,IAAe,QAAA,IAAY,UAAA,IAAc,QAAA;AAC7E;;;AClLO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EACrC,WAAA,CACE,OAAA,EACgB,IAAA,EACA,UAAA,EAChB;AACA,IAAA,KAAA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,QAAA,OAAA,CAAQ,KAAA;AAAA,UACN,IAAI,MAAM,CAAA,EAAA,EAAK,OAAO,CAAA,EAAG,aAAA,CAAc,OAAO,CAAC,CAAA,CAAA;AAAA,UAC/C,KAAA,GAAQ;AAAA,EAAK,KAAA,CAAM,KAAA,IAAS,KAAA,CAAM,OAAO,CAAA,CAAA,GAAK;AAAA,SAChD;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF;AAOO,SAAS,gBAAA,GAAiC;AAC/C,EAAA,MAAM,OAAO,MAAY;AAAA,EAAC,CAAA;AAC1B,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,IAAA;AAAA,IACP,IAAA,EAAM,IAAA;AAAA,IACN,IAAA,EAAM,IAAA;AAAA,IACN,KAAA,EAAO;AAAA,GACT;AACF;;;AC+CO,IAAM,oBAAA,GAAuB","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","/**\n * Common error types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/errors\n */\n\n/**\n * Base plugin error\n *\n * All plugin-specific errors should extend this class.\n */\nexport class PluginError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly pluginName?: string\n ) {\n super(message);\n this.name = 'PluginError';\n }\n}\n\n/**\n * API key validation error\n *\n * Thrown when an API key is invalid or has insufficient permissions.\n */\nexport class ApiKeyError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'API_KEY_ERROR', pluginName);\n this.name = 'ApiKeyError';\n }\n}\n\n/**\n * Provider API error\n *\n * Thrown when the provider API returns an error.\n */\nexport class ProviderApiError extends PluginError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly response?: unknown,\n pluginName?: string\n ) {\n super(message, 'PROVIDER_API_ERROR', pluginName);\n this.name = 'ProviderApiError';\n }\n}\n\n/**\n * Rate limit error\n *\n * Thrown when the provider rate limits the request.\n */\nexport class RateLimitError extends ProviderApiError {\n public override readonly code = 'RATE_LIMIT_ERROR';\n\n constructor(\n message: string,\n public readonly retryAfter?: number,\n pluginName?: string\n ) {\n super(message, 429, undefined, pluginName);\n this.name = 'RateLimitError';\n }\n}\n\n/**\n * Configuration error\n *\n * Thrown when plugin configuration is invalid.\n */\nexport class ConfigurationError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'CONFIGURATION_ERROR', pluginName);\n this.name = 'ConfigurationError';\n }\n}\n\n/**\n * Model not found error\n *\n * Thrown when a requested model is not available.\n */\nexport class ModelNotFoundError extends PluginError {\n constructor(\n message: string,\n public readonly modelId?: string,\n pluginName?: string\n ) {\n super(message, 'MODEL_NOT_FOUND', pluginName);\n this.name = 'ModelNotFoundError';\n }\n}\n\n/**\n * Attachment error\n *\n * Thrown when there's an issue processing file attachments.\n */\nexport class AttachmentError extends PluginError {\n constructor(\n message: string,\n public readonly attachmentId?: string,\n pluginName?: string\n ) {\n super(message, 'ATTACHMENT_ERROR', pluginName);\n this.name = 'AttachmentError';\n }\n}\n\n/**\n * Tool execution error\n *\n * Thrown when a tool call fails to execute.\n */\nexport class ToolExecutionError extends PluginError {\n constructor(\n message: string,\n public readonly toolName?: string,\n pluginName?: string\n ) {\n super(message, 'TOOL_EXECUTION_ERROR', pluginName);\n this.name = 'ToolExecutionError';\n }\n}\n","/**\n * Logger types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/logger\n */\n\n/**\n * Log level type\n */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Log context metadata\n */\nexport interface LogContext {\n /** Context identifier (e.g., module name) */\n context?: string;\n /** Additional metadata */\n [key: string]: unknown;\n}\n\n/**\n * Logger interface that plugins can implement or receive\n *\n * This interface is compatible with Quilltap's built-in logger.\n * Plugins can use this interface to accept a logger from the host\n * application or implement their own logging.\n */\nexport interface PluginLogger {\n /**\n * Log a debug message\n * @param message Message to log\n * @param context Optional context metadata\n */\n debug(message: string, context?: LogContext): void;\n\n /**\n * Log an info message\n * @param message Message to log\n * @param context Optional context metadata\n */\n info(message: string, context?: LogContext): void;\n\n /**\n * Log a warning message\n * @param message Message to log\n * @param context Optional context metadata\n */\n warn(message: string, context?: LogContext): void;\n\n /**\n * Log an error message\n * @param message Message to log\n * @param context Optional context metadata\n * @param error Optional error object\n */\n error(message: string, context?: LogContext, error?: Error): void;\n}\n\n/**\n * Simple console-based logger for standalone plugin development\n *\n * This logger writes to the console and is useful for local\n * plugin development and testing.\n *\n * @param prefix Prefix to add to all log messages\n * @param minLevel Minimum log level to output (default: 'info')\n * @returns A PluginLogger instance\n *\n * @example\n * ```typescript\n * const logger = createConsoleLogger('my-plugin', 'debug');\n * logger.debug('Initializing plugin', { version: '1.0.0' });\n * logger.info('Plugin ready');\n * logger.error('Failed to connect', { endpoint: 'api.example.com' }, new Error('Connection refused'));\n * ```\n */\nexport function createConsoleLogger(prefix: string, minLevel: LogLevel = 'info'): PluginLogger {\n const levels: LogLevel[] = ['debug', 'info', 'warn', 'error'];\n const shouldLog = (level: LogLevel): boolean =>\n levels.indexOf(level) >= levels.indexOf(minLevel);\n\n const formatContext = (context?: LogContext): string => {\n if (!context) return '';\n const entries = Object.entries(context)\n .filter(([key]) => key !== 'context')\n .map(([key, value]) => `${key}=${JSON.stringify(value)}`)\n .join(' ');\n return entries ? ` ${entries}` : '';\n };\n\n return {\n debug: (message: string, context?: LogContext): void => {\n if (shouldLog('debug')) {\n console.debug(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n info: (message: string, context?: LogContext): void => {\n if (shouldLog('info')) {\n console.info(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n warn: (message: string, context?: LogContext): void => {\n if (shouldLog('warn')) {\n console.warn(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n error: (message: string, context?: LogContext, error?: Error): void => {\n if (shouldLog('error')) {\n console.error(\n `[${prefix}] ${message}${formatContext(context)}`,\n error ? `\\n${error.stack || error.message}` : ''\n );\n }\n },\n };\n}\n\n/**\n * No-op logger for production or when logging is disabled\n *\n * @returns A PluginLogger that does nothing\n */\nexport function createNoopLogger(): PluginLogger {\n const noop = (): void => {};\n return {\n debug: noop,\n info: noop,\n warn: noop,\n error: noop,\n };\n}\n","/**\n * @quilltap/plugin-types\n *\n * Type definitions for Quilltap plugin development.\n *\n * This package provides TypeScript types and interfaces for building\n * Quilltap plugins, including LLM providers, authentication providers,\n * and utility plugins.\n *\n * @packageDocumentation\n * @module @quilltap/plugin-types\n */\n\n// ============================================================================\n// LLM Types\n// ============================================================================\n\nexport type {\n // Core message types\n FileAttachment,\n LLMMessage,\n JSONSchemaDefinition,\n ResponseFormat,\n LLMParams,\n\n // Response types\n TokenUsage,\n CacheUsage,\n AttachmentResults,\n LLMResponse,\n StreamChunk,\n\n // Image generation types\n ImageGenParams,\n GeneratedImage,\n ImageGenResponse,\n\n // Model metadata\n ModelWarningLevel,\n ModelWarning,\n ModelMetadata,\n\n // Provider interfaces\n LLMProvider,\n ImageGenProvider,\n} from './llm/base';\n\nexport type {\n // Tool definitions\n OpenAIToolDefinition,\n UniversalTool,\n AnthropicToolDefinition,\n GoogleToolDefinition,\n\n // Tool calls\n ToolCall,\n ToolCallRequest,\n ToolResult,\n ToolFormatOptions,\n} from './llm/tools';\n\nexport type {\n // Embedding types\n EmbeddingResult,\n EmbeddingOptions,\n EmbeddingProvider,\n LocalEmbeddingProviderState,\n LocalEmbeddingProvider,\n} from './llm/embeddings';\n\nexport { isLocalEmbeddingProvider } from './llm/embeddings';\n\n// ============================================================================\n// Plugin Types\n// ============================================================================\n\nexport type {\n // Provider plugin types\n ProviderMetadata,\n ProviderConfigRequirements,\n ProviderCapabilities,\n AttachmentSupport,\n ModelInfo,\n EmbeddingModelInfo,\n ImageGenerationModelInfo,\n ImageProviderConstraints,\n IconProps,\n PluginIconData,\n LLMProviderPlugin,\n ProviderPluginExport,\n // Runtime configuration types\n MessageFormatSupport,\n CheapModelConfig,\n ToolFormatType,\n} from './plugins/provider';\n\nexport type {\n // Manifest types\n PluginCapability,\n PluginCategory,\n PluginStatus,\n PluginAuthor,\n PluginCompatibility,\n ProviderConfig,\n PluginPermissions,\n PluginManifest,\n InstalledPluginInfo,\n} from './plugins/manifest';\n\nexport type {\n // Theme plugin types\n ColorPalette,\n Typography,\n Spacing,\n Effects,\n ThemeTokens,\n FontDefinition,\n EmbeddedFont,\n ThemeMetadata,\n ThemePlugin,\n ThemePluginExport,\n} from './plugins/theme';\n\nexport type {\n // Roleplay template plugin types\n RoleplayTemplateConfig,\n RoleplayTemplateMetadata,\n RoleplayTemplatePlugin,\n RoleplayTemplatePluginExport,\n} from './plugins/roleplay-template';\n\nexport type {\n // Tool plugin types\n ToolMetadata,\n ToolHierarchyInfo,\n ToolExecutionContext,\n ToolExecutionResult,\n ToolPlugin,\n ToolPluginExport,\n} from './plugins/tool';\n\nexport type {\n // File storage plugin types\n FileBackendCapabilities,\n FileBackendMetadata,\n FileMetadata,\n FileStorageBackend,\n FileStorageConfigField,\n FileStorageProviderPlugin,\n FileStoragePluginExport,\n} from './plugins/file-storage';\n\n// ============================================================================\n// Common Types\n// ============================================================================\n\nexport type { LogLevel, LogContext, PluginLogger } from './common/logger';\n\n// Error classes (these are values, not just types)\nexport {\n PluginError,\n ApiKeyError,\n ProviderApiError,\n RateLimitError,\n ConfigurationError,\n ModelNotFoundError,\n AttachmentError,\n ToolExecutionError,\n} from './common/errors';\n\n// Logger factories\nexport { createConsoleLogger, createNoopLogger } from './common/logger';\n\n// ============================================================================\n// Version\n// ============================================================================\n\n/**\n * Version of the plugin-types package.\n * Can be used at runtime to check compatibility.\n */\nexport const PLUGIN_TYPES_VERSION = '1.3.0';\n"]}
package/dist/index.mjs CHANGED
@@ -1,3 +1,8 @@
1
+ // src/llm/embeddings.ts
2
+ function isLocalEmbeddingProvider(provider) {
3
+ return "fitCorpus" in provider && "loadState" in provider && "getState" in provider;
4
+ }
5
+
1
6
  // src/common/errors.ts
2
7
  var PluginError = class extends Error {
3
8
  constructor(message, code, pluginName) {
@@ -107,6 +112,6 @@ function createNoopLogger() {
107
112
  // src/index.ts
108
113
  var PLUGIN_TYPES_VERSION = "1.3.0";
109
114
 
110
- export { ApiKeyError, AttachmentError, ConfigurationError, ModelNotFoundError, PLUGIN_TYPES_VERSION, PluginError, ProviderApiError, RateLimitError, ToolExecutionError, createConsoleLogger, createNoopLogger };
115
+ export { ApiKeyError, AttachmentError, ConfigurationError, ModelNotFoundError, PLUGIN_TYPES_VERSION, PluginError, ProviderApiError, RateLimitError, ToolExecutionError, createConsoleLogger, createNoopLogger, isLocalEmbeddingProvider };
111
116
  //# sourceMappingURL=index.mjs.map
112
117
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common/errors.ts","../src/common/logger.ts","../src/index.ts"],"names":[],"mappings":";AAWO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EACrC,WAAA,CACE,OAAA,EACgB,IAAA,EACA,UAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAHG,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AAAA,EACd;AACF;AAOO,IAAM,WAAA,GAAN,cAA0B,WAAA,CAAY;AAAA,EAC3C,WAAA,CAAY,SAAiB,UAAA,EAAqB;AAChD,IAAA,KAAA,CAAM,OAAA,EAAS,iBAAiB,UAAU,CAAA;AAC1C,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AAAA,EACd;AACF;AAOO,IAAM,gBAAA,GAAN,cAA+B,WAAA,CAAY;AAAA,EAChD,WAAA,CACE,OAAA,EACgB,UAAA,EACA,QAAA,EAChB,UAAA,EACA;AACA,IAAA,KAAA,CAAM,OAAA,EAAS,sBAAsB,UAAU,CAAA;AAJ/B,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AAIhB,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AAAA,EACd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MAAM,CAAA,EAAG;AACrB,QAAA,OAAA,CAAQ,IAAA,CAAK,IAAI,MAAM,CAAA,EAAA,EAAK,OAAO,CAAA,EAAG,aAAA,CAAc,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,MAChE;AAAA,IACF,CAAA;AAAA,IAEA,IAAA,EAAM,CAAC,OAAA,EAAiB,OAAA,KAA+B;AACrD,MAAA,IAAI,SAAA,CAAU,MAAM,CAAA,EAAG;AACrB,QAAA,OAAA,CAAQ,IAAA,CAAK,IAAI,MAAM,CAAA,EAAA,EAAK,OAAO,CAAA,EAAG,aAAA,CAAc,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,MAChE;AAAA,IACF,CAAA;AAAA,IAEA,KAAA,EAAO,CAAC,OAAA,EAAiB,OAAA,EAAsB,KAAA,KAAwB;AACrE,MAAA,IAAI,SAAA,CAAU,OAAO,CAAA,EAAG;AACtB,QAAA,OAAA,CAAQ,KAAA;AAAA,UACN,IAAI,MAAM,CAAA,EAAA,EAAK,OAAO,CAAA,EAAG,aAAA,CAAc,OAAO,CAAC,CAAA,CAAA;AAAA,UAC/C,KAAA,GAAQ;AAAA,EAAK,KAAA,CAAM,KAAA,IAAS,KAAA,CAAM,OAAO,CAAA,CAAA,GAAK;AAAA,SAChD;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF;AAOO,SAAS,gBAAA,GAAiC;AAC/C,EAAA,MAAM,OAAO,MAAY;AAAA,EAAC,CAAA;AAC1B,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,IAAA;AAAA,IACP,IAAA,EAAM,IAAA;AAAA,IACN,IAAA,EAAM,IAAA;AAAA,IACN,KAAA,EAAO;AAAA,GACT;AACF;;;ACmCO,IAAM,oBAAA,GAAuB","file":"index.mjs","sourcesContent":["/**\n * Common error types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/errors\n */\n\n/**\n * Base plugin error\n *\n * All plugin-specific errors should extend this class.\n */\nexport class PluginError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly pluginName?: string\n ) {\n super(message);\n this.name = 'PluginError';\n }\n}\n\n/**\n * API key validation error\n *\n * Thrown when an API key is invalid or has insufficient permissions.\n */\nexport class ApiKeyError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'API_KEY_ERROR', pluginName);\n this.name = 'ApiKeyError';\n }\n}\n\n/**\n * Provider API error\n *\n * Thrown when the provider API returns an error.\n */\nexport class ProviderApiError extends PluginError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly response?: unknown,\n pluginName?: string\n ) {\n super(message, 'PROVIDER_API_ERROR', pluginName);\n this.name = 'ProviderApiError';\n }\n}\n\n/**\n * Rate limit error\n *\n * Thrown when the provider rate limits the request.\n */\nexport class RateLimitError extends ProviderApiError {\n public override readonly code = 'RATE_LIMIT_ERROR';\n\n constructor(\n message: string,\n public readonly retryAfter?: number,\n pluginName?: string\n ) {\n super(message, 429, undefined, pluginName);\n this.name = 'RateLimitError';\n }\n}\n\n/**\n * Configuration error\n *\n * Thrown when plugin configuration is invalid.\n */\nexport class ConfigurationError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'CONFIGURATION_ERROR', pluginName);\n this.name = 'ConfigurationError';\n }\n}\n\n/**\n * Model not found error\n *\n * Thrown when a requested model is not available.\n */\nexport class ModelNotFoundError extends PluginError {\n constructor(\n message: string,\n public readonly modelId?: string,\n pluginName?: string\n ) {\n super(message, 'MODEL_NOT_FOUND', pluginName);\n this.name = 'ModelNotFoundError';\n }\n}\n\n/**\n * Attachment error\n *\n * Thrown when there's an issue processing file attachments.\n */\nexport class AttachmentError extends PluginError {\n constructor(\n message: string,\n public readonly attachmentId?: string,\n pluginName?: string\n ) {\n super(message, 'ATTACHMENT_ERROR', pluginName);\n this.name = 'AttachmentError';\n }\n}\n\n/**\n * Tool execution error\n *\n * Thrown when a tool call fails to execute.\n */\nexport class ToolExecutionError extends PluginError {\n constructor(\n message: string,\n public readonly toolName?: string,\n pluginName?: string\n ) {\n super(message, 'TOOL_EXECUTION_ERROR', pluginName);\n this.name = 'ToolExecutionError';\n }\n}\n","/**\n * Logger types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/logger\n */\n\n/**\n * Log level type\n */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Log context metadata\n */\nexport interface LogContext {\n /** Context identifier (e.g., module name) */\n context?: string;\n /** Additional metadata */\n [key: string]: unknown;\n}\n\n/**\n * Logger interface that plugins can implement or receive\n *\n * This interface is compatible with Quilltap's built-in logger.\n * Plugins can use this interface to accept a logger from the host\n * application or implement their own logging.\n */\nexport interface PluginLogger {\n /**\n * Log a debug message\n * @param message Message to log\n * @param context Optional context metadata\n */\n debug(message: string, context?: LogContext): void;\n\n /**\n * Log an info message\n * @param message Message to log\n * @param context Optional context metadata\n */\n info(message: string, context?: LogContext): void;\n\n /**\n * Log a warning message\n * @param message Message to log\n * @param context Optional context metadata\n */\n warn(message: string, context?: LogContext): void;\n\n /**\n * Log an error message\n * @param message Message to log\n * @param context Optional context metadata\n * @param error Optional error object\n */\n error(message: string, context?: LogContext, error?: Error): void;\n}\n\n/**\n * Simple console-based logger for standalone plugin development\n *\n * This logger writes to the console and is useful for local\n * plugin development and testing.\n *\n * @param prefix Prefix to add to all log messages\n * @param minLevel Minimum log level to output (default: 'info')\n * @returns A PluginLogger instance\n *\n * @example\n * ```typescript\n * const logger = createConsoleLogger('my-plugin', 'debug');\n * logger.debug('Initializing plugin', { version: '1.0.0' });\n * logger.info('Plugin ready');\n * logger.error('Failed to connect', { endpoint: 'api.example.com' }, new Error('Connection refused'));\n * ```\n */\nexport function createConsoleLogger(prefix: string, minLevel: LogLevel = 'info'): PluginLogger {\n const levels: LogLevel[] = ['debug', 'info', 'warn', 'error'];\n const shouldLog = (level: LogLevel): boolean =>\n levels.indexOf(level) >= levels.indexOf(minLevel);\n\n const formatContext = (context?: LogContext): string => {\n if (!context) return '';\n const entries = Object.entries(context)\n .filter(([key]) => key !== 'context')\n .map(([key, value]) => `${key}=${JSON.stringify(value)}`)\n .join(' ');\n return entries ? ` ${entries}` : '';\n };\n\n return {\n debug: (message: string, context?: LogContext): void => {\n if (shouldLog('debug')) {\n console.debug(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n info: (message: string, context?: LogContext): void => {\n if (shouldLog('info')) {\n console.info(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n warn: (message: string, context?: LogContext): void => {\n if (shouldLog('warn')) {\n console.warn(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n error: (message: string, context?: LogContext, error?: Error): void => {\n if (shouldLog('error')) {\n console.error(\n `[${prefix}] ${message}${formatContext(context)}`,\n error ? `\\n${error.stack || error.message}` : ''\n );\n }\n },\n };\n}\n\n/**\n * No-op logger for production or when logging is disabled\n *\n * @returns A PluginLogger that does nothing\n */\nexport function createNoopLogger(): PluginLogger {\n const noop = (): void => {};\n return {\n debug: noop,\n info: noop,\n warn: noop,\n error: noop,\n };\n}\n","/**\n * @quilltap/plugin-types\n *\n * Type definitions for Quilltap plugin development.\n *\n * This package provides TypeScript types and interfaces for building\n * Quilltap plugins, including LLM providers, authentication providers,\n * and utility plugins.\n *\n * @packageDocumentation\n * @module @quilltap/plugin-types\n */\n\n// ============================================================================\n// LLM Types\n// ============================================================================\n\nexport type {\n // Core message types\n FileAttachment,\n LLMMessage,\n JSONSchemaDefinition,\n ResponseFormat,\n LLMParams,\n\n // Response types\n TokenUsage,\n CacheUsage,\n AttachmentResults,\n LLMResponse,\n StreamChunk,\n\n // Image generation types\n ImageGenParams,\n GeneratedImage,\n ImageGenResponse,\n\n // Model metadata\n ModelWarningLevel,\n ModelWarning,\n ModelMetadata,\n\n // Provider interfaces\n LLMProvider,\n ImageGenProvider,\n} from './llm/base';\n\nexport type {\n // Tool definitions\n OpenAIToolDefinition,\n UniversalTool,\n AnthropicToolDefinition,\n GoogleToolDefinition,\n\n // Tool calls\n ToolCall,\n ToolCallRequest,\n ToolResult,\n ToolFormatOptions,\n} from './llm/tools';\n\n// ============================================================================\n// Plugin Types\n// ============================================================================\n\nexport type {\n // Provider plugin types\n ProviderMetadata,\n ProviderConfigRequirements,\n ProviderCapabilities,\n AttachmentSupport,\n ModelInfo,\n EmbeddingModelInfo,\n ImageGenerationModelInfo,\n ImageProviderConstraints,\n IconProps,\n LLMProviderPlugin,\n ProviderPluginExport,\n // Runtime configuration types\n MessageFormatSupport,\n CheapModelConfig,\n ToolFormatType,\n} from './plugins/provider';\n\nexport type {\n // Manifest types\n PluginCapability,\n PluginCategory,\n PluginStatus,\n PluginAuthor,\n PluginCompatibility,\n ProviderConfig,\n PluginPermissions,\n PluginManifest,\n InstalledPluginInfo,\n} from './plugins/manifest';\n\nexport type {\n // Theme plugin types\n ColorPalette,\n Typography,\n Spacing,\n Effects,\n ThemeTokens,\n FontDefinition,\n EmbeddedFont,\n ThemeMetadata,\n ThemePlugin,\n ThemePluginExport,\n} from './plugins/theme';\n\nexport type {\n // Roleplay template plugin types\n RoleplayTemplateConfig,\n RoleplayTemplateMetadata,\n RoleplayTemplatePlugin,\n RoleplayTemplatePluginExport,\n} from './plugins/roleplay-template';\n\nexport type {\n // Tool plugin types\n ToolMetadata,\n ToolHierarchyInfo,\n ToolExecutionContext,\n ToolExecutionResult,\n ToolPlugin,\n ToolPluginExport,\n} from './plugins/tool';\n\nexport type {\n // File storage plugin types\n FileBackendCapabilities,\n FileBackendMetadata,\n FileMetadata,\n FileStorageBackend,\n FileStorageConfigField,\n FileStorageProviderPlugin,\n FileStoragePluginExport,\n} from './plugins/file-storage';\n\n// ============================================================================\n// Common Types\n// ============================================================================\n\nexport type { LogLevel, LogContext, PluginLogger } from './common/logger';\n\n// Error classes (these are values, not just types)\nexport {\n PluginError,\n ApiKeyError,\n ProviderApiError,\n RateLimitError,\n ConfigurationError,\n ModelNotFoundError,\n AttachmentError,\n ToolExecutionError,\n} from './common/errors';\n\n// Logger factories\nexport { createConsoleLogger, createNoopLogger } from './common/logger';\n\n// ============================================================================\n// Version\n// ============================================================================\n\n/**\n * Version of the plugin-types package.\n * Can be used at runtime to check compatibility.\n */\nexport const PLUGIN_TYPES_VERSION = '1.3.0';\n"]}
1
+ {"version":3,"sources":["../src/llm/embeddings.ts","../src/common/errors.ts","../src/common/logger.ts","../src/index.ts"],"names":[],"mappings":";AAyLO,SAAS,yBACd,QAAA,EACoC;AACpC,EAAA,OAAO,WAAA,IAAe,QAAA,IAAY,WAAA,IAAe,QAAA,IAAY,UAAA,IAAc,QAAA;AAC7E;;;AClLO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EACrC,WAAA,CACE,OAAA,EACgB,IAAA,EACA,UAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAHG,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AAAA,EACd;AACF;AAOO,IAAM,WAAA,GAAN,cAA0B,WAAA,CAAY;AAAA,EAC3C,WAAA,CAAY,SAAiB,UAAA,EAAqB;AAChD,IAAA,KAAA,CAAM,OAAA,EAAS,iBAAiB,UAAU,CAAA;AAC1C,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AAAA,EACd;AACF;AAOO,IAAM,gBAAA,GAAN,cAA+B,WAAA,CAAY;AAAA,EAChD,WAAA,CACE,OAAA,EACgB,UAAA,EACA,QAAA,EAChB,UAAA,EACA;AACA,IAAA,KAAA,CAAM,OAAA,EAAS,sBAAsB,UAAU,CAAA;AAJ/B,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AAIhB,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AAAA,EACd;AACF;AAOO,IAAM,cAAA,GAAN,cAA6B,gBAAA,CAAiB;AAAA,EAGnD,WAAA,CACE,OAAA,EACgB,UAAA,EAChB,UAAA,EAC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,CAAc,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,MAChE;AAAA,IACF,CAAA;AAAA,IAEA,IAAA,EAAM,CAAC,OAAA,EAAiB,OAAA,KAA+B;AACrD,MAAA,IAAI,SAAA,CAAU,MAAM,CAAA,EAAG;AACrB,QAAA,OAAA,CAAQ,IAAA,CAAK,IAAI,MAAM,CAAA,EAAA,EAAK,OAAO,CAAA,EAAG,aAAA,CAAc,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,MAChE;AAAA,IACF,CAAA;AAAA,IAEA,KAAA,EAAO,CAAC,OAAA,EAAiB,OAAA,EAAsB,KAAA,KAAwB;AACrE,MAAA,IAAI,SAAA,CAAU,OAAO,CAAA,EAAG;AACtB,QAAA,OAAA,CAAQ,KAAA;AAAA,UACN,IAAI,MAAM,CAAA,EAAA,EAAK,OAAO,CAAA,EAAG,aAAA,CAAc,OAAO,CAAC,CAAA,CAAA;AAAA,UAC/C,KAAA,GAAQ;AAAA,EAAK,KAAA,CAAM,KAAA,IAAS,KAAA,CAAM,OAAO,CAAA,CAAA,GAAK;AAAA,SAChD;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF;AAOO,SAAS,gBAAA,GAAiC;AAC/C,EAAA,MAAM,OAAO,MAAY;AAAA,EAAC,CAAA;AAC1B,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,IAAA;AAAA,IACP,IAAA,EAAM,IAAA;AAAA,IACN,IAAA,EAAM,IAAA;AAAA,IACN,KAAA,EAAO;AAAA,GACT;AACF;;;AC+CO,IAAM,oBAAA,GAAuB","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","/**\n * Common error types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/errors\n */\n\n/**\n * Base plugin error\n *\n * All plugin-specific errors should extend this class.\n */\nexport class PluginError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly pluginName?: string\n ) {\n super(message);\n this.name = 'PluginError';\n }\n}\n\n/**\n * API key validation error\n *\n * Thrown when an API key is invalid or has insufficient permissions.\n */\nexport class ApiKeyError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'API_KEY_ERROR', pluginName);\n this.name = 'ApiKeyError';\n }\n}\n\n/**\n * Provider API error\n *\n * Thrown when the provider API returns an error.\n */\nexport class ProviderApiError extends PluginError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly response?: unknown,\n pluginName?: string\n ) {\n super(message, 'PROVIDER_API_ERROR', pluginName);\n this.name = 'ProviderApiError';\n }\n}\n\n/**\n * Rate limit error\n *\n * Thrown when the provider rate limits the request.\n */\nexport class RateLimitError extends ProviderApiError {\n public override readonly code = 'RATE_LIMIT_ERROR';\n\n constructor(\n message: string,\n public readonly retryAfter?: number,\n pluginName?: string\n ) {\n super(message, 429, undefined, pluginName);\n this.name = 'RateLimitError';\n }\n}\n\n/**\n * Configuration error\n *\n * Thrown when plugin configuration is invalid.\n */\nexport class ConfigurationError extends PluginError {\n constructor(message: string, pluginName?: string) {\n super(message, 'CONFIGURATION_ERROR', pluginName);\n this.name = 'ConfigurationError';\n }\n}\n\n/**\n * Model not found error\n *\n * Thrown when a requested model is not available.\n */\nexport class ModelNotFoundError extends PluginError {\n constructor(\n message: string,\n public readonly modelId?: string,\n pluginName?: string\n ) {\n super(message, 'MODEL_NOT_FOUND', pluginName);\n this.name = 'ModelNotFoundError';\n }\n}\n\n/**\n * Attachment error\n *\n * Thrown when there's an issue processing file attachments.\n */\nexport class AttachmentError extends PluginError {\n constructor(\n message: string,\n public readonly attachmentId?: string,\n pluginName?: string\n ) {\n super(message, 'ATTACHMENT_ERROR', pluginName);\n this.name = 'AttachmentError';\n }\n}\n\n/**\n * Tool execution error\n *\n * Thrown when a tool call fails to execute.\n */\nexport class ToolExecutionError extends PluginError {\n constructor(\n message: string,\n public readonly toolName?: string,\n pluginName?: string\n ) {\n super(message, 'TOOL_EXECUTION_ERROR', pluginName);\n this.name = 'ToolExecutionError';\n }\n}\n","/**\n * Logger types for Quilltap plugin development\n *\n * @module @quilltap/plugin-types/common/logger\n */\n\n/**\n * Log level type\n */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Log context metadata\n */\nexport interface LogContext {\n /** Context identifier (e.g., module name) */\n context?: string;\n /** Additional metadata */\n [key: string]: unknown;\n}\n\n/**\n * Logger interface that plugins can implement or receive\n *\n * This interface is compatible with Quilltap's built-in logger.\n * Plugins can use this interface to accept a logger from the host\n * application or implement their own logging.\n */\nexport interface PluginLogger {\n /**\n * Log a debug message\n * @param message Message to log\n * @param context Optional context metadata\n */\n debug(message: string, context?: LogContext): void;\n\n /**\n * Log an info message\n * @param message Message to log\n * @param context Optional context metadata\n */\n info(message: string, context?: LogContext): void;\n\n /**\n * Log a warning message\n * @param message Message to log\n * @param context Optional context metadata\n */\n warn(message: string, context?: LogContext): void;\n\n /**\n * Log an error message\n * @param message Message to log\n * @param context Optional context metadata\n * @param error Optional error object\n */\n error(message: string, context?: LogContext, error?: Error): void;\n}\n\n/**\n * Simple console-based logger for standalone plugin development\n *\n * This logger writes to the console and is useful for local\n * plugin development and testing.\n *\n * @param prefix Prefix to add to all log messages\n * @param minLevel Minimum log level to output (default: 'info')\n * @returns A PluginLogger instance\n *\n * @example\n * ```typescript\n * const logger = createConsoleLogger('my-plugin', 'debug');\n * logger.debug('Initializing plugin', { version: '1.0.0' });\n * logger.info('Plugin ready');\n * logger.error('Failed to connect', { endpoint: 'api.example.com' }, new Error('Connection refused'));\n * ```\n */\nexport function createConsoleLogger(prefix: string, minLevel: LogLevel = 'info'): PluginLogger {\n const levels: LogLevel[] = ['debug', 'info', 'warn', 'error'];\n const shouldLog = (level: LogLevel): boolean =>\n levels.indexOf(level) >= levels.indexOf(minLevel);\n\n const formatContext = (context?: LogContext): string => {\n if (!context) return '';\n const entries = Object.entries(context)\n .filter(([key]) => key !== 'context')\n .map(([key, value]) => `${key}=${JSON.stringify(value)}`)\n .join(' ');\n return entries ? ` ${entries}` : '';\n };\n\n return {\n debug: (message: string, context?: LogContext): void => {\n if (shouldLog('debug')) {\n console.debug(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n info: (message: string, context?: LogContext): void => {\n if (shouldLog('info')) {\n console.info(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n warn: (message: string, context?: LogContext): void => {\n if (shouldLog('warn')) {\n console.warn(`[${prefix}] ${message}${formatContext(context)}`);\n }\n },\n\n error: (message: string, context?: LogContext, error?: Error): void => {\n if (shouldLog('error')) {\n console.error(\n `[${prefix}] ${message}${formatContext(context)}`,\n error ? `\\n${error.stack || error.message}` : ''\n );\n }\n },\n };\n}\n\n/**\n * No-op logger for production or when logging is disabled\n *\n * @returns A PluginLogger that does nothing\n */\nexport function createNoopLogger(): PluginLogger {\n const noop = (): void => {};\n return {\n debug: noop,\n info: noop,\n warn: noop,\n error: noop,\n };\n}\n","/**\n * @quilltap/plugin-types\n *\n * Type definitions for Quilltap plugin development.\n *\n * This package provides TypeScript types and interfaces for building\n * Quilltap plugins, including LLM providers, authentication providers,\n * and utility plugins.\n *\n * @packageDocumentation\n * @module @quilltap/plugin-types\n */\n\n// ============================================================================\n// LLM Types\n// ============================================================================\n\nexport type {\n // Core message types\n FileAttachment,\n LLMMessage,\n JSONSchemaDefinition,\n ResponseFormat,\n LLMParams,\n\n // Response types\n TokenUsage,\n CacheUsage,\n AttachmentResults,\n LLMResponse,\n StreamChunk,\n\n // Image generation types\n ImageGenParams,\n GeneratedImage,\n ImageGenResponse,\n\n // Model metadata\n ModelWarningLevel,\n ModelWarning,\n ModelMetadata,\n\n // Provider interfaces\n LLMProvider,\n ImageGenProvider,\n} from './llm/base';\n\nexport type {\n // Tool definitions\n OpenAIToolDefinition,\n UniversalTool,\n AnthropicToolDefinition,\n GoogleToolDefinition,\n\n // Tool calls\n ToolCall,\n ToolCallRequest,\n ToolResult,\n ToolFormatOptions,\n} from './llm/tools';\n\nexport type {\n // Embedding types\n EmbeddingResult,\n EmbeddingOptions,\n EmbeddingProvider,\n LocalEmbeddingProviderState,\n LocalEmbeddingProvider,\n} from './llm/embeddings';\n\nexport { isLocalEmbeddingProvider } from './llm/embeddings';\n\n// ============================================================================\n// Plugin Types\n// ============================================================================\n\nexport type {\n // Provider plugin types\n ProviderMetadata,\n ProviderConfigRequirements,\n ProviderCapabilities,\n AttachmentSupport,\n ModelInfo,\n EmbeddingModelInfo,\n ImageGenerationModelInfo,\n ImageProviderConstraints,\n IconProps,\n PluginIconData,\n LLMProviderPlugin,\n ProviderPluginExport,\n // Runtime configuration types\n MessageFormatSupport,\n CheapModelConfig,\n ToolFormatType,\n} from './plugins/provider';\n\nexport type {\n // Manifest types\n PluginCapability,\n PluginCategory,\n PluginStatus,\n PluginAuthor,\n PluginCompatibility,\n ProviderConfig,\n PluginPermissions,\n PluginManifest,\n InstalledPluginInfo,\n} from './plugins/manifest';\n\nexport type {\n // Theme plugin types\n ColorPalette,\n Typography,\n Spacing,\n Effects,\n ThemeTokens,\n FontDefinition,\n EmbeddedFont,\n ThemeMetadata,\n ThemePlugin,\n ThemePluginExport,\n} from './plugins/theme';\n\nexport type {\n // Roleplay template plugin types\n RoleplayTemplateConfig,\n RoleplayTemplateMetadata,\n RoleplayTemplatePlugin,\n RoleplayTemplatePluginExport,\n} from './plugins/roleplay-template';\n\nexport type {\n // Tool plugin types\n ToolMetadata,\n ToolHierarchyInfo,\n ToolExecutionContext,\n ToolExecutionResult,\n ToolPlugin,\n ToolPluginExport,\n} from './plugins/tool';\n\nexport type {\n // File storage plugin types\n FileBackendCapabilities,\n FileBackendMetadata,\n FileMetadata,\n FileStorageBackend,\n FileStorageConfigField,\n FileStorageProviderPlugin,\n FileStoragePluginExport,\n} from './plugins/file-storage';\n\n// ============================================================================\n// Common Types\n// ============================================================================\n\nexport type { LogLevel, LogContext, PluginLogger } from './common/logger';\n\n// Error classes (these are values, not just types)\nexport {\n PluginError,\n ApiKeyError,\n ProviderApiError,\n RateLimitError,\n ConfigurationError,\n ModelNotFoundError,\n AttachmentError,\n ToolExecutionError,\n} from './common/errors';\n\n// Logger factories\nexport { createConsoleLogger, createNoopLogger } from './common/logger';\n\n// ============================================================================\n// Version\n// ============================================================================\n\n/**\n * Version of the plugin-types package.\n * Can be used at runtime to check compatibility.\n */\nexport const PLUGIN_TYPES_VERSION = '1.3.0';\n"]}
@@ -465,4 +465,165 @@ interface ImageGenProvider {
465
465
  getAvailableModels(apiKey?: string): Promise<string[]>;
466
466
  }
467
467
 
468
- export type { AnthropicToolDefinition, AttachmentResults, CacheUsage, FileAttachment, GeneratedImage, GoogleToolDefinition, ImageGenParams, ImageGenProvider, ImageGenResponse, JSONSchemaDefinition, LLMMessage, LLMParams, LLMProvider, LLMResponse, ModelMetadata, ModelWarning, ModelWarningLevel, OpenAIToolDefinition, ResponseFormat, StreamChunk, TokenUsage, ToolCall, ToolCallRequest, ToolFormatOptions, ToolResult, UniversalTool };
468
+ /**
469
+ * Embedding Provider Types for Quilltap plugin development
470
+ *
471
+ * Defines interfaces for embedding providers that can be implemented
472
+ * by plugins to provide text-to-vector embedding functionality.
473
+ *
474
+ * @module @quilltap/plugin-types/llm/embeddings
475
+ */
476
+ /**
477
+ * Result of an embedding operation
478
+ */
479
+ interface EmbeddingResult {
480
+ /** The embedding vector (array of floating point numbers) */
481
+ embedding: number[];
482
+ /** The model used to generate the embedding */
483
+ model: string;
484
+ /** Number of dimensions in the embedding vector */
485
+ dimensions: number;
486
+ /** Token usage information (if available) */
487
+ usage?: {
488
+ promptTokens: number;
489
+ totalTokens: number;
490
+ cost?: number;
491
+ };
492
+ }
493
+ /**
494
+ * Options for embedding generation
495
+ */
496
+ interface EmbeddingOptions {
497
+ /** Desired dimensions for the embedding (if model supports variable dimensions) */
498
+ dimensions?: number;
499
+ }
500
+ /**
501
+ * Standard embedding provider interface
502
+ *
503
+ * This is the base interface for all embedding providers that use
504
+ * external APIs (OpenAI, Ollama, OpenRouter, etc.)
505
+ */
506
+ interface EmbeddingProvider {
507
+ /**
508
+ * Generate an embedding for a single text
509
+ *
510
+ * @param text The text to embed
511
+ * @param model The model to use
512
+ * @param apiKey The API key for authentication
513
+ * @param options Optional configuration
514
+ * @returns The embedding result
515
+ */
516
+ generateEmbedding(text: string, model: string, apiKey: string, options?: EmbeddingOptions): Promise<EmbeddingResult>;
517
+ /**
518
+ * Generate embeddings for multiple texts in a batch
519
+ *
520
+ * @param texts Array of texts to embed
521
+ * @param model The model to use
522
+ * @param apiKey The API key for authentication
523
+ * @param options Optional configuration
524
+ * @returns Array of embedding results
525
+ */
526
+ generateBatchEmbeddings?(texts: string[], model: string, apiKey: string, options?: EmbeddingOptions): Promise<EmbeddingResult[]>;
527
+ /**
528
+ * Get available embedding models
529
+ *
530
+ * @param apiKey The API key for authentication
531
+ * @returns Array of model IDs
532
+ */
533
+ getAvailableModels?(apiKey: string): Promise<string[]>;
534
+ /**
535
+ * Check if the provider is available and properly configured
536
+ *
537
+ * @param apiKey Optional API key to validate
538
+ * @returns True if the provider is ready to use
539
+ */
540
+ isAvailable?(apiKey?: string): Promise<boolean>;
541
+ }
542
+ /**
543
+ * Serializable state for local embedding providers
544
+ *
545
+ * Used by providers like TF-IDF that maintain vocabulary state
546
+ */
547
+ interface LocalEmbeddingProviderState {
548
+ /** The vocabulary as an array of [term, index] pairs */
549
+ vocabulary: [string, number][];
550
+ /** The IDF (Inverse Document Frequency) weights */
551
+ idf: number[];
552
+ /** Average document length across the corpus */
553
+ avgDocLength: number;
554
+ /** Size of the vocabulary */
555
+ vocabularySize: number;
556
+ /** Whether bigrams are included in the vocabulary */
557
+ includeBigrams: boolean;
558
+ /** Timestamp when the vocabulary was fitted */
559
+ fittedAt: string;
560
+ }
561
+ /**
562
+ * Local embedding provider interface
563
+ *
564
+ * Extended interface for local/offline embedding providers that
565
+ * maintain vocabulary state (like TF-IDF). These providers don't
566
+ * require API keys and can work entirely offline.
567
+ */
568
+ interface LocalEmbeddingProvider extends Omit<EmbeddingProvider, 'generateEmbedding' | 'generateBatchEmbeddings'> {
569
+ /**
570
+ * Generate an embedding for a single text
571
+ * Local providers don't need apiKey parameter
572
+ *
573
+ * @param text The text to embed
574
+ * @returns The embedding result
575
+ */
576
+ generateEmbedding(text: string): EmbeddingResult;
577
+ /**
578
+ * Generate embeddings for multiple texts in a batch
579
+ *
580
+ * @param texts Array of texts to embed
581
+ * @returns Array of embedding results
582
+ */
583
+ generateBatchEmbeddings(texts: string[]): EmbeddingResult[];
584
+ /**
585
+ * Fit the vocabulary on a corpus of documents
586
+ *
587
+ * This method analyzes the corpus to build vocabulary, calculate IDF weights,
588
+ * and other statistics needed for embedding generation.
589
+ *
590
+ * @param documents Array of text documents to analyze
591
+ */
592
+ fitCorpus(documents: string[]): void;
593
+ /**
594
+ * Check if the vocabulary has been fitted
595
+ *
596
+ * @returns True if fitCorpus has been called with documents
597
+ */
598
+ isFitted(): boolean;
599
+ /**
600
+ * Load state from a serialized representation
601
+ *
602
+ * @param state The serialized provider state
603
+ */
604
+ loadState(state: LocalEmbeddingProviderState): void;
605
+ /**
606
+ * Get the current state for serialization
607
+ *
608
+ * @returns The provider state, or null if not fitted
609
+ */
610
+ getState(): LocalEmbeddingProviderState | null;
611
+ /**
612
+ * Get the vocabulary size
613
+ *
614
+ * @returns Number of terms in the vocabulary
615
+ */
616
+ getVocabularySize(): number;
617
+ /**
618
+ * Get the embedding dimensions
619
+ *
620
+ * @returns Number of dimensions in generated embeddings
621
+ */
622
+ getDimensions(): number;
623
+ }
624
+ /**
625
+ * Type guard to check if a provider is a local embedding provider
626
+ */
627
+ declare function isLocalEmbeddingProvider(provider: EmbeddingProvider | LocalEmbeddingProvider): provider is LocalEmbeddingProvider;
628
+
629
+ 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 };
@@ -465,4 +465,165 @@ interface ImageGenProvider {
465
465
  getAvailableModels(apiKey?: string): Promise<string[]>;
466
466
  }
467
467
 
468
- export type { AnthropicToolDefinition, AttachmentResults, CacheUsage, FileAttachment, GeneratedImage, GoogleToolDefinition, ImageGenParams, ImageGenProvider, ImageGenResponse, JSONSchemaDefinition, LLMMessage, LLMParams, LLMProvider, LLMResponse, ModelMetadata, ModelWarning, ModelWarningLevel, OpenAIToolDefinition, ResponseFormat, StreamChunk, TokenUsage, ToolCall, ToolCallRequest, ToolFormatOptions, ToolResult, UniversalTool };
468
+ /**
469
+ * Embedding Provider Types for Quilltap plugin development
470
+ *
471
+ * Defines interfaces for embedding providers that can be implemented
472
+ * by plugins to provide text-to-vector embedding functionality.
473
+ *
474
+ * @module @quilltap/plugin-types/llm/embeddings
475
+ */
476
+ /**
477
+ * Result of an embedding operation
478
+ */
479
+ interface EmbeddingResult {
480
+ /** The embedding vector (array of floating point numbers) */
481
+ embedding: number[];
482
+ /** The model used to generate the embedding */
483
+ model: string;
484
+ /** Number of dimensions in the embedding vector */
485
+ dimensions: number;
486
+ /** Token usage information (if available) */
487
+ usage?: {
488
+ promptTokens: number;
489
+ totalTokens: number;
490
+ cost?: number;
491
+ };
492
+ }
493
+ /**
494
+ * Options for embedding generation
495
+ */
496
+ interface EmbeddingOptions {
497
+ /** Desired dimensions for the embedding (if model supports variable dimensions) */
498
+ dimensions?: number;
499
+ }
500
+ /**
501
+ * Standard embedding provider interface
502
+ *
503
+ * This is the base interface for all embedding providers that use
504
+ * external APIs (OpenAI, Ollama, OpenRouter, etc.)
505
+ */
506
+ interface EmbeddingProvider {
507
+ /**
508
+ * Generate an embedding for a single text
509
+ *
510
+ * @param text The text to embed
511
+ * @param model The model to use
512
+ * @param apiKey The API key for authentication
513
+ * @param options Optional configuration
514
+ * @returns The embedding result
515
+ */
516
+ generateEmbedding(text: string, model: string, apiKey: string, options?: EmbeddingOptions): Promise<EmbeddingResult>;
517
+ /**
518
+ * Generate embeddings for multiple texts in a batch
519
+ *
520
+ * @param texts Array of texts to embed
521
+ * @param model The model to use
522
+ * @param apiKey The API key for authentication
523
+ * @param options Optional configuration
524
+ * @returns Array of embedding results
525
+ */
526
+ generateBatchEmbeddings?(texts: string[], model: string, apiKey: string, options?: EmbeddingOptions): Promise<EmbeddingResult[]>;
527
+ /**
528
+ * Get available embedding models
529
+ *
530
+ * @param apiKey The API key for authentication
531
+ * @returns Array of model IDs
532
+ */
533
+ getAvailableModels?(apiKey: string): Promise<string[]>;
534
+ /**
535
+ * Check if the provider is available and properly configured
536
+ *
537
+ * @param apiKey Optional API key to validate
538
+ * @returns True if the provider is ready to use
539
+ */
540
+ isAvailable?(apiKey?: string): Promise<boolean>;
541
+ }
542
+ /**
543
+ * Serializable state for local embedding providers
544
+ *
545
+ * Used by providers like TF-IDF that maintain vocabulary state
546
+ */
547
+ interface LocalEmbeddingProviderState {
548
+ /** The vocabulary as an array of [term, index] pairs */
549
+ vocabulary: [string, number][];
550
+ /** The IDF (Inverse Document Frequency) weights */
551
+ idf: number[];
552
+ /** Average document length across the corpus */
553
+ avgDocLength: number;
554
+ /** Size of the vocabulary */
555
+ vocabularySize: number;
556
+ /** Whether bigrams are included in the vocabulary */
557
+ includeBigrams: boolean;
558
+ /** Timestamp when the vocabulary was fitted */
559
+ fittedAt: string;
560
+ }
561
+ /**
562
+ * Local embedding provider interface
563
+ *
564
+ * Extended interface for local/offline embedding providers that
565
+ * maintain vocabulary state (like TF-IDF). These providers don't
566
+ * require API keys and can work entirely offline.
567
+ */
568
+ interface LocalEmbeddingProvider extends Omit<EmbeddingProvider, 'generateEmbedding' | 'generateBatchEmbeddings'> {
569
+ /**
570
+ * Generate an embedding for a single text
571
+ * Local providers don't need apiKey parameter
572
+ *
573
+ * @param text The text to embed
574
+ * @returns The embedding result
575
+ */
576
+ generateEmbedding(text: string): EmbeddingResult;
577
+ /**
578
+ * Generate embeddings for multiple texts in a batch
579
+ *
580
+ * @param texts Array of texts to embed
581
+ * @returns Array of embedding results
582
+ */
583
+ generateBatchEmbeddings(texts: string[]): EmbeddingResult[];
584
+ /**
585
+ * Fit the vocabulary on a corpus of documents
586
+ *
587
+ * This method analyzes the corpus to build vocabulary, calculate IDF weights,
588
+ * and other statistics needed for embedding generation.
589
+ *
590
+ * @param documents Array of text documents to analyze
591
+ */
592
+ fitCorpus(documents: string[]): void;
593
+ /**
594
+ * Check if the vocabulary has been fitted
595
+ *
596
+ * @returns True if fitCorpus has been called with documents
597
+ */
598
+ isFitted(): boolean;
599
+ /**
600
+ * Load state from a serialized representation
601
+ *
602
+ * @param state The serialized provider state
603
+ */
604
+ loadState(state: LocalEmbeddingProviderState): void;
605
+ /**
606
+ * Get the current state for serialization
607
+ *
608
+ * @returns The provider state, or null if not fitted
609
+ */
610
+ getState(): LocalEmbeddingProviderState | null;
611
+ /**
612
+ * Get the vocabulary size
613
+ *
614
+ * @returns Number of terms in the vocabulary
615
+ */
616
+ getVocabularySize(): number;
617
+ /**
618
+ * Get the embedding dimensions
619
+ *
620
+ * @returns Number of dimensions in generated embeddings
621
+ */
622
+ getDimensions(): number;
623
+ }
624
+ /**
625
+ * Type guard to check if a provider is a local embedding provider
626
+ */
627
+ declare function isLocalEmbeddingProvider(provider: EmbeddingProvider | LocalEmbeddingProvider): provider is LocalEmbeddingProvider;
628
+
629
+ 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 };
package/dist/llm/index.js CHANGED
@@ -1,4 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ // src/llm/embeddings.ts
4
+ function isLocalEmbeddingProvider(provider) {
5
+ return "fitCorpus" in provider && "loadState" in provider && "getState" in provider;
6
+ }
7
+
8
+ exports.isLocalEmbeddingProvider = isLocalEmbeddingProvider;
3
9
  //# sourceMappingURL=index.js.map
4
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
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,3 +1,8 @@
1
+ // src/llm/embeddings.ts
2
+ function isLocalEmbeddingProvider(provider) {
3
+ return "fitCorpus" in provider && "loadState" in provider && "getState" in provider;
4
+ }
1
5
 
6
+ export { isLocalEmbeddingProvider };
2
7
  //# sourceMappingURL=index.mjs.map
3
8
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
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,3 +1,3 @@
1
- export { B as AnnotationButton, A as AttachmentSupport, p as ColorPalette, G as DialogueDetection, r as Effects, t as EmbeddedFont, E as EmbeddingModelInfo, F as FontDefinition, d as IconProps, I as ImageGenerationModelInfo, c as ImageProviderConstraints, o as InstalledPluginInfo, L as LLMProviderPlugin, M as ModelInfo, j as PluginAuthor, g as PluginCapability, h as PluginCategory, k as PluginCompatibility, n as PluginManifest, m as PluginPermissions, i as PluginStatus, b as ProviderCapabilities, l as ProviderConfig, a as ProviderConfigRequirements, P as ProviderMetadata, e as ProviderPluginExport, D as RenderingPattern, R as RoleplayTemplateConfig, x as RoleplayTemplateMetadata, y as RoleplayTemplatePlugin, z as RoleplayTemplatePluginExport, S as Spacing, u as ThemeMetadata, v as ThemePlugin, w as ThemePluginExport, s as ThemeTokens, q as Typography } from '../index-DtgwAg2x.mjs';
1
+ export { D as AnnotationButton, A as AttachmentSupport, a as ColorPalette, G as DialogueDetection, E as Effects, b as EmbeddedFont, c as EmbeddingModelInfo, F as FontDefinition, I as IconProps, d as ImageGenerationModelInfo, e as ImageProviderConstraints, f as InstalledPluginInfo, L as LLMProviderPlugin, g as ModelInfo, P as PluginAuthor, h as PluginCapability, i as PluginCategory, j as PluginCompatibility, l as PluginManifest, m as PluginPermissions, n as PluginStatus, o as ProviderCapabilities, p as ProviderConfig, q as ProviderConfigRequirements, r as ProviderMetadata, s as ProviderPluginExport, H as RenderingPattern, R as RoleplayTemplateConfig, t as RoleplayTemplateMetadata, u as RoleplayTemplatePlugin, v as RoleplayTemplatePluginExport, S as Spacing, T as ThemeMetadata, w as ThemePlugin, x as ThemePluginExport, y as ThemeTokens, B as Typography } from '../index-CGx4cDk2.mjs';
2
2
  import 'react';
3
3
  import '../llm/index.mjs';
@@ -1,3 +1,3 @@
1
- export { B as AnnotationButton, A as AttachmentSupport, p as ColorPalette, G as DialogueDetection, r as Effects, t as EmbeddedFont, E as EmbeddingModelInfo, F as FontDefinition, d as IconProps, I as ImageGenerationModelInfo, c as ImageProviderConstraints, o as InstalledPluginInfo, L as LLMProviderPlugin, M as ModelInfo, j as PluginAuthor, g as PluginCapability, h as PluginCategory, k as PluginCompatibility, n as PluginManifest, m as PluginPermissions, i as PluginStatus, b as ProviderCapabilities, l as ProviderConfig, a as ProviderConfigRequirements, P as ProviderMetadata, e as ProviderPluginExport, D as RenderingPattern, R as RoleplayTemplateConfig, x as RoleplayTemplateMetadata, y as RoleplayTemplatePlugin, z as RoleplayTemplatePluginExport, S as Spacing, u as ThemeMetadata, v as ThemePlugin, w as ThemePluginExport, s as ThemeTokens, q as Typography } from '../index-3BT4ld_f.js';
1
+ export { D as AnnotationButton, A as AttachmentSupport, a as ColorPalette, G as DialogueDetection, E as Effects, b as EmbeddedFont, c as EmbeddingModelInfo, F as FontDefinition, I as IconProps, d as ImageGenerationModelInfo, e as ImageProviderConstraints, f as InstalledPluginInfo, L as LLMProviderPlugin, g as ModelInfo, P as PluginAuthor, h as PluginCapability, i as PluginCategory, j as PluginCompatibility, l as PluginManifest, m as PluginPermissions, n as PluginStatus, o as ProviderCapabilities, p as ProviderConfig, q as ProviderConfigRequirements, r as ProviderMetadata, s as ProviderPluginExport, H as RenderingPattern, R as RoleplayTemplateConfig, t as RoleplayTemplateMetadata, u as RoleplayTemplatePlugin, v as RoleplayTemplatePluginExport, S as Spacing, T as ThemeMetadata, w as ThemePlugin, x as ThemePluginExport, y as ThemeTokens, B as Typography } from '../index-Dtz0bUL8.js';
2
2
  import 'react';
3
3
  import '../llm/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quilltap/plugin-types",
3
- "version": "1.9.3",
3
+ "version": "1.10.0",
4
4
  "description": "Type definitions for Quilltap plugin development",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",