🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More →
Socket
Book a DemoSign in
Socket

@github/copilot

Package Overview
Dependencies
Maintainers
22
Versions
670
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@github/copilot - npm Package Compare versions

Comparing version
1.0.44-2
to
1.0.44-3
+71
foundry-local-sdk/...les/foundry-local-sdk/dist/catalog.d.ts
import { CoreInterop } from './detail/coreInterop.js';
import { ModelLoadManager } from './detail/modelLoadManager.js';
import { IModel } from './imodel.js';
/**
* Represents a catalog of AI models available in the system.
* Provides methods to discover, list, and retrieve models and their variants.
*/
export declare class Catalog {
private _name;
private coreInterop;
private modelLoadManager;
private _models;
private modelAliasToModel;
private modelIdToModelVariant;
private lastFetch;
private updatePromise?;
constructor(coreInterop: CoreInterop, modelLoadManager: ModelLoadManager, catalogName?: string);
/**
* Gets the name of the catalog.
* @returns The name of the catalog.
*/
get name(): string;
/** @internal */
invalidateCache(): void;
private updateModels;
private fetchAndPopulateModels;
/**
* Lists all available models in the catalog.
* This method is asynchronous as it may fetch the model list from a remote service or perform file I/O.
* @returns A Promise that resolves to an array of IModel objects.
*/
getModels(): Promise<IModel[]>;
/**
* Retrieves a model by its alias.
* This method is asynchronous as it may ensure the catalog is up-to-date by fetching from a remote service.
* @param alias - The alias of the model to retrieve.
* @returns A Promise that resolves to the IModel object if found, otherwise throws an error.
* @throws Error - If alias is null, undefined, or empty.
*/
getModel(alias: string): Promise<IModel>;
/**
* Retrieves a specific model variant by its ID.
* NOTE: This will return an IModel with a single variant. Use getModel to get an IModel with all available
* variants.
* This method is asynchronous as it may ensure the catalog is up-to-date by fetching from a remote service.
* @param modelId - The unique identifier of the model variant.
* @returns A Promise that resolves to the IModel object if found, otherwise throws an error.
* @throws Error - If modelId is null, undefined, or empty.
*/
getModelVariant(modelId: string): Promise<IModel>;
/**
* Retrieves a list of all locally cached model variants.
* This method is asynchronous as it may involve file I/O or querying the underlying core.
* @returns A Promise that resolves to an array of cached IModel objects.
*/
getCachedModels(): Promise<IModel[]>;
/**
* Retrieves a list of all currently loaded model variants.
* This operation is asynchronous because checking the loaded status may involve querying
* the underlying core or an external service, which can be an I/O bound operation.
* @returns A Promise that resolves to an array of loaded IModel objects.
*/
getLoadedModels(): Promise<IModel[]>;
/**
* Get the latest version of a model.
* This is used to check if a newer version of a model is available in the catalog for download.
* @param modelOrModelVariant - The model to check for the latest version.
* @returns The latest version of the model. Will match the input if it is the latest version.
*/
getLatestVersion(modelOrModelVariant: IModel): Promise<IModel>;
}
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIxD;;;GAGG;AACH,MAAM,OAAO,OAAO;IACR,KAAK,CAAS;IACd,WAAW,CAAc;IACzB,gBAAgB,CAAmB;IACnC,OAAO,GAAY,EAAE,CAAC;IACtB,iBAAiB,GAAuB,IAAI,GAAG,EAAE,CAAC;IAClD,qBAAqB,GAA8B,IAAI,GAAG,EAAE,CAAC;IAC7D,SAAS,GAAW,CAAC,CAAC;IACtB,aAAa,CAAiB;IAEtC,YAAY,WAAwB,EAAE,gBAAkC,EAAE,WAAoB;QAC1F,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;IACpF,CAAC;IAED;;;OAGG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,gBAAgB;IAChB,eAAe;QACX,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,YAAY;Q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AC,CAAC,IAAI,CAAC,IAAI,KAAK,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvF,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CACX,iDAAiD,KAAK,CAAC,KAAK,QAAQ;gBACpE,wBAAwB,mBAAmB,CAAC,KAAK,IAAI,CACxD,CAAC;QACN,CAAC;QAED,6EAA6E;QAC7E,4CAA4C;QAC5C,OAAO,MAAM,CAAC,EAAE,KAAK,mBAAmB,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC;IAC/E,CAAC;CACJ"}
/**
* Configuration options for the Foundry Local SDK.
* Use a plain object with these properties to configure the SDK.
*/
export interface FoundryLocalConfig {
/**
* **REQUIRED** The name of the application using the SDK.
* Used for identifying the application in logs and telemetry.
*/
appName: string;
/**
* The directory where application data should be stored.
* Optional. Defaults to `{user_home}/.{appName}`.
*/
appDataDir?: string;
/**
* The directory where models are downloaded and cached.
* Optional. Defaults to `{appDataDir}/cache/models`.
*/
modelCacheDir?: string;
/**
* The directory where log files are written.
* Optional. Defaults to `{appDataDir}/logs`.
*/
logsDir?: string;
/**
* The logging level for the SDK.
* Optional. Valid values: 'trace', 'debug', 'info', 'warn', 'error', 'fatal'.
* Defaults to 'warn'.
*/
logLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
/**
* The URL(s) for the local web service to bind to.
* Optional. Multiple URLs can be separated by semicolons.
* Example: "http://127.0.0.1:8080"
*/
webServiceUrls?: string;
/**
* The external URL if the web service is running in a separate process.
* Optional. This is used to connect to an existing service instance.
*/
serviceEndpoint?: string;
/**
* The path to the directory containing the native Foundry Local Core libraries.
* Optional. This directory must contain `Microsoft.AI.Foundry.Local.Core`, `onnxruntime`, and `onnxruntime-genai` binaries.
* If not provided, the SDK attempts to discover them in standard locations.
*/
libraryPath?: string;
/**
* Additional settings to pass to the core.
* Optional. Internal use only.
*/
additionalSettings?: {
[key: string]: string;
};
}
export declare class Configuration {
params: {
[key: string]: string;
};
constructor(config: FoundryLocalConfig);
}
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"AA+DA,8CAA8C;AAC9C,MAAM,aAAa,GAA8B;IAC7C,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,OAAO;CACnB,CAAC;AAEF,8CAA8C;AAC9C,MAAM,OAAO,aAAa;IACf,MAAM,CAA4B;IAEzC,YAAY,MAA0B;QAClC,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACxE,CAAC;QAED,IAAI,CAAC,MAAM,GAAG;YACV,SAAS,EAAE,MAAM,CAAC,OAAO;SAC5B,CAAC;QAEF,IAAI,MAAM,CAAC,UAAU;YAAE,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC;QACrE,IAAI,MAAM,CAAC,aAAa;YAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC;QAC9E,IAAI,MAAM,CAAC,OAAO;YAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;QAC5D,IAAI,MAAM,CAAC,QAAQ;YAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC;QACjG,IAAI,MAAM,CAAC,cAAc;YAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC;QACjF,IAAI,MAAM,CAAC,eAAe;YAAE,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC;QAC1F,IAAI,MAAM,CAAC,WAAW;YAAE,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC;QAEjF,0CAA0C;QAC1C,IAAI,MAAM,CAAC,kBAAkB,EAAE,CAAC;YAC5B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,kBAAkB,EAAE,CAAC;gBAC1C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;YACtD,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}
import { Configuration } from '../configuration.js';
export declare class CoreInterop {
private addon;
private static _getLibraryExtension;
private static _resolveDefaultCorePath;
constructor(config: Configuration);
executeCommand(command: string, params?: any): string;
/**
* Asynchronously execute a native command without blocking the event loop.
* Runs the native call on a libuv worker thread.
*/
executeCommandAsync(command: string, params?: any): Promise<string>;
/**
* Execute a native command with binary data (e.g., audio PCM bytes).
* Uses the execute_command_with_binary native entry point which accepts
* both JSON params and raw binary data via StreamingRequestBuffer.
*/
executeCommandWithBinary(command: string, params: any, binaryData: Uint8Array): string;
executeCommandStreaming(command: string, params: any, callback: (chunk: string) => void): Promise<string>;
}
{"version":3,"file":"coreInterop.js","sourceRoot":"","sources":["../../src/detail/coreInterop.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAGpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAA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AM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAED;;;OAGG;IACI,mBAAmB,CAAC,OAAe,EAAE,MAAY;QACpD,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,OAAO,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED;;;;OAIG;IACI,wBAAwB,CAAC,OAAe,EAAE,MAAW,EAAE,UAAsB;QAChF,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;QAC5F,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACzE,CAAC;IAEM,uBAAuB,CAAC,OAAe,EAAE,MAAW,EAAE,QAAiC;QAC1F,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,OAAO,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC1E,CAAC;CAEJ"}
import { ModelVariant } from './modelVariant.js';
import { ChatClient } from '../openai/chatClient.js';
import { AudioClient } from '../openai/audioClient.js';
import { EmbeddingClient } from '../openai/embeddingClient.js';
import { ResponsesClient } from '../openai/responsesClient.js';
import { LiveAudioTranscriptionSession } from '../openai/liveAudioSession.js';
import { IModel } from '../imodel.js';
import { ModelInfo } from '../types.js';
/**
* Represents a high-level AI model that may have multiple variants (e.g., quantized versions, different formats).
* Manages the selection and interaction with a specific model variant.
*/
export declare class Model implements IModel {
private _alias;
private _variants;
private selectedVariant;
constructor(variant: ModelVariant);
/**
* Adds a new variant to this model.
* Automatically selects the new variant if it is cached and the current one is not.
* @param variant - The model variant to add.
* @throws Error - If the variant's alias does not match the model's alias.
* @internal
*/
addVariant(variant: ModelVariant): void;
/**
* Selects a specific variant.
* @param variant - The model variant to select. Must be one of the variants in `variants`.
* @throws Error - If the variant does not belong to this model.
*/
selectVariant(variant: IModel): void;
/**
* Gets the ID of the currently selected variant.
* @returns The ID of the selected variant.
*/
get id(): string;
/**
* Gets the alias of the model.
* @returns The model alias.
*/
get alias(): string;
/**
* Gets the ModelInfo of the currently selected variant.
* @returns The ModelInfo object.
*/
get info(): ModelInfo;
/**
* Checks if the currently selected variant is cached locally.
* @returns True if cached, false otherwise.
*/
get isCached(): boolean;
/**
* Checks if the currently selected variant is loaded in memory.
* @returns True if loaded, false otherwise.
*/
isLoaded(): Promise<boolean>;
/**
* Gets all available variants for this model.
* @returns An array of IModel objects.
*/
get variants(): IModel[];
get contextLength(): number | null;
get inputModalities(): string | null;
get outputModalities(): string | null;
get capabilities(): string | null;
get supportsToolCalling(): boolean | null;
/**
* Downloads the currently selected variant.
* @param progressCallback - Optional callback to report download progress.
*/
download(progressCallback?: (progress: number) => void): Promise<void>;
/**
* Gets the local file path of the currently selected variant.
* @returns The local file path.
*/
get path(): string;
/**
* Loads the currently selected variant into memory.
* @returns A promise that resolves when the model is loaded.
*/
load(): Promise<void>;
/**
* Removes the currently selected variant from the local cache.
*/
removeFromCache(): void;
/**
* Unloads the currently selected variant from memory.
* @returns A promise that resolves when the model is unloaded.
*/
unload(): Promise<void>;
/**
* Creates a ChatClient for interacting with the model via chat completions.
* @returns A ChatClient instance.
*/
createChatClient(): ChatClient;
/**
* Creates an AudioClient for interacting with the model via audio operations.
* @returns An AudioClient instance.
*/
createAudioClient(): AudioClient;
/**
* Creates an EmbeddingClient for generating text embeddings with the model.
* @returns An EmbeddingClient instance.
*/
createEmbeddingClient(): EmbeddingClient;
/**
* Creates a LiveAudioTranscriptionSession for real-time audio streaming ASR.
* @returns A LiveAudioTranscriptionSession instance.
*/
createLiveTranscriptionSession(): LiveAudioTranscriptionSession;
/**
* Creates a ResponsesClient for interacting with the model via the Responses API.
* @param baseUrl - The base URL of the Foundry Local web service.
* @returns A ResponsesClient instance.
*/
createResponsesClient(baseUrl: string): ResponsesClient;
}
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/detail/model.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,MAAM,OAAO,KAAK;IACN,MAAM,CAAS;IAEf,SAAS,CAAiB;IAC1B,eAAe,CAAe;IAEtC,YAAY,OAAqB;QAC7B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3B,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;IACnC,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAAC,OAAqB;QACnC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,kBAAkB,OAAO,EAAE,KAAK,iCAAiC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;QACtG,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE7B,qDAAqD;QACrD,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC;YACrD,IAAI,CAAC,eAAe,GAAG,OAAO,CA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CAAC;IAED,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC;IACpD,CAAC;IAED;;;OAGG;IACI,QAAQ,CAAC,gBAA6C;QACzD,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;IACrC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,IAAI;QACb,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,eAAe;QAClB,IAAI,CAAC,eAAe,CAAC,eAAe,EAAE,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,MAAM;QACf,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;IACxC,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC;IACnD,CAAC;IAED;;;OAGG;IACI,iBAAiB;QACpB,OAAO,IAAI,CAAC,eAAe,CAAC,iBAAiB,EAAE,CAAC;IACpD,CAAC;IAED;;;OAGG;IACI,qBAAqB;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC,qBAAqB,EAAE,CAAC;IACxD,CAAC;IAED;;;OAGG;IACI,8BAA8B;QACjC,OAAO,IAAI,CAAC,eAAe,CAAC,8BAA8B,EAAE,CAAC;IACjE,CAAC;IAED;;;;OAIG;IACI,qBAAqB,CAAC,OAAe;QACxC,OAAO,IAAI,CAAC,eAAe,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC/D,CAAC;CACJ"}
import { CoreInterop } from './coreInterop.js';
/**
* Manages the loading and unloading of models.
* Handles communication with the core system or an external service (future support).
*/
export declare class ModelLoadManager {
private coreInterop;
private externalServiceUrl?;
private headers;
constructor(coreInterop: CoreInterop, externalServiceUrl?: string);
/**
* Loads a model into memory.
* @param modelId - The ID of the model to load.
* @throws Error - If loading via external service fails.
*/
load(modelId: string): Promise<void>;
/**
* Unloads a model from memory.
* @param modelId - The ID of the model to unload.
* @throws Error - If unloading via external service fails.
*/
unload(modelId: string): Promise<void>;
/**
* Lists the IDs of all currently loaded models.
* @returns An array of loaded model IDs.
* @throws Error - If listing via external service fails or if JSON parsing fails.
*/
listLoaded(): Promise<string[]>;
}
{"version":3,"file":"modelLoadManager.js","sourceRoot":"","sources":["../../src/detail/modelLoadManager.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACnE,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;AAEhC;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACjB,WAAW,CAAc;IACzB,kBAAkB,CAAU;IAC5B,OAAO,CAAc;IAE7B,YAAY,WAAwB,EAAE,kBAA2B;QAC7D,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG;YACX,YAAY,EAAE,wBAAwB,OAAO,EAAE;SAClD,CAAC;IACN,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI,CAAC,OAAe;QAC7B,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,eAAe,kBAAkB,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;YAC3F,IAAI,CAAC;gBACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;gBACxE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACf,MAAM,IA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GAAG,IAAI,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;YAC9D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;YACxE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,CAAC,kBAAkB,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;YAC3G,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAI,IAAI,EAAE,CAAC;QACtB,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;QAClF,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,mBAAmB,QAAQ,EAAE,CAAC,CAAC;QAC3F,CAAC;IACL,CAAC;CACJ"}
import { CoreInterop } from './coreInterop.js';
import { ModelLoadManager } from './modelLoadManager.js';
import { ModelInfo } from '../types.js';
import { ChatClient } from '../openai/chatClient.js';
import { AudioClient } from '../openai/audioClient.js';
import { EmbeddingClient } from '../openai/embeddingClient.js';
import { LiveAudioTranscriptionSession } from '../openai/liveAudioSession.js';
import { ResponsesClient } from '../openai/responsesClient.js';
import { IModel } from '../imodel.js';
/**
* Represents a specific variant of a model (e.g., a specific quantization or format).
* Contains the low-level implementation for interacting with the model.
* @internal
*/
export declare class ModelVariant implements IModel {
private _modelInfo;
private coreInterop;
private modelLoadManager;
constructor(modelInfo: ModelInfo, coreInterop: CoreInterop, modelLoadManager: ModelLoadManager);
/**
* Gets the unique identifier of the model variant.
* @returns The model ID.
*/
get id(): string;
/**
* Gets the alias of the model.
* @returns The model alias.
*/
get alias(): string;
/**
* Gets the detailed information about the model variant.
* @returns The ModelInfo object.
*/
get info(): ModelInfo;
/**
* A ModelVariant is a single variant, so variants returns itself.
*/
get variants(): IModel[];
/**
* SelectVariant is not supported on a ModelVariant.
* Call Catalog.getModel() to get an IModel with all variants available.
* @throws Error always.
*/
selectVariant(_variant: IModel): void;
get contextLength(): number | null;
get inputModalities(): string | null;
get outputModalities(): string | null;
get capabilities(): string | null;
get supportsToolCalling(): boolean | null;
/**
* Checks if the model variant is cached locally.
* @returns True if cached, false otherwise.
*/
get isCached(): boolean;
/**
* Checks if the model variant is loaded in memory.
* @returns True if loaded, false otherwise.
*/
isLoaded(): Promise<boolean>;
/**
* Downloads the model variant.
* @param progressCallback - Optional callback to report download progress (0-100).
*/
download(progressCallback?: (progress: number) => void): Promise<void>;
/**
* Gets the local file path of the model variant.
* @returns The local file path.
*/
get path(): string;
/**
* Loads the model variant into memory.
* @returns A promise that resolves when the model is loaded.
*/
load(): Promise<void>;
/**
* Removes the model variant from the local cache.
*/
removeFromCache(): void;
/**
* Unloads the model variant from memory.
* @returns A promise that resolves when the model is unloaded.
*/
unload(): Promise<void>;
/**
* Creates a ChatClient for interacting with the model via chat completions.
* @returns A ChatClient instance.
*/
createChatClient(): ChatClient;
/**
* Creates an AudioClient for interacting with the model via audio operations.
* @returns An AudioClient instance.
*/
createAudioClient(): AudioClient;
/**
* Creates an EmbeddingClient for generating text embeddings with the model.
* @returns An EmbeddingClient instance.
*/
createEmbeddingClient(): EmbeddingClient;
/**
* Creates a LiveAudioTranscriptionSession for real-time audio streaming ASR.
* @returns A LiveAudioTranscriptionSession instance.
*/
createLiveTranscriptionSession(): LiveAudioTranscriptionSession;
/**
* Creates a ResponsesClient for interacting with the model via the Responses API.
* @param baseUrl - The base URL of the Foundry Local web service.
* @returns A ResponsesClient instance.
*/
createResponsesClient(baseUrl: string): ResponsesClient;
}
{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IACrE,CAAC;IAED;;;OAGG;IACI,8BAA8B;QACjC,OAAO,IAAI,6BAA6B,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACnF,CAAC;IAED;;;;OAIG;IACI,qBAAqB,CAAC,OAAe;QACxC,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC5D,CAAC;CACJ"}
import { FoundryLocalConfig } from './configuration.js';
import { Catalog } from './catalog.js';
import { ResponsesClient } from './openai/responsesClient.js';
import { EpInfo, EpDownloadResult } from './types.js';
/**
* The main entry point for the Foundry Local SDK.
* Manages the initialization of the core system and provides access to the Catalog and ModelLoadManager.
*/
export declare class FoundryLocalManager {
private static instance;
private static pendingCreate?;
private config;
private coreInterop;
private _modelLoadManager;
private _catalog;
private _urls;
private constructor();
private initializeSync;
private initializeAsync;
/**
* Creates the FoundryLocalManager singleton with the provided configuration.
* Note: This method blocks the event loop during initialization.
* For non-blocking initialization, use {@link createAsync} instead.
* @param config - The configuration settings for the SDK (plain object).
* @returns The initialized FoundryLocalManager instance.
* @example
* ```typescript
* const manager = FoundryLocalManager.create({
* appName: 'MyApp',
* logLevel: 'info'
* });
* ```
*/
static create(config: FoundryLocalConfig): FoundryLocalManager;
/**
* Creates the FoundryLocalManager singleton with the provided configuration.
* Native command execution is performed asynchronously to avoid blocking the
* event loop during initialization. Note that some synchronous setup (e.g.,
* loading the native addon) still occurs before the first await.
* @param config - The configuration settings for the SDK (plain object).
* @returns A promise that resolves to the initialized FoundryLocalManager instance.
* @example
* ```typescript
* const manager = await FoundryLocalManager.createAsync({
* appName: 'MyApp',
* logLevel: 'info'
* });
* ```
*/
static createAsync(config: FoundryLocalConfig): Promise<FoundryLocalManager>;
/**
* Gets the Catalog instance for discovering and managing models.
* @returns The Catalog instance.
*/
get catalog(): Catalog;
/**
* Gets the URLs where the web service is listening.
* Returns an empty array if the web service is not running.
* @returns An array of URLs.
*/
get urls(): string[];
/**
* Starts the local web service.
* Use the `urls` property to retrieve the bound addresses after the service has started.
* If no listener address is configured, the service defaults to `127.0.0.1:0` (binding to a random ephemeral port).
* @throws Error - If starting the service fails.
*/
startWebService(): void;
/**
* Stops the local web service.
* @throws Error - If stopping the service fails.
*/
stopWebService(): void;
/**
* Whether the web service is currently running.
*/
get isWebServiceRunning(): boolean;
/**
* Discovers available execution providers (EPs) and their registration status.
* @returns An array of EpInfo describing each available EP.
*/
discoverEps(): EpInfo[];
/**
* Downloads and registers execution providers.
* @returns A promise that resolves with an EpDownloadResult describing the outcome.
*/
downloadAndRegisterEps(): Promise<EpDownloadResult>;
/**
* Downloads and registers execution providers.
* @param names - Array of EP names to download.
* @returns A promise that resolves with an EpDownloadResult describing the outcome.
*/
downloadAndRegisterEps(names: string[]): Promise<EpDownloadResult>;
/**
* Downloads and registers execution providers, reporting progress.
* @param progressCallback - Callback invoked with (epName, percent) as each EP downloads. Percent is 0-100.
* @returns A promise that resolves with an EpDownloadResult describing the outcome.
*/
downloadAndRegisterEps(progressCallback: (epName: string, percent: number) => void): Promise<EpDownloadResult>;
/**
* Downloads and registers execution providers, reporting progress.
* @param names - Array of EP names to download.
* @param progressCallback - Callback invoked with (epName, percent) as each EP downloads. Percent is 0-100.
* @returns A promise that resolves with an EpDownloadResult describing the outcome.
*/
downloadAndRegisterEps(names: string[], progressCallback: (epName: string, percent: number) => void): Promise<EpDownloadResult>;
/**
* Creates a ResponsesClient for interacting with the Responses API.
* The web service must be started first via `startWebService()`.
* @param modelId - Optional default model ID for requests.
* @returns A ResponsesClient instance.
* @throws Error - If the web service is not running.
*/
createResponsesClient(modelId?: string): ResponsesClient;
}
{"version":3,"file":"foundryLocalManager.js","sourceRoot":"","sources":["../src/foundryLocalManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAsB,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;A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C,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACJ"}
import { ChatClient } from './openai/chatClient.js';
import { AudioClient } from './openai/audioClient.js';
import { EmbeddingClient } from './openai/embeddingClient.js';
import { ResponsesClient } from './openai/responsesClient.js';
import { ModelInfo } from './types.js';
export interface IModel {
get id(): string;
get alias(): string;
get info(): ModelInfo;
get isCached(): boolean;
isLoaded(): Promise<boolean>;
get contextLength(): number | null;
get inputModalities(): string | null;
get outputModalities(): string | null;
get capabilities(): string | null;
get supportsToolCalling(): boolean | null;
download(progressCallback?: (progress: number) => void): Promise<void>;
get path(): string;
load(): Promise<void>;
removeFromCache(): void;
unload(): Promise<void>;
createChatClient(): ChatClient;
createAudioClient(): AudioClient;
createEmbeddingClient(): EmbeddingClient;
/**
* Creates a ResponsesClient for interacting with the model via the Responses API.
* Unlike createChatClient/createAudioClient (which use FFI), the Responses API
* is HTTP-based, so the web service base URL must be provided.
* @param baseUrl - The base URL of the Foundry Local web service.
*/
createResponsesClient(baseUrl: string): ResponsesClient;
/**
* Variants of the model that are available. Variants of the model are optimized for different devices.
*/
get variants(): IModel[];
/**
* Select a model variant from variants to use for IModel operations.
* An IModel from `variants` can also be used directly.
* @param variant - Model variant to select. Must be one of the variants in `variants`.
* @throws Error if variant is not valid for this model.
*/
selectVariant(variant: IModel): void;
}
{"version":3,"file":"imodel.js","sourceRoot":"","sources":["../src/imodel.ts"],"names":[],"mappings":""}
export { FoundryLocalManager } from './foundryLocalManager.js';
export type { FoundryLocalConfig } from './configuration.js';
export { Catalog } from './catalog.js';
/** @internal */
export { Model } from './detail/model.js';
/** @internal */
export { ModelVariant } from './detail/modelVariant.js';
export type { IModel } from './imodel.js';
export { ChatClient, ChatClientSettings } from './openai/chatClient.js';
export { AudioClient, AudioClientSettings } from './openai/audioClient.js';
export { EmbeddingClient } from './openai/embeddingClient.js';
export { LiveAudioTranscriptionSession, LiveAudioTranscriptionOptions } from './openai/liveAudioSession.js';
export type { LiveAudioTranscriptionResponse, TranscriptionContentPart } from './openai/liveAudioTypes.js';
export { ResponsesClient, ResponsesClientSettings, getOutputText } from './openai/responsesClient.js';
export { ModelLoadManager } from './detail/modelLoadManager.js';
/** @internal */
export { CoreInterop } from './detail/coreInterop.js';
/** @internal */
export { Configuration } from './configuration.js';
export * from './types.js';
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,gBAAgB;AAChB,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,gBAAgB;AAChB,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,6BAA6B,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAE5G,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,gBAAgB;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,gBAAgB;AAChB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,cAAc,YAAY,CAAC"}
import { CoreInterop } from '../detail/coreInterop.js';
import { LiveAudioTranscriptionSession } from './liveAudioSession.js';
export declare class AudioClientSettings {
language?: string;
temperature?: number;
/**
* Serializes the settings into an OpenAI-compatible request object.
* @internal
*/
_serialize(): {
[k: string]: unknown;
};
}
/**
* Client for performing audio operations (transcription, translation) with a loaded model.
* Follows the OpenAI Audio API structure.
*/
export declare class AudioClient {
private modelId;
private coreInterop;
/**
* Configuration settings for audio operations.
*/
settings: AudioClientSettings;
/**
* @internal
* Restricted to internal use because CoreInterop is an internal implementation detail.
* Users should create clients via the Model.createAudioClient() factory method.
*/
constructor(modelId: string, coreInterop: CoreInterop);
/**
* Creates a LiveAudioTranscriptionSession for real-time audio streaming ASR.
* @returns A LiveAudioTranscriptionSession instance.
*/
createLiveTranscriptionSession(): LiveAudioTranscriptionSession;
/**
* Validates that the audio file path is a non-empty string.
* @internal
*/
private validateAudioFilePath;
/**
* Transcribes audio into the input language.
* @param audioFilePath - Path to the audio file to transcribe.
* @returns The transcription result.
* @throws Error - If audioFilePath is invalid or transcription fails.
*/
transcribe(audioFilePath: string): Promise<any>;
/**
* Transcribes audio into the input language using streaming, returning an async iterable of chunks.
* @param audioFilePath - Path to the audio file to transcribe.
* @returns An async iterable that yields parsed streaming transcription chunks.
* @throws Error - If audioFilePath is invalid, or streaming fails.
*
* @example
* ```typescript
* for await (const chunk of audioClient.transcribeStreaming('recording.wav')) {
* process.stdout.write(chunk.text);
* }
* ```
*/
transcribeStreaming(audioFilePath: string): AsyncIterable<any>;
}
{"version":3,"file":"audioClient.js","sourceRoot":"","sources":["../../src/openai/audioClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEtE,MAAM,OAAO,mBAAmB;IAC5B,QAAQ,CAAU;IAClB,WAAW,CAAU;IAErB;;;OAGG;IACH,UAAU;QACN,6BAA6B;QAC7B,MAAM,MAAM,GAAQ;YAChB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW;SAChC,CAAC;QAEF,uCAAuC;QACvC,MAAM,QAAQ,GAA2B,EAAE,CAAC;QAC5C,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,QAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,CAA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AAE,CAAC;wCACzB,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;wCAClB,IAAI,GAAG,CAAC,CAAC;oCACb,CAAC;oCACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gCAClC,CAAC;gCACD,IAAI,KAAK,EAAE,CAAC;oCACR,MAAM,KAAK,CAAC;gCAChB,CAAC;gCACD,IAAI,IAAI,IAAI,SAAS,EAAE,CAAC;oCACpB,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gCAC5C,CAAC;gCACD,wCAAwC;gCACxC,MAAM,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,EAAE,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;4BACrD,CAAC;wBACL,CAAC;gCAAS,CAAC;4BACP,YAAY,GAAG,KAAK,CAAC;wBACzB,CAAC;oBACL,CAAC;oBACD,KAAK,CAAC,MAAM;wBACR,kDAAkD;wBAClD,yDAAyD;wBACzD,8DAA8D;wBAC9D,0DAA0D;wBAC1D,gCAAgC;wBAChC,SAAS,GAAG,IAAI,CAAC;wBACjB,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;wBAClB,IAAI,GAAG,CAAC,CAAC;wBACT,IAAI,OAAO,EAAE,CAAC;4BACV,MAAM,CAAC,GAAG,OAAO,CAAC;4BAClB,OAAO,GAAG,IAAI,CAAC;4BACf,CAAC,EAAE,CAAC;wBACR,CAAC;wBACD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;oBAC5C,CAAC;iBACJ,CAAC;YACN,CAAC;SACJ,CAAC;IACN,CAAC;CACJ"}
import { CoreInterop } from '../detail/coreInterop.js';
import { ResponseFormat, ToolChoice } from '../types.js';
export declare class ChatClientSettings {
frequencyPenalty?: number;
maxTokens?: number;
n?: number;
temperature?: number;
presencePenalty?: number;
randomSeed?: number;
topK?: number;
topP?: number;
responseFormat?: ResponseFormat;
toolChoice?: ToolChoice;
/**
* Serializes the settings into an OpenAI-compatible request object.
* @internal
*/
_serialize(): any;
/**
* Validates that the provided ResponseFormat object is well-formed.
* @internal
* @param format
*/
private validateResponseFormat;
/**
* Validates that the provided ToolChoice object is well-formed.
* @internal
* @param choice
*/
private validateToolChoice;
}
/**
* Client for performing chat completions with a loaded model.
* Follows the OpenAI Chat Completion API structure.
*/
export declare class ChatClient {
private modelId;
private coreInterop;
/**
* Configuration settings for chat completions.
*/
settings: ChatClientSettings;
/**
* @internal
* Restricted to internal use because CoreInterop is an internal implementation detail.
* Users should create clients via the Model.createChatClient() factory method.
*/
constructor(modelId: string, coreInterop: CoreInterop);
/**
* Validates that messages array is properly formed.
* @internal
*/
private validateMessages;
/**
* Validates that tools array is properly formed.
* @internal
*/
private validateTools;
/**
* Performs a synchronous chat completion.
* @param messages - An array of message objects (e.g., { role: 'user', content: 'Hello' }).
* @param tools - An array of tool objects (e.g. { type: 'function', function: { name: 'get_apps', description: 'Returns a list of apps available on the system' } }).
* @returns The chat completion response object.
* @throws Error - If messages or tools are invalid or completion fails.
*/
completeChat(messages: any[]): Promise<any>;
completeChat(messages: any[], tools: any[]): Promise<any>;
/**
* Performs a streaming chat completion, returning an async iterable of chunks.
* @param messages - An array of message objects.
* @param tools - An optional array of tool objects.
* @returns An async iterable that yields parsed streaming response chunks.
* @throws Error - If messages or tools are invalid, or streaming fails.
*
* @example
* ```typescript
* // Without tools:
* for await (const chunk of chatClient.completeStreamingChat(messages)) {
* const content = chunk.choices?.[0]?.delta?.content;
* if (content) process.stdout.write(content);
* }
*
* // With tools:
* for await (const chunk of chatClient.completeStreamingChat(messages, tools)) {
* const content = chunk.choices?.[0]?.delta?.content;
* if (content) process.stdout.write(content);
* }
* ```
*/
completeStreamingChat(messages: any[]): AsyncIterable<any>;
completeStreamingChat(messages: any[], tools: any[]): AsyncIterable<any>;
}
{"version":3,"file":"chatClient.js","sourceRoot":"","sources":["../../src/openai/ch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a loaded model.
* Follows the OpenAI Embeddings API structure.
*/
export declare class EmbeddingClient {
private modelId;
private coreInterop;
/**
* @internal
* Restricted to internal use because CoreInterop is an internal implementation detail.
* Users should create clients via the Model.createEmbeddingClient() factory method.
*/
constructor(modelId: string, coreInterop: CoreInterop);
/**
* Validates that the input text is a non-empty string.
* @internal
*/
private validateInput;
/**
* Validates that the inputs array is non-empty and all elements are non-empty strings.
* @internal
*/
private validateInputs;
/**
* Sends an embedding request and parses the response.
* @internal
*/
private executeRequest;
/**
* Generates embeddings for the given input text.
* @param input - The text to generate embeddings for.
* @returns The embedding response containing the embedding vector.
*/
generateEmbedding(input: string): Promise<any>;
/**
* Generates embeddings for multiple input texts in a single request.
* @param inputs - The texts to generate embeddings for.
* @returns The embedding response containing one embedding vector per input.
*/
generateEmbeddings(inputs: string[]): Promise<any>;
}
/**
* Client for generating text embeddings with a loaded model.
* Follows the OpenAI Embeddings API structure.
*/
export class EmbeddingClient {
modelId;
coreInterop;
/**
* @internal
* Restricted to internal use because CoreInterop is an internal implementation detail.
* Users should create clients via the Model.createEmbeddingClient() factory method.
*/
constructor(modelId, coreInterop) {
this.modelId = modelId;
this.coreInterop = coreInterop;
}
/**
* Validates that the input text is a non-empty string.
* @internal
*/
validateInput(input) {
if (typeof input !== 'string' || input.trim() === '') {
throw new Error('Input must be a non-empty string.');
}
}
/**
* Validates that the inputs array is non-empty and all elements are non-empty strings.
* @internal
*/
validateInputs(inputs) {
if (!inputs || !Array.isArray(inputs) || inputs.length === 0) {
throw new Error('Inputs must be a non-empty array of strings.');
}
for (const input of inputs) {
this.validateInput(input);
}
}
/**
* Sends an embedding request and parses the response.
* @internal
*/
executeRequest(input) {
const request = {
model: this.modelId,
input,
};
try {
const response = this.coreInterop.executeCommand('embeddings', {
Params: { OpenAICreateRequest: JSON.stringify(request) }
});
return JSON.parse(response);
}
catch (error) {
throw new Error(`Embedding generation failed for model '${this.modelId}': ${error instanceof Error ? error.message : String(error)}`, { cause: error });
}
}
/**
* Generates embeddings for the given input text.
* @param input - The text to generate embeddings for.
* @returns The embedding response containing the embedding vector.
*/
async generateEmbedding(input) {
this.validateInput(input);
return this.executeRequest(input);
}
/**
* Generates embeddings for multiple input texts in a single request.
* @param inputs - The texts to generate embeddings for.
* @returns The embedding response containing one embedding vector per input.
*/
async generateEmbeddings(inputs) {
this.validateInputs(inputs);
return this.executeRequest(inputs);
}
}
//# sourceMappingURL=embeddingClient.js.map
{"version":3,"file":"embeddingClient.js","sourceRoot":"","sources":["../../src/openai/embeddingClient.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,eAAe;IAChB,OAAO,CAAS;IAChB,WAAW,CAAc;IAEjC;;;;OAIG;IACH,YAAY,OAAe,EAAE,WAAwB;QACjD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAED;;;OAGG;IACK,aAAa,CAAC,KAAa;QAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACzD,CAAC;IACL,CAAC;IAED;;;OAGG;IACK,cAAc,CAAC,MAAgB;QACnC,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QACpE,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YACzB,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACL,CAAC;IAED;;;OAGG;IACK,cAAc,CAAC,KAAwB;QAC3C,MAAM,OAAO,GAAG;YACZ,KAAK,EAAE,IAAI,CAAC,OAAO;YACnB,KAAK;SACR,CAAC;QAEF,IAAI,CAAC;YACD,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,YAAY,EAAE;gBAC3D,MAAM,EAAE,EAAE,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;aAC3D,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACX,0CAA0C,IAAI,CAAC,OAAO,MAAM,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EACpH,EAAE,KAAK,EAAE,KAAK,EAAE,CACnB,CAAC;QACN,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,iBAAiB,CAAC,KAAa;QACxC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,kBAAkB,CAAC,MAAgB;QAC5C,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;CACJ"}
import { CoreInterop } from '../detail/coreInterop.js';
import { LiveAudioTranscriptionResponse } from './liveAudioTypes.js';
/**
* Audio format settings for a streaming session.
* Must be configured before calling start().
* Settings are frozen once the session starts.
*/
export declare class LiveAudioTranscriptionOptions {
/** PCM sample rate in Hz. Default: 16000. */
sampleRate: number;
/** Number of audio channels. Default: 1 (mono). */
channels: number;
/** Bits per sample. Default: 16. */
bitsPerSample: number;
/** Optional BCP-47 language hint (e.g., "en", "zh"). */
language?: string;
/** Maximum number of audio chunks buffered in the internal push queue. Default: 100. */
pushQueueCapacity: number;
/** @internal Create a frozen copy of these settings. */
snapshot(): LiveAudioTranscriptionOptions;
}
/**
* Client for real-time audio streaming ASR (Automatic Speech Recognition).
* Audio data from a microphone (or other source) is pushed in as PCM chunks,
* and transcription results are returned as an async iterable.
*
* Mirrors the C# LiveAudioTranscriptionSession.
*/
export declare class LiveAudioTranscriptionSession {
private modelId;
private coreInterop;
private sessionHandle;
private started;
private stopped;
private outputQueue;
private pushQueue;
private pushLoopPromise;
private activeSettings;
private sessionAbortController;
private streamConsumed;
/**
* Configuration settings for the streaming session.
* Must be configured before calling start(). Settings are snapshotted at start();
* changes made after start() are ignored for the current session.
*/
settings: LiveAudioTranscriptionOptions;
/**
* @internal
* Users should create sessions via AudioClient.createLiveTranscriptionSession().
*/
constructor(modelId: string, coreInterop: CoreInterop);
/**
* Start a real-time audio streaming session.
* Must be called before append() or getStream().
* Settings are frozen after this call.
*/
start(): Promise<void>;
/**
* Push a chunk of raw PCM audio data to the streaming session.
* Can be called from any context. Chunks are internally queued
* and serialized to native core one at a time.
*
* @param pcmData - Raw PCM audio bytes matching the configured format.
*/
append(pcmData: Uint8Array): Promise<void>;
/**
* Internal loop that drains the push queue and sends chunks to native core one at a time.
* Terminates the session on any native error.
* @internal
*/
private pushLoop;
/**
* Get the async iterable of transcription results.
* Results arrive as the native ASR engine processes audio data.
*
* Usage:
* ```ts
* for await (const result of session.getStream()) {
* console.log(result.content[0].text);
* }
* ```
*/
getStream(): AsyncGenerator<LiveAudioTranscriptionResponse>;
/**
* Signal end-of-audio and stop the streaming session.
* Any remaining buffered audio in the push queue will be drained to native core first.
* Final results are delivered through getStream() before it completes.
*/
stop(): Promise<void>;
/**
* Dispose the client and stop any active session.
* Safe to call multiple times.
*/
dispose(): Promise<void>;
}
import { parseTranscriptionResult, tryParseCoreError } from './liveAudioTypes.js';
/**
* Audio format settings for a streaming session.
* Must be configured before calling start().
* Settings are frozen once the session starts.
*/
export class LiveAudioTranscriptionOptions {
/** PCM sample rate in Hz. Default: 16000. */
sampleRate = 16000;
/** Number of audio channels. Default: 1 (mono). */
channels = 1;
/** Bits per sample. Default: 16. */
bitsPerSample = 16;
/** Optional BCP-47 language hint (e.g., "en", "zh"). */
language;
/** Maximum number of audio chunks buffered in the internal push queue. Default: 100. */
pushQueueCapacity = 100;
/** @internal Create a frozen copy of these settings. */
snapshot() {
const copy = new LiveAudioTranscriptionOptions();
copy.sampleRate = this.sampleRate;
copy.channels = this.channels;
copy.bitsPerSample = this.bitsPerSample;
copy.language = this.language;
copy.pushQueueCapacity = this.pushQueueCapacity;
return Object.freeze(copy);
}
}
/**
* Internal async queue that acts like C#'s Channel<T>.
* Supports a single consumer reading via async iteration and multiple producers writing.
* @internal
*/
class AsyncQueue {
queue = [];
waitingResolve = null;
completed = false;
completionError = null;
maxCapacity;
backpressureQueue = [];
constructor(maxCapacity = Infinity) {
this.maxCapacity = maxCapacity;
}
/** Push an item. If at capacity, waits until space is available. */
async write(item) {
if (this.completed) {
throw new Error('Cannot write to a completed queue.');
}
if (this.waitingResolve) {
const resolve = this.waitingResolve;
this.waitingResolve = null;
resolve({ value: item, done: false });
return;
}
while (this.queue.length >= this.maxCapacity) {
await new Promise((resolve) => {
this.backpressureQueue.push(resolve);
});
}
if (this.completed) {
throw new Error('Cannot write to a completed queue.');
}
this.queue.push(item);
}
/** Push an item synchronously (no backpressure wait). Returns false if completed or at capacity. */
tryWrite(item) {
if (this.completed)
return false;
if (this.waitingResolve) {
const resolve = this.waitingResolve;
this.waitingResolve = null;
resolve({ value: item, done: false });
return true;
}
if (this.queue.length >= this.maxCapacity) {
return false;
}
this.queue.push(item);
return true;
}
/** Signal that no more items will be written. */
complete(error) {
if (this.completed)
return;
this.completed = true;
this.completionError = error ?? null;
// Release all blocked writers
for (const resolve of this.backpressureQueue) {
resolve();
}
this.backpressureQueue = [];
if (this.waitingResolve) {
const resolve = this.waitingResolve;
this.waitingResolve = null;
resolve({ value: undefined, done: true });
}
}
get error() {
return this.completionError;
}
/** Async iterator for consuming items. */
async *[Symbol.asyncIterator]() {
while (true) {
if (this.backpressureQueue.length > 0 && this.queue.length < this.maxCapacity) {
const resolve = this.backpressureQueue.shift();
resolve();
}
if (this.queue.length > 0) {
yield this.queue.shift();
continue;
}
if (this.completed) {
if (this.completionError) {
throw this.completionError;
}
return;
}
const result = await new Promise((resolve) => {
this.waitingResolve = resolve;
});
if (result.done) {
if (this.completionError) {
throw this.completionError;
}
return;
}
yield result.value;
}
}
}
/**
* Client for real-time audio streaming ASR (Automatic Speech Recognition).
* Audio data from a microphone (or other source) is pushed in as PCM chunks,
* and transcription results are returned as an async iterable.
*
* Mirrors the C# LiveAudioTranscriptionSession.
*/
export class LiveAudioTranscriptionSession {
modelId;
coreInterop;
sessionHandle = null;
started = false;
stopped = false;
outputQueue = null;
pushQueue = null;
pushLoopPromise = null;
activeSettings = null;
sessionAbortController = null;
streamConsumed = false;
/**
* Configuration settings for the streaming session.
* Must be configured before calling start(). Settings are snapshotted at start();
* changes made after start() are ignored for the current session.
*/
settings = new LiveAudioTranscriptionOptions();
/**
* @internal
* Users should create sessions via AudioClient.createLiveTranscriptionSession().
*/
constructor(modelId, coreInterop) {
this.modelId = modelId;
this.coreInterop = coreInterop;
}
/**
* Start a real-time audio streaming session.
* Must be called before append() or getStream().
* Settings are frozen after this call.
*/
async start() {
if (this.started) {
throw new Error('Streaming session already started. Call stop() first.');
}
this.activeSettings = this.settings.snapshot();
this.outputQueue = new AsyncQueue();
this.pushQueue = new AsyncQueue(this.activeSettings.pushQueueCapacity);
this.streamConsumed = false;
const params = {
Model: this.modelId,
SampleRate: this.activeSettings.sampleRate.toString(),
Channels: this.activeSettings.channels.toString(),
BitsPerSample: this.activeSettings.bitsPerSample.toString(),
};
if (this.activeSettings.language) {
params['Language'] = this.activeSettings.language;
}
try {
const response = this.coreInterop.executeCommand("audio_stream_start", {
Params: params
});
this.sessionHandle = response;
if (!this.sessionHandle) {
throw new Error('Native core did not return a session handle.');
}
}
catch (error) {
const err = new Error(`Error starting audio stream session: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
this.outputQueue.complete(err);
throw err;
}
this.started = true;
this.stopped = false;
this.sessionAbortController = new AbortController();
this.pushLoopPromise = this.pushLoop();
}
/**
* Push a chunk of raw PCM audio data to the streaming session.
* Can be called from any context. Chunks are internally queued
* and serialized to native core one at a time.
*
* @param pcmData - Raw PCM audio bytes matching the configured format.
*/
async append(pcmData) {
if (!this.started || this.stopped) {
throw new Error('No active streaming session. Call start() first.');
}
const copy = new Uint8Array(pcmData.length);
copy.set(pcmData);
await this.pushQueue.write(copy);
}
/**
* Internal loop that drains the push queue and sends chunks to native core one at a time.
* Terminates the session on any native error.
* @internal
*/
async pushLoop() {
try {
for await (const audioData of this.pushQueue) {
if (this.sessionAbortController?.signal.aborted) {
break;
}
try {
const responseData = this.coreInterop.executeCommandWithBinary("audio_stream_push", {
Params: {
SessionHandle: this.sessionHandle,
}
}, audioData);
// Parse transcription result from push response and surface it
if (responseData) {
try {
const result = parseTranscriptionResult(responseData);
const text = result.content?.[0]?.text;
if (text !== undefined && text !== null && text !== '') {
this.outputQueue?.tryWrite(result);
}
}
catch {
// Non-fatal: log and continue if response isn't a transcription result
}
}
}
catch (error) {
const errorMsg = error instanceof Error ? error.message : String(error);
const errorInfo = tryParseCoreError(errorMsg);
const fatalError = new Error(`Push failed (code=${errorInfo?.code ?? 'UNKNOWN'}): ${errorMsg}`, { cause: error });
this.stopped = true;
this.started = false;
this.pushQueue?.complete(fatalError);
this.outputQueue?.complete(fatalError);
return;
}
}
}
catch (error) {
if (this.sessionAbortController?.signal.aborted) {
return;
}
const err = error instanceof Error ? error : new Error(String(error));
this.outputQueue?.complete(new Error('Push loop terminated unexpectedly.', { cause: err }));
}
}
/**
* Get the async iterable of transcription results.
* Results arrive as the native ASR engine processes audio data.
*
* Usage:
* ```ts
* for await (const result of session.getStream()) {
* console.log(result.content[0].text);
* }
* ```
*/
async *getStream() {
if (!this.outputQueue) {
throw new Error('No active streaming session. Call start() first.');
}
if (this.streamConsumed) {
throw new Error('getStream() can only be called once per session. The output stream has already been consumed.');
}
this.streamConsumed = true;
for await (const item of this.outputQueue) {
yield item;
}
}
/**
* Signal end-of-audio and stop the streaming session.
* Any remaining buffered audio in the push queue will be drained to native core first.
* Final results are delivered through getStream() before it completes.
*/
async stop() {
if (!this.started || this.stopped) {
return;
}
this.stopped = true;
this.pushQueue?.complete();
if (this.pushLoopPromise) {
await this.pushLoopPromise;
}
this.sessionAbortController?.abort();
let stopError = null;
try {
const responseData = this.coreInterop.executeCommand("audio_stream_stop", {
Params: { SessionHandle: this.sessionHandle }
});
// Parse final transcription from stop response
if (responseData) {
try {
const finalResult = parseTranscriptionResult(responseData);
if (finalResult.content?.[0]?.text) {
this.outputQueue?.tryWrite(finalResult);
}
}
catch {
// Non-fatal
}
}
}
catch (error) {
stopError = error instanceof Error ? error : new Error(String(error));
}
this.sessionHandle = null;
this.started = false;
this.sessionAbortController = null;
this.outputQueue?.complete();
if (stopError) {
throw new Error(`Error stopping audio stream session: ${stopError.message}`, { cause: stopError });
}
}
/**
* Dispose the client and stop any active session.
* Safe to call multiple times.
*/
async dispose() {
try {
if (this.started && !this.stopped) {
await this.stop();
}
}
catch {
// Swallow errors during best-effort cleanup to keep dispose() silent.
}
}
}
//# sourceMappingURL=liveAudioSession.js.map
{"version":3,"file":"liveAudioSession.js","sourceRoot":"","sources":["../../src/openai/liveAudioSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAkC,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAElH;;;;GAIG;AACH,MAAM,OAAO,6BAA6B;IACtC,6CAA6C;IAC7C,UAAU,GAAW,KAAK,CAAC;IAC3B,mDAAmD;IACnD,QAAQ,GAAW,CAAC,CAAC;IACrB,oCAAoC;IACpC,aAAa,GAAW,EAAE,CAAC;IAC3B,wDAAwD;IACxD,QAAQ,CAAU;IAClB,wFAAwF;IACxF,iBAAiB,GAAW,GAAG,CAAC;IAEhC,wDAAwD;IACxD,QAAQ;QACJ,MA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,GAAG,IAAI,CAAC;QAEnC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC;QAE7B,IAAI,SAAS,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACX,wCAAwC,SAAS,CAAC,OAAO,EAAE,EAC3D,EAAE,KAAK,EAAE,SAAS,EAAE,CACvB,CAAC;QACN,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,OAAO;QAChB,IAAI,CAAC;YACD,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAChC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YACtB,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACL,sEAAsE;QAC1E,CAAC;IACL,CAAC;CACJ"}
/**
* Types for real-time audio streaming transcription results and structured errors.
* Mirrors the C# LiveAudioTranscriptionResponse (extends ConversationItem) and CoreErrorResponse.
*/
/**
* A content part within a transcription result.
* Follows the OpenAI Realtime API's ContentPart pattern.
*/
export interface TranscriptionContentPart {
/** The transcribed text. */
text?: string | null;
/** Alias for text, matching the OpenAI Realtime API's ContentPart.transcript field. */
transcript?: string | null;
}
/**
* A transcription result from a real-time audio streaming session.
* Shaped like the OpenAI Realtime API's ConversationItem so that
* customers access text via result.content[0].text or result.content[0].transcript.
*/
export interface LiveAudioTranscriptionResponse {
/** Unique identifier for this result (if available). */
id?: string | null;
/** Whether this is a partial (interim) or final result for this segment. */
is_final: boolean;
/** The transcription content parts. Access text via content[0].text or content[0].transcript. */
content: TranscriptionContentPart[];
/** Start time offset of this segment in the audio stream (seconds). */
start_time?: number | null;
/** End time offset of this segment in the audio stream (seconds). */
end_time?: number | null;
}
/**
* Parse raw Core JSON response into a LiveAudioTranscriptionResponse.
* Maps the flat Core format (text, is_final, start_time, end_time) into
* the ConversationItem-shaped result with content[0].text and content[0].transcript.
* @internal
*/
export declare function parseTranscriptionResult(json: string): LiveAudioTranscriptionResponse;
/**
* Structured error response from native core audio streaming commands.
*/
export interface CoreErrorResponse {
/** Machine-readable error code. */
code: string;
/** Human-readable error message. */
message: string;
/** Whether this error is transient and may succeed on retry. */
isTransient: boolean;
}
/**
* Attempt to parse a native error string as a structured CoreErrorResponse.
* Handles both raw JSON and CoreInterop-prefixed messages
* (e.g., "Command 'X' failed: {...}").
* Returns null if no valid CoreErrorResponse JSON is found.
* @internal
*/
export declare function tryParseCoreError(errorString: string): CoreErrorResponse | null;
/**
* Types for real-time audio streaming transcription results and structured errors.
* Mirrors the C# LiveAudioTranscriptionResponse (extends ConversationItem) and CoreErrorResponse.
*/
/**
* Parse raw Core JSON response into a LiveAudioTranscriptionResponse.
* Maps the flat Core format (text, is_final, start_time, end_time) into
* the ConversationItem-shaped result with content[0].text and content[0].transcript.
* @internal
*/
export function parseTranscriptionResult(json) {
const raw = JSON.parse(json);
return {
id: raw.id ?? null,
is_final: raw.is_final ?? false,
start_time: raw.start_time ?? null,
end_time: raw.end_time ?? null,
content: [
{
text: raw.text ?? '',
transcript: raw.text ?? ''
}
]
};
}
/**
* Attempt to parse a native error string as a structured CoreErrorResponse.
* Handles both raw JSON and CoreInterop-prefixed messages
* (e.g., "Command 'X' failed: {...}").
* Returns null if no valid CoreErrorResponse JSON is found.
* @internal
*/
export function tryParseCoreError(errorString) {
// Try raw JSON first, then extract JSON after "failed: " prefix
const candidates = [errorString];
const prefixIdx = errorString.indexOf('failed: ');
if (prefixIdx !== -1) {
candidates.push(errorString.substring(prefixIdx + 8));
}
for (const candidate of candidates) {
try {
const parsed = JSON.parse(candidate);
if (typeof parsed.code === 'string' && typeof parsed.message === 'string' && typeof parsed.isTransient === 'boolean') {
return parsed;
}
}
catch {
// not valid JSON, try next candidate
}
}
return null;
}
//# sourceMappingURL=liveAudioTypes.js.map
{"version":3,"file":"liveAudioTypes.js","sourceRoot":"","sources":["../../src/openai/liveAudioTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+BH;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,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oice, TruncationStrategy, TextConfig, ReasoningConfig, StreamingEvent, InputItemsListResponse, DeleteResponseResult, ResponseInputItem } from '../types.js';
/**
* Extracts the text content from an assistant message in a Response.
* Equivalent to OpenAI Python SDK's `response.output_text`.
*
* @param response - The Response object.
* @returns The concatenated text from the first assistant message, or an empty string.
*/
export declare function getOutputText(response: ResponseObject): string;
/**
* Configuration settings for the Responses API client.
* Properties use camelCase in JS and are serialized to snake_case for the API.
*/
export declare class ResponsesClientSettings {
/** System-level instructions to guide the model. */
instructions?: string;
temperature?: number;
topP?: number;
maxOutputTokens?: number;
frequencyPenalty?: number;
presencePenalty?: number;
toolChoice?: ResponseToolChoice;
truncation?: TruncationStrategy;
parallelToolCalls?: boolean;
store?: boolean;
metadata?: Record<string, string>;
reasoning?: ReasoningConfig;
text?: TextConfig;
seed?: number;
/**
* Serializes settings into an OpenAI Responses API-compatible request object.
* @internal
*/
_serialize(): Partial<ResponseCreateParams>;
}
/**
* Client for the OpenAI Responses API served by Foundry Local's embedded web service.
*
* Unlike ChatClient/AudioClient (which use FFI via CoreInterop), the Responses API
* is HTTP-only. This client uses fetch() for all operations and parses Server-Sent Events
* for streaming.
*
* Create via `FoundryLocalManager.createResponsesClient()` or
* `model.createResponsesClient(baseUrl)`.
*
* @example
* ```typescript
* const manager = FoundryLocalManager.create({ appName: 'MyApp' });
* manager.startWebService();
* const client = manager.createResponsesClient('my-model-id');
*
* // Non-streaming
* const response = await client.create('Hello, world!');
* console.log(response.output);
*
* // Streaming
* await client.createStreaming('Tell me a story', (event) => {
* if (event.type === 'response.output_text.delta') {
* process.stdout.write(event.delta);
* }
* });
* ```
*/
export declare class ResponsesClient {
private baseUrl;
private modelId?;
/**
* Configuration settings for responses.
*/
settings: ResponsesClientSettings;
/**
* @param baseUrl - The base URL of the Foundry Local web service (e.g. "http://127.0.0.1:5273").
* @param modelId - Optional default model ID. Can be overridden per-request via options.
*/
constructor(baseUrl: string, modelId?: string);
/**
* Creates a model response (non-streaming).
* @param input - A string prompt or array of input items.
* @param options - Additional request parameters that override client settings.
* The `model` field is optional here if a default model was set in the constructor.
* @returns The completed Response object. Check `response.status` and `response.error`
* even on success — the server returns HTTP 200 for model-level failures too.
*/
create(input: string | ResponseInputItem[], options?: Partial<ResponseCreateParams>): Promise<ResponseObject>;
/**
* Creates a model response with streaming via Server-Sent Events.
* @param input - A string prompt or array of input items.
* @param callback - Called for each streaming event received.
* @param options - Additional request parameters that override client settings.
*/
createStreaming(input: string | ResponseInputItem[], callback: (event: StreamingEvent) => void, options?: Partial<ResponseCreateParams>): Promise<void>;
/**
* Retrieves a stored response by ID.
* @param responseId - The ID of the response to retrieve.
* @returns The Response object, or throws if not found.
*/
get(responseId: string): Promise<ResponseObject>;
/**
* Deletes a stored response by ID.
* @param responseId - The ID of the response to delete.
* @returns The deletion result.
*/
delete(responseId: string): Promise<DeleteResponseResult>;
/**
* Cancels an in-progress response.
* @param responseId - The ID of the response to cancel.
* @returns The cancelled Response object.
*/
cancel(responseId: string): Promise<ResponseObject>;
/**
* Retrieves input items for a stored response.
* @param responseId - The ID of the response.
* @returns The list of input items.
*/
getInputItems(responseId: string): Promise<InputItemsListResponse>;
/**
* Builds the full request body by merging input, settings, and per-call options.
*/
private buildRequest;
/**
* Validates that input is a non-empty string or a non-empty array of items.
*/
private validateInput;
/**
* Validates that tools array is properly formed.
* Follows the same pattern as ChatClient.validateTools.
*/
private validateTools;
/**
* Validates that a string ID parameter is non-empty and within length bounds.
*/
private validateId;
/**
* Performs a fetch and parses the JSON response, handling errors.
*/
private fetchJson;
/**
* Low-level fetch wrapper with error handling.
*/
private doFetch;
/**
* Parses a Server-Sent Events stream from the fetch response body.
* Format: "event: {type}\ndata: {json}\n\n"
* Terminal signal: "data: [DONE]\n\n"
* Per SSE spec, multiple data: lines within a single event are joined with \n.
*/
private parseSSEStream;
}
{"version":3,"file":"responsesClient.js","sourceRoot":"","sources":["../../src/openai/responsesClient.ts"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AACH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,KAAK,OAAO,EAAE,CAAC;4BAC1B,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;wBACvB,CAAC;wBACD,oEAAoE;oBACxE,CAAC;oBACD,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;oBAE1E,IAAI,SAAS,EAAE,CAAC;wBACZ,IAAI,CAAC;4BACD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAmB,CAAC;4BACvD,OAAO,CAAC,MAAM,CAAC,CAAC;wBACpB,CAAC;wBAAC,OAAO,CAAC,EAAE,CAAC;4BACT,UAAU,GAAG,IAAI,KAAK,CAClB,oCAAoC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAChF,EAAE,KAAK,EAAE,CAAC,EAAE,CACf,CAAC;wBACN,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;gBAAS,CAAC;YACP,MAAM,CAAC,WAAW,EAAE,CAAC;QACzB,CAAC;QAED,IAAI,UAAU,EAAE,CAAC;YACb,MAAM,UAAU,CAAC;QACrB,CAAC;IACL,CAAC;CACJ"}
export declare enum DeviceType {
Invalid = "Invalid",
CPU = "CPU",
GPU = "GPU",
NPU = "NPU"
}
export interface PromptTemplate {
system?: string | null;
user?: string | null;
assistant: string;
prompt: string;
}
export interface Runtime {
deviceType: DeviceType;
executionProvider: string;
}
export interface Parameter {
name: string;
value?: string | null;
}
export interface ModelSettings {
parameters?: Parameter[] | null;
}
export interface ModelInfo {
id: string;
name: string;
version: number;
alias: string;
displayName?: string | null;
providerType: string;
uri: string;
modelType: string;
promptTemplate?: PromptTemplate | null;
publisher?: string | null;
modelSettings?: ModelSettings | null;
license?: string | null;
licenseDescription?: string | null;
cached: boolean;
task?: string | null;
runtime?: Runtime | null;
fileSizeMb?: number | null;
supportsToolCalling?: boolean | null;
maxOutputTokens?: number | null;
minFLVersion?: string | null;
createdAtUnix: number;
contextLength?: number | null;
inputModalities?: string | null;
outputModalities?: string | null;
capabilities?: string | null;
}
export interface ResponseFormat {
type: string;
jsonSchema?: string;
larkGrammar?: string;
}
export interface ToolChoice {
type: string;
name?: string;
}
/** Describes a discoverable execution provider bootstrapper. */
export interface EpInfo {
/** The identifier of the bootstrapper/execution provider (e.g. "CUDAExecutionProvider"). */
name: string;
/** True if this EP has already been successfully downloaded and registered. */
isRegistered: boolean;
}
/** Result of an explicit EP download and registration operation. */
export interface EpDownloadResult {
/** True if all requested EPs were successfully downloaded and registered. */
success: boolean;
/** Human-readable status message. */
status: string;
/** Names of EPs that were successfully registered. */
registeredEps: string[];
/** Names of EPs that failed to register. */
failedEps: string[];
}
/** Status of a Response object. */
export type ResponseStatus = 'queued' | 'in_progress' | 'completed' | 'failed' | 'incomplete' | 'cancelled';
/** Role of a message in the Responses API. */
export type MessageRole = 'system' | 'user' | 'assistant' | 'developer';
/** Status of an individual response item. */
export type ResponseItemStatus = 'in_progress' | 'completed' | 'incomplete';
/** Controls which tool the model should use. */
export type ResponseToolChoice = 'none' | 'auto' | 'required' | ResponseToolChoiceFunction;
export interface ResponseToolChoiceFunction {
type: 'function';
name: string;
}
/** Truncation strategy. */
export type TruncationStrategy = 'auto' | 'disabled';
/** Service tier. */
export type ServiceTier = 'default' | 'auto' | 'flex' | 'priority';
export interface InputTextContent {
type: 'input_text';
text: string;
}
export interface OutputTextContent {
type: 'output_text';
text: string;
annotations?: Annotation[];
logprobs?: LogProb[];
}
export interface RefusalContent {
type: 'refusal';
refusal: string;
}
export type ContentPart = InputTextContent | OutputTextContent | RefusalContent;
export interface Annotation {
type: string;
start_index: number;
end_index: number;
}
export interface UrlCitationAnnotation extends Annotation {
type: 'url_citation';
url: string;
title: string;
}
export interface LogProb {
token: string;
logprob: number;
bytes?: number[];
}
export interface FunctionToolDefinition {
type: 'function';
name: string;
description?: string;
parameters?: Record<string, unknown>;
strict?: boolean;
}
export interface MessageItem {
type: 'message';
id?: string;
role: MessageRole;
content: string | ContentPart[];
status?: ResponseItemStatus;
}
export interface FunctionCallItem {
type: 'function_call';
id?: string;
call_id: string;
name: string;
arguments: string;
status?: ResponseItemStatus;
}
export interface FunctionCallOutputItem {
type: 'function_call_output';
id?: string;
call_id: string;
output: string | ContentPart[];
status?: ResponseItemStatus;
}
export interface ItemReference {
type: 'item_reference';
id: string;
}
export interface ReasoningItem {
type: 'reasoning';
id?: string;
content?: ContentPart[];
encrypted_content?: string;
summary?: string;
status?: ResponseItemStatus;
}
export type ResponseInputItem = MessageItem | FunctionCallItem | FunctionCallOutputItem | ItemReference | ReasoningItem;
export type ResponseOutputItem = MessageItem | FunctionCallItem | ReasoningItem;
export interface ReasoningConfig {
effort?: string;
summary?: string;
}
export interface TextFormat {
type: string;
name?: string;
description?: string;
schema?: unknown;
strict?: boolean;
}
export interface TextConfig {
format?: TextFormat;
verbosity?: string;
}
export interface ResponseUsage {
input_tokens: number;
output_tokens: number;
total_tokens: number;
input_tokens_details?: {
cached_tokens: number;
};
output_tokens_details?: {
reasoning_tokens: number;
};
}
export interface ResponseError {
code: string;
message: string;
}
export interface IncompleteDetails {
reason: string;
}
export interface ResponseCreateParams {
model?: string;
input?: string | ResponseInputItem[];
instructions?: string;
previous_response_id?: string;
tools?: FunctionToolDefinition[];
tool_choice?: ResponseToolChoice;
temperature?: number;
top_p?: number;
max_output_tokens?: number;
frequency_penalty?: number;
presence_penalty?: number;
truncation?: TruncationStrategy;
parallel_tool_calls?: boolean;
store?: boolean;
metadata?: Record<string, string>;
stream?: boolean;
reasoning?: ReasoningConfig;
text?: TextConfig;
seed?: number;
user?: string;
}
export interface ResponseObject {
id: string;
object: 'response';
created_at: number;
completed_at?: number | null;
failed_at?: number | null;
cancelled_at?: number | null;
status: ResponseStatus;
incomplete_details?: IncompleteDetails | null;
model: string;
previous_response_id?: string | null;
instructions?: string | null;
output: ResponseOutputItem[];
error?: ResponseError | null;
tools: FunctionToolDefinition[];
tool_choice: ResponseToolChoice;
truncation: TruncationStrategy;
parallel_tool_calls: boolean;
text: TextConfig;
top_p: number;
temperature: number;
presence_penalty: number;
frequency_penalty: number;
max_output_tokens?: number | null;
reasoning?: ReasoningConfig | null;
store: boolean;
metadata?: Record<string, string> | null;
usage?: ResponseUsage | null;
user?: string | null;
}
export interface InputItemsListResponse {
object: 'list';
data: ResponseInputItem[];
}
export interface DeleteResponseResult {
id: string;
object: string;
deleted: boolean;
}
export interface ResponseLifecycleEvent {
type: 'response.created' | 'response.queued' | 'response.in_progress' | 'response.completed' | 'response.failed' | 'response.incomplete';
response: ResponseObject;
sequence_number: number;
}
export interface OutputItemAddedEvent {
type: 'response.output_item.added';
item_id: string;
output_index: number;
item: ResponseOutputItem;
sequence_number: number;
}
export interface OutputItemDoneEvent {
type: 'response.output_item.done';
item_id: string;
output_index: number;
item: ResponseOutputItem;
sequence_number: number;
}
export interface ContentPartAddedEvent {
type: 'response.content_part.added';
item_id: string;
content_index: number;
part: ContentPart;
sequence_number: number;
}
export interface ContentPartDoneEvent {
type: 'response.content_part.done';
item_id: string;
content_index: number;
part: ContentPart;
sequence_number: number;
}
export interface OutputTextDeltaEvent {
type: 'response.output_text.delta';
item_id: string;
output_index: number;
content_index: number;
delta: string;
sequence_number: number;
}
export interface OutputTextDoneEvent {
type: 'response.output_text.done';
item_id: string;
output_index: number;
content_index: number;
text: string;
sequence_number: number;
}
export interface RefusalDeltaEvent {
type: 'response.refusal.delta';
item_id: string;
content_index: number;
delta: string;
sequence_number: number;
}
export interface RefusalDoneEvent {
type: 'response.refusal.done';
item_id: string;
content_index: number;
refusal: string;
sequence_number: number;
}
export interface FunctionCallArgsDeltaEvent {
type: 'response.function_call_arguments.delta';
item_id: string;
output_index: number;
delta: string;
sequence_number: number;
}
export interface FunctionCallArgsDoneEvent {
type: 'response.function_call_arguments.done';
item_id: string;
output_index: number;
arguments: string;
name: string;
sequence_number: number;
}
export interface StreamingErrorEvent {
type: 'error';
code?: string;
message?: string;
param?: string;
sequence_number: number;
}
export type StreamingEvent = ResponseLifecycleEvent | OutputItemAddedEvent | OutputItemDoneEvent | ContentPartAddedEvent | ContentPartDoneEvent | OutputTextDeltaEvent | OutputTextDoneEvent | RefusalDeltaEvent | RefusalDoneEvent | FunctionCallArgsDeltaEvent | FunctionCallArgsDoneEvent | StreamingErrorEvent;
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAE9C,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IAClB,iCAAmB,CAAA;IACnB,yBAAW,CAAA;IACX,yBAAW,CAAA;IACX,yBAAW,CAAA;AACf,CAAC,EALW,UAAU,KAAV,UAAU,QAKrB"}
+4
-4
{
"foundry-local-core": {
"python": "1.0.0.dev202604172003",
"nuget": "1.0.0-dev-202604172003-977b0e71"
"python": "1.1.0",
"nuget": "1.1.0"
},
"onnxruntime": {
"version": "1.24.4"
"version": "1.25.1"
},
"onnxruntime-genai": {
"version": "0.13.1"
"version": "0.13.2"
}
}

@@ -15,6 +15,7 @@ import { Model } from './detail/model.js';

lastFetch = 0;
constructor(coreInterop, modelLoadManager) {
updatePromise;
constructor(coreInterop, modelLoadManager, catalogName) {
this.coreInterop = coreInterop;
this.modelLoadManager = modelLoadManager;
this._name = this.coreInterop.executeCommand("get_catalog_name");
this._name = catalogName ?? this.coreInterop.executeCommand("get_catalog_name");
}

@@ -37,4 +38,11 @@ /**

}
// Potential network call to fetch model list
const modelListJson = this.coreInterop.executeCommand("get_model_list");
if (this.updatePromise) {
return this.updatePromise;
}
this.updatePromise = this.fetchAndPopulateModels()
.finally(() => { this.updatePromise = undefined; });
return this.updatePromise;
}
async fetchAndPopulateModels() {
const modelListJson = await this.coreInterop.executeCommandAsync("get_model_list");
let modelsInfo = [];

@@ -121,3 +129,3 @@ try {

await this.updateModels();
const cachedModelListJson = this.coreInterop.executeCommand("get_cached_models");
const cachedModelListJson = await this.coreInterop.executeCommandAsync("get_cached_models");
let cachedModelIds = [];

@@ -187,1 +195,2 @@ try {

}
//# sourceMappingURL=catalog.js.map

@@ -45,1 +45,2 @@ // Log level mapping from JS-style to C#-style

}
//# sourceMappingURL=configuration.js.map

@@ -88,2 +88,10 @@ import path from 'path';

/**
* Asynchronously execute a native command without blocking the event loop.
* Runs the native call on a libuv worker thread.
*/
executeCommandAsync(command, params) {
const dataStr = params ? JSON.stringify(params) : '';
return this.addon.executeCommandAsync(command, dataStr);
}
/**
* Execute a native command with binary data (e.g., audio PCM bytes).

@@ -103,1 +111,2 @@ * Uses the execute_command_with_binary native entry point which accepts

}
//# sourceMappingURL=coreInterop.js.map

@@ -149,2 +149,9 @@ /**

/**
* Creates an EmbeddingClient for generating text embeddings with the model.
* @returns An EmbeddingClient instance.
*/
createEmbeddingClient() {
return this.selectedVariant.createEmbeddingClient();
}
/**
* Creates a LiveAudioTranscriptionSession for real-time audio streaming ASR.

@@ -165,1 +172,2 @@ * @returns A LiveAudioTranscriptionSession instance.

}
//# sourceMappingURL=model.js.map

@@ -37,3 +37,3 @@ import packageJson from '../../package.json' with { type: "json" };

}
this.coreInterop.executeCommand("load_model", { Params: { Model: modelId } });
await this.coreInterop.executeCommandAsync("load_model", { Params: { Model: modelId } });
}

@@ -54,3 +54,3 @@ /**

}
this.coreInterop.executeCommand("unload_model", { Params: { Model: modelId } });
await this.coreInterop.executeCommandAsync("unload_model", { Params: { Model: modelId } });
}

@@ -72,3 +72,3 @@ /**

}
const response = this.coreInterop.executeCommand("list_loaded_models");
const response = await this.coreInterop.executeCommandAsync("list_loaded_models");
try {

@@ -82,1 +82,2 @@ return JSON.parse(response);

}
//# sourceMappingURL=modelLoadManager.js.map
import { ChatClient } from '../openai/chatClient.js';
import { AudioClient } from '../openai/audioClient.js';
import { LiveAudioTranscriptionSession } from '../openai/liveAudioTranscriptionClient.js';
import { EmbeddingClient } from '../openai/embeddingClient.js';
import { LiveAudioTranscriptionSession } from '../openai/liveAudioSession.js';
import { ResponsesClient } from '../openai/responsesClient.js';

@@ -93,3 +94,3 @@ /**

if (!progressCallback) {
this.coreInterop.executeCommand("download_model", request);
await this.coreInterop.executeCommandAsync("download_model", request);
}

@@ -148,2 +149,9 @@ else {

/**
* Creates an EmbeddingClient for generating text embeddings with the model.
* @returns An EmbeddingClient instance.
*/
createEmbeddingClient() {
return new EmbeddingClient(this._modelInfo.id, this.coreInterop);
}
/**
* Creates a LiveAudioTranscriptionSession for real-time audio streaming ASR.

@@ -164,1 +172,2 @@ * @returns A LiveAudioTranscriptionSession instance.

}
//# sourceMappingURL=modelVariant.js.map

@@ -12,2 +12,3 @@ import { Configuration } from './configuration.js';

static instance;
static pendingCreate;
config;

@@ -21,8 +22,18 @@ coreInterop;

this.coreInterop = new CoreInterop(this.config);
this.coreInterop.executeCommand("initialize", { Params: this.config.params });
this._modelLoadManager = new ModelLoadManager(this.coreInterop);
this._catalog = new Catalog(this.coreInterop, this._modelLoadManager);
}
initializeSync() {
this.coreInterop.executeCommand("initialize", { Params: this.config.params });
const catalogName = this.coreInterop.executeCommand("get_catalog_name");
this._catalog = new Catalog(this.coreInterop, this._modelLoadManager, catalogName);
}
async initializeAsync() {
await this.coreInterop.executeCommandAsync("initialize", { Params: this.config.params });
const catalogName = await this.coreInterop.executeCommandAsync("get_catalog_name");
this._catalog = new Catalog(this.coreInterop, this._modelLoadManager, catalogName);
}
/**
* Creates the FoundryLocalManager singleton with the provided configuration.
* Note: This method blocks the event loop during initialization.
* For non-blocking initialization, use {@link createAsync} instead.
* @param config - The configuration settings for the SDK (plain object).

@@ -40,4 +51,10 @@ * @returns The initialized FoundryLocalManager instance.

if (!FoundryLocalManager.instance) {
if (FoundryLocalManager.pendingCreate) {
throw new Error("FoundryLocalManager.createAsync() is in progress. " +
"Await that call instead of invoking create().");
}
const internalConfig = new Configuration(config);
FoundryLocalManager.instance = new FoundryLocalManager(internalConfig);
const manager = new FoundryLocalManager(internalConfig);
manager.initializeSync();
FoundryLocalManager.instance = manager;
}

@@ -47,2 +64,35 @@ return FoundryLocalManager.instance;

/**
* Creates the FoundryLocalManager singleton with the provided configuration.
* Native command execution is performed asynchronously to avoid blocking the
* event loop during initialization. Note that some synchronous setup (e.g.,
* loading the native addon) still occurs before the first await.
* @param config - The configuration settings for the SDK (plain object).
* @returns A promise that resolves to the initialized FoundryLocalManager instance.
* @example
* ```typescript
* const manager = await FoundryLocalManager.createAsync({
* appName: 'MyApp',
* logLevel: 'info'
* });
* ```
*/
static createAsync(config) {
if (FoundryLocalManager.instance) {
return Promise.resolve(FoundryLocalManager.instance);
}
if (!FoundryLocalManager.pendingCreate) {
const internalConfig = new Configuration(config);
const manager = new FoundryLocalManager(internalConfig);
FoundryLocalManager.pendingCreate = manager.initializeAsync()
.then(() => {
FoundryLocalManager.instance = manager;
return manager;
})
.finally(() => {
FoundryLocalManager.pendingCreate = undefined;
});
}
return FoundryLocalManager.pendingCreate;
}
/**
* Gets the Catalog instance for discovering and managing models.

@@ -173,1 +223,2 @@ * @returns The Catalog instance.

}
//# sourceMappingURL=foundryLocalManager.js.map
export {};
//# sourceMappingURL=imodel.js.map

@@ -9,3 +9,4 @@ export { FoundryLocalManager } from './foundryLocalManager.js';

export { AudioClient, AudioClientSettings } from './openai/audioClient.js';
export { LiveAudioTranscriptionSession, LiveAudioTranscriptionOptions } from './openai/liveAudioTranscriptionClient.js';
export { EmbeddingClient } from './openai/embeddingClient.js';
export { LiveAudioTranscriptionSession, LiveAudioTranscriptionOptions } from './openai/liveAudioSession.js';
export { ResponsesClient, ResponsesClientSettings, getOutputText } from './openai/responsesClient.js';

@@ -18,1 +19,2 @@ export { ModelLoadManager } from './detail/modelLoadManager.js';

export * from './types.js';
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { LiveAudioTranscriptionSession } from './liveAudioTranscriptionClient.js';
import { LiveAudioTranscriptionSession } from './liveAudioSession.js';
export class AudioClientSettings {

@@ -227,1 +227,2 @@ language;

}
//# sourceMappingURL=audioClient.js.map

@@ -312,1 +312,2 @@ export class ChatClientSettings {

}
//# sourceMappingURL=chatClient.js.map

@@ -399,1 +399,2 @@ /**

}
//# sourceMappingURL=responsesClient.js.map

@@ -9,1 +9,2 @@ // adapted from sdk\cs\src\FoundryModelInfo.cs

})(DeviceType || (DeviceType = {}));
//# sourceMappingURL=types.js.map
{
"name": "foundry-local-sdk",
"version": "1.0.0-dev.202604172003",
"version": "1.1.0",
"description": "Foundry Local JavaScript SDK",

@@ -48,3 +48,3 @@ "main": "dist/index.js",

"author": "",
"license": "ISC"
"license": "MIT"
}

@@ -11,2 +11,3 @@ # Foundry Local JS SDK

- **Chat completions** — OpenAI-compatible chat API with both synchronous and streaming responses
- **Embeddings** — Generate text embeddings via OpenAI-compatible API
- **Audio transcription** — Transcribe audio files locally with streaming support

@@ -24,2 +25,8 @@ - **Multi-variant models** — Models can have multiple variants (e.g., different quantizations) with automatic selection of the best cached variant

## TypeScript support
The package is authored in TypeScript and ships with bundled type declarations (`.d.ts` files) alongside the compiled JavaScript. No `@types/foundry-local-sdk` package or manual ambient declarations are needed.
Importing from `foundry-local-sdk` in a TypeScript project gives you full type information and IntelliSense for every public API, including `FoundryLocalManager`, `Catalog`, `ChatClient`, `AudioClient`, `EmbeddingClient`, `ResponsesClient`, `LiveAudioTranscriptionSession`, and all of their associated option and response types.
## WinML: Automatic Hardware Acceleration (Windows)

@@ -209,2 +216,24 @@

### Embeddings
Generate text embeddings using the `EmbeddingClient`:
```typescript
const embeddingClient = model.createEmbeddingClient();
// Single input
const response = await embeddingClient.generateEmbedding(
'The quick brown fox jumps over the lazy dog'
);
const embedding = response.data[0].embedding; // number[]
console.log(`Dimensions: ${embedding.length}`);
// Batch input
const batchResponse = await embeddingClient.generateEmbeddings([
'The quick brown fox',
'The capital of France is Paris'
]);
// batchResponse.data[0].embedding, batchResponse.data[1].embedding
```
### Audio Transcription

@@ -211,0 +240,0 @@

@@ -32,4 +32,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

const NUGET_FEED = 'https://api.nuget.org/v3/index.json';
const ORT_NIGHTLY_FEED = 'https://pkgs.dev.azure.com/aiinfra/PublicPackages/_packaging/ORT-Nightly/nuget/v3/index.json';
// Feeds tried in order. Primary: nuget.org (stable releases). Fallback:
// the public ORT-Nightly Azure DevOps NuGet feed (where dev / pre-release
// builds of Foundry Local Core, ONNX Runtime and ONNX Runtime GenAI live
// before they reach nuget.org). If a download from a feed fails for any
// reason, the next feed is tried.
const FEEDS = [
'https://api.nuget.org/v3/index.json',
'https://pkgs.dev.azure.com/aiinfra/PublicPackages/_packaging/ORT-Nightly/nuget/v3/index.json',
];

@@ -132,39 +139,56 @@ // --- Download helpers ---

const baseAddress = await getBaseAddress(artifact.feed);
const nameLower = pkgName.toLowerCase();
const verLower = pkgVer.toLowerCase();
const downloadUrl = `${baseAddress}${nameLower}/${verLower}/${nameLower}.${verLower}.nupkg`;
// Try each configured feed in order; on failure fall back to the next.
let lastError;
for (let i = 0; i < FEEDS.length; i++) {
const feedUrl = FEEDS[i];
const feedHost = new URL(feedUrl).host;
try {
const baseAddress = await getBaseAddress(feedUrl);
const nameLower = pkgName.toLowerCase();
const verLower = pkgVer.toLowerCase();
const downloadUrl = `${baseAddress}${nameLower}/${verLower}/${nameLower}.${verLower}.nupkg`;
const nupkgPath = path.join(tempDir, `${pkgName}.${pkgVer}.nupkg`);
console.log(` Downloading ${pkgName} ${pkgVer}...`);
await downloadFile(downloadUrl, nupkgPath);
const nupkgPath = path.join(tempDir, `${pkgName}.${pkgVer}.nupkg`);
console.log(` Downloading ${pkgName} ${pkgVer} from ${feedHost}...`);
await downloadFile(downloadUrl, nupkgPath);
console.log(` Extracting...`);
const zip = new AdmZip(nupkgPath);
const targetPathPrefix = `runtimes/${RID}/native/`.toLowerCase();
const entries = zip.getEntries().filter(e => {
const p = e.entryName.toLowerCase();
return p.includes(targetPathPrefix) && p.endsWith(EXT);
});
console.log(` Extracting...`);
const zip = new AdmZip(nupkgPath);
const targetPathPrefix = `runtimes/${RID}/native/`.toLowerCase();
const entries = zip.getEntries().filter(e => {
const p = e.entryName.toLowerCase();
return p.includes(targetPathPrefix) && p.endsWith(EXT);
});
if (entries.length > 0) {
entries.forEach(entry => {
zip.extractEntryTo(entry, binDir, false, true);
console.log(` Extracted ${entry.name}`);
});
} else {
console.warn(` No files found for RID ${RID} in ${pkgName}.`);
}
if (entries.length > 0) {
entries.forEach(entry => {
zip.extractEntryTo(entry, binDir, false, true);
console.log(` Extracted ${entry.name}`);
});
} else {
console.warn(` No files found for RID ${RID} in ${pkgName}.`);
}
// Write a metadata package.json with version info for diagnostics
if (pkgName.startsWith('Microsoft.AI.Foundry.Local.Core')) {
const pkgJsonPath = path.join(binDir, 'package.json');
const pkgContent = {
name: `@foundry-local-core/${platformKey}`,
version: pkgVer,
description: `Native binaries for Foundry Local SDK (${platformKey})`,
private: true
};
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgContent, null, 2));
// Write a metadata package.json with version info for diagnostics
if (pkgName.startsWith('Microsoft.AI.Foundry.Local.Core')) {
const pkgJsonPath = path.join(binDir, 'package.json');
const pkgContent = {
name: `@foundry-local-core/${platformKey}`,
version: pkgVer,
description: `Native binaries for Foundry Local SDK (${platformKey})`,
private: true
};
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgContent, null, 2));
}
return;
} catch (err) {
lastError = err;
const isLast = i === FEEDS.length - 1;
const reason = err instanceof Error ? err.message : String(err);
if (!isLast) {
console.warn(` ${pkgName} ${pkgVer}: download from ${feedHost} failed (${reason}); trying next feed...`);
}
}
}
throw new Error(`Failed to download ${pkgName} ${pkgVer} from any configured feed (${FEEDS.map(f => new URL(f).host).join(', ')}): ${lastError instanceof Error ? lastError.message : lastError}`);
}

@@ -198,2 +222,2 @@

module.exports = { NUGET_FEED, ORT_NIGHTLY_FEED, runInstall };
module.exports = { runInstall };
{
"name": "@github/copilot",
"description": "GitHub Copilot CLI brings the power of Copilot coding agent directly to your terminal.",
"version": "1.0.44-2",
"version": "1.0.44-3",
"license": "SEE LICENSE IN LICENSE.md",

@@ -72,12 +72,12 @@ "type": "module",

"buildMetadata": {
"gitCommit": "b033450"
"gitCommit": "23f4a3b"
},
"optionalDependencies": {
"@github/copilot-linux-x64": "1.0.44-2",
"@github/copilot-linux-arm64": "1.0.44-2",
"@github/copilot-darwin-x64": "1.0.44-2",
"@github/copilot-darwin-arm64": "1.0.44-2",
"@github/copilot-win32-x64": "1.0.44-2",
"@github/copilot-win32-arm64": "1.0.44-2"
"@github/copilot-linux-x64": "1.0.44-3",
"@github/copilot-linux-arm64": "1.0.44-3",
"@github/copilot-darwin-x64": "1.0.44-3",
"@github/copilot-darwin-arm64": "1.0.44-3",
"@github/copilot-win32-x64": "1.0.44-3",
"@github/copilot-win32-arm64": "1.0.44-3"
}
}

@@ -75,2 +75,2 @@

const __dirname = __path.dirname(__filename);
var U=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});import{parentPort as v,workerData as re}from"node:worker_threads";var a=class extends Error{constructor(n,t,o){super(n,o);this.code=t;this.name="VoiceBackendError"}},W=16;function S(s){return E(s,new WeakSet,0)}function E(s,e,n){if(n>=W)return{name:"Error",message:"<cause chain truncated>"};if(typeof s=="object"&&s!==null){if(e.has(s))return{name:"Error",message:"<cyclic cause>"};e.add(s)}let t;if(s instanceof a)t={name:s.name,message:s.message,stack:s.stack,code:s.code};else if(s instanceof Error)t={name:s.name,message:s.message,stack:s.stack};else return{name:"Error",message:String(s)};return s instanceof Error&&s.cause!==void 0&&(t.cause=E(s.cause,e,n+1)),t}function L(s){return s instanceof Error?s:new Error(String(s))}function k(s,e){s.on("message",n=>{if(n==null||typeof n!="object")return;let t=n;t.kind==="request"&&j(s,e,t).catch(()=>{})})}async function j(s,e,n){try{let t=n.method,o=n.params,i=await e.call(t,o),r={kind:"response",id:n.id,ok:!0,result:i};s.postMessage(r)}catch(t){let o={kind:"response",id:n.id,ok:!1,error:S(t)};s.postMessage(o)}}var p=class{initialQueue=[];initialQueueResolvers=Promise.withResolvers();logWriter=null;writePromise=this.initialQueueResolvers.promise;setLogWriter(e){this.logWriter=e;for(let n of this.initialQueue)this.writePromise=this.logWriter.writeLog(n.method,n.message);this.initialQueue=[],this.initialQueueResolvers.resolve()}async flush(){await this.writePromise}async dispose(){await this.flush()}outputPath(){return this.logWriter?.outputPath()}logToLevel(e,n){this.logWriter?this.writePromise=this.logWriter.writeLog(e,n):this.initialQueue.push({method:e,message:n})}info(e){this.logToLevel("info",e)}debug(e){this.logToLevel("debug",e)}warning(e){this.logToLevel("warning",e)}error(e){this.logToLevel("error",e instanceof Error?e.message:e)}log(e){this.error(e)}isDebug(){return!1}shouldLog(e){return!0}notice(e){this.info(e instanceof Error?e.message:e)}startGroup(e,n){this.info(`--- Start of group: ${e} ---`)}endGroup(e){this.info("--- End of group ---")}},P=new p;var f=16*1024,m=class{constructor(e){this.port=e}writeLog(e,n){let t={kind:"log",level:e,message:H(n)};try{this.port.postMessage(t)}catch{}return Promise.resolve()}outputPath(){return"<voice-worker>"}};function I(s,e=P){e.setLogWriter(new m(s))}function H(s){return s.length<=f?s:`${s.slice(0,f)}\u2026 [truncated, ${s.length-f} more chars]`}import*as _ from"node:fs/promises";import*as C from"node:os";import*as G from"node:path";function $(s){if(s.includes("<!DOCTYPE")||s.includes("<html")){let e=Math.min(s.indexOf("<!DOCTYPE")!==-1?s.indexOf("<!DOCTYPE"):1/0,s.indexOf("<html")!==-1?s.indexOf("<html"):1/0),n=s.substring(0,e).trim();return n?`${n} [HTML error page omitted]`:"[HTML error page omitted]"}return s}function T(s){let e;if(s instanceof Error)e=String(s);else if(typeof s=="object"&&s!==null)try{e=JSON.stringify(s)??"[object]"}catch{return"[object with circular reference]"}else e=String(s);return $(e)}var u=class{listeners=new Map;on(e,n){let t=this.listeners.get(e);t||(t=new Set,this.listeners.set(e,t));let o=n,i=t;return i.add(o),()=>{i.delete(o)}}emit(e,n){let t=this.listeners.get(e);if(!t)return;let o=[...t];for(let i of o)try{i(n)}catch{}}clear(){this.listeners.clear()}};var z={listModels:!0,downloadModel:!0,deleteModel:!0,loadModel:!0,openSession:!0,appendSession:!0,stopSession:!0,cancelSession:!0,shutdown:!0},me=Object.keys(z),b="automatic-speech-recognition",Y={modelDownloadProgress:!0,sessionPreview:!0},ye=Object.keys(Y);import*as R from"node:fs/promises";import{open as Q}from"node:fs/promises";var x=16e3,y=1,w=16,A=44,g=class{constructor(e){this.path=e}handle;dataSize=0;writeTail=Promise.resolve();async open(){this.handle=await Q(this.path,"w"),await this.handle.write(F(0))}append(e){let n=this.writeTail.then(async()=>{if(!this.handle)throw new Error("WavStreamWriter not opened");await this.handle.write(e),this.dataSize+=e.byteLength});return this.writeTail=n.catch(()=>{}),n}async finalize(){if(!this.handle||(await this.writeTail,!this.handle))return;let e=this.handle;this.handle=void 0;try{await e.write(F(this.dataSize),0,A,0)}finally{await e.close()}}async discard(){this.handle&&(await this.handle.close().catch(()=>{}),this.handle=void 0),await R.unlink(this.path).catch(()=>{})}};function F(s){let e=x*y*w/8,n=y*w/8,t=Buffer.alloc(A);return t.write("RIFF",0,"ascii"),t.writeUInt32LE(36+s,4),t.write("WAVE",8,"ascii"),t.write("fmt ",12,"ascii"),t.writeUInt32LE(16,16),t.writeUInt16LE(1,20),t.writeUInt16LE(y,22),t.writeUInt32LE(x,24),t.writeUInt32LE(e,28),t.writeUInt16LE(n,32),t.writeUInt16LE(w,34),t.write("data",36,"ascii"),t.writeUInt32LE(s,40),t}var q="github-copilot-cli",J={AzureCatalogFilter:"'',test"},K=1e4,X=2e3,Z="voice-foundry-batch-";function ee(s){switch(s.tag){case"opening":return;case"active":case"stopping":case"cancelling":return s.session;default:return s}}var h=class{managerPromise;state={tag:"unloaded"};lastModelGeneration=0;downloads=new Map;shutdownPromise;events=new u;foundryAdditionalSettings;nativeLocation;tempDir;managerFactory;handlers={listModels:()=>this.handleListModels(),downloadModel:e=>this.handleDownloadModel(e),deleteModel:e=>this.handleDeleteModel(e),loadModel:e=>this.handleLoadModel(e),openSession:e=>this.handleOpenSession(e),appendSession:e=>this.handleAppendSession(e),stopSession:e=>this.handleStopSession(e),cancelSession:e=>this.handleCancelSession(e),shutdown:()=>this.handleShutdown()};constructor(e={}){this.foundryAdditionalSettings=e.foundryAdditionalSettings??J,this.nativeLocation=e.nativeLocation,this.tempDir=e.tempDir??C.tmpdir(),this.managerFactory=e.managerFactory}call(e,n,t){if(this.shutdownPromise&&e!=="shutdown")return Promise.reject(this.disposedError());let o=this.handlers[e];return o(n)}on(e,n){return this.events.on(e,n)}onFatalError(e){return()=>{}}shutdown(e){return this.handleShutdown()}async handleListModels(){return O(async()=>{let n=await(await this.getManager()).catalog.getModels(),t=[];for(let o of n)for(let i of o.variants)se(i)&&t.push(await ie(i));return t})}async handleDownloadModel(e){let{variantId:n,downloadId:t}=e,o=this.downloads.get(n);if(o){if(o.downloadId===t)return o.promise;throw new a(`A different download for '${n}' is in flight.`,"io")}let i=(async()=>{await(await this.getVariant(n)).download(d=>{this.events.emit("modelDownloadProgress",{downloadId:t,variantId:n,percent:d})})})(),r={downloadId:t,promise:i};this.downloads.set(n,r);try{await i}finally{this.downloads.get(n)===r&&this.downloads.delete(n)}}async handleDeleteModel(e){let{variantId:n}=e;if(this.downloads.has(n))throw new a(`Cannot delete '${n}' while a download is in flight.`,"io");let t=this.state;switch(t.tag){case"unloaded":break;case"loading":t.selection.variantId===n&&await this.unloadSelected();break;case"ready":if(t.selection.variantId===n){if(t.session!==void 0)throw new a(`Cannot delete '${n}' while a session is active.`,"session-active");await this.unloadSelected()}break;default:}(await this.getVariant(n)).removeFromCache()}async handleLoadModel(e){let{variantId:n}=e;if(this.shutdownPromise)throw this.disposedError();let t=this.state;switch(t.tag){case"unloaded":return this.startLoad(n,void 0);case"loading":if(t.selection.variantId===n){let o=await t.selection.loadedModel;return o.modelGeneration=this.bumpModelGeneration(),{modelGeneration:o.modelGeneration}}return this.startLoad(n,t.selection);case"ready":if(t.session!==void 0&&t.selection.variantId!==n)throw new a(`Cannot load '${n}' while a session is active.`,"session-active");return t.selection.variantId===n?(t.selection.loaded.modelGeneration=this.bumpModelGeneration(),{modelGeneration:t.selection.loaded.modelGeneration}):this.startLoad(n,t.selection);default:return t}}async startLoad(e,n){let t=this.loadVariant(e,n),o={variantId:e,loadedModel:t,previous:n};return this.state={tag:"loading",selection:o},t.then(r=>{this.state.tag==="loading"&&this.state.selection===o&&(this.state={tag:"ready",selection:{variantId:e,loadedModel:t,loaded:r}})},()=>{this.state.tag==="loading"&&this.state.selection===o&&(this.state={tag:"unloaded"})}),{modelGeneration:(await t).modelGeneration}}async loadVariant(e,n){if(n){let o=await n.loadedModel.catch(()=>{});o&&await o.variant.unload().catch(()=>{})}if(this.shutdownPromise)throw this.disposedError();let t=await this.getVariant(e);if(!t.isCached)throw new a(`Voice model '${e}' is not downloaded.`,"model-not-downloaded");if(await t.load(),this.shutdownPromise)throw await t.unload().catch(()=>{}),this.disposedError();return{variant:t,isStreaming:ne(t.alias),modelGeneration:this.bumpModelGeneration()}}bumpModelGeneration(){return this.lastModelGeneration=this.lastModelGeneration+1,this.lastModelGeneration}async unloadSelected(){if(this.state.tag==="unloaded")return;let e=this.state.selection;this.state={tag:"unloaded"};let n=await e.loadedModel.catch(()=>{});n&&await n.variant.unload().catch(()=>{})}async handleOpenSession(e){let n=this.state;switch(n.tag){case"unloaded":throw new a("Loaded model has changed since this session was prepared.","stale-model");case"loading":return await n.selection.loadedModel.catch(()=>{}),this.handleOpenSession(e);case"ready":{let t=n,{sessionId:o,modelGeneration:i}=e;if(t.session!==void 0)throw new a("A voice session is already active.","session-active");if(t.selection.loaded.modelGeneration!==i)throw new a("Loaded model has changed since this session was prepared.","stale-model");let r=t.selection.loaded,c=(async()=>{try{let d=r.isStreaming?await this.openStreamingSession(r,o):await this.openBatchSession(o),l=t.session;this.state===t&&l?.tag==="opening"&&l.sessionId===o?t.session={tag:"active",session:d}:await this.teardownSession(d).catch(()=>{})}catch(d){let l=t.session;throw this.state===t&&l?.tag==="opening"&&l.sessionId===o&&(t.session=void 0),d}})();t.session={tag:"opening",sessionId:o,opening:c},await c;return}default:return n}}async handleAppendSession(e){let n=this.state;switch(n.tag){case"unloaded":case"loading":return;case"ready":{let t=n.session;if(t===void 0)return;switch(t.tag){case"opening":case"stopping":case"cancelling":return;case"active":{if(t.session.sessionId!==e.sessionId)return;let o=t.session;if(o.kind==="streaming"){await o.foundrySdkSession.append(e.pcm);return}await o.wav.append(e.pcm);return}default:return t}}default:return n}}async handleStopSession(e){let n=()=>{throw new a(`No session '${e.sessionId}'.`,"session-not-found")},t=this.state;switch(t.tag){case"unloaded":case"loading":return n();case"ready":{let o=t,i=o.session;if(i===void 0)return n();switch(i.tag){case"opening":case"stopping":case"cancelling":return n();case"active":{if(i.session.sessionId!==e.sessionId)return n();let r=i.session,c=r.error;if(c)throw o.session=void 0,await this.teardownSession(r).catch(()=>{}),c;o.session={tag:"stopping",session:r};try{return{text:r.kind==="streaming"?await this.stopStreaming(r):await this.stopBatch(r)}}catch(d){throw r.error?r.error:d}finally{let d=o.session;this.state===o&&d?.tag==="stopping"&&d.session===r&&(o.session=void 0),await this.teardownSession(r).catch(()=>{})}}default:return i}}default:return t}}async handleCancelSession(e){let n=this.state;switch(n.tag){case"unloaded":case"loading":return;case"ready":{let t=n,o=t.session;if(o===void 0)return;switch(o.tag){case"opening":case"cancelling":return;case"active":{if(o.session.sessionId!==e.sessionId)return;let i=o.session;t.session={tag:"cancelling",session:i};try{await this.teardownSession(i)}finally{let r=t.session;this.state===t&&r?.tag==="cancelling"&&r.session===i&&(t.session=void 0)}return}case"stopping":{if(o.session.sessionId!==e.sessionId)return;let i=o.session;i.error=i.error??new a("Session cancelled.","cancelled"),t.session={tag:"cancelling",session:i},await this.teardownSession(i).catch(()=>{});return}default:return o}}default:return n}}async openStreamingSession(e,n){let t=e.variant.createAudioClient().createLiveTranscriptionSession();try{await t.start()}catch(i){throw await this.disposeSdk(t),i}let o={kind:"streaming",sessionId:n,foundrySdkSession:t,committed:"",tail:"",drainTask:Promise.resolve("")};return o.drainTask=this.runStreamingDrain(o),o.drainTask.catch(()=>{}),o}async openBatchSession(e){let n=new g(G.join(this.tempDir,`${Z}${e}.wav`));try{await n.open()}catch(t){throw await n.discard(),t}return{kind:"batch",sessionId:e,wav:n}}async runStreamingDrain(e){try{for await(let n of e.foundrySdkSession.getTranscriptionStream()){if(this.isCancellingSession(e))break;let t=te(n);t&&(n.is_final?(e.committed+=t,e.tail=""):e.tail+=t,this.events.emit("sessionPreview",{sessionId:e.sessionId,text:e.committed+e.tail}))}return e.committed+e.tail}catch(n){let t=L(n);throw e.error=t,t}}isCancellingSession(e){let n=this.state;switch(n.tag){case"unloaded":case"loading":return!1;case"ready":{let t=n.session;if(t===void 0)return!1;switch(t.tag){case"opening":case"active":case"stopping":return!1;case"cancelling":return t.session===e;default:return t}}default:return n}}async stopStreaming(e){return D((async()=>(await e.foundrySdkSession.stop(),e.drainTask))(),K,"session-timeout","Streaming session drain timed out.")}async stopBatch(e){if(this.state.tag!=="ready")return"";let n=this.state.selection.loaded;await e.wav.finalize();try{return(await n.variant.createAudioClient().transcribe(e.wav.path)).text??""}finally{await _.unlink(e.wav.path).catch(()=>{})}}async teardownSession(e){e.kind==="streaming"?await this.disposeSdk(e.foundrySdkSession):await e.wav.discard()}async disposeSdk(e){await D(e.dispose(),X,"io","SDK dispose timed out.").catch(()=>{})}async handleShutdown(){return this.shutdownPromise?this.shutdownPromise:(this.shutdownPromise=(async()=>{if(this.state.tag==="ready"&&this.state.session?.tag==="opening"&&await this.state.session.opening.catch(()=>{}),this.state.tag==="ready"){let e=this.state,n=e.session;if(n!==void 0){let t=ee(n);t&&(e.session=void 0,await this.teardownSession(t).catch(()=>{}))}}await this.unloadSelected().catch(()=>{}),this.managerPromise=void 0,this.events.clear()})(),this.shutdownPromise)}disposedError(){return new a("Foundry backend has been shut down.","disposed")}async getVariant(e){return(await this.getManager()).catalog.getModelVariant(e)}getManager(){return this.managerPromise||(this.managerPromise=this.initManager().catch(e=>{throw this.managerPromise=void 0,e})),this.managerPromise}async initManager(){if(this.managerFactory)return this.managerFactory();if(!this.nativeLocation)throw new a("Voice runtime is not downloaded. RuntimeInstaller must resolve it before backend construction.","runtime-not-downloaded");let e=this.nativeLocation;return O(async()=>{let n=U("foundry-local-sdk"),t={...this.foundryAdditionalSettings,FoundryLocalCorePath:e.corePath};return e.needsBootstrap&&!("Bootstrap"in t)&&(t.Bootstrap="true"),n.FoundryLocalManager.create({appName:q,additionalSettings:t})})}};function te(s){return s.content?.[0]?.text??""}function ne(s){return s.toLowerCase().includes("streaming")}function se(s){return s.info.task===b}async function O(s,e){try{return await s()}catch(n){if((e?.platform??process.platform)!=="win32")throw n;let o=T(n);if(!/Failed to load (?:dependency|core) library/i.test(o))throw n;let r=(e?.arch??process.arch)==="arm64"?"https://aka.ms/vs/17/release/vc_redist.arm64.exe":"https://aka.ms/vs/17/release/vc_redist.x64.exe";throw new a(`Voice mode requires the Microsoft Visual C++ Redistributable (2015-2022). Download and install it, then try again: ${r}`,"windows-runtime-missing",{cause:n})}}function oe(s){return Array.isArray(s)?s.filter(e=>typeof e=="string"):s&&typeof s=="object"?Object.keys(s):[]}async function ie(s){let e=s.isCached,n=oe(s.info.capabilities),t=s.info,o=t.runtime?.deviceType??t.device,i=o?o.toLowerCase():void 0,r=t.sizeInBytes??(typeof t.fileSizeMb=="number"?Math.round(t.fileSizeMb*1024*1024):void 0);return{id:s.id,alias:s.alias,name:s.info.name??s.id,cached:e,capabilities:n,sizeBytes:r,device:i}}function D(s,e,n,t){let o,i=new Promise((r,c)=>{o=setTimeout(()=>c(new a(t,n)),e)});return Promise.race([s,i]).finally(()=>{o&&clearTimeout(o)})}if(!v)throw new Error("voice-foundry.worker.js must be loaded as a worker thread.");I(v);var N=re;if(!N?.nativeLocation)throw new Error("voice-foundry.worker.ts requires workerData.nativeLocation.");var B=v,M=new h({nativeLocation:N.nativeLocation});M.on("modelDownloadProgress",s=>V("modelDownloadProgress",s));M.on("sessionPreview",s=>V("sessionPreview",s));k(B,M);function V(s,e){let n={kind:"event",event:s,payload:e};B.postMessage(n)}
var V=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});import{parentPort as v,workerData as re}from"node:worker_threads";var a=class extends Error{constructor(n,t,o){super(n,o);this.code=t;this.name="VoiceBackendError"}},W=16;function S(s){return E(s,new WeakSet,0)}function E(s,e,n){if(n>=W)return{name:"Error",message:"<cause chain truncated>"};if(typeof s=="object"&&s!==null){if(e.has(s))return{name:"Error",message:"<cyclic cause>"};e.add(s)}let t;if(s instanceof a)t={name:s.name,message:s.message,stack:s.stack,code:s.code};else if(s instanceof Error)t={name:s.name,message:s.message,stack:s.stack};else return{name:"Error",message:String(s)};return s instanceof Error&&s.cause!==void 0&&(t.cause=E(s.cause,e,n+1)),t}function L(s){return s instanceof Error?s:new Error(String(s))}function k(s,e){s.on("message",n=>{if(n==null||typeof n!="object")return;let t=n;t.kind==="request"&&j(s,e,t).catch(()=>{})})}async function j(s,e,n){try{let t=n.method,o=n.params,i=await e.call(t,o),r={kind:"response",id:n.id,ok:!0,result:i};s.postMessage(r)}catch(t){let o={kind:"response",id:n.id,ok:!1,error:S(t)};s.postMessage(o)}}var p=class{initialQueue=[];initialQueueResolvers=Promise.withResolvers();logWriter=null;writePromise=this.initialQueueResolvers.promise;setLogWriter(e){this.logWriter=e;for(let n of this.initialQueue)this.writePromise=this.logWriter.writeLog(n.method,n.message);this.initialQueue=[],this.initialQueueResolvers.resolve()}async flush(){await this.writePromise}async dispose(){await this.flush()}outputPath(){return this.logWriter?.outputPath()}logToLevel(e,n){this.logWriter?this.writePromise=this.logWriter.writeLog(e,n):this.initialQueue.push({method:e,message:n})}info(e){this.logToLevel("info",e)}debug(e){this.logToLevel("debug",e)}warning(e){this.logToLevel("warning",e)}error(e){this.logToLevel("error",e instanceof Error?e.message:e)}log(e){this.error(e)}isDebug(){return!1}shouldLog(e){return!0}notice(e){this.info(e instanceof Error?e.message:e)}startGroup(e,n){this.info(`--- Start of group: ${e} ---`)}endGroup(e){this.info("--- End of group ---")}},P=new p;var f=16*1024,m=class{constructor(e){this.port=e}writeLog(e,n){let t={kind:"log",level:e,message:H(n)};try{this.port.postMessage(t)}catch{}return Promise.resolve()}outputPath(){return"<voice-worker>"}};function I(s,e=P){e.setLogWriter(new m(s))}function H(s){return s.length<=f?s:`${s.slice(0,f)}\u2026 [truncated, ${s.length-f} more chars]`}import*as _ from"node:fs/promises";import*as G from"node:os";import*as C from"node:path";function $(s){if(s.includes("<!DOCTYPE")||s.includes("<html")){let e=Math.min(s.indexOf("<!DOCTYPE")!==-1?s.indexOf("<!DOCTYPE"):1/0,s.indexOf("<html")!==-1?s.indexOf("<html"):1/0),n=s.substring(0,e).trim();return n?`${n} [HTML error page omitted]`:"[HTML error page omitted]"}return s}function b(s){let e;if(s instanceof Error)e=String(s);else if(typeof s=="object"&&s!==null)try{e=JSON.stringify(s)??"[object]"}catch{return"[object with circular reference]"}else e=String(s);return $(e)}var u=class{listeners=new Map;on(e,n){let t=this.listeners.get(e);t||(t=new Set,this.listeners.set(e,t));let o=n,i=t;return i.add(o),()=>{i.delete(o)}}emit(e,n){let t=this.listeners.get(e);if(!t)return;let o=[...t];for(let i of o)try{i(n)}catch{}}clear(){this.listeners.clear()}};var z={listModels:!0,downloadModel:!0,deleteModel:!0,loadModel:!0,openSession:!0,appendSession:!0,stopSession:!0,cancelSession:!0,shutdown:!0},me=Object.keys(z),T="automatic-speech-recognition",Y={modelDownloadProgress:!0,sessionPreview:!0},we=Object.keys(Y);import*as A from"node:fs/promises";import{open as Q}from"node:fs/promises";var x=16e3,w=1,y=16,R=44,g=class{constructor(e){this.path=e}handle;dataSize=0;writeTail=Promise.resolve();async open(){this.handle=await Q(this.path,"w"),await this.handle.write(F(0))}append(e){let n=this.writeTail.then(async()=>{if(!this.handle)throw new Error("WavStreamWriter not opened");await this.handle.write(e),this.dataSize+=e.byteLength});return this.writeTail=n.catch(()=>{}),n}async finalize(){if(!this.handle||(await this.writeTail,!this.handle))return;let e=this.handle;this.handle=void 0;try{await e.write(F(this.dataSize),0,R,0)}finally{await e.close()}}async discard(){this.handle&&(await this.handle.close().catch(()=>{}),this.handle=void 0),await A.unlink(this.path).catch(()=>{})}};function F(s){let e=x*w*y/8,n=w*y/8,t=Buffer.alloc(R);return t.write("RIFF",0,"ascii"),t.writeUInt32LE(36+s,4),t.write("WAVE",8,"ascii"),t.write("fmt ",12,"ascii"),t.writeUInt32LE(16,16),t.writeUInt16LE(1,20),t.writeUInt16LE(w,22),t.writeUInt32LE(x,24),t.writeUInt32LE(e,28),t.writeUInt16LE(n,32),t.writeUInt16LE(y,34),t.write("data",36,"ascii"),t.writeUInt32LE(s,40),t}var q="github-copilot-cli",J={AzureCatalogFilter:"'',test"},K=1e4,X=2e3,Z="voice-foundry-batch-";function ee(s){switch(s.tag){case"opening":return;case"active":case"stopping":case"cancelling":return s.session;default:return s}}var h=class{managerPromise;state={tag:"unloaded"};lastModelGeneration=0;downloads=new Map;shutdownPromise;events=new u;foundryAdditionalSettings;nativeLocation;tempDir;managerFactory;handlers={listModels:()=>this.handleListModels(),downloadModel:e=>this.handleDownloadModel(e),deleteModel:e=>this.handleDeleteModel(e),loadModel:e=>this.handleLoadModel(e),openSession:e=>this.handleOpenSession(e),appendSession:e=>this.handleAppendSession(e),stopSession:e=>this.handleStopSession(e),cancelSession:e=>this.handleCancelSession(e),shutdown:()=>this.handleShutdown()};constructor(e={}){this.foundryAdditionalSettings=e.foundryAdditionalSettings??J,this.nativeLocation=e.nativeLocation,this.tempDir=e.tempDir??G.tmpdir(),this.managerFactory=e.managerFactory}call(e,n,t){if(this.shutdownPromise&&e!=="shutdown")return Promise.reject(this.disposedError());let o=this.handlers[e];return o(n)}on(e,n){return this.events.on(e,n)}onFatalError(e){return()=>{}}shutdown(e){return this.handleShutdown()}async handleListModels(){return O(async()=>{let n=await(await this.getManager()).catalog.getModels(),t=[];for(let o of n)for(let i of o.variants)se(i)&&t.push(await ie(i));return t})}async handleDownloadModel(e){let{variantId:n,downloadId:t}=e,o=this.downloads.get(n);if(o){if(o.downloadId===t)return o.promise;throw new a(`A different download for '${n}' is in flight.`,"io")}let i=(async()=>{await(await this.getVariant(n)).download(d=>{this.events.emit("modelDownloadProgress",{downloadId:t,variantId:n,percent:d})})})(),r={downloadId:t,promise:i};this.downloads.set(n,r);try{await i}finally{this.downloads.get(n)===r&&this.downloads.delete(n)}}async handleDeleteModel(e){let{variantId:n}=e;if(this.downloads.has(n))throw new a(`Cannot delete '${n}' while a download is in flight.`,"io");let t=this.state;switch(t.tag){case"unloaded":break;case"loading":t.selection.variantId===n&&await this.unloadSelected();break;case"ready":if(t.selection.variantId===n){if(t.session!==void 0)throw new a(`Cannot delete '${n}' while a session is active.`,"session-active");await this.unloadSelected()}break;default:}(await this.getVariant(n)).removeFromCache()}async handleLoadModel(e){let{variantId:n}=e;if(this.shutdownPromise)throw this.disposedError();let t=this.state;switch(t.tag){case"unloaded":return this.startLoad(n,void 0);case"loading":if(t.selection.variantId===n){let o=await t.selection.loadedModel;return o.modelGeneration=this.bumpModelGeneration(),{modelGeneration:o.modelGeneration}}return this.startLoad(n,t.selection);case"ready":if(t.session!==void 0&&t.selection.variantId!==n)throw new a(`Cannot load '${n}' while a session is active.`,"session-active");return t.selection.variantId===n?(t.selection.loaded.modelGeneration=this.bumpModelGeneration(),{modelGeneration:t.selection.loaded.modelGeneration}):this.startLoad(n,t.selection);default:return t}}async startLoad(e,n){let t=this.loadVariant(e,n),o={variantId:e,loadedModel:t,previous:n};return this.state={tag:"loading",selection:o},t.then(r=>{this.state.tag==="loading"&&this.state.selection===o&&(this.state={tag:"ready",selection:{variantId:e,loadedModel:t,loaded:r}})},()=>{this.state.tag==="loading"&&this.state.selection===o&&(this.state={tag:"unloaded"})}),{modelGeneration:(await t).modelGeneration}}async loadVariant(e,n){if(n){let o=await n.loadedModel.catch(()=>{});o&&await o.variant.unload().catch(()=>{})}if(this.shutdownPromise)throw this.disposedError();let t=await this.getVariant(e);if(!t.isCached)throw new a(`Voice model '${e}' is not downloaded.`,"model-not-downloaded");if(await t.load(),this.shutdownPromise)throw await t.unload().catch(()=>{}),this.disposedError();return{variant:t,isStreaming:ne(t.alias),modelGeneration:this.bumpModelGeneration()}}bumpModelGeneration(){return this.lastModelGeneration=this.lastModelGeneration+1,this.lastModelGeneration}async unloadSelected(){if(this.state.tag==="unloaded")return;let e=this.state.selection;this.state={tag:"unloaded"};let n=await e.loadedModel.catch(()=>{});n&&await n.variant.unload().catch(()=>{})}async handleOpenSession(e){let n=this.state;switch(n.tag){case"unloaded":throw new a("Loaded model has changed since this session was prepared.","stale-model");case"loading":return await n.selection.loadedModel.catch(()=>{}),this.handleOpenSession(e);case"ready":{let t=n,{sessionId:o,modelGeneration:i}=e;if(t.session!==void 0)throw new a("A voice session is already active.","session-active");if(t.selection.loaded.modelGeneration!==i)throw new a("Loaded model has changed since this session was prepared.","stale-model");let r=t.selection.loaded,c=(async()=>{try{let d=r.isStreaming?await this.openStreamingSession(r,o):await this.openBatchSession(o),l=t.session;this.state===t&&l?.tag==="opening"&&l.sessionId===o?t.session={tag:"active",session:d}:await this.teardownSession(d).catch(()=>{})}catch(d){let l=t.session;throw this.state===t&&l?.tag==="opening"&&l.sessionId===o&&(t.session=void 0),d}})();t.session={tag:"opening",sessionId:o,opening:c},await c;return}default:return n}}async handleAppendSession(e){let n=this.state;switch(n.tag){case"unloaded":case"loading":return;case"ready":{let t=n.session;if(t===void 0)return;switch(t.tag){case"opening":case"stopping":case"cancelling":return;case"active":{if(t.session.sessionId!==e.sessionId)return;let o=t.session;if(o.kind==="streaming"){await o.foundrySdkSession.append(e.pcm);return}await o.wav.append(e.pcm);return}default:return t}}default:return n}}async handleStopSession(e){let n=()=>{throw new a(`No session '${e.sessionId}'.`,"session-not-found")},t=this.state;switch(t.tag){case"unloaded":case"loading":return n();case"ready":{let o=t,i=o.session;if(i===void 0)return n();switch(i.tag){case"opening":case"stopping":case"cancelling":return n();case"active":{if(i.session.sessionId!==e.sessionId)return n();let r=i.session,c=r.error;if(c)throw o.session=void 0,await this.teardownSession(r).catch(()=>{}),c;o.session={tag:"stopping",session:r};try{return{text:r.kind==="streaming"?await this.stopStreaming(r):await this.stopBatch(r)}}catch(d){throw r.error?r.error:d}finally{let d=o.session;this.state===o&&d?.tag==="stopping"&&d.session===r&&(o.session=void 0),await this.teardownSession(r).catch(()=>{})}}default:return i}}default:return t}}async handleCancelSession(e){let n=this.state;switch(n.tag){case"unloaded":case"loading":return;case"ready":{let t=n,o=t.session;if(o===void 0)return;switch(o.tag){case"opening":case"cancelling":return;case"active":{if(o.session.sessionId!==e.sessionId)return;let i=o.session;t.session={tag:"cancelling",session:i};try{await this.teardownSession(i)}finally{let r=t.session;this.state===t&&r?.tag==="cancelling"&&r.session===i&&(t.session=void 0)}return}case"stopping":{if(o.session.sessionId!==e.sessionId)return;let i=o.session;i.error=i.error??new a("Session cancelled.","cancelled"),t.session={tag:"cancelling",session:i},await this.teardownSession(i).catch(()=>{});return}default:return o}}default:return n}}async openStreamingSession(e,n){let t=e.variant.createAudioClient().createLiveTranscriptionSession();try{await t.start()}catch(i){throw await this.disposeSdk(t),i}let o={kind:"streaming",sessionId:n,foundrySdkSession:t,committed:"",tail:"",drainTask:Promise.resolve("")};return o.drainTask=this.runStreamingDrain(o),o.drainTask.catch(()=>{}),o}async openBatchSession(e){let n=new g(C.join(this.tempDir,`${Z}${e}.wav`));try{await n.open()}catch(t){throw await n.discard(),t}return{kind:"batch",sessionId:e,wav:n}}async runStreamingDrain(e){try{for await(let n of e.foundrySdkSession.getStream()){if(this.isCancellingSession(e))break;let t=te(n);t&&(n.is_final?(e.committed+=t,e.tail=""):e.tail+=t,this.events.emit("sessionPreview",{sessionId:e.sessionId,text:e.committed+e.tail}))}return e.committed+e.tail}catch(n){let t=L(n);throw e.error=t,t}}isCancellingSession(e){let n=this.state;switch(n.tag){case"unloaded":case"loading":return!1;case"ready":{let t=n.session;if(t===void 0)return!1;switch(t.tag){case"opening":case"active":case"stopping":return!1;case"cancelling":return t.session===e;default:return t}}default:return n}}async stopStreaming(e){return D((async()=>(await e.foundrySdkSession.stop(),e.drainTask))(),K,"session-timeout","Streaming session drain timed out.")}async stopBatch(e){if(this.state.tag!=="ready")return"";let n=this.state.selection.loaded;await e.wav.finalize();try{return(await n.variant.createAudioClient().transcribe(e.wav.path)).text??""}finally{await _.unlink(e.wav.path).catch(()=>{})}}async teardownSession(e){e.kind==="streaming"?await this.disposeSdk(e.foundrySdkSession):await e.wav.discard()}async disposeSdk(e){await D(e.dispose(),X,"io","SDK dispose timed out.").catch(()=>{})}async handleShutdown(){return this.shutdownPromise?this.shutdownPromise:(this.shutdownPromise=(async()=>{if(this.state.tag==="ready"&&this.state.session?.tag==="opening"&&await this.state.session.opening.catch(()=>{}),this.state.tag==="ready"){let e=this.state,n=e.session;if(n!==void 0){let t=ee(n);t&&(e.session=void 0,await this.teardownSession(t).catch(()=>{}))}}await this.unloadSelected().catch(()=>{}),this.managerPromise=void 0,this.events.clear()})(),this.shutdownPromise)}disposedError(){return new a("Foundry backend has been shut down.","disposed")}async getVariant(e){return(await this.getManager()).catalog.getModelVariant(e)}getManager(){return this.managerPromise||(this.managerPromise=this.initManager().catch(e=>{throw this.managerPromise=void 0,e})),this.managerPromise}async initManager(){if(this.managerFactory)return this.managerFactory();if(!this.nativeLocation)throw new a("Voice runtime is not downloaded. RuntimeInstaller must resolve it before backend construction.","runtime-not-downloaded");let e=this.nativeLocation;return O(async()=>{let n=V("foundry-local-sdk"),t={...this.foundryAdditionalSettings};return e.needsBootstrap&&!("Bootstrap"in t)&&(t.Bootstrap="true"),n.FoundryLocalManager.create({appName:q,libraryPath:e.corePath,additionalSettings:t})})}};function te(s){return s.content?.[0]?.text??""}function ne(s){return s.toLowerCase().includes("streaming")}function se(s){return s.info.task===T}async function O(s,e){try{return await s()}catch(n){if((e?.platform??process.platform)!=="win32")throw n;let o=b(n);if(!/Failed to load (?:dependency|core) library/i.test(o))throw n;let r=(e?.arch??process.arch)==="arm64"?"https://aka.ms/vs/17/release/vc_redist.arm64.exe":"https://aka.ms/vs/17/release/vc_redist.x64.exe";throw new a(`Voice mode requires the Microsoft Visual C++ Redistributable (2015-2022). Download and install it, then try again: ${r}`,"windows-runtime-missing",{cause:n})}}function oe(s){return Array.isArray(s)?s.filter(e=>typeof e=="string"):typeof s=="string"?s.split(/[,\s]+/).filter(e=>e.length>0):s&&typeof s=="object"?Object.keys(s):[]}async function ie(s){let e=s.isCached,n=oe(s.info.capabilities),t=s.info,o=s.info.runtime?.deviceType??t.device,i=o?o.toLowerCase():void 0,r=t.sizeInBytes??(typeof s.info.fileSizeMb=="number"?Math.round(s.info.fileSizeMb*1024*1024):void 0);return{id:s.id,alias:s.alias,name:s.info.name??s.id,cached:e,capabilities:n,sizeBytes:r,device:i}}function D(s,e,n,t){let o,i=new Promise((r,c)=>{o=setTimeout(()=>c(new a(t,n)),e)});return Promise.race([s,i]).finally(()=>{o&&clearTimeout(o)})}if(!v)throw new Error("voice-foundry.worker.js must be loaded as a worker thread.");I(v);var N=re;if(!N?.nativeLocation)throw new Error("voice-foundry.worker.ts requires workerData.nativeLocation.");var B=v,M=new h({nativeLocation:N.nativeLocation});M.on("modelDownloadProgress",s=>U("modelDownloadProgress",s));M.on("sessionPreview",s=>U("sessionPreview",s));k(B,M);function U(s,e){let n={kind:"event",event:s,payload:e};B.postMessage(n)}

@@ -75,2 +75,2 @@

const __dirname = __path.dirname(__filename);
import{parentPort as $,workerData as ee}from"node:worker_threads";import{createRequire as W}from"node:module";import{existsSync as H}from"node:fs";import*as o from"node:fs/promises";import*as a from"node:path";import{createHash as U}from"node:crypto";import{join as u,basename as oe}from"node:path";import{homedir as g}from"node:os";function j(){return process.env.XDG_CACHE_HOME||u(g(),".cache")}function k(){if(process.platform==="darwin")return u(g(),"Library","Caches","copilot");if(process.platform==="win32"){let e=process.env.LOCALAPPDATA||u(g(),".cache");return u(e,"copilot")}return u(j(),"copilot")}function A(e){if(e.includes("<!DOCTYPE")||e.includes("<html")){let r=Math.min(e.indexOf("<!DOCTYPE")!==-1?e.indexOf("<!DOCTYPE"):1/0,e.indexOf("<html")!==-1?e.indexOf("<html"):1/0),t=e.substring(0,r).trim();return t?`${t} [HTML error page omitted]`:"[HTML error page omitted]"}return e}function m(e){let r;if(e instanceof Error)r=String(e);else if(typeof e=="object"&&e!==null)try{r=JSON.stringify(e)??"[object]"}catch{return"[object with circular reference]"}else r=String(e);return A(r)}var J=1,b=".complete";var h={"win32-x64":"win-x64","win32-arm64":"win-arm64","linux-x64":"linux-x64","darwin-arm64":"osx-arm64"};function S(){return typeof __foundryRequire<"u"&&__foundryRequire||W(import.meta.url)}var d;function I(){if(d)return d;try{let e=S()("foundry-local-sdk/script/install-utils.cjs");if(typeof e.NUGET_FEED!="string"||typeof e.ORT_NIGHTLY_FEED!="string"||typeof e.runInstall!="function")throw new Error(`Expected exports {NUGET_FEED: string, ORT_NIGHTLY_FEED: string, runInstall: function}, got: ${JSON.stringify(Object.fromEntries(Object.entries(e).map(([r,t])=>[r,typeof t])))}`);return d=e,d}catch(e){throw new Error(`Failed to load foundry-local-sdk/script/install-utils.cjs: ${m(e)}. The upstream foundry-local-sdk installer may have changed shape \u2014 re-run the audit checklist in src/cli/voice/foundry/installer/nativeLoader.ts and update accordingly.`)}}var f;function G(){if(f)return f;try{let e=S()("foundry-local-sdk/deps_versions.json");if(typeof e["foundry-local-core"]?.nuget!="string"||typeof e.onnxruntime?.version!="string"||typeof e["onnxruntime-genai"]?.version!="string")throw new Error('deps_versions.json is missing one of the expected version keys: ["foundry-local-core"].nuget, .onnxruntime.version, ["onnxruntime-genai"].version');return f=e,f}catch(e){throw new Error(`Failed to load foundry-local-sdk/deps_versions.json: ${m(e)}. The upstream foundry-local-sdk installer may have changed shape \u2014 re-run the audit checklist in src/cli/voice/foundry/installer/nativeLoader.ts and update accordingly.`)}}function O(e=process.platform){let r=I(),t=G();return[{name:"Microsoft.AI.Foundry.Local.Core",version:t["foundry-local-core"].nuget,feed:r.ORT_NIGHTLY_FEED},{name:e==="linux"?"Microsoft.ML.OnnxRuntime.Gpu.Linux":"Microsoft.ML.OnnxRuntime.Foundry",version:t.onnxruntime.version,feed:r.NUGET_FEED},{name:"Microsoft.ML.OnnxRuntimeGenAI.Foundry",version:t["onnxruntime-genai"].version,feed:r.NUGET_FEED}]}function _(e){return e==="win32"?".dll":e==="darwin"?".dylib":".so"}function V(e,r){return a.join(e,`Microsoft.AI.Foundry.Local.Core${_(r)}`)}function q(e){let r=_(e),t=e==="win32"?"":"lib";return[`Microsoft.AI.Foundry.Local.Core${r}`,`${t}onnxruntime${r}`,`${t}onnxruntime-genai${r}`]}function Y(e,r=process.platform,t=process.arch){let n=h[`${r}-${t}`];if(!n)throw new Error(`Voice mode not supported on ${r}-${t}`);let i=e??process.env.COPILOT_CACHE_HOME??k(),s=O(r),c=U("sha256").update(JSON.stringify({schema:J,artifacts:s})).digest("hex").slice(0,12);return a.join(i,"foundry",c,n)}async function C(e={}){let r=e.platform??process.platform,t=e.arch??process.arch,n=`${r}-${t}`;if(!h[n])throw new Error(`Voice mode is not supported on ${n}. Supported platforms: ${Object.keys(h).join(", ")}.`);let s=Y(e.cacheRoot,r,t),c=V(s,r),l=q(r);return await N(s,l)||(e.onDownloadStart?.(),await z(s,r,l,e.runInstall)),P(c,s,r,e.existsSyncImpl)}async function N(e,r){return await y(a.join(e,b))?(await Promise.all(r.map(n=>y(a.join(e,n))))).every(Boolean):!1}function P(e,r,t,n=K){if(t!=="win32")return{corePath:e,needsBootstrap:!1};let i=a.join(r,"Microsoft.WindowsAppRuntime.Bootstrap.dll");return{corePath:e,needsBootstrap:n(i)}}function K(e){try{return H(e)}catch{return!1}}async function y(e){try{return await o.access(e),!0}catch{return!1}}async function z(e,r,t,n){let i=a.dirname(e);await o.mkdir(i,{recursive:!0});let s=a.join(i,`.tmp-${a.basename(e)}-${process.pid}-${Date.now()}`);await o.mkdir(s,{recursive:!0});try{let c=n??I().runInstall,l=O(r);await B(()=>c(l,{binDir:s}));for(let L of t)if(!await y(a.join(s,L)))throw new Error(`Foundry runtime download finished but required file is missing: ${L}. RID for ${r} may not be supported by the published packages.`);await o.writeFile(a.join(s,b),""),await Q(s,e,t)}catch(c){throw await o.rm(s,{recursive:!0,force:!0}).catch(()=>{}),c}}async function Q(e,r,t){try{await o.rename(e,r)}catch(n){let i=n.code;if(i==="ENOTEMPTY"||i==="EEXIST"||i==="EPERM"){if(await N(r,t)){await o.rm(e,{recursive:!0,force:!0}).catch(()=>{});return}await o.rm(r,{recursive:!0,force:!0}),await o.rename(e,r);return}throw n}}async function B(e){let r=process.stdout.write.bind(process.stdout),t=process.stderr.write.bind(process.stderr);process.stdout.write=(()=>!0),process.stderr.write=(()=>!0);try{return await e()}finally{process.stdout.write=r,process.stderr.write=t}}var E=class extends Error{constructor(t,n,i){super(t,i);this.code=n;this.name="VoiceBackendError"}},X=16;function T(e){return F(e,new WeakSet,0)}function F(e,r,t){if(t>=X)return{name:"Error",message:"<cause chain truncated>"};if(typeof e=="object"&&e!==null){if(r.has(e))return{name:"Error",message:"<cyclic cause>"};r.add(e)}let n;if(e instanceof E)n={name:e.name,message:e.message,stack:e.stack,code:e.code};else if(e instanceof Error)n={name:e.name,message:e.message,stack:e.stack};else return{name:"Error",message:String(e)};return e instanceof Error&&e.cause!==void 0&&(n.cause=F(e.cause,r,t+1)),n}function M(e){return e instanceof Error?e:new Error(String(e))}var w=class{initialQueue=[];initialQueueResolvers=Promise.withResolvers();logWriter=null;writePromise=this.initialQueueResolvers.promise;setLogWriter(r){this.logWriter=r;for(let t of this.initialQueue)this.writePromise=this.logWriter.writeLog(t.method,t.message);this.initialQueue=[],this.initialQueueResolvers.resolve()}async flush(){await this.writePromise}async dispose(){await this.flush()}outputPath(){return this.logWriter?.outputPath()}logToLevel(r,t){this.logWriter?this.writePromise=this.logWriter.writeLog(r,t):this.initialQueue.push({method:r,message:t})}info(r){this.logToLevel("info",r)}debug(r){this.logToLevel("debug",r)}warning(r){this.logToLevel("warning",r)}error(r){this.logToLevel("error",r instanceof Error?r.message:r)}log(r){this.error(r)}isDebug(){return!1}shouldLog(r){return!0}notice(r){this.info(r instanceof Error?r.message:r)}startGroup(r,t){this.info(`--- Start of group: ${r} ---`)}endGroup(r){this.info("--- End of group ---")}},R=new w;var v=16*1024,x=class{constructor(r){this.port=r}writeLog(r,t){let n={kind:"log",level:r,message:Z(t)};try{this.port.postMessage(n)}catch{}return Promise.resolve()}outputPath(){return"<voice-worker>"}};function D(e,r=R){r.setLogWriter(new x(e))}function Z(e){return e.length<=v?e:`${e.slice(0,v)}\u2026 [truncated, ${e.length-v} more chars]`}if(!$)throw new Error("voice-installer.worker.js must be loaded as a worker thread.");var p=$;D(p);var re=ee??{};async function te(){try{let r={kind:"ok",location:await C({cacheRoot:re.cacheRoot,onDownloadStart:()=>{let t={kind:"download-started"};p.postMessage(t)}})};p.postMessage(r)}catch(e){let r={kind:"error",error:T(M(e))};p.postMessage(r)}finally{setImmediate(()=>process.exit(0))}}te().catch(()=>{process.exit(1)});
import{parentPort as T,workerData as ee}from"node:worker_threads";import{createRequire as D}from"node:module";import{existsSync as W}from"node:fs";import*as o from"node:fs/promises";import*as a from"node:path";import{createHash as H}from"node:crypto";import{join as u,basename as oe}from"node:path";import{homedir as g}from"node:os";function j(){return process.env.XDG_CACHE_HOME||u(g(),".cache")}function L(){if(process.platform==="darwin")return u(g(),"Library","Caches","copilot");if(process.platform==="win32"){let e=process.env.LOCALAPPDATA||u(g(),".cache");return u(e,"copilot")}return u(j(),"copilot")}function A(e){if(e.includes("<!DOCTYPE")||e.includes("<html")){let r=Math.min(e.indexOf("<!DOCTYPE")!==-1?e.indexOf("<!DOCTYPE"):1/0,e.indexOf("<html")!==-1?e.indexOf("<html"):1/0),t=e.substring(0,r).trim();return t?`${t} [HTML error page omitted]`:"[HTML error page omitted]"}return e}function m(e){let r;if(e instanceof Error)r=String(e);else if(typeof e=="object"&&e!==null)try{r=JSON.stringify(e)??"[object]"}catch{return"[object with circular reference]"}else r=String(e);return A(r)}var J=1,b=".complete";var h={"win32-x64":"win-x64","win32-arm64":"win-arm64","linux-x64":"linux-x64","darwin-arm64":"osx-arm64"};function S(){return typeof __foundryRequire<"u"&&__foundryRequire||D(import.meta.url)}var d;function U(){if(d)return d;try{let e=S()("foundry-local-sdk/script/install-utils.cjs");if(typeof e.runInstall!="function")throw new Error(`Expected exports {runInstall: function}, got: ${JSON.stringify(Object.fromEntries(Object.entries(e).map(([r,t])=>[r,typeof t])))}`);return d=e,d}catch(e){throw new Error(`Failed to load foundry-local-sdk/script/install-utils.cjs: ${m(e)}. The upstream foundry-local-sdk installer may have changed shape \u2014 re-run the audit checklist in src/cli/voice/foundry/installer/nativeLoader.ts and update accordingly.`)}}var f;function V(){if(f)return f;try{let e=S()("foundry-local-sdk/deps_versions.json");if(typeof e["foundry-local-core"]?.nuget!="string"||typeof e.onnxruntime?.version!="string"||typeof e["onnxruntime-genai"]?.version!="string")throw new Error('deps_versions.json is missing one of the expected version keys: ["foundry-local-core"].nuget, .onnxruntime.version, ["onnxruntime-genai"].version');return f=e,f}catch(e){throw new Error(`Failed to load foundry-local-sdk/deps_versions.json: ${m(e)}. The upstream foundry-local-sdk installer may have changed shape \u2014 re-run the audit checklist in src/cli/voice/foundry/installer/nativeLoader.ts and update accordingly.`)}}function I(e=process.platform){let r=V();return[{name:"Microsoft.AI.Foundry.Local.Core",version:r["foundry-local-core"].nuget},{name:e==="linux"?"Microsoft.ML.OnnxRuntime.Gpu.Linux":"Microsoft.ML.OnnxRuntime.Foundry",version:r.onnxruntime.version},{name:"Microsoft.ML.OnnxRuntimeGenAI.Foundry",version:r["onnxruntime-genai"].version}]}function O(e){return e==="win32"?".dll":e==="darwin"?".dylib":".so"}function q(e,r){return a.join(e,`Microsoft.AI.Foundry.Local.Core${O(r)}`)}function K(e){let r=O(e),t=e==="win32"?"":"lib";return[`Microsoft.AI.Foundry.Local.Core${r}`,`${t}onnxruntime${r}`,`${t}onnxruntime-genai${r}`]}function G(e,r=process.platform,t=process.arch){let n=h[`${r}-${t}`];if(!n)throw new Error(`Voice mode not supported on ${r}-${t}`);let i=e??process.env.COPILOT_CACHE_HOME??L(),s=I(r),c=H("sha256").update(JSON.stringify({schema:J,artifacts:s})).digest("hex").slice(0,12);return a.join(i,"foundry",c,n)}async function C(e={}){let r=e.platform??process.platform,t=e.arch??process.arch,n=`${r}-${t}`;if(!h[n])throw new Error(`Voice mode is not supported on ${n}. Supported platforms: ${Object.keys(h).join(", ")}.`);let s=G(e.cacheRoot,r,t),c=q(s,r),l=K(r);return await M(s,l)||(e.onDownloadStart?.(),await Q(s,r,l,e.runInstall)),P(c,s,r,e.existsSyncImpl)}async function M(e,r){return await y(a.join(e,b))?(await Promise.all(r.map(n=>y(a.join(e,n))))).every(Boolean):!1}function P(e,r,t,n=z){if(t!=="win32")return{corePath:e,needsBootstrap:!1};let i=a.join(r,"Microsoft.WindowsAppRuntime.Bootstrap.dll");return{corePath:e,needsBootstrap:n(i)}}function z(e){try{return W(e)}catch{return!1}}async function y(e){try{return await o.access(e),!0}catch{return!1}}async function Q(e,r,t,n){let i=a.dirname(e);await o.mkdir(i,{recursive:!0});let s=a.join(i,`.tmp-${a.basename(e)}-${process.pid}-${Date.now()}`);await o.mkdir(s,{recursive:!0});try{let c=n??U().runInstall,l=I(r);await B(()=>c(l,{binDir:s}));for(let k of t)if(!await y(a.join(s,k)))throw new Error(`Foundry runtime download finished but required file is missing: ${k}. RID for ${r} may not be supported by the published packages.`);await o.writeFile(a.join(s,b),""),await Y(s,e,t)}catch(c){throw await o.rm(s,{recursive:!0,force:!0}).catch(()=>{}),c}}async function Y(e,r,t){try{await o.rename(e,r)}catch(n){let i=n.code;if(i==="ENOTEMPTY"||i==="EEXIST"||i==="EPERM"){if(await M(r,t)){await o.rm(e,{recursive:!0,force:!0}).catch(()=>{});return}await o.rm(r,{recursive:!0,force:!0}),await o.rename(e,r);return}throw n}}async function B(e){let r=process.stdout.write.bind(process.stdout),t=process.stderr.write.bind(process.stderr);process.stdout.write=(()=>!0),process.stderr.write=(()=>!0);try{return await e()}finally{process.stdout.write=r,process.stderr.write=t}}var w=class extends Error{constructor(t,n,i){super(t,i);this.code=n;this.name="VoiceBackendError"}},X=16;function N(e){return _(e,new WeakSet,0)}function _(e,r,t){if(t>=X)return{name:"Error",message:"<cause chain truncated>"};if(typeof e=="object"&&e!==null){if(r.has(e))return{name:"Error",message:"<cyclic cause>"};r.add(e)}let n;if(e instanceof w)n={name:e.name,message:e.message,stack:e.stack,code:e.code};else if(e instanceof Error)n={name:e.name,message:e.message,stack:e.stack};else return{name:"Error",message:String(e)};return e instanceof Error&&e.cause!==void 0&&(n.cause=_(e.cause,r,t+1)),n}function R(e){return e instanceof Error?e:new Error(String(e))}var v=class{initialQueue=[];initialQueueResolvers=Promise.withResolvers();logWriter=null;writePromise=this.initialQueueResolvers.promise;setLogWriter(r){this.logWriter=r;for(let t of this.initialQueue)this.writePromise=this.logWriter.writeLog(t.method,t.message);this.initialQueue=[],this.initialQueueResolvers.resolve()}async flush(){await this.writePromise}async dispose(){await this.flush()}outputPath(){return this.logWriter?.outputPath()}logToLevel(r,t){this.logWriter?this.writePromise=this.logWriter.writeLog(r,t):this.initialQueue.push({method:r,message:t})}info(r){this.logToLevel("info",r)}debug(r){this.logToLevel("debug",r)}warning(r){this.logToLevel("warning",r)}error(r){this.logToLevel("error",r instanceof Error?r.message:r)}log(r){this.error(r)}isDebug(){return!1}shouldLog(r){return!0}notice(r){this.info(r instanceof Error?r.message:r)}startGroup(r,t){this.info(`--- Start of group: ${r} ---`)}endGroup(r){this.info("--- End of group ---")}},F=new v;var E=16*1024,x=class{constructor(r){this.port=r}writeLog(r,t){let n={kind:"log",level:r,message:Z(t)};try{this.port.postMessage(n)}catch{}return Promise.resolve()}outputPath(){return"<voice-worker>"}};function $(e,r=F){r.setLogWriter(new x(e))}function Z(e){return e.length<=E?e:`${e.slice(0,E)}\u2026 [truncated, ${e.length-E} more chars]`}if(!T)throw new Error("voice-installer.worker.js must be loaded as a worker thread.");var p=T;$(p);var re=ee??{};async function te(){try{let r={kind:"ok",location:await C({cacheRoot:re.cacheRoot,onDownloadStart:()=>{let t={kind:"download-started"};p.postMessage(t)}})};p.postMessage(r)}catch(e){let r={kind:"error",error:N(R(e))};p.postMessage(r)}finally{setImmediate(()=>process.exit(0))}}te().catch(()=>{process.exit(1)});
import { parseTranscriptionResult, tryParseCoreError } from './liveAudioTranscriptionTypes.js';
/**
* Audio format settings for a streaming session.
* Must be configured before calling start().
* Settings are frozen once the session starts.
*/
export class LiveAudioTranscriptionOptions {
/** PCM sample rate in Hz. Default: 16000. */
sampleRate = 16000;
/** Number of audio channels. Default: 1 (mono). */
channels = 1;
/** Bits per sample. Default: 16. */
bitsPerSample = 16;
/** Optional BCP-47 language hint (e.g., "en", "zh"). */
language;
/** Maximum number of audio chunks buffered in the internal push queue. Default: 100. */
pushQueueCapacity = 100;
/** @internal Create a frozen copy of these settings. */
snapshot() {
const copy = new LiveAudioTranscriptionOptions();
copy.sampleRate = this.sampleRate;
copy.channels = this.channels;
copy.bitsPerSample = this.bitsPerSample;
copy.language = this.language;
copy.pushQueueCapacity = this.pushQueueCapacity;
return Object.freeze(copy);
}
}
/**
* Internal async queue that acts like C#'s Channel<T>.
* Supports a single consumer reading via async iteration and multiple producers writing.
* @internal
*/
class AsyncQueue {
queue = [];
waitingResolve = null;
completed = false;
completionError = null;
maxCapacity;
backpressureQueue = [];
constructor(maxCapacity = Infinity) {
this.maxCapacity = maxCapacity;
}
/** Push an item. If at capacity, waits until space is available. */
async write(item) {
if (this.completed) {
throw new Error('Cannot write to a completed queue.');
}
if (this.waitingResolve) {
const resolve = this.waitingResolve;
this.waitingResolve = null;
resolve({ value: item, done: false });
return;
}
while (this.queue.length >= this.maxCapacity) {
await new Promise((resolve) => {
this.backpressureQueue.push(resolve);
});
}
if (this.completed) {
throw new Error('Cannot write to a completed queue.');
}
this.queue.push(item);
}
/** Push an item synchronously (no backpressure wait). Returns false if completed or at capacity. */
tryWrite(item) {
if (this.completed)
return false;
if (this.waitingResolve) {
const resolve = this.waitingResolve;
this.waitingResolve = null;
resolve({ value: item, done: false });
return true;
}
if (this.queue.length >= this.maxCapacity) {
return false;
}
this.queue.push(item);
return true;
}
/** Signal that no more items will be written. */
complete(error) {
if (this.completed)
return;
this.completed = true;
this.completionError = error ?? null;
// Release all blocked writers
for (const resolve of this.backpressureQueue) {
resolve();
}
this.backpressureQueue = [];
if (this.waitingResolve) {
const resolve = this.waitingResolve;
this.waitingResolve = null;
resolve({ value: undefined, done: true });
}
}
get error() {
return this.completionError;
}
/** Async iterator for consuming items. */
async *[Symbol.asyncIterator]() {
while (true) {
if (this.backpressureQueue.length > 0 && this.queue.length < this.maxCapacity) {
const resolve = this.backpressureQueue.shift();
resolve();
}
if (this.queue.length > 0) {
yield this.queue.shift();
continue;
}
if (this.completed) {
if (this.completionError) {
throw this.completionError;
}
return;
}
const result = await new Promise((resolve) => {
this.waitingResolve = resolve;
});
if (result.done) {
if (this.completionError) {
throw this.completionError;
}
return;
}
yield result.value;
}
}
}
/**
* Client for real-time audio streaming ASR (Automatic Speech Recognition).
* Audio data from a microphone (or other source) is pushed in as PCM chunks,
* and transcription results are returned as an async iterable.
*
* Mirrors the C# LiveAudioTranscriptionSession.
*/
export class LiveAudioTranscriptionSession {
modelId;
coreInterop;
sessionHandle = null;
started = false;
stopped = false;
outputQueue = null;
pushQueue = null;
pushLoopPromise = null;
activeSettings = null;
sessionAbortController = null;
streamConsumed = false;
/**
* Configuration settings for the streaming session.
* Must be configured before calling start(). Settings are snapshotted at start();
* changes made after start() are ignored for the current session.
*/
settings = new LiveAudioTranscriptionOptions();
/**
* @internal
* Users should create sessions via AudioClient.createLiveTranscriptionSession().
*/
constructor(modelId, coreInterop) {
this.modelId = modelId;
this.coreInterop = coreInterop;
}
/**
* Start a real-time audio streaming session.
* Must be called before append() or getTranscriptionStream().
* Settings are frozen after this call.
*/
async start() {
if (this.started) {
throw new Error('Streaming session already started. Call stop() first.');
}
this.activeSettings = this.settings.snapshot();
this.outputQueue = new AsyncQueue();
this.pushQueue = new AsyncQueue(this.activeSettings.pushQueueCapacity);
this.streamConsumed = false;
const params = {
Model: this.modelId,
SampleRate: this.activeSettings.sampleRate.toString(),
Channels: this.activeSettings.channels.toString(),
BitsPerSample: this.activeSettings.bitsPerSample.toString(),
};
if (this.activeSettings.language) {
params['Language'] = this.activeSettings.language;
}
try {
const response = this.coreInterop.executeCommand("audio_stream_start", {
Params: params
});
this.sessionHandle = response;
if (!this.sessionHandle) {
throw new Error('Native core did not return a session handle.');
}
}
catch (error) {
const err = new Error(`Error starting audio stream session: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
this.outputQueue.complete(err);
throw err;
}
this.started = true;
this.stopped = false;
this.sessionAbortController = new AbortController();
this.pushLoopPromise = this.pushLoop();
}
/**
* Push a chunk of raw PCM audio data to the streaming session.
* Can be called from any context. Chunks are internally queued
* and serialized to native core one at a time.
*
* @param pcmData - Raw PCM audio bytes matching the configured format.
*/
async append(pcmData) {
if (!this.started || this.stopped) {
throw new Error('No active streaming session. Call start() first.');
}
const copy = new Uint8Array(pcmData.length);
copy.set(pcmData);
await this.pushQueue.write(copy);
}
/**
* Internal loop that drains the push queue and sends chunks to native core one at a time.
* Terminates the session on any native error.
* @internal
*/
async pushLoop() {
try {
for await (const audioData of this.pushQueue) {
if (this.sessionAbortController?.signal.aborted) {
break;
}
try {
const responseData = this.coreInterop.executeCommandWithBinary("audio_stream_push", {
Params: {
SessionHandle: this.sessionHandle,
}
}, audioData);
// Parse transcription result from push response and surface it
if (responseData) {
try {
const result = parseTranscriptionResult(responseData);
const text = result.content?.[0]?.text;
if (text !== undefined && text !== null && text !== '') {
this.outputQueue?.tryWrite(result);
}
}
catch {
// Non-fatal: log and continue if response isn't a transcription result
}
}
}
catch (error) {
const errorMsg = error instanceof Error ? error.message : String(error);
const errorInfo = tryParseCoreError(errorMsg);
const fatalError = new Error(`Push failed (code=${errorInfo?.code ?? 'UNKNOWN'}): ${errorMsg}`, { cause: error });
this.stopped = true;
this.started = false;
this.pushQueue?.complete(fatalError);
this.outputQueue?.complete(fatalError);
return;
}
}
}
catch (error) {
if (this.sessionAbortController?.signal.aborted) {
return;
}
const err = error instanceof Error ? error : new Error(String(error));
this.outputQueue?.complete(new Error('Push loop terminated unexpectedly.', { cause: err }));
}
}
/**
* Get the async iterable of transcription results.
* Results arrive as the native ASR engine processes audio data.
*
* Usage:
* ```ts
* for await (const result of client.getTranscriptionStream()) {
* console.log(result.content[0].text);
* }
* ```
*/
async *getTranscriptionStream() {
if (!this.outputQueue) {
throw new Error('No active streaming session. Call start() first.');
}
if (this.streamConsumed) {
throw new Error('getTranscriptionStream() can only be called once per session. The output stream has already been consumed.');
}
this.streamConsumed = true;
for await (const item of this.outputQueue) {
yield item;
}
}
/**
* Signal end-of-audio and stop the streaming session.
* Any remaining buffered audio in the push queue will be drained to native core first.
* Final results are delivered through getTranscriptionStream() before it completes.
*/
async stop() {
if (!this.started || this.stopped) {
return;
}
this.stopped = true;
this.pushQueue?.complete();
if (this.pushLoopPromise) {
await this.pushLoopPromise;
}
this.sessionAbortController?.abort();
let stopError = null;
try {
const responseData = this.coreInterop.executeCommand("audio_stream_stop", {
Params: { SessionHandle: this.sessionHandle }
});
// Parse final transcription from stop response
if (responseData) {
try {
const finalResult = parseTranscriptionResult(responseData);
if (finalResult.content?.[0]?.text) {
this.outputQueue?.tryWrite(finalResult);
}
}
catch {
// Non-fatal
}
}
}
catch (error) {
stopError = error instanceof Error ? error : new Error(String(error));
}
this.sessionHandle = null;
this.started = false;
this.sessionAbortController = null;
this.outputQueue?.complete();
if (stopError) {
throw new Error(`Error stopping audio stream session: ${stopError.message}`, { cause: stopError });
}
}
/**
* Dispose the client and stop any active session.
* Safe to call multiple times.
*/
async dispose() {
try {
if (this.started && !this.stopped) {
await this.stop();
}
}
catch {
// Swallow errors during best-effort cleanup to keep dispose() silent.
}
}
}
/**
* Types for real-time audio streaming transcription results and structured errors.
* Mirrors the C# LiveAudioTranscriptionResponse (extends ConversationItem) and CoreErrorResponse.
*/
/**
* Parse raw Core JSON response into a LiveAudioTranscriptionResponse.
* Maps the flat Core format (text, is_final, start_time, end_time) into
* the ConversationItem-shaped result with content[0].text and content[0].transcript.
* @internal
*/
export function parseTranscriptionResult(json) {
const raw = JSON.parse(json);
return {
id: raw.id ?? null,
is_final: raw.is_final ?? false,
start_time: raw.start_time ?? null,
end_time: raw.end_time ?? null,
content: [
{
text: raw.text ?? '',
transcript: raw.text ?? ''
}
]
};
}
/**
* Attempt to parse a native error string as a structured CoreErrorResponse.
* Handles both raw JSON and CoreInterop-prefixed messages
* (e.g., "Command 'X' failed: {...}").
* Returns null if no valid CoreErrorResponse JSON is found.
* @internal
*/
export function tryParseCoreError(errorString) {
// Try raw JSON first, then extract JSON after "failed: " prefix
const candidates = [errorString];
const prefixIdx = errorString.indexOf('failed: ');
if (prefixIdx !== -1) {
candidates.push(errorString.substring(prefixIdx + 8));
}
for (const candidate of candidates) {
try {
const parsed = JSON.parse(candidate);
if (typeof parsed.code === 'string' && typeof parsed.message === 'string' && typeof parsed.isTransient === 'boolean') {
return parsed;
}
}
catch {
// not valid JSON, try next candidate
}
}
return null;
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet