@dudko.dev/agent-web-react 0.0.11 → 0.0.13

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/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { DependencyList, ReactNode, RefObject, ComponentType, CSSProperties } from 'react';
3
- import { IPlan, IPlanStep, IUsage, ReplanMode, AgentEvent, RunFile, RunResult, Agent, ToolApprovalMode, CompactResult, AgentEventHandler, BrowserAgentConfig, VirtualFileInfo, VirtualFileSystem, CredentialStore, AgentToolSet, WebLLMModelOptions, createWebLLMModel } from '@dudko.dev/agent-web';
3
+ import { IPlan, IPlanStep, IUsage, ReplanMode, AgentEvent, RunFile, RunResult, Agent, ToolApprovalMode, CompactResult, AgentEventHandler, BrowserAgentConfig, VirtualFileInfo, VirtualFileSystem, CredentialStore, AgentToolSet, createWebLLMModel, WebLLMModelOptions } from '@dudko.dev/agent-web';
4
4
  export { Agent, AgentEvent, AgentEventHandler, AgentLoggerSink, AgentTool, AgentToolSet, AttachmentsNotSupportedError, BrowserAgentConfig, CompactResult, CompactionConfig, CredentialStore, FileToolsOptions, IPlan, IPlanStep, IStepResult, IToolCall, IUsage, ImagesNotSupportedError, IndexedDBStore, LogLevel, MemoryCredentialStore, MemoryStore, ModelInput, ProviderModelSpec, ProviderType, RunFile, RunOptions, RunResult, Skill, SubagentToolOptions, SubagentWorkerConfig, ThinkingLevel, ThinkingSetting, TokenLimits, ToolApprovalConfig, ToolApprovalMode, ToolApprovalRequest, VaultCredentialStore, VirtualFile, VirtualFileInfo, VirtualFileSystem, createAgent, createFileTools, createSubagentTool, createWebLLMModel, defineSkill, defineTool, isWebGPUAvailable, loadSkillFromUrl, markReadOnly, parseSkillMarkdown, preloadWebLLMModel, serveSubagentWorker, supportsImages, supportsPdf, unloadWebLLMModel } from '@dudko.dev/agent-web';
5
5
 
6
6
  /** Why a run stopped early (a `budget.exceeded` event). */
