You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement working Phi Silica integration with DllGetActivationFactory
Key breakthrough: Use DllGetActivationFactory directly from bundled Windows
App SDK DLLs instead of RoGetActivationFactory which blocks third-party apps.
Changes:
- Add direct DLL activation via create_language_model_direct()
- Bundle Windows App SDK 2.0-experimental3 DLLs (x64 and ARM64)
- Add PackageDependency on Microsoft.WindowsAppRuntime.2.0-experimental3
- Generate WinRT bindings using windows-bindgen 0.65
- Update build-cross.py to copy AI SDK DLLs to MSIX packages
Technical details:
- Load Microsoft.Windows.AI.Text.dll from app directory
- Call DllGetActivationFactory to get ILanguageModelStatics
- Bypass WinRT activation tables that block third-party apps
- Works on both ARM64 and x64 Copilot+ PCs
Tested successfully on Snapdragon X Elite (ARM64) device.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+130-1Lines changed: 130 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -205,4 +205,133 @@ The backend makes extensive use of Windows APIs through the `windows` crate:
205
205
5.**Testing**: Manual testing required due to system-specific nature of diagnostics
206
206
6.**Performance**: Keep diagnostic batches small (5 tasks) to maintain UI responsiveness
207
207
7.**Tauri v2 Imports**: Use `@tauri-apps/api/core` for invoke, plugin packages for specific features
208
-
8.**Real-time Updates**: Use Tauri events (`emit` from backend, `listen` in frontend) for streaming data
208
+
8.**Real-time Updates**: Use Tauri events (`emit` from backend, `listen` in frontend) for streaming data
209
+
210
+
## Phi Silica (On-Device AI) Integration
211
+
212
+
### Overview
213
+
Phi Silica is Microsoft's on-device AI model available on Copilot+ PCs (Windows 11 24H2+, build 26100+). It uses the `Microsoft.Windows.AI.Text.LanguageModel` WinRT API.
214
+
215
+
### Current Status: ✅ WORKING (December 2025)
216
+
217
+
The integration is **complete and working** on both ARM64 and x64 Copilot+ PCs!
218
+
219
+
### The Solution: Direct DLL Activation
220
+
221
+
The key breakthrough was understanding that **standard WinRT activation (`RoGetActivationFactory`) doesn't work** for Windows App SDK classes from third-party apps. The solution is to use `DllGetActivationFactory` directly from bundled DLLs, which is exactly how Microsoft's CsWinRT projection works with `WindowsAppSDKSelfContained=true`.
222
+
223
+
**What works:**
224
+
1. Bundle Windows App SDK 2.0-experimental3 DLLs with the app
225
+
2. Load `Microsoft.Windows.AI.Text.dll` from app directory
4. Use the returned factory to create LanguageModel instances
228
+
229
+
**Why this works:** The bundled DLLs are Microsoft-signed and contain the full implementation. By calling their activation factory directly, we bypass the WinRT activation tables that block third-party apps.
230
+
231
+
### Files Involved
232
+
-**`src-tauri/src/phi_silica.rs`**: Main implementation with `create_language_model_direct()` function
233
+
-**`src-tauri/src/windows_ai_bindings.rs`**: Auto-generated WinRT bindings via `windows-bindgen` 0.65
234
+
-**`build-cross.py`**: Build script that bundles Windows App SDK DLLs
235
+
236
+
### Bundled DLLs (per architecture)
237
+
The MSIX package includes these DLLs for both x64 and ARM64:
0 commit comments