From 73db20fd131e24b30509a8d89a0a9d2af6e03816 Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Fri, 13 Feb 2026 14:32:41 -0800 Subject: [PATCH 1/7] impl --- sdk_v2/js/src/detail/coreInterop.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sdk_v2/js/src/detail/coreInterop.ts b/sdk_v2/js/src/detail/coreInterop.ts index d74c1c1a..2615665f 100644 --- a/sdk_v2/js/src/detail/coreInterop.ts +++ b/sdk_v2/js/src/detail/coreInterop.ts @@ -72,6 +72,17 @@ export class CoreInterop { if (process.platform === 'win32') { koffi.load(path.join(coreDir, `onnxruntime${ext}`)); koffi.load(path.join(coreDir, `onnxruntime-genai${ext}`)); + + // Load WinML libraries only if they exist (needed for NPU execution providers) + const winAppRuntimePath = path.join(coreDir, `Microsoft.WindowsAppRuntime${ext}`); + if (fs.existsSync(winAppRuntimePath)) { + koffi.load(winAppRuntimePath); + } + + const winAIMachineLearningPath = path.join(coreDir, `Microsoft.Windows.AI.MachineLearning${ext}`); + if (fs.existsSync(winAIMachineLearningPath)) { + koffi.load(winAIMachineLearningPath); + } } this.lib = koffi.load(corePath); From 14054b509fb7520f47d479a90a9776892b68f1f3 Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Tue, 17 Feb 2026 11:17:05 -0800 Subject: [PATCH 2/7] workaround --- .../cs/src/Microsoft.AI.Foundry.Local.csproj | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj b/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj index c645cd3e..eda23dbf 100644 --- a/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj +++ b/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj @@ -121,4 +121,28 @@ + + + + + + + + + + $(TargetDir)onnxruntime.dll + $(TargetDir)libonnxruntime.so + $(TargetDir)libonnxruntime.dylib + + + + + + \ No newline at end of file From 28464e76fd1d27b5f15941e4fe92b9afbd8117aa Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Tue, 17 Feb 2026 11:21:54 -0800 Subject: [PATCH 3/7] less --- sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj b/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj index eda23dbf..18d07816 100644 --- a/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj +++ b/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj @@ -129,20 +129,4 @@ - - - - $(TargetDir)onnxruntime.dll - $(TargetDir)libonnxruntime.so - $(TargetDir)libonnxruntime.dylib - - - - - - \ No newline at end of file From da1157a0f94f0f974255a4261816abc3c9408d92 Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Tue, 17 Feb 2026 11:23:27 -0800 Subject: [PATCH 4/7] undo --- sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj | 7 ------- 1 file changed, 7 deletions(-) diff --git a/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj b/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj index 18d07816..c8529a11 100644 --- a/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj +++ b/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj @@ -122,11 +122,4 @@ - - - - - \ No newline at end of file From 58b1e5d494e4baacd69459900f511f2df3bb7205 Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Tue, 17 Feb 2026 11:23:41 -0800 Subject: [PATCH 5/7] undo --- sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj b/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj index c8529a11..c645cd3e 100644 --- a/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj +++ b/sdk_v2/cs/src/Microsoft.AI.Foundry.Local.csproj @@ -121,5 +121,4 @@ - \ No newline at end of file From 50d34c3f8d999b5f662066d3951ad64fd6eba443 Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Thu, 19 Feb 2026 10:56:34 -0800 Subject: [PATCH 6/7] bootstrap --- sdk_v2/js/src/detail/coreInterop.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sdk_v2/js/src/detail/coreInterop.ts b/sdk_v2/js/src/detail/coreInterop.ts index 2615665f..a0040168 100644 --- a/sdk_v2/js/src/detail/coreInterop.ts +++ b/sdk_v2/js/src/detail/coreInterop.ts @@ -77,11 +77,38 @@ export class CoreInterop { const winAppRuntimePath = path.join(coreDir, `Microsoft.WindowsAppRuntime${ext}`); if (fs.existsSync(winAppRuntimePath)) { koffi.load(winAppRuntimePath); + } else { + console.warn(`Microsoft.WindowsAppRuntime${ext} not found at ${winAppRuntimePath}, NPU execution providers may not be available`); } const winAIMachineLearningPath = path.join(coreDir, `Microsoft.Windows.AI.MachineLearning${ext}`); if (fs.existsSync(winAIMachineLearningPath)) { koffi.load(winAIMachineLearningPath); + } else { + console.warn(`Microsoft.Windows.AI.MachineLearning${ext} not found at ${winAIMachineLearningPath}, NPU execution providers may not be available`); + } + + // Initialize the Windows App SDK bootstrapper so WinRT APIs (e.g. ExecutionProviderCatalog) + // can discover and download NPU execution providers. + const bootstrapPath = path.join(coreDir, 'Microsoft.WindowsAppRuntime.Bootstrap.dll'); + if (fs.existsSync(bootstrapPath)) { + const bootstrapLib = koffi.load(bootstrapPath); + const MddBootstrapInitialize2 = bootstrapLib.func( + 'int32_t MddBootstrapInitialize2(uint32_t majorMinorVersion, str16 versionTag, uint64_t minVersion, uint32_t options)' + ); + + // Windows App SDK 1.8 → major=1, minor=8 → 0x00010008 + const majorMinorVersion = 0x00010008; + const versionTag = null; // no tag + const minVersion = 0n; // accept any minimum version (BigInt for uint64) + const options = 0; // MddBootstrapInitializeOptions::None + + const hr = MddBootstrapInitialize2(majorMinorVersion, versionTag, minVersion, options); + if (hr !== 0) { + console.warn(`MddBootstrapInitialize2 failed with HRESULT: 0x${(hr >>> 0).toString(16)}`); + } + } else { + console.warn(`Microsoft.WindowsAppRuntime.Bootstrap.dll not found at ${bootstrapPath}, NPU execution providers may not be available`); } } this.lib = koffi.load(corePath); From 55758276fe235f1e9ce7a0cd04f26957a7b44da0 Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Thu, 19 Feb 2026 14:55:34 -0800 Subject: [PATCH 7/7] update default core for winml --- sdk_v2/js/script/install.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk_v2/js/script/install.cjs b/sdk_v2/js/script/install.cjs index f43f4f09..94d27a6b 100644 --- a/sdk_v2/js/script/install.cjs +++ b/sdk_v2/js/script/install.cjs @@ -55,7 +55,7 @@ const CORE_FEED = useNightly ? ORT_NIGHTLY_FEED : NUGET_FEED; const ARTIFACTS = [ { name: useWinML ? 'Microsoft.AI.Foundry.Local.Core.WinML' : 'Microsoft.AI.Foundry.Local.Core', - version: useNightly ? undefined : useWinML ? '0.9.0.7-dev.20260209T090407.b5352143' : '0.9.0.8-dev.20260209T090216.b5352143', // Set later using resolveLatestVersion if undefined + version: useNightly ? undefined : useWinML ? '0.9.0.170-dev-20260219T211559-2c971802' : '0.9.0.8-dev.20260209T090216.b5352143', // Set later using resolveLatestVersion if undefined feed: ORT_NIGHTLY_FEED }, {