@@ -726,6 +726,113 @@ interface UseMcpServersReturn {
726
726
  */
727
727
  declare const useMcpServers: (options?: UseMcpServersOptions) => UseMcpServersReturn;
728
728
 
729
+ /** An AI SDK `LanguageModel` (the type, via the core — no `ai` import here). */
730
+ type LanguageModel = Awaited<ReturnType<typeof createWebLLMModel>>;
731
+ /** Download / initialisation progress of a local model. */
732
+ interface LocalModelProgress {
733
+ /** 0..1. */
734
+ progress: number;
735
+ /** Human-readable status from the runtime. */
736
+ text: string;
737
+ }
738
+ /** What `create` and `warmUp` are given. */
739
+ interface LocalModelLoadContext {
740
+ /** Report progress; the hook shows it for the load in flight only. */
741
+ onProgress: (report: LocalModelProgress) => void;
742
+ /** The window to load the model with, when the host asked for one. */
743
+ contextWindowTokens?: number;
744
+ }
745
+ /**
746
+ * How to run one kind of on-device model — WebLLM, the browser's built-in
747
+ * model (`@browser-ai/core`), transformers.js (`@browser-ai/transformers-js`),
748
+ * or your own. Only `create` is required.
749
+ */
750
+ interface LocalModelEngine<M extends LanguageModel = LanguageModel> {
751
+ /** Build the model (cheap: the download starts in `warmUp`). */
752
+ create: (modelId: string, ctx: LocalModelLoadContext) => Promise<M>;
753
+ /**
754
+ * Download the weights and initialise now, so `ready` means "ready to chat"
755
+ * and the progress shows during the load (default: nothing — the runtime
756
+ * then loads on the first message).
757
+ */
758
+ warmUp?: (model: M, ctx: LocalModelLoadContext) => Promise<void>;
759
+ /** Free the model's memory (default: nothing). */
760
+ unload?: (model: M) => Promise<void>;
761
+ /** Whether this browser can run it at all (default true). */
762
+ supported?: () => boolean;
763
+ /** The error a load reports when `supported()` is false. */
764
+ unsupportedMessage?: string;
765
+ /** The model's context window once loaded, when the runtime says. */
766
+ contextWindowOf?: (model: M) => number | undefined;
767
+ }
768
+ interface UseLocalModelOptions {
769
+ /**
770
+ * The window to load the model with (WebLLM loads with 4096 unless told
771
+ * otherwise). A different window is a different load.
772
+ */
773
+ contextWindowTokens?: number;
774
+ }
775
+ interface UseLocalModelReturn<M extends LanguageModel = LanguageModel> {
776
+ /**
777
+ * The built model, once **this** `modelId` is loaded — pass to
778
+ * `createAgent({ model })`. Undefined right after the id changes, until the
779
+ * new one is loaded.
780
+ */
781
+ model: M | undefined;
782
+ /**
783
+ * Download and initialize the current `modelId`. Resolves with the model
784
+ * already loaded for it, if any. Loading another id first frees the previous
785
+ * model's memory (one model per hook); call again after an error to retry.
786
+ */
787
+ load: () => Promise<M | undefined>;
788
+ /** Free the loaded model's memory (and drop a load in flight). */
789
+ unload: () => Promise<void>;
790
+ /** The id of the model held in memory, whichever id is current. */
791
+ loadedModelId: string | undefined;
792
+ /** True while the current `modelId` is downloading / initializing. */
793
+ loading: boolean;
794
+ /** Load progress of the current `modelId`, 0..1. */
795
+ progress: number;
796
+ /** Human-readable progress text from the runtime. */
797
+ text: string;
798
+ /** Why the current `modelId` failed to load. */
799
+ error: string | undefined;
800
+ /** Whether this browser can run the engine. */
801
+ supported: boolean;
802
+ /** True once the current `modelId` is ready. */
803
+ ready: boolean;
804
+ /** The loaded model's context window, in tokens, when the runtime says. */
805
+ contextWindow: number | undefined;
806
+ }
807
+ /**
808
+ * Load an on-device model and track its download — for any local runtime,
809
+ * described by an {@link LocalModelEngine}. Nothing downloads until you call
810
+ * `load()` (models are large), so you can gate it behind a user action.
811
+ *
812
+ * Everything it reports is about the **current** `modelId`: switch the id and
813
+ * `model` / `ready` / `progress` / `error` describe the new one (not loaded
814
+ * yet), while the previous model stays in memory — switching back is instant.
815
+ * Loading the new id frees the previous one first, so two models never hold
816
+ * memory at once; `unload()` frees it on demand. A load superseded by another
817
+ * frees its model; a second `load()` of the same id shares the download.
818
+ *
819
+ * ```tsx
820
+ * import { browserAI, doesBrowserSupportBrowserAI } from '@browser-ai/core'
821
+ * const nano: LocalModelEngine = {
822
+ * create: async () => browserAI('text', { expectedInputs: [{ type: 'image' }] }),
823
+ * warmUp: async (m, { onProgress }) => {
824
+ * await m.createSessionWithProgress((p) => onProgress({ progress: p, text: 'Downloading' }))
825
+ * },
826
+ * supported: doesBrowserSupportBrowserAI,
827
+ * contextWindowOf: (m) => m.getContextWindow(),
828
+ * }
829
+ * const local = useLocalModel('gemini-nano', nano)
830
+ * ```
831
+ *
832
+ * {@link useWebLLMModel} is this hook with the WebLLM engine.
833
+ */
834
+ declare const useLocalModel: <M extends LanguageModel = LanguageModel>(modelId: string, engine: LocalModelEngine<M>, options?: UseLocalModelOptions) => UseLocalModelReturn<M>;
835
+
729
836
  /** The AI SDK `LanguageModel` a WebLLM build produces (resolved via agent-web). */
730
837
  type WebLLMModel = Awaited<ReturnType<typeof createWebLLMModel>>;
731
838
  /**
@@ -751,30 +858,25 @@ interface UseWebLLMModelOptions extends WebLLMModelOptions {
751
858
  */
752
859
  create?: WebLLMModelFactory;
753
860
  }
