@stina/extension-api 0.36.0 → 0.44.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.
@@ -6,4 +6,4 @@ function generateMessageId() {
6
6
  export {
7
7
  generateMessageId
8
8
  };
9
- //# sourceMappingURL=chunk-K53YNG2W.js.map
9
+ //# sourceMappingURL=chunk-ZB7GJUPS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/messages.ts"],"sourcesContent":["/**\n * Message protocol between Extension Host and Extension Workers\n */\n\nimport type {\n ChatMessage,\n ChatOptions,\n GetModelsOptions,\n StreamEvent,\n ToolResult,\n ActionResult,\n ModelInfo,\n SchedulerFirePayload,\n VoiceSessionOptions,\n VoiceSessionDescriptor,\n} from './types.js'\n\n// ============================================================================\n// Host → Worker Messages\n// ============================================================================\n\nexport type HostToWorkerMessage =\n | ActivateMessage\n | DeactivateMessage\n | SettingsChangedMessage\n | SchedulerFireMessage\n | ProviderChatRequestMessage\n | ProviderModelsRequestMessage\n | ProviderVoiceSessionRequestMessage\n | ToolExecuteRequestMessage\n | ActionExecuteRequestMessage\n | ResponseMessage\n | StreamingFetchChunkMessage\n | BackgroundTaskStartMessage\n | BackgroundTaskStopMessage\n\nexport interface ActivateMessage {\n type: 'activate'\n id: string\n payload: {\n extensionId: string\n extensionVersion: string\n storagePath: string\n permissions: string[]\n settings: Record<string, unknown>\n }\n}\n\nexport interface DeactivateMessage {\n type: 'deactivate'\n id: string\n}\n\nexport interface SettingsChangedMessage {\n type: 'settings-changed'\n id: string\n payload: {\n key: string\n value: unknown\n }\n}\n\nexport interface SchedulerFireMessage {\n type: 'scheduler-fire'\n id: string\n payload: SchedulerFirePayload\n}\n\nexport interface ProviderChatRequestMessage {\n type: 'provider-chat-request'\n id: string\n payload: {\n providerId: string\n messages: ChatMessage[]\n options: ChatOptions\n }\n}\n\nexport interface ProviderModelsRequestMessage {\n type: 'provider-models-request'\n id: string\n payload: {\n providerId: string\n options?: GetModelsOptions\n }\n}\n\nexport interface ProviderVoiceSessionRequestMessage {\n type: 'provider-voice-session-request'\n id: string\n payload: {\n providerId: string\n /**\n * `signal` is dropped on the way across: an AbortSignal cannot be\n * structured-cloned into a worker. Cancellation is handled by the host\n * rejecting the pending request instead.\n */\n options: Omit<VoiceSessionOptions, 'signal'>\n }\n}\n\nexport interface ToolExecuteRequestMessage {\n type: 'tool-execute-request'\n id: string\n payload: {\n toolId: string\n params: Record<string, unknown>\n /** User ID if the tool is executed in a user context */\n userId?: string\n }\n}\n\nexport interface ActionExecuteRequestMessage {\n type: 'action-execute-request'\n id: string\n payload: {\n actionId: string\n params: Record<string, unknown>\n /** User ID if the action is executed in a user context */\n userId?: string\n }\n}\n\nexport interface ResponseMessage {\n type: 'response'\n id: string\n payload: {\n requestId: string\n success: boolean\n data?: unknown\n error?: string\n }\n}\n\n/**\n * Message sent from host to worker with streaming fetch data chunks.\n * Used for streaming network responses (e.g., NDJSON streams from Ollama).\n */\nexport interface StreamingFetchChunkMessage {\n type: 'streaming-fetch-chunk'\n id: string\n payload: {\n requestId: string\n chunk: string\n done: boolean\n error?: string\n }\n}\n\n/**\n * Message sent from host to worker to start a registered background task.\n */\nexport interface BackgroundTaskStartMessage {\n type: 'background-task-start'\n id: string\n payload: {\n taskId: string\n }\n}\n\n/**\n * Message sent from host to worker to stop a running background task.\n */\nexport interface BackgroundTaskStopMessage {\n type: 'background-task-stop'\n id: string\n payload: {\n taskId: string\n }\n}\n\n// ============================================================================\n// Worker → Host Messages\n// ============================================================================\n\nexport type WorkerToHostMessage =\n | ReadyMessage\n | RequestMessage\n | ProviderRegisteredMessage\n | ToolRegisteredMessage\n | ActionRegisteredMessage\n | StreamEventMessage\n | LogMessage\n | ProviderModelsResponseMessage\n | ProviderVoiceSessionResponseMessage\n | ToolExecuteResponseMessage\n | ActionExecuteResponseMessage\n | StreamingFetchAckMessage\n | BackgroundTaskRegisteredMessage\n | BackgroundTaskStatusMessage\n | BackgroundTaskHealthMessage\n\nexport interface ReadyMessage {\n type: 'ready'\n}\n\n/**\n * Message sent from worker to host to acknowledge receipt of a streaming fetch chunk.\n * This enables backpressure control to prevent unbounded memory growth.\n */\nexport interface StreamingFetchAckMessage {\n type: 'streaming-fetch-ack'\n payload: {\n requestId: string\n }\n}\n\nexport interface RequestMessage {\n type: 'request'\n id: string\n method: RequestMethod\n payload: unknown\n}\n\nexport type RequestMethod =\n | 'network.fetch'\n | 'network.fetch-stream'\n | 'settings.getAll'\n | 'settings.get'\n | 'settings.set'\n | 'user.getProfile'\n | 'user.listIds'\n | 'events.emit'\n | 'scheduler.schedule'\n | 'scheduler.cancel'\n | 'scheduler.reportFireResult'\n | 'chat.appendInstruction'\n | 'database.execute'\n // Simple key-value storage methods\n | 'storage.set'\n | 'storage.keys'\n | 'storage.setForUser'\n | 'storage.keysForUser'\n // Collection-based storage methods\n | 'storage.put'\n | 'storage.get'\n | 'storage.delete'\n | 'storage.find'\n | 'storage.findOne'\n | 'storage.count'\n | 'storage.putMany'\n | 'storage.deleteMany'\n | 'storage.dropCollection'\n | 'storage.listCollections'\n | 'storage.putForUser'\n | 'storage.getForUser'\n | 'storage.deleteForUser'\n | 'storage.findForUser'\n | 'storage.findOneForUser'\n | 'storage.countForUser'\n | 'storage.putManyForUser'\n | 'storage.deleteManyForUser'\n | 'storage.dropCollectionForUser'\n | 'storage.listCollectionsForUser'\n // Secrets methods\n | 'secrets.set'\n | 'secrets.get'\n | 'secrets.delete'\n | 'secrets.list'\n | 'secrets.setForUser'\n | 'secrets.getForUser'\n | 'secrets.deleteForUser'\n | 'secrets.listForUser'\n // Tools cross-extension methods\n | 'tools.list'\n | 'tools.execute'\n\nexport interface ProviderRegisteredMessage {\n type: 'provider-registered'\n payload: {\n id: string\n name: string\n }\n}\n\nexport interface ToolRegisteredMessage {\n type: 'tool-registered'\n payload: {\n id: string\n name: string\n description: string\n parameters?: Record<string, unknown>\n }\n}\n\nexport interface ActionRegisteredMessage {\n type: 'action-registered'\n payload: {\n id: string\n }\n}\n\nexport interface StreamEventMessage {\n type: 'stream-event'\n payload: {\n requestId: string\n event: StreamEvent\n }\n}\n\nexport interface ProviderModelsResponseMessage {\n type: 'provider-models-response'\n payload: {\n requestId: string\n models: ModelInfo[]\n error?: string\n }\n}\n\nexport interface ProviderVoiceSessionResponseMessage {\n type: 'provider-voice-session-response'\n payload: {\n requestId: string\n /** Absent when `error` is set. */\n descriptor?: VoiceSessionDescriptor\n error?: string\n }\n}\n\nexport interface ToolExecuteResponseMessage {\n type: 'tool-execute-response'\n payload: {\n requestId: string\n result: ToolResult\n error?: string\n }\n}\n\nexport interface ActionExecuteResponseMessage {\n type: 'action-execute-response'\n payload: {\n requestId: string\n result: ActionResult\n error?: string\n }\n}\n\nexport interface LogMessage {\n type: 'log'\n payload: {\n level: 'debug' | 'info' | 'warn' | 'error'\n message: string\n data?: Record<string, unknown>\n }\n}\n\n/**\n * Message sent from worker to host when a background task is registered.\n */\nexport interface BackgroundTaskRegisteredMessage {\n type: 'background-task-registered'\n payload: {\n taskId: string\n name: string\n userId: string\n restartPolicy: {\n type: 'always' | 'on-failure' | 'never'\n maxRestarts?: number\n initialDelayMs?: number\n maxDelayMs?: number\n backoffMultiplier?: number\n }\n payload?: Record<string, unknown>\n }\n}\n\n/**\n * Message sent from worker to host with background task status updates.\n */\nexport interface BackgroundTaskStatusMessage {\n type: 'background-task-status'\n payload: {\n taskId: string\n status: 'running' | 'stopped' | 'completed' | 'failed'\n error?: string\n }\n}\n\n/**\n * Message sent from worker to host with background task health reports.\n */\nexport interface BackgroundTaskHealthMessage {\n type: 'background-task-health'\n payload: {\n taskId: string\n status: string\n timestamp: string\n }\n}\n\n// ============================================================================\n// Utility Types\n// ============================================================================\n\nexport interface PendingRequest<T = unknown> {\n resolve: (value: T) => void\n reject: (error: Error) => void\n timeout: ReturnType<typeof setTimeout>\n}\n\n/**\n * Generate a unique message ID\n */\nexport function generateMessageId(): string {\n return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`\n}\n"],"mappings":";AAmZO,SAAS,oBAA4B;AAC1C,SAAO,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACjE;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/types.localization.ts","../src/messages.ts"],"sourcesContent":["/**\n * @stina/extension-api\n *\n * Types and utilities for building Stina extensions.\n *\n * Extensions should import from this package for type definitions.\n * The runtime (worker-side code) should import from '@stina/extension-api/runtime'.\n */\n\n// Localization\nexport type { LocalizedString } from './types.js'\nexport { resolveLocalizedString } from './types.js'\n\n// Types\nexport type {\n // Manifest\n ExtensionManifest,\n Platform,\n ExtensionContributions,\n ToolSettingsViewDefinition,\n ToolSettingsView,\n ToolSettingsListView,\n ToolSettingsListMapping,\n ToolSettingsComponentView,\n ToolSettingsActionDataSource,\n PanelDefinition,\n PanelView,\n PanelComponentView,\n PanelActionDataSource,\n PanelUnknownView,\n ProviderDefinition,\n ProviderConfigView,\n PromptContribution,\n PromptSection,\n ToolDefinition,\n ToolConfirmationConfig,\n CommandDefinition,\n\n // Permissions\n Permission,\n NetworkPermission,\n StoragePermission,\n UserDataPermission,\n CapabilityPermission,\n SystemPermission,\n\n // Context\n ExtensionContext,\n Disposable,\n NetworkAPI,\n SettingsAPI,\n ProvidersAPI,\n ToolsAPI,\n ActionsAPI,\n EventsAPI,\n SchedulerAPI,\n SchedulerJobRequest,\n SchedulerSchedule,\n SchedulerFirePayload,\n UserAPI,\n UserProfile,\n ChatAPI,\n ChatInstructionMessage,\n LogAPI,\n\n // Background workers\n BackgroundWorkersAPI,\n BackgroundTaskConfig,\n BackgroundTaskCallback,\n BackgroundTaskContext,\n BackgroundTaskHealth,\n BackgroundRestartPolicy,\n\n // Storage and Secrets\n Query,\n QueryOptions,\n StorageAPI,\n SecretsAPI,\n StorageCollectionConfig,\n StorageContributions,\n\n // AI Provider\n AIProvider,\n ModelInfo,\n ChatMessage,\n ChatOptions,\n GetModelsOptions,\n StreamEvent,\n ToolCall,\n\n // Tools\n Tool,\n ToolResult,\n\n // Actions\n Action,\n ActionResult,\n\n // Entry point\n ExtensionModule,\n} from './types.js'\n\n// Messages (for host implementation)\nexport type {\n HostToWorkerMessage,\n WorkerToHostMessage,\n ActivateMessage,\n DeactivateMessage,\n SettingsChangedMessage,\n ProviderChatRequestMessage,\n ProviderModelsRequestMessage,\n ToolExecuteRequestMessage,\n ToolExecuteResponseMessage,\n ActionExecuteRequestMessage,\n ActionExecuteResponseMessage,\n ResponseMessage,\n ReadyMessage,\n RequestMessage,\n RequestMethod,\n ProviderRegisteredMessage,\n ToolRegisteredMessage,\n ActionRegisteredMessage,\n StreamEventMessage,\n LogMessage,\n PendingRequest,\n // Background task messages\n BackgroundTaskStartMessage,\n BackgroundTaskStopMessage,\n BackgroundTaskRegisteredMessage,\n BackgroundTaskStatusMessage,\n BackgroundTaskHealthMessage,\n} from './messages.js'\n\nexport { generateMessageId } from './messages.js'\n\n// Component types (for extension UI components)\nexport type {\n // Icon Names\n HugeIconName,\n // Styling\n AllowedCSSProperty,\n ExtensionComponentStyle,\n // Base types\n ExtensionComponentData,\n // Iteration & Children\n ExtensionComponentIterator,\n ExtensionComponentChildren,\n // Actions\n ExtensionActionCall,\n ExtensionActionRef,\n // Data Sources & Panel Definition\n ExtensionDataSource,\n ExtensionPanelDefinition,\n // Component Props\n HeaderProps,\n LabelProps,\n ParagraphProps,\n ButtonProps,\n TextInputProps,\n PasswordInputProps,\n NumberInputProps,\n TextAreaProps,\n DateTimeInputProps,\n SelectProps,\n IconPickerProps,\n VerticalStackProps,\n HorizontalStackProps,\n GridProps,\n DividerProps,\n IconProps,\n IconButtonType,\n IconButtonProps,\n PanelAction,\n PanelProps,\n ToggleProps,\n CollapsibleProps,\n FrameVariant,\n FrameProps,\n ListProps,\n PillVariant,\n PillProps,\n CheckboxProps,\n MarkdownProps,\n TextPreviewProps,\n ModalProps,\n ConditionalGroupProps,\n} from './types.components.js'\n","/**\n * Localization Types\n *\n * Types and utilities for localized strings in extensions.\n */\n\n/**\n * A string that can be either a simple string or a map of language codes to localized strings.\n * When a simple string is provided, it's used as the default/fallback value.\n * When a map is provided, the appropriate language is selected at runtime.\n *\n * @example\n * // Simple string (backwards compatible)\n * name: \"Get Weather\"\n *\n * @example\n * // Localized strings\n * name: { en: \"Get Weather\", sv: \"Hämta väder\", de: \"Wetter abrufen\" }\n */\nexport type LocalizedString = string | Record<string, string>\n\n/**\n * Resolves a LocalizedString to an actual string value.\n * @param value The LocalizedString to resolve\n * @param lang The preferred language code (e.g., \"sv\", \"en\")\n * @param fallbackLang The fallback language code (defaults to \"en\")\n * @returns The resolved string value\n */\nexport function resolveLocalizedString(\n value: LocalizedString,\n lang: string,\n fallbackLang = 'en'\n): string {\n if (typeof value === 'string') {\n return value\n }\n // Try preferred language first, then fallback language, then first available, then empty string\n return value[lang] ?? value[fallbackLang] ?? Object.values(value)[0] ?? ''\n}\n","/**\n * Message protocol between Extension Host and Extension Workers\n */\n\nimport type {\n ChatMessage,\n ChatOptions,\n GetModelsOptions,\n StreamEvent,\n ToolResult,\n ActionResult,\n ModelInfo,\n SchedulerFirePayload,\n} from './types.js'\n\n// ============================================================================\n// Host → Worker Messages\n// ============================================================================\n\nexport type HostToWorkerMessage =\n | ActivateMessage\n | DeactivateMessage\n | SettingsChangedMessage\n | SchedulerFireMessage\n | ProviderChatRequestMessage\n | ProviderModelsRequestMessage\n | ToolExecuteRequestMessage\n | ActionExecuteRequestMessage\n | ResponseMessage\n | StreamingFetchChunkMessage\n | BackgroundTaskStartMessage\n | BackgroundTaskStopMessage\n\nexport interface ActivateMessage {\n type: 'activate'\n id: string\n payload: {\n extensionId: string\n extensionVersion: string\n storagePath: string\n permissions: string[]\n settings: Record<string, unknown>\n }\n}\n\nexport interface DeactivateMessage {\n type: 'deactivate'\n id: string\n}\n\nexport interface SettingsChangedMessage {\n type: 'settings-changed'\n id: string\n payload: {\n key: string\n value: unknown\n }\n}\n\nexport interface SchedulerFireMessage {\n type: 'scheduler-fire'\n id: string\n payload: SchedulerFirePayload\n}\n\nexport interface ProviderChatRequestMessage {\n type: 'provider-chat-request'\n id: string\n payload: {\n providerId: string\n messages: ChatMessage[]\n options: ChatOptions\n }\n}\n\nexport interface ProviderModelsRequestMessage {\n type: 'provider-models-request'\n id: string\n payload: {\n providerId: string\n options?: GetModelsOptions\n }\n}\n\nexport interface ToolExecuteRequestMessage {\n type: 'tool-execute-request'\n id: string\n payload: {\n toolId: string\n params: Record<string, unknown>\n /** User ID if the tool is executed in a user context */\n userId?: string\n }\n}\n\nexport interface ActionExecuteRequestMessage {\n type: 'action-execute-request'\n id: string\n payload: {\n actionId: string\n params: Record<string, unknown>\n /** User ID if the action is executed in a user context */\n userId?: string\n }\n}\n\nexport interface ResponseMessage {\n type: 'response'\n id: string\n payload: {\n requestId: string\n success: boolean\n data?: unknown\n error?: string\n }\n}\n\n/**\n * Message sent from host to worker with streaming fetch data chunks.\n * Used for streaming network responses (e.g., NDJSON streams from Ollama).\n */\nexport interface StreamingFetchChunkMessage {\n type: 'streaming-fetch-chunk'\n id: string\n payload: {\n requestId: string\n chunk: string\n done: boolean\n error?: string\n }\n}\n\n/**\n * Message sent from host to worker to start a registered background task.\n */\nexport interface BackgroundTaskStartMessage {\n type: 'background-task-start'\n id: string\n payload: {\n taskId: string\n }\n}\n\n/**\n * Message sent from host to worker to stop a running background task.\n */\nexport interface BackgroundTaskStopMessage {\n type: 'background-task-stop'\n id: string\n payload: {\n taskId: string\n }\n}\n\n// ============================================================================\n// Worker → Host Messages\n// ============================================================================\n\nexport type WorkerToHostMessage =\n | ReadyMessage\n | RequestMessage\n | ProviderRegisteredMessage\n | ToolRegisteredMessage\n | ActionRegisteredMessage\n | StreamEventMessage\n | LogMessage\n | ProviderModelsResponseMessage\n | ToolExecuteResponseMessage\n | ActionExecuteResponseMessage\n | StreamingFetchAckMessage\n | BackgroundTaskRegisteredMessage\n | BackgroundTaskStatusMessage\n | BackgroundTaskHealthMessage\n\nexport interface ReadyMessage {\n type: 'ready'\n}\n\n/**\n * Message sent from worker to host to acknowledge receipt of a streaming fetch chunk.\n * This enables backpressure control to prevent unbounded memory growth.\n */\nexport interface StreamingFetchAckMessage {\n type: 'streaming-fetch-ack'\n payload: {\n requestId: string\n }\n}\n\nexport interface RequestMessage {\n type: 'request'\n id: string\n method: RequestMethod\n payload: unknown\n}\n\nexport type RequestMethod =\n | 'network.fetch'\n | 'network.fetch-stream'\n | 'settings.getAll'\n | 'settings.get'\n | 'settings.set'\n | 'user.getProfile'\n | 'user.listIds'\n | 'events.emit'\n | 'scheduler.schedule'\n | 'scheduler.cancel'\n | 'scheduler.reportFireResult'\n | 'chat.appendInstruction'\n | 'database.execute'\n // Simple key-value storage methods\n | 'storage.set'\n | 'storage.keys'\n | 'storage.setForUser'\n | 'storage.keysForUser'\n // Collection-based storage methods\n | 'storage.put'\n | 'storage.get'\n | 'storage.delete'\n | 'storage.find'\n | 'storage.findOne'\n | 'storage.count'\n | 'storage.putMany'\n | 'storage.deleteMany'\n | 'storage.dropCollection'\n | 'storage.listCollections'\n | 'storage.putForUser'\n | 'storage.getForUser'\n | 'storage.deleteForUser'\n | 'storage.findForUser'\n | 'storage.findOneForUser'\n | 'storage.countForUser'\n | 'storage.putManyForUser'\n | 'storage.deleteManyForUser'\n | 'storage.dropCollectionForUser'\n | 'storage.listCollectionsForUser'\n // Secrets methods\n | 'secrets.set'\n | 'secrets.get'\n | 'secrets.delete'\n | 'secrets.list'\n | 'secrets.setForUser'\n | 'secrets.getForUser'\n | 'secrets.deleteForUser'\n | 'secrets.listForUser'\n // Tools cross-extension methods\n | 'tools.list'\n | 'tools.execute'\n\nexport interface ProviderRegisteredMessage {\n type: 'provider-registered'\n payload: {\n id: string\n name: string\n }\n}\n\nexport interface ToolRegisteredMessage {\n type: 'tool-registered'\n payload: {\n id: string\n name: string\n description: string\n parameters?: Record<string, unknown>\n }\n}\n\nexport interface ActionRegisteredMessage {\n type: 'action-registered'\n payload: {\n id: string\n }\n}\n\nexport interface StreamEventMessage {\n type: 'stream-event'\n payload: {\n requestId: string\n event: StreamEvent\n }\n}\n\nexport interface ProviderModelsResponseMessage {\n type: 'provider-models-response'\n payload: {\n requestId: string\n models: ModelInfo[]\n error?: string\n }\n}\n\nexport interface ToolExecuteResponseMessage {\n type: 'tool-execute-response'\n payload: {\n requestId: string\n result: ToolResult\n error?: string\n }\n}\n\nexport interface ActionExecuteResponseMessage {\n type: 'action-execute-response'\n payload: {\n requestId: string\n result: ActionResult\n error?: string\n }\n}\n\nexport interface LogMessage {\n type: 'log'\n payload: {\n level: 'debug' | 'info' | 'warn' | 'error'\n message: string\n data?: Record<string, unknown>\n }\n}\n\n/**\n * Message sent from worker to host when a background task is registered.\n */\nexport interface BackgroundTaskRegisteredMessage {\n type: 'background-task-registered'\n payload: {\n taskId: string\n name: string\n userId: string\n restartPolicy: {\n type: 'always' | 'on-failure' | 'never'\n maxRestarts?: number\n initialDelayMs?: number\n maxDelayMs?: number\n backoffMultiplier?: number\n }\n payload?: Record<string, unknown>\n }\n}\n\n/**\n * Message sent from worker to host with background task status updates.\n */\nexport interface BackgroundTaskStatusMessage {\n type: 'background-task-status'\n payload: {\n taskId: string\n status: 'running' | 'stopped' | 'failed'\n error?: string\n }\n}\n\n/**\n * Message sent from worker to host with background task health reports.\n */\nexport interface BackgroundTaskHealthMessage {\n type: 'background-task-health'\n payload: {\n taskId: string\n status: string\n timestamp: string\n }\n}\n\n// ============================================================================\n// Utility Types\n// ============================================================================\n\nexport interface PendingRequest<T = unknown> {\n resolve: (value: T) => void\n reject: (error: Error) => void\n timeout: ReturnType<typeof setTimeout>\n}\n\n/**\n * Generate a unique message ID\n */\nexport function generateMessageId(): string {\n return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC4BO,SAAS,uBACd,OACA,MACA,eAAe,MACP;AACR,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,IAAI,KAAK,MAAM,YAAY,KAAK,OAAO,OAAO,KAAK,EAAE,CAAC,KAAK;AAC1E;;;ACiVO,SAAS,oBAA4B;AAC1C,SAAO,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACjE;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/types.localization.ts","../src/messages.ts"],"sourcesContent":["/**\n * @stina/extension-api\n *\n * Types and utilities for building Stina extensions.\n *\n * Extensions should import from this package for type definitions.\n * The runtime (worker-side code) should import from '@stina/extension-api/runtime'.\n */\n\n// Localization\nexport type { LocalizedString } from './types.js'\nexport { resolveLocalizedString } from './types.js'\n\n// Types\nexport type {\n // Manifest\n ExtensionManifest,\n Platform,\n ExtensionContributions,\n ToolSettingsViewDefinition,\n ToolSettingsView,\n ToolSettingsListView,\n ToolSettingsListMapping,\n ToolSettingsComponentView,\n ToolSettingsActionDataSource,\n PanelDefinition,\n PanelView,\n PanelComponentView,\n PanelActionDataSource,\n PanelUnknownView,\n ProviderDefinition,\n ProviderConfigView,\n PromptContribution,\n PromptSection,\n ToolDefinition,\n ToolConfirmationConfig,\n CommandDefinition,\n\n // Permissions\n Permission,\n NetworkPermission,\n StoragePermission,\n UserDataPermission,\n CapabilityPermission,\n SystemPermission,\n\n // Context\n ExtensionContext,\n Disposable,\n NetworkAPI,\n SettingsAPI,\n ProvidersAPI,\n ToolsAPI,\n ActionsAPI,\n EventsAPI,\n SchedulerAPI,\n SchedulerJobRequest,\n SchedulerSchedule,\n SchedulerFirePayload,\n UserAPI,\n UserProfile,\n ChatAPI,\n ChatInstructionMessage,\n ConversationPresentation,\n LogAPI,\n\n // Background workers\n BackgroundWorkersAPI,\n BackgroundTaskConfig,\n BackgroundTaskCallback,\n BackgroundTaskContext,\n BackgroundTaskHealth,\n BackgroundRestartPolicy,\n\n // Storage and Secrets\n Query,\n QueryOptions,\n StorageAPI,\n SecretsAPI,\n StorageCollectionConfig,\n StorageContributions,\n\n // AI Provider\n AIProvider,\n ModelInfo,\n ModelCapabilities,\n ChatMessage,\n ChatOptions,\n GetModelsOptions,\n StreamEvent,\n ToolCall,\n\n // Duplex voice\n VoiceSessionOptions,\n VoiceSessionDescriptor,\n VoiceTransportRequest,\n\n // Tools\n Tool,\n ToolResult,\n\n // Actions\n Action,\n ActionResult,\n\n // Entry point\n ExtensionModule,\n} from './types.js'\n\n// Messages (for host implementation)\nexport type {\n HostToWorkerMessage,\n WorkerToHostMessage,\n ActivateMessage,\n DeactivateMessage,\n SettingsChangedMessage,\n ProviderChatRequestMessage,\n ProviderModelsRequestMessage,\n ToolExecuteRequestMessage,\n ToolExecuteResponseMessage,\n ActionExecuteRequestMessage,\n ActionExecuteResponseMessage,\n ResponseMessage,\n ReadyMessage,\n RequestMessage,\n RequestMethod,\n ProviderRegisteredMessage,\n ToolRegisteredMessage,\n ActionRegisteredMessage,\n StreamEventMessage,\n LogMessage,\n PendingRequest,\n // Background task messages\n BackgroundTaskStartMessage,\n BackgroundTaskStopMessage,\n BackgroundTaskRegisteredMessage,\n BackgroundTaskStatusMessage,\n BackgroundTaskHealthMessage,\n} from './messages.js'\n\nexport { generateMessageId } from './messages.js'\n\n// Component types (for extension UI components)\nexport type {\n // Icon Names\n HugeIconName,\n // Styling\n AllowedCSSProperty,\n ExtensionComponentStyle,\n // Base types\n ExtensionComponentData,\n // Iteration & Children\n ExtensionComponentIterator,\n ExtensionComponentChildren,\n // Actions\n ExtensionActionCall,\n ExtensionActionRef,\n // Data Sources & Panel Definition\n ExtensionDataSource,\n ExtensionPanelDefinition,\n // Component Props\n HeaderProps,\n LabelProps,\n ParagraphProps,\n ButtonProps,\n TextInputProps,\n PasswordInputProps,\n NumberInputProps,\n TextAreaProps,\n DateTimeInputProps,\n SelectProps,\n IconPickerProps,\n VerticalStackProps,\n HorizontalStackProps,\n GridProps,\n DividerProps,\n IconProps,\n IconButtonType,\n IconButtonProps,\n PanelAction,\n PanelProps,\n ToggleProps,\n CollapsibleProps,\n FrameVariant,\n FrameProps,\n ListProps,\n PillVariant,\n PillProps,\n CheckboxProps,\n MarkdownProps,\n TextPreviewProps,\n ModalProps,\n ConditionalGroupProps,\n} from './types.components.js'\n","/**\n * Localization Types\n *\n * Types and utilities for localized strings in extensions.\n */\n\n/**\n * A string that can be either a simple string or a map of language codes to localized strings.\n * When a simple string is provided, it's used as the default/fallback value.\n * When a map is provided, the appropriate language is selected at runtime.\n *\n * @example\n * // Simple string (backwards compatible)\n * name: \"Get Weather\"\n *\n * @example\n * // Localized strings\n * name: { en: \"Get Weather\", sv: \"Hämta väder\", de: \"Wetter abrufen\" }\n */\nexport type LocalizedString = string | Record<string, string>\n\n/**\n * Resolves a LocalizedString to an actual string value.\n * @param value The LocalizedString to resolve\n * @param lang The preferred language code (e.g., \"sv\", \"en\")\n * @param fallbackLang The fallback language code (defaults to \"en\")\n * @returns The resolved string value\n */\nexport function resolveLocalizedString(\n value: LocalizedString,\n lang: string,\n fallbackLang = 'en'\n): string {\n if (typeof value === 'string') {\n return value\n }\n // Try preferred language first, then fallback language, then first available, then empty string\n return value[lang] ?? value[fallbackLang] ?? Object.values(value)[0] ?? ''\n}\n","/**\n * Message protocol between Extension Host and Extension Workers\n */\n\nimport type {\n ChatMessage,\n ChatOptions,\n GetModelsOptions,\n StreamEvent,\n ToolResult,\n ActionResult,\n ModelInfo,\n SchedulerFirePayload,\n VoiceSessionOptions,\n VoiceSessionDescriptor,\n} from './types.js'\n\n// ============================================================================\n// Host → Worker Messages\n// ============================================================================\n\nexport type HostToWorkerMessage =\n | ActivateMessage\n | DeactivateMessage\n | SettingsChangedMessage\n | SchedulerFireMessage\n | ProviderChatRequestMessage\n | ProviderModelsRequestMessage\n | ProviderVoiceSessionRequestMessage\n | ToolExecuteRequestMessage\n | ActionExecuteRequestMessage\n | ResponseMessage\n | StreamingFetchChunkMessage\n | BackgroundTaskStartMessage\n | BackgroundTaskStopMessage\n\nexport interface ActivateMessage {\n type: 'activate'\n id: string\n payload: {\n extensionId: string\n extensionVersion: string\n storagePath: string\n permissions: string[]\n settings: Record<string, unknown>\n }\n}\n\nexport interface DeactivateMessage {\n type: 'deactivate'\n id: string\n}\n\nexport interface SettingsChangedMessage {\n type: 'settings-changed'\n id: string\n payload: {\n key: string\n value: unknown\n }\n}\n\nexport interface SchedulerFireMessage {\n type: 'scheduler-fire'\n id: string\n payload: SchedulerFirePayload\n}\n\nexport interface ProviderChatRequestMessage {\n type: 'provider-chat-request'\n id: string\n payload: {\n providerId: string\n messages: ChatMessage[]\n options: ChatOptions\n }\n}\n\nexport interface ProviderModelsRequestMessage {\n type: 'provider-models-request'\n id: string\n payload: {\n providerId: string\n options?: GetModelsOptions\n }\n}\n\nexport interface ProviderVoiceSessionRequestMessage {\n type: 'provider-voice-session-request'\n id: string\n payload: {\n providerId: string\n /**\n * `signal` is dropped on the way across: an AbortSignal cannot be\n * structured-cloned into a worker. Cancellation is handled by the host\n * rejecting the pending request instead.\n */\n options: Omit<VoiceSessionOptions, 'signal'>\n }\n}\n\nexport interface ToolExecuteRequestMessage {\n type: 'tool-execute-request'\n id: string\n payload: {\n toolId: string\n params: Record<string, unknown>\n /** User ID if the tool is executed in a user context */\n userId?: string\n }\n}\n\nexport interface ActionExecuteRequestMessage {\n type: 'action-execute-request'\n id: string\n payload: {\n actionId: string\n params: Record<string, unknown>\n /** User ID if the action is executed in a user context */\n userId?: string\n }\n}\n\nexport interface ResponseMessage {\n type: 'response'\n id: string\n payload: {\n requestId: string\n success: boolean\n data?: unknown\n error?: string\n }\n}\n\n/**\n * Message sent from host to worker with streaming fetch data chunks.\n * Used for streaming network responses (e.g., NDJSON streams from Ollama).\n */\nexport interface StreamingFetchChunkMessage {\n type: 'streaming-fetch-chunk'\n id: string\n payload: {\n requestId: string\n chunk: string\n done: boolean\n error?: string\n }\n}\n\n/**\n * Message sent from host to worker to start a registered background task.\n */\nexport interface BackgroundTaskStartMessage {\n type: 'background-task-start'\n id: string\n payload: {\n taskId: string\n }\n}\n\n/**\n * Message sent from host to worker to stop a running background task.\n */\nexport interface BackgroundTaskStopMessage {\n type: 'background-task-stop'\n id: string\n payload: {\n taskId: string\n }\n}\n\n// ============================================================================\n// Worker → Host Messages\n// ============================================================================\n\nexport type WorkerToHostMessage =\n | ReadyMessage\n | RequestMessage\n | ProviderRegisteredMessage\n | ToolRegisteredMessage\n | ActionRegisteredMessage\n | StreamEventMessage\n | LogMessage\n | ProviderModelsResponseMessage\n | ProviderVoiceSessionResponseMessage\n | ToolExecuteResponseMessage\n | ActionExecuteResponseMessage\n | StreamingFetchAckMessage\n | BackgroundTaskRegisteredMessage\n | BackgroundTaskStatusMessage\n | BackgroundTaskHealthMessage\n\nexport interface ReadyMessage {\n type: 'ready'\n}\n\n/**\n * Message sent from worker to host to acknowledge receipt of a streaming fetch chunk.\n * This enables backpressure control to prevent unbounded memory growth.\n */\nexport interface StreamingFetchAckMessage {\n type: 'streaming-fetch-ack'\n payload: {\n requestId: string\n }\n}\n\nexport interface RequestMessage {\n type: 'request'\n id: string\n method: RequestMethod\n payload: unknown\n}\n\nexport type RequestMethod =\n | 'network.fetch'\n | 'network.fetch-stream'\n | 'settings.getAll'\n | 'settings.get'\n | 'settings.set'\n | 'user.getProfile'\n | 'user.listIds'\n | 'events.emit'\n | 'scheduler.schedule'\n | 'scheduler.cancel'\n | 'scheduler.reportFireResult'\n | 'chat.appendInstruction'\n | 'database.execute'\n // Simple key-value storage methods\n | 'storage.set'\n | 'storage.keys'\n | 'storage.setForUser'\n | 'storage.keysForUser'\n // Collection-based storage methods\n | 'storage.put'\n | 'storage.get'\n | 'storage.delete'\n | 'storage.find'\n | 'storage.findOne'\n | 'storage.count'\n | 'storage.putMany'\n | 'storage.deleteMany'\n | 'storage.dropCollection'\n | 'storage.listCollections'\n | 'storage.putForUser'\n | 'storage.getForUser'\n | 'storage.deleteForUser'\n | 'storage.findForUser'\n | 'storage.findOneForUser'\n | 'storage.countForUser'\n | 'storage.putManyForUser'\n | 'storage.deleteManyForUser'\n | 'storage.dropCollectionForUser'\n | 'storage.listCollectionsForUser'\n // Secrets methods\n | 'secrets.set'\n | 'secrets.get'\n | 'secrets.delete'\n | 'secrets.list'\n | 'secrets.setForUser'\n | 'secrets.getForUser'\n | 'secrets.deleteForUser'\n | 'secrets.listForUser'\n // Tools cross-extension methods\n | 'tools.list'\n | 'tools.execute'\n\nexport interface ProviderRegisteredMessage {\n type: 'provider-registered'\n payload: {\n id: string\n name: string\n }\n}\n\nexport interface ToolRegisteredMessage {\n type: 'tool-registered'\n payload: {\n id: string\n name: string\n description: string\n parameters?: Record<string, unknown>\n }\n}\n\nexport interface ActionRegisteredMessage {\n type: 'action-registered'\n payload: {\n id: string\n }\n}\n\nexport interface StreamEventMessage {\n type: 'stream-event'\n payload: {\n requestId: string\n event: StreamEvent\n }\n}\n\nexport interface ProviderModelsResponseMessage {\n type: 'provider-models-response'\n payload: {\n requestId: string\n models: ModelInfo[]\n error?: string\n }\n}\n\nexport interface ProviderVoiceSessionResponseMessage {\n type: 'provider-voice-session-response'\n payload: {\n requestId: string\n /** Absent when `error` is set. */\n descriptor?: VoiceSessionDescriptor\n error?: string\n }\n}\n\nexport interface ToolExecuteResponseMessage {\n type: 'tool-execute-response'\n payload: {\n requestId: string\n result: ToolResult\n error?: string\n }\n}\n\nexport interface ActionExecuteResponseMessage {\n type: 'action-execute-response'\n payload: {\n requestId: string\n result: ActionResult\n error?: string\n }\n}\n\nexport interface LogMessage {\n type: 'log'\n payload: {\n level: 'debug' | 'info' | 'warn' | 'error'\n message: string\n data?: Record<string, unknown>\n }\n}\n\n/**\n * Message sent from worker to host when a background task is registered.\n */\nexport interface BackgroundTaskRegisteredMessage {\n type: 'background-task-registered'\n payload: {\n taskId: string\n name: string\n userId: string\n restartPolicy: {\n type: 'always' | 'on-failure' | 'never'\n maxRestarts?: number\n initialDelayMs?: number\n maxDelayMs?: number\n backoffMultiplier?: number\n }\n payload?: Record<string, unknown>\n }\n}\n\n/**\n * Message sent from worker to host with background task status updates.\n */\nexport interface BackgroundTaskStatusMessage {\n type: 'background-task-status'\n payload: {\n taskId: string\n status: 'running' | 'stopped' | 'completed' | 'failed'\n error?: string\n }\n}\n\n/**\n * Message sent from worker to host with background task health reports.\n */\nexport interface BackgroundTaskHealthMessage {\n type: 'background-task-health'\n payload: {\n taskId: string\n status: string\n timestamp: string\n }\n}\n\n// ============================================================================\n// Utility Types\n// ============================================================================\n\nexport interface PendingRequest<T = unknown> {\n resolve: (value: T) => void\n reject: (error: Error) => void\n timeout: ReturnType<typeof setTimeout>\n}\n\n/**\n * Generate a unique message ID\n */\nexport function generateMessageId(): string {\n return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC4BO,SAAS,uBACd,OACA,MACA,eAAe,MACP;AACR,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,IAAI,KAAK,MAAM,YAAY,KAAK,OAAO,OAAO,KAAK,EAAE,CAAC,KAAK;AAC1E;;;AC6WO,SAAS,oBAA4B;AAC1C,SAAO,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACjE;","names":[]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as ExtensionContributions, S as SchedulerFirePayload, C as ChatMessage, a as ChatOptions, G as GetModelsOptions, b as StreamEvent, M as ModelInfo, T as ToolResult, A as ActionResult } from './types.tools-BYgcVNP4.cjs';
2
- export { a3 as AIProvider, a6 as Action, y as ActionsAPI, a9 as AllowedCSSProperty, Y as BackgroundRestartPolicy, V as BackgroundTaskCallback, R as BackgroundTaskConfig, W as BackgroundTaskContext, X as BackgroundTaskHealth, Q as BackgroundWorkersAPI, al as ButtonProps, J as ChatAPI, K as ChatInstructionMessage, aJ as CheckboxProps, aD as CollapsibleProps, t as CommandDefinition, aN as ConditionalGroupProps, aq as DateTimeInputProps, D as Disposable, aw as DividerProps, z as EventsAPI, ae as ExtensionActionCall, af as ExtensionActionRef, ad as ExtensionComponentChildren, ab as ExtensionComponentData, ac as ExtensionComponentIterator, aa as ExtensionComponentStyle, u as ExtensionContext, ag as ExtensionDataSource, a7 as ExtensionModule, ah as ExtensionPanelDefinition, aF as FrameProps, aE as FrameVariant, av as GridProps, ai as HeaderProps, au as HorizontalStackProps, a8 as HugeIconName, az as IconButtonProps, ay as IconButtonType, as as IconPickerProps, ax as IconProps, aj as LabelProps, aG as ListProps, L as LocalizedString, O as LogAPI, aK as MarkdownProps, aM as ModalProps, N as NetworkAPI, ao as NumberInputProps, aA as PanelAction, k as PanelActionDataSource, j as PanelComponentView, P as PanelDefinition, aB as PanelProps, l as PanelUnknownView, i as PanelView, ak as ParagraphProps, an as PasswordInputProps, aI as PillProps, aH as PillVariant, o as PromptContribution, p as PromptSection, n as ProviderConfigView, m as ProviderDefinition, w as ProvidersAPI, Z as Query, _ as QueryOptions, B as SchedulerAPI, F as SchedulerJobRequest, H as SchedulerSchedule, a0 as SecretsAPI, ar as SelectProps, v as SettingsAPI, $ as StorageAPI, a1 as StorageCollectionConfig, a2 as StorageContributions, ap as TextAreaProps, am as TextInputProps, aL as TextPreviewProps, aC as ToggleProps, a5 as Tool, a4 as ToolCall, s as ToolConfirmationConfig, q as ToolDefinition, h as ToolSettingsActionDataSource, g as ToolSettingsComponentView, f as ToolSettingsListMapping, e as ToolSettingsListView, d as ToolSettingsView, c as ToolSettingsViewDefinition, x as ToolsAPI, U as UserAPI, I as UserProfile, at as VerticalStackProps, r as resolveLocalizedString } from './types.tools-BYgcVNP4.cjs';
1
+ import { H as HugeIconName, E as ExtensionContributions, S as SchedulerFirePayload, C as ChatMessage, a as ChatOptions, G as GetModelsOptions, V as VoiceSessionOptions, b as StreamEvent, M as ModelInfo, c as VoiceSessionDescriptor, T as ToolResult, A as ActionResult } from './types.tools-BZQrEs91.cjs';
2
+ export { a7 as AIProvider, ac as Action, z as ActionsAPI, ae as AllowedCSSProperty, a0 as BackgroundRestartPolicy, Z as BackgroundTaskCallback, Y as BackgroundTaskConfig, _ as BackgroundTaskContext, $ as BackgroundTaskHealth, X as BackgroundWorkersAPI, aq as ButtonProps, O as ChatAPI, Q as ChatInstructionMessage, aO as CheckboxProps, aI as CollapsibleProps, u as CommandDefinition, aS as ConditionalGroupProps, R as ConversationPresentation, av as DateTimeInputProps, D as Disposable, aB as DividerProps, B as EventsAPI, aj as ExtensionActionCall, ak as ExtensionActionRef, ai as ExtensionComponentChildren, ag as ExtensionComponentData, ah as ExtensionComponentIterator, af as ExtensionComponentStyle, v as ExtensionContext, al as ExtensionDataSource, ad as ExtensionModule, am as ExtensionPanelDefinition, aK as FrameProps, aJ as FrameVariant, aA as GridProps, an as HeaderProps, az as HorizontalStackProps, aE as IconButtonProps, aD as IconButtonType, ax as IconPickerProps, aC as IconProps, ao as LabelProps, aL as ListProps, L as LocalizedString, W as LogAPI, aP as MarkdownProps, aR as ModalProps, a8 as ModelCapabilities, N as NetworkAPI, at as NumberInputProps, aF as PanelAction, l as PanelActionDataSource, k as PanelComponentView, P as PanelDefinition, aG as PanelProps, m as PanelUnknownView, j as PanelView, ap as ParagraphProps, as as PasswordInputProps, aN as PillProps, aM as PillVariant, p as PromptContribution, q as PromptSection, o as ProviderConfigView, n as ProviderDefinition, x as ProvidersAPI, a1 as Query, a2 as QueryOptions, F as SchedulerAPI, I as SchedulerJobRequest, J as SchedulerSchedule, a4 as SecretsAPI, aw as SelectProps, w as SettingsAPI, a3 as StorageAPI, a5 as StorageCollectionConfig, a6 as StorageContributions, au as TextAreaProps, ar as TextInputProps, aQ as TextPreviewProps, aH as ToggleProps, ab as Tool, a9 as ToolCall, t as ToolConfirmationConfig, s as ToolDefinition, i as ToolSettingsActionDataSource, h as ToolSettingsComponentView, g as ToolSettingsListMapping, f as ToolSettingsListView, e as ToolSettingsView, d as ToolSettingsViewDefinition, y as ToolsAPI, U as UserAPI, K as UserProfile, ay as VerticalStackProps, aa as VoiceTransportRequest, r as resolveLocalizedString } from './types.tools-BZQrEs91.cjs';
3
3
 
4
4
  /**
5
5
  * Permission Types
@@ -36,6 +36,12 @@ interface ExtensionManifest {
36
36
  version: string;
37
37
  /** Short description */
38
38
  description: string;
39
+ /**
40
+ * Optional icon (Hugeicons name) representing the extension. Used as the default
41
+ * icon for proactive conversation list entries this extension triggers, and as a
42
+ * general visual identity for the extension in the UI.
43
+ */
44
+ icon?: HugeIconName;
39
45
  /** Author information */
40
46
  author: {
41
47
  name: string;
@@ -64,7 +70,7 @@ type Platform = 'web' | 'electron' | 'tui';
64
70
  * Message protocol between Extension Host and Extension Workers
65
71
  */
66
72
 
67
- type HostToWorkerMessage = ActivateMessage | DeactivateMessage | SettingsChangedMessage | SchedulerFireMessage | ProviderChatRequestMessage | ProviderModelsRequestMessage | ToolExecuteRequestMessage | ActionExecuteRequestMessage | ResponseMessage | StreamingFetchChunkMessage | BackgroundTaskStartMessage | BackgroundTaskStopMessage;
73
+ type HostToWorkerMessage = ActivateMessage | DeactivateMessage | SettingsChangedMessage | SchedulerFireMessage | ProviderChatRequestMessage | ProviderModelsRequestMessage | ProviderVoiceSessionRequestMessage | ToolExecuteRequestMessage | ActionExecuteRequestMessage | ResponseMessage | StreamingFetchChunkMessage | BackgroundTaskStartMessage | BackgroundTaskStopMessage;
68
74
  interface ActivateMessage {
69
75
  type: 'activate';
70
76
  id: string;
@@ -110,6 +116,19 @@ interface ProviderModelsRequestMessage {
110
116
  options?: GetModelsOptions;
111
117
  };
112
118
  }
119
+ interface ProviderVoiceSessionRequestMessage {
120
+ type: 'provider-voice-session-request';
121
+ id: string;
122
+ payload: {
123
+ providerId: string;
124
+ /**
125
+ * `signal` is dropped on the way across: an AbortSignal cannot be
126
+ * structured-cloned into a worker. Cancellation is handled by the host
127
+ * rejecting the pending request instead.
128
+ */
129
+ options: Omit<VoiceSessionOptions, 'signal'>;
130
+ };
131
+ }
113
132
  interface ToolExecuteRequestMessage {
114
133
  type: 'tool-execute-request';
115
134
  id: string;
@@ -174,7 +193,7 @@ interface BackgroundTaskStopMessage {
174
193
  taskId: string;
175
194
  };
176
195
  }
177
- type WorkerToHostMessage = ReadyMessage | RequestMessage | ProviderRegisteredMessage | ToolRegisteredMessage | ActionRegisteredMessage | StreamEventMessage | LogMessage | ProviderModelsResponseMessage | ToolExecuteResponseMessage | ActionExecuteResponseMessage | StreamingFetchAckMessage | BackgroundTaskRegisteredMessage | BackgroundTaskStatusMessage | BackgroundTaskHealthMessage;
196
+ type WorkerToHostMessage = ReadyMessage | RequestMessage | ProviderRegisteredMessage | ToolRegisteredMessage | ActionRegisteredMessage | StreamEventMessage | LogMessage | ProviderModelsResponseMessage | ProviderVoiceSessionResponseMessage | ToolExecuteResponseMessage | ActionExecuteResponseMessage | StreamingFetchAckMessage | BackgroundTaskRegisteredMessage | BackgroundTaskStatusMessage | BackgroundTaskHealthMessage;
178
197
  interface ReadyMessage {
179
198
  type: 'ready';
180
199
  }
@@ -232,6 +251,15 @@ interface ProviderModelsResponseMessage {
232
251
  error?: string;
233
252
  };
234
253
  }
254
+ interface ProviderVoiceSessionResponseMessage {
255
+ type: 'provider-voice-session-response';
256
+ payload: {
257
+ requestId: string;
258
+ /** Absent when `error` is set. */
259
+ descriptor?: VoiceSessionDescriptor;
260
+ error?: string;
261
+ };
262
+ }
235
263
  interface ToolExecuteResponseMessage {
236
264
  type: 'tool-execute-response';
237
265
  payload: {
@@ -282,7 +310,7 @@ interface BackgroundTaskStatusMessage {
282
310
  type: 'background-task-status';
283
311
  payload: {
284
312
  taskId: string;
285
- status: 'running' | 'stopped' | 'failed';
313
+ status: 'running' | 'stopped' | 'completed' | 'failed';
286
314
  error?: string;
287
315
  };
288
316
  }
@@ -307,4 +335,4 @@ interface PendingRequest<T = unknown> {
307
335
  */
308
336
  declare function generateMessageId(): string;
309
337
 
310
- export { type ActionExecuteRequestMessage, type ActionExecuteResponseMessage, type ActionRegisteredMessage, ActionResult, type ActivateMessage, type BackgroundTaskHealthMessage, type BackgroundTaskRegisteredMessage, type BackgroundTaskStartMessage, type BackgroundTaskStatusMessage, type BackgroundTaskStopMessage, type CapabilityPermission, ChatMessage, ChatOptions, type DeactivateMessage, ExtensionContributions, type ExtensionManifest, GetModelsOptions, type HostToWorkerMessage, type LogMessage, ModelInfo, type NetworkPermission, type PendingRequest, type Permission, type Platform, type ProviderChatRequestMessage, type ProviderModelsRequestMessage, type ProviderRegisteredMessage, type ReadyMessage, type RequestMessage, type RequestMethod, type ResponseMessage, SchedulerFirePayload, type SettingsChangedMessage, type StoragePermission, StreamEvent, type StreamEventMessage, type SystemPermission, type ToolExecuteRequestMessage, type ToolExecuteResponseMessage, type ToolRegisteredMessage, ToolResult, type UserDataPermission, type WorkerToHostMessage, generateMessageId };
338
+ export { type ActionExecuteRequestMessage, type ActionExecuteResponseMessage, type ActionRegisteredMessage, ActionResult, type ActivateMessage, type BackgroundTaskHealthMessage, type BackgroundTaskRegisteredMessage, type BackgroundTaskStartMessage, type BackgroundTaskStatusMessage, type BackgroundTaskStopMessage, type CapabilityPermission, ChatMessage, ChatOptions, type DeactivateMessage, ExtensionContributions, type ExtensionManifest, GetModelsOptions, type HostToWorkerMessage, HugeIconName, type LogMessage, ModelInfo, type NetworkPermission, type PendingRequest, type Permission, type Platform, type ProviderChatRequestMessage, type ProviderModelsRequestMessage, type ProviderRegisteredMessage, type ReadyMessage, type RequestMessage, type RequestMethod, type ResponseMessage, SchedulerFirePayload, type SettingsChangedMessage, type StoragePermission, StreamEvent, type StreamEventMessage, type SystemPermission, type ToolExecuteRequestMessage, type ToolExecuteResponseMessage, type ToolRegisteredMessage, ToolResult, type UserDataPermission, VoiceSessionDescriptor, VoiceSessionOptions, type WorkerToHostMessage, generateMessageId };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as ExtensionContributions, S as SchedulerFirePayload, C as ChatMessage, a as ChatOptions, G as GetModelsOptions, b as StreamEvent, M as ModelInfo, T as ToolResult, A as ActionResult } from './types.tools-BYgcVNP4.js';
2
- export { a3 as AIProvider, a6 as Action, y as ActionsAPI, a9 as AllowedCSSProperty, Y as BackgroundRestartPolicy, V as BackgroundTaskCallback, R as BackgroundTaskConfig, W as BackgroundTaskContext, X as BackgroundTaskHealth, Q as BackgroundWorkersAPI, al as ButtonProps, J as ChatAPI, K as ChatInstructionMessage, aJ as CheckboxProps, aD as CollapsibleProps, t as CommandDefinition, aN as ConditionalGroupProps, aq as DateTimeInputProps, D as Disposable, aw as DividerProps, z as EventsAPI, ae as ExtensionActionCall, af as ExtensionActionRef, ad as ExtensionComponentChildren, ab as ExtensionComponentData, ac as ExtensionComponentIterator, aa as ExtensionComponentStyle, u as ExtensionContext, ag as ExtensionDataSource, a7 as ExtensionModule, ah as ExtensionPanelDefinition, aF as FrameProps, aE as FrameVariant, av as GridProps, ai as HeaderProps, au as HorizontalStackProps, a8 as HugeIconName, az as IconButtonProps, ay as IconButtonType, as as IconPickerProps, ax as IconProps, aj as LabelProps, aG as ListProps, L as LocalizedString, O as LogAPI, aK as MarkdownProps, aM as ModalProps, N as NetworkAPI, ao as NumberInputProps, aA as PanelAction, k as PanelActionDataSource, j as PanelComponentView, P as PanelDefinition, aB as PanelProps, l as PanelUnknownView, i as PanelView, ak as ParagraphProps, an as PasswordInputProps, aI as PillProps, aH as PillVariant, o as PromptContribution, p as PromptSection, n as ProviderConfigView, m as ProviderDefinition, w as ProvidersAPI, Z as Query, _ as QueryOptions, B as SchedulerAPI, F as SchedulerJobRequest, H as SchedulerSchedule, a0 as SecretsAPI, ar as SelectProps, v as SettingsAPI, $ as StorageAPI, a1 as StorageCollectionConfig, a2 as StorageContributions, ap as TextAreaProps, am as TextInputProps, aL as TextPreviewProps, aC as ToggleProps, a5 as Tool, a4 as ToolCall, s as ToolConfirmationConfig, q as ToolDefinition, h as ToolSettingsActionDataSource, g as ToolSettingsComponentView, f as ToolSettingsListMapping, e as ToolSettingsListView, d as ToolSettingsView, c as ToolSettingsViewDefinition, x as ToolsAPI, U as UserAPI, I as UserProfile, at as VerticalStackProps, r as resolveLocalizedString } from './types.tools-BYgcVNP4.js';
1
+ import { H as HugeIconName, E as ExtensionContributions, S as SchedulerFirePayload, C as ChatMessage, a as ChatOptions, G as GetModelsOptions, V as VoiceSessionOptions, b as StreamEvent, M as ModelInfo, c as VoiceSessionDescriptor, T as ToolResult, A as ActionResult } from './types.tools-BZQrEs91.js';
2
+ export { a7 as AIProvider, ac as Action, z as ActionsAPI, ae as AllowedCSSProperty, a0 as BackgroundRestartPolicy, Z as BackgroundTaskCallback, Y as BackgroundTaskConfig, _ as BackgroundTaskContext, $ as BackgroundTaskHealth, X as BackgroundWorkersAPI, aq as ButtonProps, O as ChatAPI, Q as ChatInstructionMessage, aO as CheckboxProps, aI as CollapsibleProps, u as CommandDefinition, aS as ConditionalGroupProps, R as ConversationPresentation, av as DateTimeInputProps, D as Disposable, aB as DividerProps, B as EventsAPI, aj as ExtensionActionCall, ak as ExtensionActionRef, ai as ExtensionComponentChildren, ag as ExtensionComponentData, ah as ExtensionComponentIterator, af as ExtensionComponentStyle, v as ExtensionContext, al as ExtensionDataSource, ad as ExtensionModule, am as ExtensionPanelDefinition, aK as FrameProps, aJ as FrameVariant, aA as GridProps, an as HeaderProps, az as HorizontalStackProps, aE as IconButtonProps, aD as IconButtonType, ax as IconPickerProps, aC as IconProps, ao as LabelProps, aL as ListProps, L as LocalizedString, W as LogAPI, aP as MarkdownProps, aR as ModalProps, a8 as ModelCapabilities, N as NetworkAPI, at as NumberInputProps, aF as PanelAction, l as PanelActionDataSource, k as PanelComponentView, P as PanelDefinition, aG as PanelProps, m as PanelUnknownView, j as PanelView, ap as ParagraphProps, as as PasswordInputProps, aN as PillProps, aM as PillVariant, p as PromptContribution, q as PromptSection, o as ProviderConfigView, n as ProviderDefinition, x as ProvidersAPI, a1 as Query, a2 as QueryOptions, F as SchedulerAPI, I as SchedulerJobRequest, J as SchedulerSchedule, a4 as SecretsAPI, aw as SelectProps, w as SettingsAPI, a3 as StorageAPI, a5 as StorageCollectionConfig, a6 as StorageContributions, au as TextAreaProps, ar as TextInputProps, aQ as TextPreviewProps, aH as ToggleProps, ab as Tool, a9 as ToolCall, t as ToolConfirmationConfig, s as ToolDefinition, i as ToolSettingsActionDataSource, h as ToolSettingsComponentView, g as ToolSettingsListMapping, f as ToolSettingsListView, e as ToolSettingsView, d as ToolSettingsViewDefinition, y as ToolsAPI, U as UserAPI, K as UserProfile, ay as VerticalStackProps, aa as VoiceTransportRequest, r as resolveLocalizedString } from './types.tools-BZQrEs91.js';
3
3
 
4
4
  /**
5
5
  * Permission Types
@@ -36,6 +36,12 @@ interface ExtensionManifest {
36
36
  version: string;
37
37
  /** Short description */
38
38
  description: string;
39
+ /**
40
+ * Optional icon (Hugeicons name) representing the extension. Used as the default
41
+ * icon for proactive conversation list entries this extension triggers, and as a
42
+ * general visual identity for the extension in the UI.
43
+ */
44
+ icon?: HugeIconName;
39
45
  /** Author information */
40
46
  author: {
41
47
  name: string;
@@ -64,7 +70,7 @@ type Platform = 'web' | 'electron' | 'tui';
64
70
  * Message protocol between Extension Host and Extension Workers
65
71
  */
66
72
 
67
- type HostToWorkerMessage = ActivateMessage | DeactivateMessage | SettingsChangedMessage | SchedulerFireMessage | ProviderChatRequestMessage | ProviderModelsRequestMessage | ToolExecuteRequestMessage | ActionExecuteRequestMessage | ResponseMessage | StreamingFetchChunkMessage | BackgroundTaskStartMessage | BackgroundTaskStopMessage;
73
+ type HostToWorkerMessage = ActivateMessage | DeactivateMessage | SettingsChangedMessage | SchedulerFireMessage | ProviderChatRequestMessage | ProviderModelsRequestMessage | ProviderVoiceSessionRequestMessage | ToolExecuteRequestMessage | ActionExecuteRequestMessage | ResponseMessage | StreamingFetchChunkMessage | BackgroundTaskStartMessage | BackgroundTaskStopMessage;
68
74
  interface ActivateMessage {
69
75
  type: 'activate';
70
76
  id: string;
@@ -110,6 +116,19 @@ interface ProviderModelsRequestMessage {
110
116
  options?: GetModelsOptions;
111
117
  };
112
118
  }
119
+ interface ProviderVoiceSessionRequestMessage {
120
+ type: 'provider-voice-session-request';
121
+ id: string;
122
+ payload: {
123
+ providerId: string;
124
+ /**
125
+ * `signal` is dropped on the way across: an AbortSignal cannot be
126
+ * structured-cloned into a worker. Cancellation is handled by the host
127
+ * rejecting the pending request instead.
128
+ */
129
+ options: Omit<VoiceSessionOptions, 'signal'>;
130
+ };
131
+ }
113
132
  interface ToolExecuteRequestMessage {
114
133
  type: 'tool-execute-request';
115
134
  id: string;
@@ -174,7 +193,7 @@ interface BackgroundTaskStopMessage {
174
193
  taskId: string;
175
194
  };
176
195
  }
177
- type WorkerToHostMessage = ReadyMessage | RequestMessage | ProviderRegisteredMessage | ToolRegisteredMessage | ActionRegisteredMessage | StreamEventMessage | LogMessage | ProviderModelsResponseMessage | ToolExecuteResponseMessage | ActionExecuteResponseMessage | StreamingFetchAckMessage | BackgroundTaskRegisteredMessage | BackgroundTaskStatusMessage | BackgroundTaskHealthMessage;
196
+ type WorkerToHostMessage = ReadyMessage | RequestMessage | ProviderRegisteredMessage | ToolRegisteredMessage | ActionRegisteredMessage | StreamEventMessage | LogMessage | ProviderModelsResponseMessage | ProviderVoiceSessionResponseMessage | ToolExecuteResponseMessage | ActionExecuteResponseMessage | StreamingFetchAckMessage | BackgroundTaskRegisteredMessage | BackgroundTaskStatusMessage | BackgroundTaskHealthMessage;
178
197
  interface ReadyMessage {
179
198
  type: 'ready';
180
199
  }
@@ -232,6 +251,15 @@ interface ProviderModelsResponseMessage {
232
251
  error?: string;
233
252
  };
234
253
  }
254
+ interface ProviderVoiceSessionResponseMessage {
255
+ type: 'provider-voice-session-response';
256
+ payload: {
257
+ requestId: string;
258
+ /** Absent when `error` is set. */
259
+ descriptor?: VoiceSessionDescriptor;
260
+ error?: string;
261
+ };
262
+ }
235
263
  interface ToolExecuteResponseMessage {
236
264
  type: 'tool-execute-response';
237
265
  payload: {
@@ -282,7 +310,7 @@ interface BackgroundTaskStatusMessage {
282
310
  type: 'background-task-status';
283
311
  payload: {
284
312
  taskId: string;
285
- status: 'running' | 'stopped' | 'failed';
313
+ status: 'running' | 'stopped' | 'completed' | 'failed';
286
314
  error?: string;
287
315
  };
288
316
  }
@@ -307,4 +335,4 @@ interface PendingRequest<T = unknown> {
307
335
  */
308
336
  declare function generateMessageId(): string;
309
337
 
310
- export { type ActionExecuteRequestMessage, type ActionExecuteResponseMessage, type ActionRegisteredMessage, ActionResult, type ActivateMessage, type BackgroundTaskHealthMessage, type BackgroundTaskRegisteredMessage, type BackgroundTaskStartMessage, type BackgroundTaskStatusMessage, type BackgroundTaskStopMessage, type CapabilityPermission, ChatMessage, ChatOptions, type DeactivateMessage, ExtensionContributions, type ExtensionManifest, GetModelsOptions, type HostToWorkerMessage, type LogMessage, ModelInfo, type NetworkPermission, type PendingRequest, type Permission, type Platform, type ProviderChatRequestMessage, type ProviderModelsRequestMessage, type ProviderRegisteredMessage, type ReadyMessage, type RequestMessage, type RequestMethod, type ResponseMessage, SchedulerFirePayload, type SettingsChangedMessage, type StoragePermission, StreamEvent, type StreamEventMessage, type SystemPermission, type ToolExecuteRequestMessage, type ToolExecuteResponseMessage, type ToolRegisteredMessage, ToolResult, type UserDataPermission, type WorkerToHostMessage, generateMessageId };
338
+ export { type ActionExecuteRequestMessage, type ActionExecuteResponseMessage, type ActionRegisteredMessage, ActionResult, type ActivateMessage, type BackgroundTaskHealthMessage, type BackgroundTaskRegisteredMessage, type BackgroundTaskStartMessage, type BackgroundTaskStatusMessage, type BackgroundTaskStopMessage, type CapabilityPermission, ChatMessage, ChatOptions, type DeactivateMessage, ExtensionContributions, type ExtensionManifest, GetModelsOptions, type HostToWorkerMessage, HugeIconName, type LogMessage, ModelInfo, type NetworkPermission, type PendingRequest, type Permission, type Platform, type ProviderChatRequestMessage, type ProviderModelsRequestMessage, type ProviderRegisteredMessage, type ReadyMessage, type RequestMessage, type RequestMethod, type ResponseMessage, SchedulerFirePayload, type SettingsChangedMessage, type StoragePermission, StreamEvent, type StreamEventMessage, type SystemPermission, type ToolExecuteRequestMessage, type ToolExecuteResponseMessage, type ToolRegisteredMessage, ToolResult, type UserDataPermission, VoiceSessionDescriptor, VoiceSessionOptions, type WorkerToHostMessage, generateMessageId };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  generateMessageId
3
- } from "./chunk-K53YNG2W.js";
3
+ } from "./chunk-ZB7GJUPS.js";
4
4
  import "./chunk-DGUM43GV.js";
5
5
 
6
6
  // src/types.localization.ts
package/dist/runtime.cjs CHANGED
@@ -88,19 +88,19 @@ var WorkerBackgroundTaskManager = class {
88
88
  task.abortController.abort();
89
89
  task.abortController = null;
90
90
  }
91
- task.abortController = new AbortController();
91
+ const abortController = new AbortController();
92
+ task.abortController = abortController;
92
93
  task.status = "running";
93
94
  task.error = void 0;
94
95
  const context = this.buildTaskContext(task);
95
96
  this.options.sendTaskStatus(taskId, "running");
96
97
  try {
97
98
  await task.callback(context);
98
- if (task.abortController?.signal.aborted) {
99
+ if (abortController.signal.aborted) {
99
100
  task.status = "stopped";
100
- this.options.sendTaskStatus(taskId, "stopped");
101
101
  } else {
102
- task.status = "stopped";
103
- this.options.sendTaskStatus(taskId, "stopped");
102
+ task.status = "completed";
103
+ this.options.sendTaskStatus(taskId, "completed");
104
104
  }
105
105
  } catch (error) {
106
106
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -358,6 +358,9 @@ async function handleHostMessage(message) {
358
358
  case "provider-models-request":
359
359
  await handleProviderModelsRequest(message.id, message.payload);
360
360
  break;
361
+ case "provider-voice-session-request":
362
+ await handleProviderVoiceSessionRequest(message.id, message.payload);
363
+ break;
361
364
  case "tool-execute-request":
362
365
  await handleToolExecuteRequest(message.id, message.payload);
363
366
  break;
@@ -578,6 +581,24 @@ async function handleProviderModelsRequest(requestId, payload) {
578
581
  });
579
582
  }
580
583
  }
584
+ async function handleProviderVoiceSessionRequest(requestId, payload) {
585
+ const respond = (error) => postMessage({ type: "provider-voice-session-response", payload: { requestId, error } });
586
+ const provider = registeredProviders.get(payload.providerId);
587
+ if (!provider) {
588
+ respond(`Provider ${payload.providerId} not found`);
589
+ return;
590
+ }
591
+ if (!provider.createVoiceSession) {
592
+ respond(`Provider ${payload.providerId} does not support voice sessions`);
593
+ return;
594
+ }
595
+ try {
596
+ const descriptor = await provider.createVoiceSession(payload.options);
597
+ postMessage({ type: "provider-voice-session-response", payload: { requestId, descriptor } });
598
+ } catch (error) {
599
+ respond(error instanceof Error ? error.message : String(error));
600
+ }
601
+ }
581
602
  async function handleToolExecuteRequest(requestId, payload) {
582
603
  const tool = registeredTools.get(payload.toolId);
583
604
  if (!tool) {