foundryLocalRuntime.ts ×21

Frontier kind: Code frontier

unlabeled · c_9e98b522469f

12 tests · 7578 LOC · 36 files · introduces 0 tests · 169 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
21 ranges169 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1097 ranges7578 lines · 36 files · Browse complete extent
All tests (intent)
12 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Introduced files, introduced tests, and structurally relevant concept specializationfoundryLocalRuntime.ts ×3 · 8 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×1 · 2 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×6 · 17 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×2 · 6 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×14 · 89 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×1 · 1 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×1 · 6 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×6 · 16 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×2 · 6 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×1 · 3 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×1 · 3 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×1 · 1 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×1 · 3 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×1 · 8 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×3 · 5 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×4 · 11 introduced LOCfoundryLocalRuntime.ts ×…foundryLocalRuntime.ts ×2 · 5 introduced LOCfoundryLocalRuntime.ts ×…pfs.ts ×1 · 2 introduced LOCpfs.ts ×1pfs.ts ×3 · 8 introduced LOCpfs.ts ×3pfs.ts ×32 · 306 introduced LOCpfs.ts ×32async.ts ×1 · 7 introduced LOCasync.ts ×1async.ts ×202 · 1247 introduced LOCasync.ts ×202testUtils.ts ×1 · 2 introduced LOCtestUtils.ts ×1extpath.ts ×1 · 2 introduced LOCextpath.ts ×1resources.ts ×23 · 253 introduced LOCresources.ts ×23extpath.ts ×2 · 6 introduced LOCextpath.ts ×2testUtils.ts ×2 · 12 introduced LOCtestUtils.ts ×2extpath.ts ×3 · 18 introduced LOCextpath.ts ×3network.ts ×20 · 292 introduced LOCnetwork.ts ×20testUtils.ts ×1 · 13 introduced LOCtestUtils.ts ×1strings.test|title=Strings trimWhitespace|occurrence=1 · 0 introduced LOCstrings.test|title=Strin…extpath.ts ×17 · 91 introduced LOCextpath.ts ×17strings.ts ×101 · 542 introduced LOCstrings.ts ×101cancellation.test|title=CancellationToken None|occurrence=1 · 0 introduced LOCcancellation.test|title=…cancellation.ts ×18 · 90 introduced LOCcancellation.ts ×18event.ts ×1 · 1 introduced LOCevent.ts ×1event.ts ×4 · 9 introduced LOCevent.ts ×4event.ts ×2 · 6 introduced LOCevent.ts ×2event.ts ×93 · 864 introduced LOCevent.ts ×93normalization.ts ×5 · 27 introduced LOCnormalization.ts ×5map.ts ×1 · 2 introduced LOCmap.ts ×1map.ts ×1 · 4 introduced LOCmap.ts ×1map.ts ×1 · 6 introduced LOCmap.ts ×1uri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…utils.ts ×3 · 9 introduced LOCutils.ts ×3path.ts ×3 · 5 introduced LOCpath.ts ×3path.ts ×3 · 15 introduced LOCpath.ts ×3linkedList.ts ×13 · 44 introduced LOClinkedList.ts ×13path.ts ×1 · 2 introduced LOCpath.ts ×1path.ts ×3 · 10 introduced LOCpath.ts ×3path.ts ×3 · 14 introduced LOCpath.ts ×3lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2path.ts ×1 · 1 introduced LOCpath.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1path.ts ×6 · 24 introduced LOCpath.ts ×6lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lazy.ts ×1 · 2 introduced LOClazy.ts ×1lazy.ts ×3 · 37 introduced LOClazy.ts ×3lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1path.ts ×2 · 3 introduced LOCpath.ts ×2testUtils.ts ×2 · 19 introduced LOCtestUtils.ts ×2uint.ts ×2 · 43 introduced LOCuint.ts ×2lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/async.ts · 2749 LOCcommon/async.tssrc/vs/base/common/cache.ts · 153 LOCcommon/cache.tssrc/vs/base/common/cancellation.ts · 206 LOCcommon/cancellation.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/event.ts · 1964 LOCcommon/event.tssrc/vs/base/common/extpath.ts · 433 LOCcommon/extpath.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lazy.ts · 57 LOCcommon/lazy.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/linkedList.ts · 151 LOCcommon/linkedList.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/network.ts · 440 LOCcommon/network.tssrc/vs/base/common/normalization.ts · 63 LOCcommon/normalization.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/resources.ts · 444 LOCcommon/resources.tssrc/vs/base/common/stopwatch.ts · 41 LOCcommon/stopwatch.tssrc/vs/base/common/strings.ts · 1413 LOCcommon/strings.tssrc/vs/base/common/symbols.ts · 9 LOCcommon/symbols.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uint.ts · 59 LOCcommon/uint.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/node/pfs.ts · 866 LOCnode/pfs.tssrc/vs/base/test/common/testUtils.ts · 34 LOCcommon/testUtils.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/base/test/node/testUtils.ts · 14 LOCnode/testUtils.tssrc/vs/nls.ts · 244 LOCvs/nls.tssrc/vs/platform/localTranscription/node/foundryLocalRuntime.ts · 446 LOCnode/foundryLocalRuntime…cancellation.test|title=CancellationToken None|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/cancellation.test|title=CancellationToken None|occurrence=1cancellation.test|title=…charCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…strings.test|title=Strings trimWhitespace|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/strings.test|title=Strings trimWhitespace|occurrence=1strings.test|title=Strin…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…foundryLocalRuntime.test|title=FoundryLocalRuntime isRuntimeProvisioned: a different arch marker does not satisfy this arch|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/localTranscription/test/node/foundryLocalRuntime.test|title=FoundryLocalRuntime isRuntimeProvisioned: a different arch marker does not satisfy this arch|occurrence=1foundryLocalRuntime.test…foundryLocalRuntime.test|title=FoundryLocalRuntime isRuntimeProvisioned: false when marker present but payload missing (partial cache)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/localTranscription/test/node/foundryLocalRuntime.test|title=FoundryLocalRuntime isRuntimeProvisioned: false when marker present but payload missing (partial cache)|occurrence=1foundryLocalRuntime.test…foundryLocalRuntime.test|title=FoundryLocalRuntime isRuntimeProvisioned: false when nothing is present|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/localTranscription/test/node/foundryLocalRuntime.test|title=FoundryLocalRuntime isRuntimeProvisioned: false when nothing is present|occurrence=1foundryLocalRuntime.test…foundryLocalRuntime.test|title=FoundryLocalRuntime isRuntimeProvisioned: false when one core library is missing (partial cache)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/localTranscription/test/node/foundryLocalRuntime.test|title=FoundryLocalRuntime isRuntimeProvisioned: false when one core library is missing (partial cache)|occurrence=1foundryLocalRuntime.test…foundryLocalRuntime.test|title=FoundryLocalRuntime isRuntimeProvisioned: true only when marker AND payload are present (cache hit)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/localTranscription/test/node/foundryLocalRuntime.test|title=FoundryLocalRuntime isRuntimeProvisioned: true only when marker AND payload are present (cache hit)|occurrence=1foundryLocalRuntime.test…foundryLocalRuntime.test|title=FoundryLocalRuntime platform key reflects the supported-platform set|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/localTranscription/test/node/foundryLocalRuntime.test|title=FoundryLocalRuntime platform key reflects the supported-platform set|occurrence=1foundryLocalRuntime.test…foundryLocalRuntime.test|title=FoundryLocalRuntime promoteDir: keeps the existing copy when a concurrent winner already promoted|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/localTranscription/test/node/foundryLocalRuntime.test|title=FoundryLocalRuntime promoteDir: keeps the existing copy when a concurrent winner already promoted|occurrence=1foundryLocalRuntime.test…foundryLocalRuntime.test|title=FoundryLocalRuntime promoteDir: moves a staged dir into place|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/localTranscription/test/node/foundryLocalRuntime.test|title=FoundryLocalRuntime promoteDir: moves a staged dir into place|occurrence=1foundryLocalRuntime.test…foundryLocalRuntime.test|title=FoundryLocalRuntime provisionRuntime: rejects an incomplete payload (missing core library) and writes no marker|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/localTranscription/test/node/foundryLocalRuntime.test|title=FoundryLocalRuntime provisionRuntime: rejects an incomplete payload (missing core library) and writes no marker|occurrence=1foundryLocalRuntime.test…foundryLocalRuntime.test|title=FoundryLocalRuntime provisionRuntime: rejects and writes no marker when the download 404s|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/localTranscription/test/node/foundryLocalRuntime.test|title=FoundryLocalRuntime provisionRuntime: rejects and writes no marker when the download 404s|occurrence=1foundryLocalRuntime.test…foundryLocalRuntime.test|title=FoundryLocalRuntime provisionRuntime: substitutes {target}, extracts the expected layout, writes the marker|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/localTranscription/test/node/foundryLocalRuntime.test|title=FoundryLocalRuntime provisionRuntime: substitutes {target}, extracts the expected layout, writes the marker|occurrence=1foundryLocalRuntime.test…foundryLocalRuntime.test|title=FoundryLocalRuntime resolveProxyUrl: honors scheme-specific vars, ALL_PROXY fallback, and NO_PROXY|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/localTranscription/test/node/foundryLocalRuntime.test|title=FoundryLocalRuntime resolveProxyUrl: honors scheme-specific vars, ALL_PROXY fallback, and NO_PROXY|occurrence=1foundryLocalRuntime.test…serverMain.test|title=server.main directory creation should create nested directories with recursive option|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/server/test/node/serverMain.test|title=server.main directory creation should create nested directories with recursive option|occurrence=1serverMain.test|title=se…serverMain.test|title=server.main directory creation should handle existing directories gracefully|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/server/test/node/serverMain.test|title=server.main directory creation should handle existing directories gracefully|occurrence=1serverMain.test|title=se…serverMain.test|title=server.main directory creation should not fail when parent directories do not exist|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/server/test/node/serverMain.test|title=server.main directory creation should not fail when parent directories do not exist|occurrence=1serverMain.test|title=se…Focused concept · foundryLocalRuntime.ts ×21 · 169 introduced LOCfoundryLocalRuntime.ts ×…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 169 introduced LOC across 21 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/localTranscription/node/foundryLocalRuntime.ts 169 introduced LOC · 21 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- foundryLocalRuntime.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import * as fs from 'fs';
7 > import * as os from 'os';
8 > import { dirname, join } from '../../../base/common/path.js';
9 > import { format2 } from '../../../base/common/strings.js';
10 > import { CancellationToken } from '../../../base/common/cancellation.js';
11 > import { CancellationError } from '../../../base/common/errors.js';
12 >
13 > /**
14 > * On-demand provisioning of the Foundry Local native runtime used by on-device
15 > * dictation.
16 > *
17 > * `foundry-local-sdk` ships a prebuilt N-API addon (`foundry_local_napi.node`)
18 > * and native core libraries (Foundry Local Core + ONNX Runtime + ONNX Runtime
19 > * GenAI). The addon requires a newer glibc than VS Code's minimum supported
20 > * Linux distros, so we deliberately do NOT bundle any of this native payload
21 > * with the product (see `build/gulpfile.vscode.ts`). Instead we republish a
22 > * per-target tarball of the addon + core libraries to VS Code's CDN at build
23 > * time (see `build/dictation-runtime/`) and download it here, at runtime, only
24 > * on supported platforms, into a per-user writable cache — keeping the shipped
25 > * package's glibc floor intact and avoiding any runtime dependency on the npm
26 > * registry or NuGet.
27 > *
28 > * The SDK loader (`dist/detail/coreInterop.js`) is patched during
29 > * `postinstall` to honor `VSCODE_FOUNDRY_LOCAL_NATIVE_DIR`, pointing it at the
30 > * cache directory this module populates. The tarball's internal layout mirrors
31 > * the SDK's own package layout so the patched resolution is a trivial path join:
32 > *
33 > * <cacheRoot>/<version>/prebuilds/<target>/foundry_local_napi.node
34 > * <cacheRoot>/<version>/foundry-local-core/<target>/<core libraries>
35 > *
36 > * NOTE: the single CDN download leg honors the standard proxy environment
37 > * variables (`HTTPS_PROXY`/`HTTP_PROXY`/`ALL_PROXY`, with `NO_PROXY`). VS Code's
38 > * `http.proxy`/`http.noProxy` settings are applied as these same environment
39 > * variables before provisioning (see `LocalTranscriptionService.start`), so a
40 > * proxy configured only in VS Code is honored here and by the native model
41 > * download too; `http.proxyAuthorization` (Basic) is folded into the proxy URL
42 > * and `http.proxyStrictSSL === false` disables TLS verification for this leg.
43 > * TLS-intercepting proxies otherwise rely on the CA being in the OS trust store.
44 > */
45 >
46 > /**
47 > * Platforms (`<process.platform>-<process.arch>`) for which Foundry Local ships
48 > * a native addon + core libraries. Mirrors the SDK installer's RID map.
49 > */
50 > export const FOUNDRY_LOCAL_SUPPORTED_PLATFORMS: ReadonlySet<string> = new Set([
51 > 'darwin-arm64',
52 > 'linux-x64',
53 > 'linux-arm64',
54 > 'win32-x64',
55 > 'win32-arm64',
56 > ]);
57 >
58 > /** The current host platform key, or `undefined` if Foundry Local can't run here. */
59 > export function foundryLocalPlatformKey(): string | undefined {
60 const key = `${process.platform}-${process.arch}`;
61 return FOUNDRY_LOCAL_SUPPORTED_PLATFORMS.has(key) ? key : undefined;
62 }
64 > /** Whether on-device dictation's native runtime can run on this host. */
65 > export function isFoundryLocalRuntimeSupported(): boolean {
66 return foundryLocalPlatformKey() !== undefined;
67 }
69 > /** Progress callback invoked while the native runtime is being fetched. */
70 > export type FoundryLocalRuntimeProgress = (message: string) => void;
71 >
72 > /** Where the native runtime tarball is published (from `product.dictationRuntime`). */
73 > export interface IFoundryLocalRuntimeDownload {
74 > /** CDN URL template with a `{target}` placeholder for the host platform key. */
75 > readonly urlTemplate: string;
76 > /** The published runtime version (the pinned `foundry-local-sdk` version). */
77 > readonly version: string;
78 > }
79 >
80 > /** De-dupes concurrent provisioning requests targeting the same cache dir. */
81 > const inFlight = new Map<string, Promise<string>>();
82 >
83 > /** Abort a download after this long without any connection/response progress. */
84 > const DOWNLOAD_INACTIVITY_TIMEOUT_MS = 60_000;
85 >
86 > /**
87 > * Ensure the Foundry Local native runtime (addon + core libraries) is present
88 > * in `<cacheRoot>`, downloading the per-target CDN tarball if necessary. Returns
89 > * the versioned override directory to set as `VSCODE_FOUNDRY_LOCAL_NATIVE_DIR`
90 > * before loading the SDK.
91 > *
92 > * Idempotent: once a version is fully provisioned a per-platform `.complete`
93 > * marker is written and subsequent calls return immediately (after verifying the
94 > * payload) without touching the network.
95 > */
96 export async function ensureFoundryLocalRuntime(cacheRoot: string, download: IFoundryLocalRuntimeDownload, token: CancellationToken, onProgress?: FoundryLocalRuntimeProgress): Promise<string> {
97 const platformKey = foundryLocalPlatformKey();
112 return promise;
113 }
115 async function doEnsure(overrideDir: string, platformKey: string, download: IFoundryLocalRuntimeDownload, token: CancellationToken, onProgress?: FoundryLocalRuntimeProgress): Promise<string> {
116 // The completion marker is per-platform: the shared `<cacheRoot>/<version>`
134 return overrideDir;
135 }
137 > /**
138 > * Download the `{target}`-substituted CDN tarball for `platformKey` into
139 > * `overrideDir`, extract + verify + atomically promote its payload, and write the
140 > * per-platform completion marker. Host-independent (does NOT run the glibc
141 > * loadability gate); exported for tests. Callers that provision for the running
142 > * host should use `ensureFoundryLocalRuntime`, which gates and de-dupes.
143 > */
144 export async function provisionRuntime(overrideDir: string, platformKey: string, urlTemplate: string, version: string, token: CancellationToken): Promise<void> {
145 const addonPath = foundryAddonPath(overrideDir, platformKey);
176 await fs.promises.writeFile(foundryMarkerPath(overrideDir, platformKey), `${version}\n`).catch(() => { /* best effort marker */ });
177 }
179 > /** Path of the per-platform completion marker inside a versioned override dir. */
180 function foundryMarkerPath(overrideDir: string, platformKey: string): string {
181 return join(overrideDir, `.complete-${platformKey}`);
182 }
184 > /** Path of the prebuilt N-API addon inside a versioned override dir. */
185 function foundryAddonPath(overrideDir: string, platformKey: string): string {
186 return join(overrideDir, 'prebuilds', platformKey, 'foundry_local_napi.node');
187 }
189 > /** Directory of the native core libraries inside a versioned override dir. */
190 function foundryCoreDir(overrideDir: string, platformKey: string): string {
191 return join(overrideDir, 'foundry-local-core', platformKey);
192 }
194 > /**
195 > * Whether `<overrideDir>` holds a complete, verified runtime for `platformKey`:
196 > * the per-platform marker AND the actual addon + all core libraries. A marker
197 > * alone is insufficient (it can belong to a different architecture, or the
198 > * payload can be partially deleted). Exported for tests.
199 > */
200 > export function isRuntimeProvisioned(overrideDir: string, platformKey: string): boolean {
201 return fs.existsSync(foundryMarkerPath(overrideDir, platformKey))
202 && fs.existsSync(foundryAddonPath(overrideDir, platformKey))
203 && hasAllCoreLibraries(foundryCoreDir(overrideDir, platformKey));
204 }
206 > /**
207 > * Atomically move the fully-staged directory `from` to `to`. If another process
208 > * already promoted the same payload (the destination exists), keep the existing
209 > * copy — the caller re-verifies completeness afterwards. Exported for tests.
210 > */
211 export async function promoteDir(from: string, to: string): Promise<void> {
212 await fs.promises.mkdir(dirname(to), { recursive: true });
223 }
224 }
226 function randomSuffix(): string {
227 return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
228 }
230 > /** Minimum glibc version the Foundry Local addon requires on Linux. */
231 > const MIN_GLIBC: readonly [number, number] = [2, 34];
232 >
233 > /**
234 > * Throw a classified error if this host cannot load the downloaded addon. Only
235 > * Linux is gated (on glibc): the prebuilt addon needs GLIBC_2.34, newer than VS
236 > * Code's minimum supported distros, so downloading + loading it there would
237 > * crash. Non-glibc / undetectable systems are left to fail at load time.
238 > */
239 function assertRuntimeLoadable(platformKey: string): void {
240 if (!platformKey.startsWith('linux-')) {
248 }
249 }
251 > /** Best-effort runtime glibc version via Node's diagnostic report, if available. */
252 function detectGlibcVersion(): [number, number] | undefined {
253 try {
263 return undefined;
264 }
266 > /**
267 > * Download the per-target runtime tarball from `url` and extract it into
268 > * `stagingDir`, which then contains `prebuilds/<target>/foundry_local_napi.node`
269 > * and `foundry-local-core/<target>/<core libraries>` (the tarball's layout
270 > * mirrors the cache layout). The tarball is published to VS Code's CDN by
271 > * `build/dictation-runtime/`.
272 > */
273 async function downloadAndExtractTarball(url: string, stagingDir: string, token: CancellationToken): Promise<void> {
274 await fs.promises.mkdir(stagingDir, { recursive: true });
286 }
287 }
289 > /** The core library filenames required for the current platform. Exported for tests. */
290 > export function requiredCoreLibraryNames(): string[] {
291 const ext = process.platform === 'win32' ? '.dll' : process.platform === 'darwin' ? '.dylib' : '.so';
292 const prefix = process.platform === 'win32' ? '' : 'lib';
297 ];
298 }
300 > /** Whether all required core libraries already exist in `coreDir`. */
301 function hasAllCoreLibraries(coreDir: string): boolean {
302 return requiredCoreLibraryNames().every(name => fs.existsSync(join(coreDir, name)));
303 }
305 > /**
306 > * Resolve the proxy URL to use for `targetUrl` from the standard proxy
307 > * environment variables, or `undefined` when the request should go direct.
308 > *
309 > * Mirrors the env-var handling of the GitHub desktop app's Rust
310 > * `foundry-local-sdk` (reqwest/ureq): for an `https:` target it prefers
311 > * `HTTPS_PROXY`, for an `http:` target `HTTP_PROXY`, each falling back to
312 > * `ALL_PROXY` (all case-insensitive), and it skips the proxy when the host
313 > * matches `NO_PROXY`. `env` defaults to `process.env`; it is a parameter so the
314 > * resolution can be unit-tested without mutating global environment state.
315 > */
316 > export function resolveProxyUrl(targetUrl: string, env: NodeJS.ProcessEnv = process.env): string | undefined {
317 let parsed: URL;
318 try {
334 return proxy;
335 }
337 > /** Whether `hostname` matches any entry in a `NO_PROXY` list. */
338 function isNoProxyHost(noProxy: string, hostname: string): boolean {
339 const host = hostname.toLowerCase();
346 });
347 }
349 > /**
350 > * A proxy `Agent` for `targetUrl` built from the environment, or `undefined`
351 > * when no proxy applies. `https-proxy-agent` is a `node_modules` package, so it
352 > * is imported dynamically like the other runtime-only dependencies here.
353 > */
354 async function resolveProxyAgent(targetUrl: string): Promise<import('http').Agent | undefined> {
355 const proxyUrl = resolveProxyUrl(targetUrl);
360 return new HttpsProxyAgent(proxyUrl);
361 }
363 > /** Download `url` to `dest`, following redirects, honoring cancellation. */
364 async function downloadFile(url: string, dest: string, token: CancellationToken): Promise<void> {
365 // `http`/`https` are slow-to-load builtins; import them lazily at runtime.
439 });
440 }
442 function throwIfCancelled(token: CancellationToken): void {
443 if (token.isCancellationRequested) {