754
- interface UseWebLLMModelReturn {
755
- /** The built model once loaded — pass to `createAgent({ model })`. */
756
- model: WebLLMModel | undefined;
757
- /** Start the download / engine init. Idempotent-ish: safe to call again to retry. */
758
- load: () => Promise<WebLLMModel | undefined>;
759
- /** True while weights are downloading / the engine is initializing. */
760
- loading: boolean;
761
- /** Load progress, 0..1. */
762
- progress: number;
763
- /** Human-readable progress text from WebLLM. */
764
- text: string;
765
- /** Error message if the load failed. */
766
- error: string | undefined;
767
- /** Whether WebGPU is available (required for local models). */
768
- supported: boolean;
769
- /** True once the model is ready. */
770
- ready: boolean;
771
- }
861
+ /** What {@link useWebLLMModel} returns — {@link UseLocalModelReturn} for a WebLLM model. */
862
+ type UseWebLLMModelReturn = UseLocalModelReturn<WebLLMModel>;
772
863
  /**
773
- * Load a local WebGPU model with WebLLM and track its download progress.
774
- * Nothing downloads until you call `load()` (models are large), so you can
775
- * gate it behind a user action. `load()` eagerly initializes the engine (via
776
- * the core's `preloadWebLLMModel`), so `ready` means "ready to chat" and
777
- * progress fills during the load rather than silently on the first message.
864
+ * Load a local WebGPU model with WebLLM and track its download progress —
865
+ * {@link useLocalModel} with the WebLLM engine. Nothing downloads until you
866
+ * call `load()` (models are large), so you can gate it behind a user action.
867
+ * `load()` eagerly initializes the engine (via the core's
868
+ * `preloadWebLLMModel`), so `ready` means "ready to chat" and progress fills
869
+ * during the load rather than silently on the first message.
870
+ *
871
+ * Everything it reports is about the **current** `modelId`: switch the id and
872
+ * `model` / `ready` / `progress` / `error` describe the new one (not loaded
873
+ * yet), while the previous model stays in memory — switching back is instant.
874
+ * Loading the new id frees the previous one first, so two models never hold
875
+ * GPU memory at once; `unload()` frees it on demand.
876
+ *
877
+ * WebLLM loads its models with a 4096-token window; pass `contextWindowTokens`
878
+ * to load with more (Qwen3, Llama 3.x take far more — it costs KV-cache VRAM,
879
+ * not a new download). A different window is a different load.
778
880
  *
779
881
  * ```tsx
780
882
  * import { webLLM } from '@browser-ai/web-llm' // your app's optional peer
@@ -786,6 +888,12 @@ interface UseWebLLMModelReturn {
786
888
  * ```
787
889
  */
788
890
  declare const useWebLLMModel: (modelId: string, options?: UseWebLLMModelOptions) => UseWebLLMModelReturn;
891
+ /**
892
+ * The WebLLM {@link LocalModelEngine}: what {@link useWebLLMModel} runs, for
893
+ * hosts that switch between local runtimes with one {@link useLocalModel}
894
+ * (pass the window to that hook's `contextWindowTokens`).
895
+ */
896
+ declare const createWebLLMEngine: (options?: UseWebLLMModelOptions) => LocalModelEngine<WebLLMModel>;
789
897
 
