@happyvertical/smrt-svelte 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +317 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/README.md +185 -0
- package/dist/Provider.svelte +204 -0
- package/dist/Provider.svelte.d.ts +73 -0
- package/dist/Provider.svelte.d.ts.map +1 -0
- package/dist/__tests__/app-state.test.js +156 -0
- package/dist/__tests__/warm-clients.test.js +186 -0
- package/dist/browser-ai/adapters/llm/factory.d.ts +38 -0
- package/dist/browser-ai/adapters/llm/factory.d.ts.map +1 -0
- package/dist/browser-ai/adapters/llm/factory.js +91 -0
- package/dist/browser-ai/adapters/llm/index.d.ts +7 -0
- package/dist/browser-ai/adapters/llm/index.d.ts.map +1 -0
- package/dist/browser-ai/adapters/llm/index.js +6 -0
- package/dist/browser-ai/adapters/llm/types.d.ts +182 -0
- package/dist/browser-ai/adapters/llm/types.d.ts.map +1 -0
- package/dist/browser-ai/adapters/llm/types.js +43 -0
- package/dist/browser-ai/adapters/llm/webllm.d.ts +33 -0
- package/dist/browser-ai/adapters/llm/webllm.d.ts.map +1 -0
- package/dist/browser-ai/adapters/llm/webllm.js +225 -0
- package/dist/browser-ai/adapters/stt/browser-speech.d.ts +31 -0
- package/dist/browser-ai/adapters/stt/browser-speech.d.ts.map +1 -0
- package/dist/browser-ai/adapters/stt/browser-speech.js +217 -0
- package/dist/browser-ai/adapters/stt/factory.d.ts +49 -0
- package/dist/browser-ai/adapters/stt/factory.d.ts.map +1 -0
- package/dist/browser-ai/adapters/stt/factory.js +110 -0
- package/dist/browser-ai/adapters/stt/index.d.ts +9 -0
- package/dist/browser-ai/adapters/stt/index.d.ts.map +1 -0
- package/dist/browser-ai/adapters/stt/index.js +8 -0
- package/dist/browser-ai/adapters/stt/types.d.ts +154 -0
- package/dist/browser-ai/adapters/stt/types.d.ts.map +1 -0
- package/dist/browser-ai/adapters/stt/types.js +4 -0
- package/dist/browser-ai/adapters/stt/whisper-cpp.d.ts +46 -0
- package/dist/browser-ai/adapters/stt/whisper-cpp.d.ts.map +1 -0
- package/dist/browser-ai/adapters/stt/whisper-cpp.js +348 -0
- package/dist/browser-ai/adapters/stt/whisper-wasm.d.ts +51 -0
- package/dist/browser-ai/adapters/stt/whisper-wasm.d.ts.map +1 -0
- package/dist/browser-ai/adapters/stt/whisper-wasm.js +380 -0
- package/dist/browser-ai/adapters/tts/browser-synthesis.d.ts +42 -0
- package/dist/browser-ai/adapters/tts/browser-synthesis.d.ts.map +1 -0
- package/dist/browser-ai/adapters/tts/browser-synthesis.js +235 -0
- package/dist/browser-ai/adapters/tts/factory.d.ts +53 -0
- package/dist/browser-ai/adapters/tts/factory.d.ts.map +1 -0
- package/dist/browser-ai/adapters/tts/factory.js +92 -0
- package/dist/browser-ai/adapters/tts/index.d.ts +7 -0
- package/dist/browser-ai/adapters/tts/index.d.ts.map +1 -0
- package/dist/browser-ai/adapters/tts/index.js +6 -0
- package/dist/browser-ai/adapters/tts/types.d.ts +140 -0
- package/dist/browser-ai/adapters/tts/types.d.ts.map +1 -0
- package/dist/browser-ai/adapters/tts/types.js +4 -0
- package/dist/browser-ai/capabilities/detector.d.ts +38 -0
- package/dist/browser-ai/capabilities/detector.d.ts.map +1 -0
- package/dist/browser-ai/capabilities/detector.js +211 -0
- package/dist/browser-ai/core/errors.d.ts +62 -0
- package/dist/browser-ai/core/errors.d.ts.map +1 -0
- package/dist/browser-ai/core/errors.js +92 -0
- package/dist/browser-ai/core/index.d.ts +6 -0
- package/dist/browser-ai/core/index.d.ts.map +1 -0
- package/dist/browser-ai/core/index.js +5 -0
- package/dist/browser-ai/core/types.d.ts +115 -0
- package/dist/browser-ai/core/types.d.ts.map +1 -0
- package/dist/browser-ai/core/types.js +34 -0
- package/dist/browser-ai/index.d.ts +12 -0
- package/dist/browser-ai/index.d.ts.map +1 -0
- package/dist/browser-ai/index.js +16 -0
- package/dist/browser-ai/svelte/components/AILoadingOverlay.svelte +77 -0
- package/dist/browser-ai/svelte/components/AILoadingOverlay.svelte.d.ts +16 -0
- package/dist/browser-ai/svelte/components/AILoadingOverlay.svelte.d.ts.map +1 -0
- package/dist/browser-ai/svelte/components/CapabilityGate.svelte +57 -0
- package/dist/browser-ai/svelte/components/CapabilityGate.svelte.d.ts +15 -0
- package/dist/browser-ai/svelte/components/CapabilityGate.svelte.d.ts.map +1 -0
- package/dist/browser-ai/svelte/components/DownloadProgress.svelte +141 -0
- package/dist/browser-ai/svelte/components/DownloadProgress.svelte.d.ts +15 -0
- package/dist/browser-ai/svelte/components/DownloadProgress.svelte.d.ts.map +1 -0
- package/dist/browser-ai/svelte/components/STTTest.svelte +379 -0
- package/dist/browser-ai/svelte/components/STTTest.svelte.d.ts +9 -0
- package/dist/browser-ai/svelte/components/STTTest.svelte.d.ts.map +1 -0
- package/dist/browser-ai/svelte/components/VoiceInput.svelte +200 -0
- package/dist/browser-ai/svelte/components/VoiceInput.svelte.d.ts +16 -0
- package/dist/browser-ai/svelte/components/VoiceInput.svelte.d.ts.map +1 -0
- package/dist/browser-ai/svelte/index.d.ts +15 -0
- package/dist/browser-ai/svelte/index.d.ts.map +1 -0
- package/dist/browser-ai/svelte/index.js +28 -0
- package/dist/browser-ai/ui.d.ts +16 -0
- package/dist/browser-ai/ui.d.ts.map +1 -0
- package/dist/browser-ai/ui.js +67 -0
- package/dist/components/admin/AgentAdminPanel.svelte +111 -0
- package/dist/components/admin/AgentAdminPanel.svelte.d.ts +25 -0
- package/dist/components/admin/AgentAdminPanel.svelte.d.ts.map +1 -0
- package/dist/components/admin/AgentAdminTabs.svelte +280 -0
- package/dist/components/admin/AgentAdminTabs.svelte.d.ts +23 -0
- package/dist/components/admin/AgentAdminTabs.svelte.d.ts.map +1 -0
- package/dist/components/admin/AgentSettingsShell.svelte +257 -0
- package/dist/components/admin/AgentSettingsShell.svelte.d.ts +33 -0
- package/dist/components/admin/AgentSettingsShell.svelte.d.ts.map +1 -0
- package/dist/components/admin/index.d.ts +5 -0
- package/dist/components/admin/index.d.ts.map +1 -0
- package/dist/components/admin/index.js +6 -0
- package/dist/components/forms/AddressInput.svelte +500 -0
- package/dist/components/forms/AddressInput.svelte.d.ts +36 -0
- package/dist/components/forms/AddressInput.svelte.d.ts.map +1 -0
- package/dist/components/forms/CheckboxInput.svelte +208 -0
- package/dist/components/forms/CheckboxInput.svelte.d.ts +20 -0
- package/dist/components/forms/CheckboxInput.svelte.d.ts.map +1 -0
- package/dist/components/forms/DateRangeInput.svelte +628 -0
- package/dist/components/forms/DateRangeInput.svelte.d.ts +33 -0
- package/dist/components/forms/DateRangeInput.svelte.d.ts.map +1 -0
- package/dist/components/forms/DateTimeInput.svelte +521 -0
- package/dist/components/forms/DateTimeInput.svelte.d.ts +24 -0
- package/dist/components/forms/DateTimeInput.svelte.d.ts.map +1 -0
- package/dist/components/forms/FileUpload.svelte +358 -0
- package/dist/components/forms/FileUpload.svelte.d.ts +22 -0
- package/dist/components/forms/FileUpload.svelte.d.ts.map +1 -0
- package/dist/components/forms/Form.svelte +771 -0
- package/dist/components/forms/Form.svelte.d.ts +26 -0
- package/dist/components/forms/Form.svelte.d.ts.map +1 -0
- package/dist/components/forms/FormGroup.svelte +86 -0
- package/dist/components/forms/FormGroup.svelte.d.ts +13 -0
- package/dist/components/forms/FormGroup.svelte.d.ts.map +1 -0
- package/dist/components/forms/FormMicButton.svelte +179 -0
- package/dist/components/forms/FormMicButton.svelte.d.ts +10 -0
- package/dist/components/forms/FormMicButton.svelte.d.ts.map +1 -0
- package/dist/components/forms/Input.svelte +83 -0
- package/dist/components/forms/Input.svelte.d.ts +9 -0
- package/dist/components/forms/Input.svelte.d.ts.map +1 -0
- package/dist/components/forms/MeasurementInput.svelte +505 -0
- package/dist/components/forms/MeasurementInput.svelte.d.ts +35 -0
- package/dist/components/forms/MeasurementInput.svelte.d.ts.map +1 -0
- package/dist/components/forms/MoneyInput.svelte +412 -0
- package/dist/components/forms/MoneyInput.svelte.d.ts +30 -0
- package/dist/components/forms/MoneyInput.svelte.d.ts.map +1 -0
- package/dist/components/forms/NumberInput.svelte +310 -0
- package/dist/components/forms/NumberInput.svelte.d.ts +28 -0
- package/dist/components/forms/NumberInput.svelte.d.ts.map +1 -0
- package/dist/components/forms/PhoneInput.svelte +530 -0
- package/dist/components/forms/PhoneInput.svelte.d.ts +22 -0
- package/dist/components/forms/PhoneInput.svelte.d.ts.map +1 -0
- package/dist/components/forms/SearchInput.svelte +358 -0
- package/dist/components/forms/SearchInput.svelte.d.ts +33 -0
- package/dist/components/forms/SearchInput.svelte.d.ts.map +1 -0
- package/dist/components/forms/Select.svelte +83 -0
- package/dist/components/forms/Select.svelte.d.ts +11 -0
- package/dist/components/forms/Select.svelte.d.ts.map +1 -0
- package/dist/components/forms/SelectInput.svelte +254 -0
- package/dist/components/forms/SelectInput.svelte.d.ts +25 -0
- package/dist/components/forms/SelectInput.svelte.d.ts.map +1 -0
- package/dist/components/forms/TextInput.svelte +415 -0
- package/dist/components/forms/TextInput.svelte.d.ts +26 -0
- package/dist/components/forms/TextInput.svelte.d.ts.map +1 -0
- package/dist/components/forms/Textarea.svelte +85 -0
- package/dist/components/forms/Textarea.svelte.d.ts +10 -0
- package/dist/components/forms/Textarea.svelte.d.ts.map +1 -0
- package/dist/components/forms/TextareaInput.svelte +386 -0
- package/dist/components/forms/TextareaInput.svelte.d.ts +26 -0
- package/dist/components/forms/TextareaInput.svelte.d.ts.map +1 -0
- package/dist/components/forms/Toggle.svelte +217 -0
- package/dist/components/forms/Toggle.svelte.d.ts +37 -0
- package/dist/components/forms/Toggle.svelte.d.ts.map +1 -0
- package/dist/components/forms/__tests__/AddressInput.behavior.test.js +122 -0
- package/dist/components/forms/__tests__/CheckboxInput.test.js +92 -0
- package/dist/components/forms/__tests__/DateRangeInput.behavior.test.js +135 -0
- package/dist/components/forms/__tests__/DateTimeInput.behavior.test.js +103 -0
- package/dist/components/forms/__tests__/FileUpload.test.js +90 -0
- package/dist/components/forms/__tests__/Form.behavior.test.js +137 -0
- package/dist/components/forms/__tests__/Form.test.js +58 -0
- package/dist/components/forms/__tests__/FormGroup.test.js +48 -0
- package/dist/components/forms/__tests__/FormMicButton.test.js +86 -0
- package/dist/components/forms/__tests__/Input.test.js +49 -0
- package/dist/components/forms/__tests__/MeasurementInput.behavior.test.js +129 -0
- package/dist/components/forms/__tests__/MoneyInput.behavior.test.js +124 -0
- package/dist/components/forms/__tests__/NumberInput.behavior.test.js +141 -0
- package/dist/components/forms/__tests__/PhoneInput.behavior.test.js +96 -0
- package/dist/components/forms/__tests__/SearchInput.test.js +79 -0
- package/dist/components/forms/__tests__/Select.test.js +37 -0
- package/dist/components/forms/__tests__/SelectInput.behavior.test.js +132 -0
- package/dist/components/forms/__tests__/TextInput.behavior.test.js +131 -0
- package/dist/components/forms/__tests__/Textarea.test.js +39 -0
- package/dist/components/forms/__tests__/TextareaInput.behavior.test.js +96 -0
- package/dist/components/forms/__tests__/Toggle.test.js +87 -0
- package/dist/components/forms/__tests__/composite-inputs-a11y.test.js +69 -0
- package/dist/components/forms/__tests__/form-group-input.fixture.svelte +16 -0
- package/dist/components/forms/__tests__/form-group-input.fixture.svelte.d.ts +9 -0
- package/dist/components/forms/__tests__/form-group-input.fixture.svelte.d.ts.map +1 -0
- package/dist/components/forms/__tests__/form-with-fields.fixture.svelte +33 -0
- package/dist/components/forms/__tests__/form-with-fields.fixture.svelte.d.ts +12 -0
- package/dist/components/forms/__tests__/form-with-fields.fixture.svelte.d.ts.map +1 -0
- package/dist/components/forms/__tests__/rich-inputs-a11y.test.js +87 -0
- package/dist/components/forms/index.d.ts +25 -0
- package/dist/components/forms/index.d.ts.map +1 -0
- package/dist/components/forms/index.js +25 -0
- package/dist/components/forms/types.d.ts +33 -0
- package/dist/components/forms/types.d.ts.map +1 -0
- package/dist/components/forms/types.js +4 -0
- package/dist/components/module/ModulePanel.svelte +134 -0
- package/dist/components/module/ModulePanel.svelte.d.ts +22 -0
- package/dist/components/module/ModulePanel.svelte.d.ts.map +1 -0
- package/dist/components/module/index.d.ts +5 -0
- package/dist/components/module/index.d.ts.map +1 -0
- package/dist/components/module/index.js +4 -0
- package/dist/components/workspace/Breadcrumbs.svelte +141 -0
- package/dist/components/workspace/Breadcrumbs.svelte.d.ts +21 -0
- package/dist/components/workspace/Breadcrumbs.svelte.d.ts.map +1 -0
- package/dist/components/workspace/NavTree.svelte +354 -0
- package/dist/components/workspace/NavTree.svelte.d.ts +45 -0
- package/dist/components/workspace/NavTree.svelte.d.ts.map +1 -0
- package/dist/components/workspace/README.md +34 -0
- package/dist/components/workspace/RoleShell.svelte +309 -0
- package/dist/components/workspace/RoleShell.svelte.d.ts +91 -0
- package/dist/components/workspace/RoleShell.svelte.d.ts.map +1 -0
- package/dist/components/workspace/WorkspaceShell.svelte +951 -0
- package/dist/components/workspace/WorkspaceShell.svelte.d.ts +112 -0
- package/dist/components/workspace/WorkspaceShell.svelte.d.ts.map +1 -0
- package/dist/components/workspace/__tests__/RoleShell.test.js +772 -0
- package/dist/components/workspace/__tests__/WorkspaceShell.test.js +630 -0
- package/dist/components/workspace/__tests__/breadcrumbs-helpers.test.js +141 -0
- package/dist/components/workspace/__tests__/context-forwarding-harness.svelte +45 -0
- package/dist/components/workspace/__tests__/context-forwarding-harness.svelte.d.ts +21 -0
- package/dist/components/workspace/__tests__/context-forwarding-harness.svelte.d.ts.map +1 -0
- package/dist/components/workspace/__tests__/define-tools-dock.test.js +1010 -0
- package/dist/components/workspace/__tests__/harness.svelte +25 -0
- package/dist/components/workspace/__tests__/harness.svelte.d.ts +14 -0
- package/dist/components/workspace/__tests__/harness.svelte.d.ts.map +1 -0
- package/dist/components/workspace/__tests__/index.test.js +37 -0
- package/dist/components/workspace/__tests__/manifest-nav-helpers.test.js +24 -0
- package/dist/components/workspace/__tests__/manifest-nav.test.js +599 -0
- package/dist/components/workspace/__tests__/nav-helpers.test.js +95 -0
- package/dist/components/workspace/__tests__/render-harness.svelte +66 -0
- package/dist/components/workspace/__tests__/render-harness.svelte.d.ts +32 -0
- package/dist/components/workspace/__tests__/render-harness.svelte.d.ts.map +1 -0
- package/dist/components/workspace/__tests__/render-tools-dock.test.js +243 -0
- package/dist/components/workspace/__tests__/role-shell-bind-harness.svelte +58 -0
- package/dist/components/workspace/__tests__/role-shell-bind-harness.svelte.d.ts +16 -0
- package/dist/components/workspace/__tests__/role-shell-bind-harness.svelte.d.ts.map +1 -0
- package/dist/components/workspace/__tests__/role-shell-switch-harness.svelte +41 -0
- package/dist/components/workspace/__tests__/role-shell-switch-harness.svelte.d.ts +13 -0
- package/dist/components/workspace/__tests__/role-shell-switch-harness.svelte.d.ts.map +1 -0
- package/dist/components/workspace/__tests__/test-icon.svelte +17 -0
- package/dist/components/workspace/__tests__/test-icon.svelte.d.ts +19 -0
- package/dist/components/workspace/__tests__/test-icon.svelte.d.ts.map +1 -0
- package/dist/components/workspace/__tests__/typed-tool-fixture/TypedTool.svelte +38 -0
- package/dist/components/workspace/__tests__/typed-tool-fixture/TypedTool.svelte.d.ts +22 -0
- package/dist/components/workspace/__tests__/typed-tool-fixture/TypedTool.svelte.d.ts.map +1 -0
- package/dist/components/workspace/__tests__/typed-tool-fixture/register-typed-tool.d.ts +65 -0
- package/dist/components/workspace/__tests__/typed-tool-fixture/register-typed-tool.d.ts.map +1 -0
- package/dist/components/workspace/__tests__/typed-tool-fixture/register-typed-tool.js +115 -0
- package/dist/components/workspace/__tests__/typed-tool-fixture/typed-tool-types.d.ts +15 -0
- package/dist/components/workspace/__tests__/typed-tool-fixture/typed-tool-types.d.ts.map +1 -0
- package/dist/components/workspace/__tests__/typed-tool-fixture/typed-tool-types.js +7 -0
- package/dist/components/workspace/__tests__/typed-tool-fixture.test.js +115 -0
- package/dist/components/workspace/__tests__/use-harness-orphan.svelte +9 -0
- package/dist/components/workspace/__tests__/use-harness-orphan.svelte.d.ts +19 -0
- package/dist/components/workspace/__tests__/use-harness-orphan.svelte.d.ts.map +1 -0
- package/dist/components/workspace/__tests__/use-harness.svelte +23 -0
- package/dist/components/workspace/__tests__/use-harness.svelte.d.ts +8 -0
- package/dist/components/workspace/__tests__/use-harness.svelte.d.ts.map +1 -0
- package/dist/components/workspace/__tests__/use-tools-dock.test.js +33 -0
- package/dist/components/workspace/__tests__/workspace-shell-bind-harness.svelte +43 -0
- package/dist/components/workspace/__tests__/workspace-shell-bind-harness.svelte.d.ts +11 -0
- package/dist/components/workspace/__tests__/workspace-shell-bind-harness.svelte.d.ts.map +1 -0
- package/dist/components/workspace/breadcrumbs-helpers.d.ts +44 -0
- package/dist/components/workspace/breadcrumbs-helpers.d.ts.map +1 -0
- package/dist/components/workspace/breadcrumbs-helpers.js +88 -0
- package/dist/components/workspace/index.d.ts +16 -0
- package/dist/components/workspace/index.d.ts.map +1 -0
- package/dist/components/workspace/index.js +14 -0
- package/dist/components/workspace/manifest-nav.d.ts +200 -0
- package/dist/components/workspace/manifest-nav.d.ts.map +1 -0
- package/dist/components/workspace/manifest-nav.js +408 -0
- package/dist/components/workspace/nav-helpers.d.ts +36 -0
- package/dist/components/workspace/nav-helpers.d.ts.map +1 -0
- package/dist/components/workspace/nav-helpers.js +60 -0
- package/dist/components/workspace/server/__tests__/compose-availability.test.js +383 -0
- package/dist/components/workspace/server/__tests__/typed-context-fixture.d.ts +78 -0
- package/dist/components/workspace/server/__tests__/typed-context-fixture.d.ts.map +1 -0
- package/dist/components/workspace/server/__tests__/typed-context-fixture.js +104 -0
- package/dist/components/workspace/server/compose-availability.d.ts +73 -0
- package/dist/components/workspace/server/compose-availability.d.ts.map +1 -0
- package/dist/components/workspace/server/compose-availability.js +114 -0
- package/dist/components/workspace/server/index.d.ts +13 -0
- package/dist/components/workspace/server/index.d.ts.map +1 -0
- package/dist/components/workspace/server/index.js +11 -0
- package/dist/components/workspace/server/types.d.ts +108 -0
- package/dist/components/workspace/server/types.d.ts.map +1 -0
- package/dist/components/workspace/server/types.js +11 -0
- package/dist/components/workspace/tools-dock/ToolsDock.svelte +565 -0
- package/dist/components/workspace/tools-dock/ToolsDock.svelte.d.ts +14 -0
- package/dist/components/workspace/tools-dock/ToolsDock.svelte.d.ts.map +1 -0
- package/dist/components/workspace/tools-dock/define-tools-dock.svelte.d.ts +143 -0
- package/dist/components/workspace/tools-dock/define-tools-dock.svelte.d.ts.map +1 -0
- package/dist/components/workspace/tools-dock/define-tools-dock.svelte.js +487 -0
- package/dist/components/workspace/tools-dock/use-tools-dock.d.ts +41 -0
- package/dist/components/workspace/tools-dock/use-tools-dock.d.ts.map +1 -0
- package/dist/components/workspace/tools-dock/use-tools-dock.js +50 -0
- package/dist/components/workspace/types.d.ts +372 -0
- package/dist/components/workspace/types.d.ts.map +1 -0
- package/dist/components/workspace/types.js +6 -0
- package/dist/hooks/index.d.ts +11 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/useAppState.svelte.d.ts +46 -0
- package/dist/hooks/useAppState.svelte.d.ts.map +1 -0
- package/dist/hooks/useAppState.svelte.js +59 -0
- package/dist/hooks/useAuth.svelte.d.ts +41 -0
- package/dist/hooks/useAuth.svelte.d.ts.map +1 -0
- package/dist/hooks/useAuth.svelte.js +43 -0
- package/dist/hooks/useLLM.svelte.d.ts +69 -0
- package/dist/hooks/useLLM.svelte.d.ts.map +1 -0
- package/dist/hooks/useLLM.svelte.js +85 -0
- package/dist/hooks/useSTT.svelte.d.ts +68 -0
- package/dist/hooks/useSTT.svelte.d.ts.map +1 -0
- package/dist/hooks/useSTT.svelte.js +97 -0
- package/dist/hooks/useSocket.svelte.d.ts +45 -0
- package/dist/hooks/useSocket.svelte.d.ts.map +1 -0
- package/dist/hooks/useSocket.svelte.js +54 -0
- package/dist/hooks/useTTS.svelte.d.ts +65 -0
- package/dist/hooks/useTTS.svelte.d.ts.map +1 -0
- package/dist/hooks/useTTS.svelte.js +93 -0
- package/dist/hooks/useTheme.d.ts +13 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/hooks/useTheme.js +16 -0
- package/dist/i18n/__tests__/server.spec.js +50 -0
- package/dist/i18n/server.d.ts +47 -0
- package/dist/i18n/server.d.ts.map +1 -0
- package/dist/i18n/server.js +58 -0
- package/dist/i18n/strings.forms.d.ts +33 -0
- package/dist/i18n/strings.forms.d.ts.map +1 -0
- package/dist/i18n/strings.forms.js +54 -0
- package/dist/i18n/strings.workspace.d.ts +34 -0
- package/dist/i18n/strings.workspace.d.ts.map +1 -0
- package/dist/i18n/strings.workspace.js +40 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/state/__tests__/warm-clients.test.js +40 -0
- package/dist/state/app-state.d.ts +308 -0
- package/dist/state/app-state.d.ts.map +1 -0
- package/dist/state/app-state.js +64 -0
- package/dist/state/app-state.svelte.d.ts +196 -0
- package/dist/state/app-state.svelte.d.ts.map +1 -0
- package/dist/state/app-state.svelte.js +774 -0
- package/dist/state/context.d.ts +23 -0
- package/dist/state/context.d.ts.map +1 -0
- package/dist/state/context.js +32 -0
- package/dist/state/form-context.d.ts +59 -0
- package/dist/state/form-context.d.ts.map +1 -0
- package/dist/state/form-context.js +31 -0
- package/dist/state/form-group-context.d.ts +13 -0
- package/dist/state/form-group-context.d.ts.map +1 -0
- package/dist/state/form-group-context.js +28 -0
- package/dist/state/index.d.ts +9 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +8 -0
- package/dist/state/warm-clients.d.ts +136 -0
- package/dist/state/warm-clients.d.ts.map +1 -0
- package/dist/state/warm-clients.js +231 -0
- package/package.json +137 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte context helpers for app state
|
|
3
|
+
*/
|
|
4
|
+
import type { SmrtAppStateManager } from './app-state.svelte.js';
|
|
5
|
+
/**
|
|
6
|
+
* Context key for app state
|
|
7
|
+
*/
|
|
8
|
+
export declare const APP_STATE_KEY: unique symbol;
|
|
9
|
+
/**
|
|
10
|
+
* Set app state in context (used by SmrtProvider)
|
|
11
|
+
*/
|
|
12
|
+
export declare function setAppStateContext(state: SmrtAppStateManager): void;
|
|
13
|
+
/**
|
|
14
|
+
* Get app state from context
|
|
15
|
+
* @throws If called outside of SmrtProvider
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAppStateContext(): SmrtAppStateManager;
|
|
18
|
+
/**
|
|
19
|
+
* Try to get app state from context
|
|
20
|
+
* Returns null if not available (doesn't throw)
|
|
21
|
+
*/
|
|
22
|
+
export declare function tryGetAppStateContext(): SmrtAppStateManager | null;
|
|
23
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/state/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,aAAa,eAA2B,CAAC;AAEtD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAEnE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,mBAAmB,CAUxD;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,mBAAmB,GAAG,IAAI,CAElE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte context helpers for app state
|
|
3
|
+
*/
|
|
4
|
+
import { getContext, setContext } from 'svelte';
|
|
5
|
+
/**
|
|
6
|
+
* Context key for app state
|
|
7
|
+
*/
|
|
8
|
+
export const APP_STATE_KEY = Symbol('smrt-app-state');
|
|
9
|
+
/**
|
|
10
|
+
* Set app state in context (used by SmrtProvider)
|
|
11
|
+
*/
|
|
12
|
+
export function setAppStateContext(state) {
|
|
13
|
+
setContext(APP_STATE_KEY, state);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get app state from context
|
|
17
|
+
* @throws If called outside of SmrtProvider
|
|
18
|
+
*/
|
|
19
|
+
export function getAppStateContext() {
|
|
20
|
+
const state = getContext(APP_STATE_KEY);
|
|
21
|
+
if (!state) {
|
|
22
|
+
throw new Error('App state not found. Make sure to wrap your app with <SmrtProvider>');
|
|
23
|
+
}
|
|
24
|
+
return state;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Try to get app state from context
|
|
28
|
+
* Returns null if not available (doesn't throw)
|
|
29
|
+
*/
|
|
30
|
+
export function tryGetAppStateContext() {
|
|
31
|
+
return getContext(APP_STATE_KEY) ?? null;
|
|
32
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMRT Form context for field registration and coordination
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Field definition for form registration
|
|
6
|
+
*/
|
|
7
|
+
/** All supported form field types */
|
|
8
|
+
export type FormFieldType = 'text' | 'email' | 'datetime' | 'number' | 'address' | 'checkbox' | 'daterange' | 'measurement' | 'money' | 'phone' | 'select' | 'textarea';
|
|
9
|
+
export interface FieldDefinition {
|
|
10
|
+
/** Field name (used as key for LLM extraction) */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Field type */
|
|
13
|
+
type: FormFieldType;
|
|
14
|
+
/** Human-readable label */
|
|
15
|
+
label?: string;
|
|
16
|
+
/** Description to help LLM understand field purpose */
|
|
17
|
+
description?: string;
|
|
18
|
+
/** Set the field value */
|
|
19
|
+
setValue: (value: unknown) => void;
|
|
20
|
+
/** Get current field value */
|
|
21
|
+
getValue: () => unknown;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* SMRT Form context interface
|
|
25
|
+
*/
|
|
26
|
+
export interface SMRTFormContext {
|
|
27
|
+
/** Current mode */
|
|
28
|
+
readonly mode: 'smrt' | 'default';
|
|
29
|
+
/** Register a field with the form */
|
|
30
|
+
registerField: (field: FieldDefinition) => void;
|
|
31
|
+
/** Unregister a field */
|
|
32
|
+
unregisterField: (name: string) => void;
|
|
33
|
+
/** Get all registered fields schema (for LLM prompt) */
|
|
34
|
+
getFieldSchema: () => FieldDefinition[];
|
|
35
|
+
/** Whether form-level listening is active */
|
|
36
|
+
readonly isFormListening: boolean;
|
|
37
|
+
/** Whether currently extracting from speech */
|
|
38
|
+
readonly isExtracting: boolean;
|
|
39
|
+
/** Toggle form-level listening on/off */
|
|
40
|
+
toggleListening: () => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Context key for SMRT form
|
|
44
|
+
*/
|
|
45
|
+
export declare const SMRT_FORM_KEY: unique symbol;
|
|
46
|
+
/**
|
|
47
|
+
* Set form context (used by SMRTForm)
|
|
48
|
+
*/
|
|
49
|
+
export declare function setFormContext(ctx: SMRTFormContext): void;
|
|
50
|
+
/**
|
|
51
|
+
* Get form context
|
|
52
|
+
* @throws If called outside of SMRTForm
|
|
53
|
+
*/
|
|
54
|
+
export declare function getFormContext(): SMRTFormContext;
|
|
55
|
+
/**
|
|
56
|
+
* Try to get form context (returns null if not available)
|
|
57
|
+
*/
|
|
58
|
+
export declare function tryGetFormContext(): SMRTFormContext | null;
|
|
59
|
+
//# sourceMappingURL=form-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-context.d.ts","sourceRoot":"","sources":["../../src/state/form-context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,qCAAqC;AACrC,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,OAAO,GACP,UAAU,GACV,QAAQ,GACR,SAAS,GACT,UAAU,GACV,WAAW,GACX,aAAa,GACb,OAAO,GACP,OAAO,GACP,QAAQ,GACR,UAAU,CAAC;AAEf,MAAM,WAAW,eAAe;IAC9B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,IAAI,EAAE,aAAa,CAAC;IACpB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,mBAAmB;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,qCAAqC;IACrC,aAAa,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAChD,yBAAyB;IACzB,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,wDAAwD;IACxD,cAAc,EAAE,MAAM,eAAe,EAAE,CAAC;IACxC,6CAA6C;IAC7C,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,+CAA+C;IAC/C,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,yCAAyC;IACzC,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,eAAsB,CAAC;AAEjD;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI,CAEzD;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,eAAe,CAUhD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,eAAe,GAAG,IAAI,CAE1D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMRT Form context for field registration and coordination
|
|
3
|
+
*/
|
|
4
|
+
import { getContext, setContext } from 'svelte';
|
|
5
|
+
/**
|
|
6
|
+
* Context key for SMRT form
|
|
7
|
+
*/
|
|
8
|
+
export const SMRT_FORM_KEY = Symbol('smrt-form');
|
|
9
|
+
/**
|
|
10
|
+
* Set form context (used by SMRTForm)
|
|
11
|
+
*/
|
|
12
|
+
export function setFormContext(ctx) {
|
|
13
|
+
setContext(SMRT_FORM_KEY, ctx);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get form context
|
|
17
|
+
* @throws If called outside of SMRTForm
|
|
18
|
+
*/
|
|
19
|
+
export function getFormContext() {
|
|
20
|
+
const ctx = getContext(SMRT_FORM_KEY);
|
|
21
|
+
if (!ctx) {
|
|
22
|
+
throw new Error('Form context not found. Make sure to wrap your inputs with <SMRTForm>');
|
|
23
|
+
}
|
|
24
|
+
return ctx;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Try to get form context (returns null if not available)
|
|
28
|
+
*/
|
|
29
|
+
export function tryGetFormContext() {
|
|
30
|
+
return getContext(SMRT_FORM_KEY) ?? null;
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface FormGroupContextValue {
|
|
2
|
+
/** Stable id for the field control; matches the FormGroup label's `for`. */
|
|
3
|
+
inputId: string;
|
|
4
|
+
/** Space-joined ids of the visible hint/error text, or undefined if none. */
|
|
5
|
+
describedBy: string | undefined;
|
|
6
|
+
/** Whether the field is currently showing an error. */
|
|
7
|
+
invalid: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function setFormGroupContext(get: () => FormGroupContextValue): void;
|
|
10
|
+
export declare function tryGetFormGroupContext(): (() => FormGroupContextValue) | undefined;
|
|
11
|
+
/** Deterministic, collision-resistant id for a FormGroup that wasn't given one. */
|
|
12
|
+
export declare function nextFieldId(): string;
|
|
13
|
+
//# sourceMappingURL=form-group-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-group-context.d.ts","sourceRoot":"","sources":["../../src/state/form-group-context.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,qBAAqB;IACpC,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,uDAAuD;IACvD,OAAO,EAAE,OAAO,CAAC;CAClB;AAID,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,qBAAqB,GAAG,IAAI,CAE1E;AAED,wBAAgB,sBAAsB,IAClC,CAAC,MAAM,qBAAqB,CAAC,GAC7B,SAAS,CAEZ;AAID,mFAAmF;AACnF,wBAAgB,WAAW,IAAI,MAAM,CAGpC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FormGroup accessibility context (Sweep L1, #1420).
|
|
3
|
+
*
|
|
4
|
+
* `FormGroup` publishes the wiring a wrapped input needs to be programmatically
|
|
5
|
+
* accessible — the input's `id` (so the `<label for>` resolves), the
|
|
6
|
+
* space-joined ids of the hint/error text (for `aria-describedby`), and whether
|
|
7
|
+
* the field is currently in an error state (`aria-invalid`). The base form
|
|
8
|
+
* primitives (`Input`, `Select`, `Textarea`) read this and auto-apply those
|
|
9
|
+
* attributes when the consumer hasn't set them explicitly, so an input dropped
|
|
10
|
+
* inside a `<FormGroup>` is accessible with no extra wiring.
|
|
11
|
+
*
|
|
12
|
+
* The value is a getter so the consuming input always reads the *current*
|
|
13
|
+
* reactive state (id is stable; describedBy/invalid change as hint/error do).
|
|
14
|
+
*/
|
|
15
|
+
import { getContext, setContext } from 'svelte';
|
|
16
|
+
const FORM_GROUP_KEY = Symbol('smrt-form-group');
|
|
17
|
+
export function setFormGroupContext(get) {
|
|
18
|
+
setContext(FORM_GROUP_KEY, get);
|
|
19
|
+
}
|
|
20
|
+
export function tryGetFormGroupContext() {
|
|
21
|
+
return getContext(FORM_GROUP_KEY);
|
|
22
|
+
}
|
|
23
|
+
let autoIdCounter = 0;
|
|
24
|
+
/** Deterministic, collision-resistant id for a FormGroup that wasn't given one. */
|
|
25
|
+
export function nextFieldId() {
|
|
26
|
+
autoIdCounter += 1;
|
|
27
|
+
return `smrt-field-${autoIdCounter}`;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module-level warm client cache for AI adapters
|
|
3
|
+
*
|
|
4
|
+
* This cache persists across Svelte component lifecycle, surviving
|
|
5
|
+
* navigation between pages (SPA) and remounts of SmrtProvider.
|
|
6
|
+
*
|
|
7
|
+
* ## Key Benefits
|
|
8
|
+
* - Avoids re-downloading WASM/models on every navigation
|
|
9
|
+
* - Keeps WebGPU contexts warm (avoiding cold start delays)
|
|
10
|
+
* - Enables pre-initialization during idle time
|
|
11
|
+
*
|
|
12
|
+
* ## How It Works
|
|
13
|
+
* The cache is a simple Map at module scope. When SmrtProvider mounts,
|
|
14
|
+
* it checks the cache before creating new adapters. Adapters stay cached
|
|
15
|
+
* until explicitly cleared or the page is refreshed.
|
|
16
|
+
*
|
|
17
|
+
* ## Usage
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { getCachedSTT, getCacheStats, clearAllCaches } from '@happyvertical/smrt-svelte';
|
|
20
|
+
*
|
|
21
|
+
* // Check if whisper-cpp is already loaded
|
|
22
|
+
* const cached = getCachedSTT('whisper-cpp');
|
|
23
|
+
* if (cached?.initState === 'ready') {
|
|
24
|
+
* console.log('STT already initialized!');
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* // Debug cache status
|
|
28
|
+
* const stats = getCacheStats();
|
|
29
|
+
* console.log('Cached adapters:', stats);
|
|
30
|
+
*
|
|
31
|
+
* // Clear cache to free memory
|
|
32
|
+
* await clearAllCaches();
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @module warm-clients
|
|
36
|
+
*/
|
|
37
|
+
import type { DownloadProgressInfo, InitState, LLMAdapter, STTAdapter, TTSAdapter } from '../browser-ai/index.js';
|
|
38
|
+
/**
|
|
39
|
+
* Adapter cache entry with metadata
|
|
40
|
+
*/
|
|
41
|
+
export interface CachedAdapter<T> {
|
|
42
|
+
/** The adapter instance */
|
|
43
|
+
adapter: T;
|
|
44
|
+
/** When the adapter was cached */
|
|
45
|
+
cachedAt: number;
|
|
46
|
+
/** Initialization state */
|
|
47
|
+
initState: InitState;
|
|
48
|
+
/** Current download progress (if initializing) */
|
|
49
|
+
downloadProgress: DownloadProgressInfo | null;
|
|
50
|
+
/** Error if initialization failed */
|
|
51
|
+
error: Error | null;
|
|
52
|
+
/** Adapter type identifier (for cache key matching) */
|
|
53
|
+
type: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* STT adapter types that can be cached
|
|
57
|
+
*/
|
|
58
|
+
export type STTType = 'browser-speech' | 'whisper-cpp' | 'whisper-wasm';
|
|
59
|
+
/**
|
|
60
|
+
* TTS adapter types that can be cached
|
|
61
|
+
*/
|
|
62
|
+
export type TTSType = 'browser-synthesis';
|
|
63
|
+
/**
|
|
64
|
+
* LLM adapter types that can be cached
|
|
65
|
+
*/
|
|
66
|
+
export type LLMType = 'webllm' | 'transformers-llm';
|
|
67
|
+
/**
|
|
68
|
+
* Get a cached STT adapter
|
|
69
|
+
*/
|
|
70
|
+
export declare function getCachedSTT(type: STTType): CachedAdapter<STTAdapter> | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Cache an STT adapter
|
|
73
|
+
*/
|
|
74
|
+
export declare function setCachedSTT(type: STTType, adapter: STTAdapter, initState?: InitState, error?: Error | null): void;
|
|
75
|
+
/**
|
|
76
|
+
* Update STT cache entry state (for progress tracking)
|
|
77
|
+
*/
|
|
78
|
+
export declare function updateSTTCacheState(type: STTType, updates: Partial<Pick<CachedAdapter<STTAdapter>, 'initState' | 'downloadProgress' | 'error'>>): void;
|
|
79
|
+
/**
|
|
80
|
+
* Remove an STT adapter from cache
|
|
81
|
+
*/
|
|
82
|
+
export declare function removeCachedSTT(type: STTType): void;
|
|
83
|
+
/**
|
|
84
|
+
* Get a cached TTS adapter
|
|
85
|
+
*/
|
|
86
|
+
export declare function getCachedTTS(type: TTSType): CachedAdapter<TTSAdapter> | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Cache a TTS adapter
|
|
89
|
+
*/
|
|
90
|
+
export declare function setCachedTTS(type: TTSType, adapter: TTSAdapter, initState?: InitState, error?: Error | null): void;
|
|
91
|
+
/**
|
|
92
|
+
* Update TTS cache entry state
|
|
93
|
+
*/
|
|
94
|
+
export declare function updateTTSCacheState(type: TTSType, updates: Partial<Pick<CachedAdapter<TTSAdapter>, 'initState' | 'downloadProgress' | 'error'>>): void;
|
|
95
|
+
/**
|
|
96
|
+
* Remove a TTS adapter from cache
|
|
97
|
+
*/
|
|
98
|
+
export declare function removeCachedTTS(type: TTSType): void;
|
|
99
|
+
/**
|
|
100
|
+
* Get a cached LLM adapter
|
|
101
|
+
*/
|
|
102
|
+
export declare function getCachedLLM(type: LLMType, modelId?: string): CachedAdapter<LLMAdapter> | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Cache an LLM adapter
|
|
105
|
+
*/
|
|
106
|
+
export declare function setCachedLLM(type: LLMType, adapter: LLMAdapter, modelId?: string, initState?: InitState, error?: Error | null): void;
|
|
107
|
+
/**
|
|
108
|
+
* Update LLM cache entry state
|
|
109
|
+
*/
|
|
110
|
+
export declare function updateLLMCacheState(type: LLMType, modelId: string | undefined, updates: Partial<Pick<CachedAdapter<LLMAdapter>, 'initState' | 'downloadProgress' | 'error'>>): void;
|
|
111
|
+
/**
|
|
112
|
+
* Remove an LLM adapter from cache
|
|
113
|
+
*/
|
|
114
|
+
export declare function removeCachedLLM(type: LLMType, modelId?: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* Clear all cached adapters
|
|
117
|
+
*/
|
|
118
|
+
export declare function clearAllCaches(): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Get cache statistics for debugging
|
|
121
|
+
*/
|
|
122
|
+
export declare function getCacheStats(): {
|
|
123
|
+
stt: {
|
|
124
|
+
count: number;
|
|
125
|
+
types: STTType[];
|
|
126
|
+
};
|
|
127
|
+
tts: {
|
|
128
|
+
count: number;
|
|
129
|
+
types: TTSType[];
|
|
130
|
+
};
|
|
131
|
+
llm: {
|
|
132
|
+
count: number;
|
|
133
|
+
keys: string[];
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=warm-clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warm-clients.d.ts","sourceRoot":"","sources":["../../src/state/warm-clients.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module-level warm client cache for AI adapters
|
|
3
|
+
*
|
|
4
|
+
* This cache persists across Svelte component lifecycle, surviving
|
|
5
|
+
* navigation between pages (SPA) and remounts of SmrtProvider.
|
|
6
|
+
*
|
|
7
|
+
* ## Key Benefits
|
|
8
|
+
* - Avoids re-downloading WASM/models on every navigation
|
|
9
|
+
* - Keeps WebGPU contexts warm (avoiding cold start delays)
|
|
10
|
+
* - Enables pre-initialization during idle time
|
|
11
|
+
*
|
|
12
|
+
* ## How It Works
|
|
13
|
+
* The cache is a simple Map at module scope. When SmrtProvider mounts,
|
|
14
|
+
* it checks the cache before creating new adapters. Adapters stay cached
|
|
15
|
+
* until explicitly cleared or the page is refreshed.
|
|
16
|
+
*
|
|
17
|
+
* ## Usage
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { getCachedSTT, getCacheStats, clearAllCaches } from '@happyvertical/smrt-svelte';
|
|
20
|
+
*
|
|
21
|
+
* // Check if whisper-cpp is already loaded
|
|
22
|
+
* const cached = getCachedSTT('whisper-cpp');
|
|
23
|
+
* if (cached?.initState === 'ready') {
|
|
24
|
+
* console.log('STT already initialized!');
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* // Debug cache status
|
|
28
|
+
* const stats = getCacheStats();
|
|
29
|
+
* console.log('Cached adapters:', stats);
|
|
30
|
+
*
|
|
31
|
+
* // Clear cache to free memory
|
|
32
|
+
* await clearAllCaches();
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @module warm-clients
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Module-level cache - survives component remounts
|
|
39
|
+
*/
|
|
40
|
+
const sttCache = new Map();
|
|
41
|
+
const ttsCache = new Map();
|
|
42
|
+
const llmCache = new Map(); // key = type:modelId
|
|
43
|
+
/**
|
|
44
|
+
* Get a cached STT adapter
|
|
45
|
+
*/
|
|
46
|
+
export function getCachedSTT(type) {
|
|
47
|
+
return sttCache.get(type);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Cache an STT adapter
|
|
51
|
+
*/
|
|
52
|
+
export function setCachedSTT(type, adapter, initState = 'ready', error = null) {
|
|
53
|
+
sttCache.set(type, {
|
|
54
|
+
adapter,
|
|
55
|
+
cachedAt: Date.now(),
|
|
56
|
+
initState,
|
|
57
|
+
downloadProgress: null,
|
|
58
|
+
error,
|
|
59
|
+
type,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Update STT cache entry state (for progress tracking)
|
|
64
|
+
*/
|
|
65
|
+
export function updateSTTCacheState(type, updates) {
|
|
66
|
+
const entry = sttCache.get(type);
|
|
67
|
+
if (entry) {
|
|
68
|
+
Object.assign(entry, updates);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Remove an STT adapter from cache
|
|
73
|
+
*/
|
|
74
|
+
export function removeCachedSTT(type) {
|
|
75
|
+
const entry = sttCache.get(type);
|
|
76
|
+
if (entry) {
|
|
77
|
+
const disposeResult = entry.adapter.dispose?.();
|
|
78
|
+
disposeResult?.catch?.((error) => {
|
|
79
|
+
console.error('Error disposing STT adapter:', type, error);
|
|
80
|
+
});
|
|
81
|
+
sttCache.delete(type);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get a cached TTS adapter
|
|
86
|
+
*/
|
|
87
|
+
export function getCachedTTS(type) {
|
|
88
|
+
return ttsCache.get(type);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Cache a TTS adapter
|
|
92
|
+
*/
|
|
93
|
+
export function setCachedTTS(type, adapter, initState = 'ready', error = null) {
|
|
94
|
+
ttsCache.set(type, {
|
|
95
|
+
adapter,
|
|
96
|
+
cachedAt: Date.now(),
|
|
97
|
+
initState,
|
|
98
|
+
downloadProgress: null,
|
|
99
|
+
error,
|
|
100
|
+
type,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Update TTS cache entry state
|
|
105
|
+
*/
|
|
106
|
+
export function updateTTSCacheState(type, updates) {
|
|
107
|
+
const entry = ttsCache.get(type);
|
|
108
|
+
if (entry) {
|
|
109
|
+
Object.assign(entry, updates);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Remove a TTS adapter from cache
|
|
114
|
+
*/
|
|
115
|
+
export function removeCachedTTS(type) {
|
|
116
|
+
const entry = ttsCache.get(type);
|
|
117
|
+
if (entry) {
|
|
118
|
+
const disposeResult = entry.adapter.dispose?.();
|
|
119
|
+
disposeResult?.catch?.((error) => {
|
|
120
|
+
console.error('Error disposing TTS adapter:', type, error);
|
|
121
|
+
});
|
|
122
|
+
ttsCache.delete(type);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get a cached LLM adapter
|
|
127
|
+
*/
|
|
128
|
+
export function getCachedLLM(type, modelId) {
|
|
129
|
+
const key = modelId ? `${type}:${modelId}` : type;
|
|
130
|
+
return llmCache.get(key);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Cache an LLM adapter
|
|
134
|
+
*/
|
|
135
|
+
export function setCachedLLM(type, adapter, modelId, initState = 'ready', error = null) {
|
|
136
|
+
const key = modelId ? `${type}:${modelId}` : type;
|
|
137
|
+
llmCache.set(key, {
|
|
138
|
+
adapter,
|
|
139
|
+
cachedAt: Date.now(),
|
|
140
|
+
initState,
|
|
141
|
+
downloadProgress: null,
|
|
142
|
+
error,
|
|
143
|
+
type,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Update LLM cache entry state
|
|
148
|
+
*/
|
|
149
|
+
export function updateLLMCacheState(type, modelId, updates) {
|
|
150
|
+
const key = modelId ? `${type}:${modelId}` : type;
|
|
151
|
+
const entry = llmCache.get(key);
|
|
152
|
+
if (entry) {
|
|
153
|
+
Object.assign(entry, updates);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Remove an LLM adapter from cache
|
|
158
|
+
*/
|
|
159
|
+
export function removeCachedLLM(type, modelId) {
|
|
160
|
+
const key = modelId ? `${type}:${modelId}` : type;
|
|
161
|
+
const entry = llmCache.get(key);
|
|
162
|
+
if (entry) {
|
|
163
|
+
const disposeResult = entry.adapter.dispose?.();
|
|
164
|
+
disposeResult?.catch?.((error) => {
|
|
165
|
+
console.error('Error disposing LLM adapter:', key, error);
|
|
166
|
+
});
|
|
167
|
+
llmCache.delete(key);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Clear all cached adapters
|
|
172
|
+
*/
|
|
173
|
+
export async function clearAllCaches() {
|
|
174
|
+
const errors = [];
|
|
175
|
+
// Dispose all STT adapters
|
|
176
|
+
for (const [type, entry] of sttCache.entries()) {
|
|
177
|
+
try {
|
|
178
|
+
await entry.adapter.dispose?.();
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
console.error('Error disposing STT adapter:', type, error);
|
|
182
|
+
errors.push(error);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
sttCache.clear();
|
|
186
|
+
// Dispose all TTS adapters
|
|
187
|
+
for (const [type, entry] of ttsCache.entries()) {
|
|
188
|
+
try {
|
|
189
|
+
await entry.adapter.dispose?.();
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
console.error('Error disposing TTS adapter:', type, error);
|
|
193
|
+
errors.push(error);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
ttsCache.clear();
|
|
197
|
+
// Dispose all LLM adapters
|
|
198
|
+
for (const [key, entry] of llmCache.entries()) {
|
|
199
|
+
try {
|
|
200
|
+
await entry.adapter.dispose?.();
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
console.error('Error disposing LLM adapter:', key, error);
|
|
204
|
+
errors.push(error);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
llmCache.clear();
|
|
208
|
+
// Throw the first error after all caches are cleared
|
|
209
|
+
if (errors.length > 0) {
|
|
210
|
+
throw errors[0];
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get cache statistics for debugging
|
|
215
|
+
*/
|
|
216
|
+
export function getCacheStats() {
|
|
217
|
+
return {
|
|
218
|
+
stt: {
|
|
219
|
+
count: sttCache.size,
|
|
220
|
+
types: Array.from(sttCache.keys()),
|
|
221
|
+
},
|
|
222
|
+
tts: {
|
|
223
|
+
count: ttsCache.size,
|
|
224
|
+
types: Array.from(ttsCache.keys()),
|
|
225
|
+
},
|
|
226
|
+
llm: {
|
|
227
|
+
count: llmCache.size,
|
|
228
|
+
keys: Array.from(llmCache.keys()),
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
}
|