790
898
  /**
791
899
  * Pure helpers behind `<AgentComposer>`: slash commands, attachments, notices
@@ -949,8 +1057,10 @@ interface AgentLabels {
949
1057
  readOnly: string;
950
1058
  think: (levels: string) => string;
951
1059
  };
1060
+ /** `off` = the provider's default; `none` = thinking switched off. */
952
1061
  thinkingLevels: {
953
1062
  off: string;
1063
+ none: string;
954
1064
  low: string;
955
1065
  medium: string;
956
1066
  high: string;
@@ -1558,4 +1668,4 @@ interface ApiKeyFormProps {
1558
1668
  */
1559
1669
  declare const ApiKeyForm: ({ credentials, credentialRef, label, placeholder, onChange, className, }: ApiKeyFormProps) => react.JSX.Element;
1560
1670
 
1561
- export { type AgentAction, AgentChat, type AgentChatClassNames, type AgentChatComponents, type AgentChatProps, type AgentChatSlots, AgentComposer, type AgentComposerProps, type AgentLabels, type AgentLabelsOverride, AgentLabelsProvider, type AgentLabelsProviderProps, AgentProvider, type AgentProviderProps, type AgentStatus, type AgentUiState, ApiKeyForm, type ApiKeyFormProps, ApprovalModeSwitch, type ApprovalModeSwitchProps, type ApprovalView, type ApproveOptions, AttachmentView, type BudgetView, type ChatAttachment, ChatHistoryList, type ChatHistoryListProps, ChatHistoryStore, type ChatHistoryStoreOptions, type ChatMessage, type ChatRecord, type ChatSummary, type CompactionView, Composer, type ComposerAttachment, type ComposerModelChip, type ComposerNotice, type ComposerProps, type ComposerThinkingChip, type ConnectedMcp, ContextMeter, type ContextMeterProps, type ConvertedFile, type DownscaleOptions, FilesPanel, type FilesPanelProps, type McpAuthMode, type McpCatalogEntry, type McpConnectOptions, type McpModule, type McpOAuthCallback, type McpServerResult, type McpServerSpec, type McpServerView, type McpStatus, MessageList, type MessageListProps, ModelLoadBar, type ModelLoadBarProps, type ModelLoadState, type NoticeTexts, PlanView, type PlanViewProps, type RenderToolCall, type ReplanState, type RunGoalOptions, type SlashCommand, type SpeechRecognizerLike, StepList, type StepListProps, type StepView, SubagentRow, type SubagentView, ToolApprovalPrompt, type ToolApprovalPromptProps, ToolCallRow, type ToolCallRowProps, type ToolCallView, UsageBadge, type UsageBadgeProps, type UseAgentOptions, type UseAgentReturn, type UseChatHistoryOptions, type UseChatHistoryReturn, type UseCredentialsReturn, type UseMcpOptions, type UseMcpReturn, type UseMcpServersOptions, type UseMcpServersReturn, type UseSpeechToTextOptions, type UseSpeechToTextReturn, type UseVirtualFilesReturn, type UseWebLLMModelOptions, type UseWebLLMModelReturn, type WebLLMModelFactory, agentStateReducer, attachmentKindOf, attachmentRefusal, chatTitle, claimOAuthCallback, createInitialAgentState, defaultLabels, describeMcpResult, downscaleImage, filterCommands, formatElapsed, isUnauthorizedError, mergeLabels, newChatId, noticesOf, parseSlash, readCallbackParams, stripOAuthParams, usageLine, useAgent, useAgentContext, useChatHistory, useCredentials, useLabels, useMcp, useMcpServers, useOptionalAgentContext, useSpeechToText, useVirtualFiles, useWebLLMModel, withAttachments };
1671
+ export { type AgentAction, AgentChat, type AgentChatClassNames, type AgentChatComponents, type AgentChatProps, type AgentChatSlots, AgentComposer, type AgentComposerProps, type AgentLabels, type AgentLabelsOverride, AgentLabelsProvider, type AgentLabelsProviderProps, AgentProvider, type AgentProviderProps, type AgentStatus, type AgentUiState, ApiKeyForm, type ApiKeyFormProps, ApprovalModeSwitch, type ApprovalModeSwitchProps, type ApprovalView, type ApproveOptions, AttachmentView, type BudgetView, type ChatAttachment, ChatHistoryList, type ChatHistoryListProps, ChatHistoryStore, type ChatHistoryStoreOptions, type ChatMessage, type ChatRecord, type ChatSummary, type CompactionView, Composer, type ComposerAttachment, type ComposerModelChip, type ComposerNotice, type ComposerProps, type ComposerThinkingChip, type ConnectedMcp, ContextMeter, type ContextMeterProps, type ConvertedFile, type DownscaleOptions, FilesPanel, type FilesPanelProps, type LocalModelEngine, type LocalModelLoadContext, type LocalModelProgress, type McpAuthMode, type McpCatalogEntry, type McpConnectOptions, type McpModule, type McpOAuthCallback, type McpServerResult, type McpServerSpec, type McpServerView, type McpStatus, MessageList, type MessageListProps, ModelLoadBar, type ModelLoadBarProps, type ModelLoadState, type NoticeTexts, PlanView, type PlanViewProps, type RenderToolCall, type ReplanState, type RunGoalOptions, type SlashCommand, type SpeechRecognizerLike, StepList, type StepListProps, type StepView, SubagentRow, type SubagentView, ToolApprovalPrompt, type ToolApprovalPromptProps, ToolCallRow, type ToolCallRowProps, type ToolCallView, UsageBadge, type UsageBadgeProps, type UseAgentOptions, type UseAgentReturn, type UseChatHistoryOptions, type UseChatHistoryReturn, type UseCredentialsReturn, type UseLocalModelOptions, type UseLocalModelReturn, type UseMcpOptions, type UseMcpReturn, type UseMcpServersOptions, type UseMcpServersReturn, type UseSpeechToTextOptions, type UseSpeechToTextReturn, type UseVirtualFilesReturn, type UseWebLLMModelOptions, type UseWebLLMModelReturn, type WebLLMModelFactory, agentStateReducer, attachmentKindOf, attachmentRefusal, chatTitle, claimOAuthCallback, createInitialAgentState, createWebLLMEngine, defaultLabels, describeMcpResult, downscaleImage, filterCommands, formatElapsed, isUnauthorizedError, mergeLabels, newChatId, noticesOf, parseSlash, readCallbackParams, stripOAuthParams, usageLine, useAgent, useAgentContext, useChatHistory, useCredentials, useLabels, useLocalModel, useMcp, useMcpServers, useOptionalAgentContext, useSpeechToText, useVirtualFiles, useWebLLMModel, withAttachments };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { DependencyList, ReactNode, RefObject, ComponentType, CSSProperties } from 'react';
3
- import { IPlan, IPlanStep, IUsage, ReplanMode, AgentEvent, RunFile, RunResult, Agent, ToolApprovalMode, CompactResult, AgentEventHandler, BrowserAgentConfig, VirtualFileInfo, VirtualFileSystem, CredentialStore, AgentToolSet, WebLLMModelOptions, createWebLLMModel } from '@dudko.dev/agent-web';
3
+ import { IPlan, IPlanStep, IUsage, ReplanMode, AgentEvent, RunFile, RunResult, Agent, ToolApprovalMode, CompactResult, AgentEventHandler, BrowserAgentConfig, VirtualFileInfo, VirtualFileSystem, CredentialStore, AgentToolSet, createWebLLMModel, WebLLMModelOptions } from '@dudko.dev/agent-web';
4
4
  export { Agent, AgentEvent, AgentEventHandler, AgentLoggerSink, AgentTool, AgentToolSet, AttachmentsNotSupportedError, BrowserAgentConfig, CompactResult, CompactionConfig, CredentialStore, FileToolsOptions, IPlan, IPlanStep, IStepResult, IToolCall, IUsage, ImagesNotSupportedError, IndexedDBStore, LogLevel, MemoryCredentialStore, MemoryStore, ModelInput, ProviderModelSpec, ProviderType, RunFile, RunOptions, RunResult, Skill, SubagentToolOptions, SubagentWorkerConfig, ThinkingLevel, ThinkingSetting, TokenLimits, ToolApprovalConfig, ToolApprovalMode, ToolApprovalRequest, VaultCredentialStore, VirtualFile, VirtualFileInfo, VirtualFileSystem, createAgent, createFileTools, createSubagentTool, createWebLLMModel, defineSkill, defineTool, isWebGPUAvailable, loadSkillFromUrl, markReadOnly, parseSkillMarkdown, preloadWebLLMModel, serveSubagentWorker, supportsImages, supportsPdf, unloadWebLLMModel } from '@dudko.dev/agent-web';
5
5
 
6
6
  /** Why a run stopped early (a `budget.exceeded` event). */
@@ -726,6 +726,113 @@ interface UseMcpServersReturn {
726
726
  */
727
727
  declare const useMcpServers: (options?: UseMcpServersOptions) => UseMcpServersReturn;
728
728
 
729
+ /** An AI SDK `LanguageModel` (the type, via the core — no `ai` import here). */
730
+ type LanguageModel = Awaited<ReturnType<typeof createWebLLMModel>>;
731
+ /** Download / initialisation progress of a local model. */
732
+ interface LocalModelProgress {
733
+ /** 0..1. */
734
+ progress: number;
735
+ /** Human-readable status from the runtime. */
736
+ text: string;
737
+ }
738
+ /** What `create` and `warmUp` are given. */
739
+ interface LocalModelLoadContext {
740
+ /** Report progress; the hook shows it for the load in flight only. */
741
+ onProgress: (report: LocalModelProgress) => void;
742
+ /** The window to load the model with, when the host asked for one. */
743
+ contextWindowTokens?: number;
744
+ }
745
+ /**
746
+ * How to run one kind of on-device model — WebLLM, the browser's built-in
747
+ * model (`@browser-ai/core`), transformers.js (`@browser-ai/transformers-js`),
748
+ * or your own. Only `create` is required.
749
+ */
750
+ interface LocalModelEngine<M extends LanguageModel = LanguageModel> {
751
+ /** Build the model (cheap: the download starts in `warmUp`). */
752
+ create: (modelId: string, ctx: LocalModelLoadContext) => Promise<M>;
753
+ /**
754
+ * Download the weights and initialise now, so `ready` means "ready to chat"
755
+ * and the progress shows during the load (default: nothing — the runtime
756
+ * then loads on the first message).
757
+ */
758
+ warmUp?: (model: M, ctx: LocalModelLoadContext) => Promise<void>;
759
+ /** Free the model's memory (default: nothing). */
760
+ unload?: (model: M) => Promise<void>;
761
+ /** Whether this browser can run it at all (default true). */
762
+ supported?: () => boolean;
763
+ /** The error a load reports when `supported()` is false. */
764
+ unsupportedMessage?: string;
765
+ /** The model's context window once loaded, when the runtime says. */
766
+ contextWindowOf?: (model: M) => number | undefined;
767
+ }
768
+ interface UseLocalModelOptions {
769
+ /**
770
+ * The window to load the model with (WebLLM loads with 4096 unless told
771
+ * otherwise). A different window is a different load.
772
+ */
773
+ contextWindowTokens?: number;
774
+ }
775
+ interface UseLocalModelReturn<M extends LanguageModel = LanguageModel> {
776
+ /**
777
+ * The built model, once **this** `modelId` is loaded — pass to
778
+ * `createAgent({ model })`. Undefined right after the id changes, until the
779
+ * new one is loaded.
780
+ */
781
+ model: M | undefined;
782
+ /**
783
+ * Download and initialize the current `modelId`. Resolves with the model
784
+ * already loaded for it, if any. Loading another id first frees the previous
785
+ * model's memory (one model per hook); call again after an error to retry.
786
+ */
787
+ load: () => Promise<M | undefined>;
788
+ /** Free the loaded model's memory (and drop a load in flight). */
789
+ unload: () => Promise<void>;
790
+ /** The id of the model held in memory, whichever id is current. */
791
+ loadedModelId: string | undefined;
792
+ /** True while the current `modelId` is downloading / initializing. */
793
+ loading: boolean;
794
+ /** Load progress of the current `modelId`, 0..1. */
795
+ progress: number;
796
+ /** Human-readable progress text from the runtime. */
797
+ text: string;
798
+ /** Why the current `modelId` failed to load. */
799
+ error: string | undefined;
800
+ /** Whether this browser can run the engine. */
801
+ supported: boolean;
802
+ /** True once the current `modelId` is ready. */
803
+ ready: boolean;
804
+ /** The loaded model's context window, in tokens, when the runtime says. */
805
+ contextWindow: number | undefined;
806
+ }
807
+ /**
808
+ * Load an on-device model and track its download — for any local runtime,
809
+ * described by an {@link LocalModelEngine}. Nothing downloads until you call
810
+ * `load()` (models are large), so you can gate it behind a user action.
811
+ *
812
+ * Everything it reports is about the **current** `modelId`: switch the id and
813
+ * `model` / `ready` / `progress` / `error` describe the new one (not loaded
814
+ * yet), while the previous model stays in memory — switching back is instant.
815
+ * Loading the new id frees the previous one first, so two models never hold
816
+ * memory at once; `unload()` frees it on demand. A load superseded by another
817
+ * frees its model; a second `load()` of the same id shares the download.
818
+ *
819
+ * ```tsx
820
+ * import { browserAI, doesBrowserSupportBrowserAI } from '@browser-ai/core'
821
+ * const nano: LocalModelEngine = {
822
+ * create: async () => browserAI('text', { expectedInputs: [{ type: 'image' }] }),
823
+ * warmUp: async (m, { onProgress }) => {
824
+ * await m.createSessionWithProgress((p) => onProgress({ progress: p, text: 'Downloading' }))
825
+ * },
826
+ * supported: doesBrowserSupportBrowserAI,
827
+ * contextWindowOf: (m) => m.getContextWindow(),
828
+ * }
829
+ * const local = useLocalModel('gemini-nano', nano)
830
+ * ```
831
+ *
832
+ * {@link useWebLLMModel} is this hook with the WebLLM engine.
833
+ */
834
+ declare const useLocalModel: <M extends LanguageModel = LanguageModel>(modelId: string, engine: LocalModelEngine<M>, options?: UseLocalModelOptions) => UseLocalModelReturn<M>;
835
+
729
836
  /** The AI SDK `LanguageModel` a WebLLM build produces (resolved via agent-web). */
730
837
  type WebLLMModel = Awaited<ReturnType<typeof createWebLLMModel>>;
731
838
  /**
@@ -751,30 +858,25 @@ interface UseWebLLMModelOptions extends WebLLMModelOptions {
751
858
  */
752
859
  create?: WebLLMModelFactory;
753
860
  }
754
- interface UseWebLLMModelReturn {
755
- /** The built model once loaded — pass to `createAgent({ model })`. */
756
- model: WebLLMModel | undefined;
757
- /** Start the download / engine init. Idempotent-ish: safe to call again to retry. */
758
- load: () => Promise<WebLLMModel | undefined>;
759
- /** True while weights are downloading / the engine is initializing. */
760
- loading: boolean;
761
- /** Load progress, 0..1. */
762
- progress: number;
763
- /** Human-readable progress text from WebLLM. */
764
- text: string;
765
- /** Error message if the load failed. */
766
- error: string | undefined;
767
- /** Whether WebGPU is available (required for local models). */
768
- supported: boolean;
769
- /** True once the model is ready. */
770
- ready: boolean;
771
- }
861
+ /** What {@link useWebLLMModel} returns — {@link UseLocalModelReturn} for a WebLLM model. */
862
+ type UseWebLLMModelReturn = UseLocalModelReturn<WebLLMModel>;
772
863
  /**
773
- * Load a local WebGPU model with WebLLM and track its download progress.
774
- * Nothing downloads until you call `load()` (models are large), so you can
775
- * gate it behind a user action. `load()` eagerly initializes the engine (via
776
- * the core's `preloadWebLLMModel`), so `ready` means "ready to chat" and
777
- * progress fills during the load rather than silently on the first message.
864
+ * Load a local WebGPU model with WebLLM and track its download progress —
865
+ * {@link useLocalModel} with the WebLLM engine. Nothing downloads until you
866
+ * call `load()` (models are large), so you can gate it behind a user action.
867
+ * `load()` eagerly initializes the engine (via the core's
868
+ * `preloadWebLLMModel`), so `ready` means "ready to chat" and progress fills
869
+ * during the load rather than silently on the first message.
870
+ *
871
+ * Everything it reports is about the **current** `modelId`: switch the id and
872
+ * `model` / `ready` / `progress` / `error` describe the new one (not loaded
873
+ * yet), while the previous model stays in memory — switching back is instant.
874
+ * Loading the new id frees the previous one first, so two models never hold
875
+ * GPU memory at once; `unload()` frees it on demand.
876
+ *
877
+ * WebLLM loads its models with a 4096-token window; pass `contextWindowTokens`
878
+ * to load with more (Qwen3, Llama 3.x take far more — it costs KV-cache VRAM,
879
+ * not a new download). A different window is a different load.
778
880
  *
779
881
  * ```tsx
780
882
  * import { webLLM } from '@browser-ai/web-llm' // your app's optional peer
@@ -786,6 +888,12 @@ interface UseWebLLMModelReturn {
786
888
  * ```
787
889
  */
788
890
  declare const useWebLLMModel: (modelId: string, options?: UseWebLLMModelOptions) => UseWebLLMModelReturn;
891
+ /**
892
+ * The WebLLM {@link LocalModelEngine}: what {@link useWebLLMModel} runs, for
893
+ * hosts that switch between local runtimes with one {@link useLocalModel}
894
+ * (pass the window to that hook's `contextWindowTokens`).
895
+ */
896
+ declare const createWebLLMEngine: (options?: UseWebLLMModelOptions) => LocalModelEngine<WebLLMModel>;
789
897
 
790
898
  /**
791
899
  * Pure helpers behind `<AgentComposer>`: slash commands, attachments, notices
@@ -949,8 +1057,10 @@ interface AgentLabels {
949
1057
  readOnly: string;
950
1058
  think: (levels: string) => string;
951
1059
  };
1060
+ /** `off` = the provider's default; `none` = thinking switched off. */
952
1061
  thinkingLevels: {
953
1062
  off: string;
1063
+ none: string;
954
1064
  low: string;
955
1065
  medium: string;
956
1066
  high: string;
@@ -1558,4 +1668,4 @@ interface ApiKeyFormProps {
1558
1668
  */
1559
1669
  declare const ApiKeyForm: ({ credentials, credentialRef, label, placeholder, onChange, className, }: ApiKeyFormProps) => react.JSX.Element;
1560
1670
 
1561
- export { type AgentAction, AgentChat, type AgentChatClassNames, type AgentChatComponents, type AgentChatProps, type AgentChatSlots, AgentComposer, type AgentComposerProps, type AgentLabels, type AgentLabelsOverride, AgentLabelsProvider, type AgentLabelsProviderProps, AgentProvider, type AgentProviderProps, type AgentStatus, type AgentUiState, ApiKeyForm, type ApiKeyFormProps, ApprovalModeSwitch, type ApprovalModeSwitchProps, type ApprovalView, type ApproveOptions, AttachmentView, type BudgetView, type ChatAttachment, ChatHistoryList, type ChatHistoryListProps, ChatHistoryStore, type ChatHistoryStoreOptions, type ChatMessage, type ChatRecord, type ChatSummary, type CompactionView, Composer, type ComposerAttachment, type ComposerModelChip, type ComposerNotice, type ComposerProps, type ComposerThinkingChip, type ConnectedMcp, ContextMeter, type ContextMeterProps, type ConvertedFile, type DownscaleOptions, FilesPanel, type FilesPanelProps, type McpAuthMode, type McpCatalogEntry, type McpConnectOptions, type McpModule, type McpOAuthCallback, type McpServerResult, type McpServerSpec, type McpServerView, type McpStatus, MessageList, type MessageListProps, ModelLoadBar, type ModelLoadBarProps, type ModelLoadState, type NoticeTexts, PlanView, type PlanViewProps, type RenderToolCall, type ReplanState, type RunGoalOptions, type SlashCommand, type SpeechRecognizerLike, StepList, type StepListProps, type StepView, SubagentRow, type SubagentView, ToolApprovalPrompt, type ToolApprovalPromptProps, ToolCallRow, type ToolCallRowProps, type ToolCallView, UsageBadge, type UsageBadgeProps, type UseAgentOptions, type UseAgentReturn, type UseChatHistoryOptions, type UseChatHistoryReturn, type UseCredentialsReturn, type UseMcpOptions, type UseMcpReturn, type UseMcpServersOptions, type UseMcpServersReturn, type UseSpeechToTextOptions, type UseSpeechToTextReturn, type UseVirtualFilesReturn, type UseWebLLMModelOptions, type UseWebLLMModelReturn, type WebLLMModelFactory, agentStateReducer, attachmentKindOf, attachmentRefusal, chatTitle, claimOAuthCallback, createInitialAgentState, defaultLabels, describeMcpResult, downscaleImage, filterCommands, formatElapsed, isUnauthorizedError, mergeLabels, newChatId, noticesOf, parseSlash, readCallbackParams, stripOAuthParams, usageLine, useAgent, useAgentContext, useChatHistory, useCredentials, useLabels, useMcp, useMcpServers, useOptionalAgentContext, useSpeechToText, useVirtualFiles, useWebLLMModel, withAttachments };
1671
+ export { type AgentAction, AgentChat, type AgentChatClassNames, type AgentChatComponents, type AgentChatProps, type AgentChatSlots, AgentComposer, type AgentComposerProps, type AgentLabels, type AgentLabelsOverride, AgentLabelsProvider, type AgentLabelsProviderProps, AgentProvider, type AgentProviderProps, type AgentStatus, type AgentUiState, ApiKeyForm, type ApiKeyFormProps, ApprovalModeSwitch, type ApprovalModeSwitchProps, type ApprovalView, type ApproveOptions, AttachmentView, type BudgetView, type ChatAttachment, ChatHistoryList, type ChatHistoryListProps, ChatHistoryStore, type ChatHistoryStoreOptions, type ChatMessage, type ChatRecord, type ChatSummary, type CompactionView, Composer, type ComposerAttachment, type ComposerModelChip, type ComposerNotice, type ComposerProps, type ComposerThinkingChip, type ConnectedMcp, ContextMeter, type ContextMeterProps, type ConvertedFile, type DownscaleOptions, FilesPanel, type FilesPanelProps, type LocalModelEngine, type LocalModelLoadContext, type LocalModelProgress, type McpAuthMode, type McpCatalogEntry, type McpConnectOptions, type McpModule, type McpOAuthCallback, type McpServerResult, type McpServerSpec, type McpServerView, type McpStatus, MessageList, type MessageListProps, ModelLoadBar, type ModelLoadBarProps, type ModelLoadState, type NoticeTexts, PlanView, type PlanViewProps, type RenderToolCall, type ReplanState, type RunGoalOptions, type SlashCommand, type SpeechRecognizerLike, StepList, type StepListProps, type StepView, SubagentRow, type SubagentView, ToolApprovalPrompt, type ToolApprovalPromptProps, ToolCallRow, type ToolCallRowProps, type ToolCallView, UsageBadge, type UsageBadgeProps, type UseAgentOptions, type UseAgentReturn, type UseChatHistoryOptions, type UseChatHistoryReturn, type UseCredentialsReturn, type UseLocalModelOptions, type UseLocalModelReturn, type UseMcpOptions, type UseMcpReturn, type UseMcpServersOptions, type UseMcpServersReturn, type UseSpeechToTextOptions, type UseSpeechToTextReturn, type UseVirtualFilesReturn, type UseWebLLMModelOptions, type UseWebLLMModelReturn, type WebLLMModelFactory, agentStateReducer, attachmentKindOf, attachmentRefusal, chatTitle, claimOAuthCallback, createInitialAgentState, createWebLLMEngine, defaultLabels, describeMcpResult, downscaleImage, filterCommands, formatElapsed, isUnauthorizedError, mergeLabels, newChatId, noticesOf, parseSlash, readCallbackParams, stripOAuthParams, usageLine, useAgent, useAgentContext, useChatHistory, useCredentials, useLabels, useLocalModel, useMcp, useMcpServers, useOptionalAgentContext, useSpeechToText, useVirtualFiles, useWebLLMModel, withAttachments };