Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

update release.yml

Aleksei Savine87014fefbbc
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 7eddeee67..116dcc90f 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -230,18 +230,10 @@ jobs:
# ---------------------------------------------------------------
# Publish Platform
# ---------------------------------------------------------------
- - name: "Publish Platform: Decode bucket credentials"
- run: |
- {
- echo "PLATFORM_CREDENTIALS_JSON<<EOF"
- echo "${{ secrets.PLATFORM_BUCKET_BASE64_CREDENTIALS }}" | base64 -d
- echo "EOF"
- } >> "$GITHUB_ENV"
-
- name: "Publish Platform: Authenticate to GCS"
uses: google-github-actions/auth@v2
with:
- credentials_json: ${{ env.PLATFORM_CREDENTIALS_JSON }}
+ credentials_json: ${{ secrets.PLATFORM_BUCKET_JSON_CREDENTIALS }}
- name: "Publish Platform: Setup gcloud"
uses: google-github-actions/setup-gcloud@v2
@@ -255,18 +247,10 @@ jobs:
# ---------------------------------------------------------------
# Publish Swift
# ---------------------------------------------------------------
- - name: "Publish Swift: Decode artifacts bucket credentials"
- run: |
- {
- echo "ARTIFACTS_CREDENTIALS_JSON<<EOF"
- echo "${{ secrets.ARTIFACTS_BUCKET_BASE64_CREDENTIALS }}" | base64 -d
- echo "EOF"
- } >> "$GITHUB_ENV"
-
- name: "Publish Swift: Authenticate to GCS"
uses: google-github-actions/auth@v2
with:
- credentials_json: ${{ env.ARTIFACTS_CREDENTIALS_JSON }}
+ credentials_json: ${{ secrets.ARTIFACTS_BUCKET_JSON_CREDENTIALS }}
- name: "Publish Swift: Setup gcloud"
uses: google-github-actions/setup-gcloud@v2
diff --git a/bindings/typescript/scripts/utils/generate-napi-wrappers.cjs b/bindings/typescript/scripts/utils/generate-napi-wrappers.cjs
index bd6dbd58a..93601ed42 100644
--- a/bindings/typescript/scripts/utils/generate-napi-wrappers.cjs
+++ b/bindings/typescript/scripts/utils/generate-napi-wrappers.cjs
@@ -18,8 +18,8 @@ function extractRuntimeExportsFromCommonJs(commonJsPath) {
return unique(exports);
}
-function generateEsmWrapper(exports, outputPath) {
- const namedExports = exports
+function generateEsmWrapper(runtimeExports, outputPath) {
+ const namedExports = runtimeExports
.map((runtimeExport) => `export const ${runtimeExport} = cjs.${runtimeExport};`)
.join('\n');
const content = `// Auto-generated ESM adapter for the NAPI-RS CommonJS wrapper.
@@ -35,16 +35,27 @@ ${namedExports}
fs.writeFileSync(outputPath, content);
}
+function generateEsmDeclarations(commonJsDeclarationsPath, outputPath) {
+ fs.copyFileSync(commonJsDeclarationsPath, outputPath);
+}
+
function main() {
const napiDir = path.join(__dirname, '../../src/napi');
const commonJsPath = path.join(napiDir, 'index.js');
+ const commonJsDeclarationsPath = path.join(napiDir, 'index.d.ts');
const esmPath = path.join(napiDir, 'index.mjs');
+ const esmDeclarationsPath = path.join(napiDir, 'index.d.mts');
if (!fs.existsSync(commonJsPath)) {
console.error('NAPI file not found:', commonJsPath);
process.exit(1);
}
+ if (!fs.existsSync(commonJsDeclarationsPath)) {
+ console.error('NAPI declarations file not found:', commonJsDeclarationsPath);
+ process.exit(1);
+ }
+
const runtimeExports = extractRuntimeExportsFromCommonJs(commonJsPath);
if (runtimeExports.length === 0) {
console.error('No runtime exports found in:', commonJsPath);
@@ -52,8 +63,10 @@ function main() {
}
generateEsmWrapper(runtimeExports, esmPath);
+ generateEsmDeclarations(commonJsDeclarationsPath, esmDeclarationsPath);
console.log(`Generated ${esmPath} with ${runtimeExports.length} named exports`);
+ console.log(`Generated ${esmDeclarationsPath}`);
}
if (require.main === module) {
@@ -62,5 +75,6 @@ if (require.main === module) {
module.exports = {
extractRuntimeExportsFromCommonJs,
+ generateEsmDeclarations,
generateEsmWrapper,
};
diff --git a/bindings/typescript/src/napi/index.d.mts b/bindings/typescript/src/napi/index.d.mts
new file mode 100644
index 000000000..770f2662d
--- /dev/null
+++ b/bindings/typescript/src/napi/index.d.mts
@@ -0,0 +1,1014 @@
+/* auto-generated by NAPI-RS */
+/* eslint-disable */
+export declare class ChatSession {
+ get state(): Promise<ChatSessionState>
+ get messages(): Promise<Array<ChatMessage>>
+ reset(): Promise<void>
+ reply(input: Array<ChatMessage>, config: ChatReplyConfig): Promise<Array<ChatReply>>
+ replyWithStream(input: Array<ChatMessage>, config: ChatReplyConfig): Promise<ChatSessionStream>
+}
+
+/**
+ * This type implements JavaScript's async iterable protocol.
+ * It can be used with `for await...of` loops.
+ *
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
+ */
+export declare class ChatSessionStream {
+ next(): Promise<ChatSessionStreamChunk | null>
+ get cancelToken(): CancelToken
+ [Symbol.asyncIterator](): AsyncGenerator<ChatSessionStreamChunk, void, undefined>
+}
+
+export declare class ChatSessionStreamChunkError {
+ error: ChatSessionError
+ constructor(error: ChatSessionError)
+}
+
+export declare class ChatSessionStreamChunkReplies {
+ replies: Array<ChatReply>
+ constructor(replies: Array<ChatReply>)
+}
+
+export declare class ClassificationSession {
+ get state(): Promise<ClassificationSessionState>
+ classify(input: Array<ClassificationMessage>): Promise<ClassificationOutput>
+}
+
+export declare class TextToSpeechSession {
+ get state(): Promise<TextToSpeechSessionState>
+ synthesize(input: string): Promise<TextToSpeechOutput>
+ synthesizeStream(input: string): Promise<TextToSpeechSessionStream>
+}
+
+/**
+ * This type implements JavaScript's async iterable protocol.
+ * It can be used with `for await...of` loops.
+ *
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
+ */
+export declare class TextToSpeechSessionStream {
+ next(): Promise<TextToSpeechSessionStreamChunk | null>
+ get cancelToken(): CancelToken
+ [Symbol.asyncIterator](): AsyncGenerator<TextToSpeechSessionStreamChunk, void, undefined>
+}
+
+export declare class TextToSpeechSessionStreamChunkError {
+ error: TextToSpeechSessionError
+ constructor(error: TextToSpeechSessionError)
+}
+
+export declare class TextToSpeechSessionStreamChunkOutput {
+ output: TextToSpeechOutput
+ constructor(output: TextToSpeechOutput)
+}
+
+export type ChatSessionError =
+ | { type: 'Backend', message: string }
+ | { type: 'UnsupportedModel' }
+ | { type: 'UnableToPerformOperationInCurrentState' }
+ | { type: 'NoResponse' }
+
+export declare const enum ChatSessionState {
+ Idle = 'Idle',
+ Generation = 'Generation',
+ ToolCalling = 'ToolCalling',
+ Resetting = 'Resetting'
+}
+
+export type ChatSessionStreamChunk =
+ ChatSessionStreamChunkReplies | ChatSessionStreamChunkError
+
+export type ClassificationSessionError =
+ | { type: 'Backend', message: string }
+ | { type: 'UnsupportedModel' }
+ | { type: 'UnableToPerformOperationInCurrentState' }
+ | { type: 'NoResponse' }
+
+export declare const enum ClassificationSessionState {
+ Idle = 'Idle',
+ Classifying = 'Classifying'
+}
+
+export type TextToSpeechSessionError =
+ | { type: 'Backend', message: string }
+ | { type: 'UnsupportedModel' }
+ | { type: 'UnableToPerformOperationInCurrentState' }
+ | { type: 'NoResponse' }
+
+export declare const enum TextToSpeechSessionState {
+ Idle = 'Idle',
+ Synthesizing = 'Synthesizing'
+}
+
+export type TextToSpeechSessionStreamChunk =
+ TextToSpeechSessionStreamChunkOutput | TextToSpeechSessionStreamChunkError
+export declare class CancelToken {
+ cancel(): void
+ get isCancelled(): boolean
+ static create(): CancelToken
+}
+
+export declare class ChatConfig {
+ contextLength: ContextLength
+ samplingSeed: SamplingSeed
+ speculationPreset?: ChatSpeculationPreset
+ constructor(contextLength: ContextLength, samplingSeed: SamplingSeed, speculationPreset?: ChatSpeculationPreset)
+
+ static create(): ChatConfig
+ withContextLength(contextLength: ContextLength): ChatConfig
+ withSamplingSeed(samplingSeed: SamplingSeed): ChatConfig
+ withSpeculationPreset(speculationPreset?: ChatSpeculationPreset | undefined | null): ChatConfig
+}
+
+export declare class ChatContentBlockAudio {
+ url: string
+ constructor(url: string)
+}
+
+export declare class ChatContentBlockBuiltinTools {
+ names: Array<string>
+ constructor(names: Array<string>)
+}
+
+export declare class ChatContentBlockConversationStartDate {
+ value: string
+ constructor(value: string)
+}
+
+export declare class ChatContentBlockCustom {
+ value: any
+ constructor(value: any)
+}
+
+export declare class ChatContentBlockFile {
+ url: string
+ constructor(url: string)
+}
+
+export declare class ChatContentBlockIdentity {
+ value: string
+ constructor(value: string)
+}
+
+export declare class ChatContentBlockImage {
+ url: string
+ constructor(url: string)
+}
+
+export declare class ChatContentBlockKnowledgeCutoff {
+ value: string
+ constructor(value: string)
+}
+
+export declare class ChatContentBlockReasoning {
+ value: string
+ constructor(value: string)
+}
+
+export declare class ChatContentBlockReasoningEffort {
+ value: ReasoningEffort
+ constructor(value: ReasoningEffort)
+}
+
+export declare class ChatContentBlockText {
+ value: string
+ constructor(value: string)
+}
+
+export declare class ChatContentBlockToolCall {
+ value: ToolCall
+ constructor(value: ToolCall)
+}
+
+export declare class ChatContentBlockToolCallCandidate {
+ value: any
+ constructor(value: any)
+}
+
+export declare class ChatContentBlockToolCallResult {
+ identifier?: string
+ name?: string
+ value: any
+ constructor(identifier?: string, name?: string, value: any)
+}
+
+export declare class ChatContentBlockTools {
+ namespaces: Array<ToolNamespace>
+ constructor(namespaces: Array<ToolNamespace>)
+}
+
+export declare class ChatContentBlockTranslation {
+ payload: TranslationPayload
+ sourceLanguageCode: string
+ targetLanguageCode: string
+ constructor(payload: TranslationPayload, sourceLanguageCode: string, targetLanguageCode: string)
+}
+
+export declare class ChatContentBlockVideo {
+ url: string
+ constructor(url: string)
+}
+
+export declare class ChatMessage {
+ role: ChatRole
+ content: Array<ChatContentBlock>
+ metadata: ChatMessageMetadata
+ constructor(role: ChatRole, content: Array<ChatContentBlock>, metadata: ChatMessageMetadata)
+
+ static for_role(role: ChatRole): ChatMessage
+ static system(): ChatMessage
+ static developer(): ChatMessage
+ static user(): ChatMessage
+ static assistant(): ChatMessage
+ static tool(): ChatMessage
+ withBlock(block: ChatContentBlock): ChatMessage
+ withReasoningEffort(reasoningEffort: ReasoningEffort): ChatMessage
+ withToolNamespaces(toolNamespaces: Array<ToolNamespace>): ChatMessage
+ withText(text: string): ChatMessage
+ withReasoning(reasoning: string): ChatMessage
+ withToolCall(toolCall: ToolCall): ChatMessage
+ withToolCallCandidate(value: any): ChatMessage
+ get reasoningEffort(): ReasoningEffort | null
+ get text(): string | null
+ get reasoning(): string | null
+ get toolNamespaces(): Array<ToolNamespace>
+ get toolCalls(): Array<ToolCall>
+}
+
+export declare class ChatModelCapabilities {
+ supportsReasoning: boolean
+ supportsDisableReasoning: boolean
+ supportsTools: boolean
+ supportsMultipleToolCalls: boolean
+ requiresTools: boolean
+ constructor(supportsReasoning: boolean, supportsDisableReasoning: boolean, supportsTools: boolean, supportsMultipleToolCalls: boolean, requiresTools: boolean)
+}
+
+export declare class ChatReply {
+ message: ChatMessage
+ stats: ChatReplyStats
+ finishReason?: ChatReplyFinishReason
+ constructor(message: ChatMessage, stats: ChatReplyStats, finishReason?: ChatReplyFinishReason)
+}
+
+export declare class ChatReplyConfig {
+ tokenLimit?: number
+ samplingPolicy: SamplingPolicy
+ grammar?: Grammar
+ constructor(tokenLimit?: number, samplingPolicy: SamplingPolicy, grammar?: Grammar)
+
+ static create(): ChatReplyConfig
+ withTokenLimit(tokenLimit?: number | undefined | null): ChatReplyConfig
+ withSamplingPolicy(samplingPolicy: SamplingPolicy): ChatReplyConfig
+ withSamplingMethod(samplingMethod: SamplingMethod): ChatReplyConfig
+ withGrammar(grammar?: Grammar | undefined | null): ChatReplyConfig
+}
+
+export declare class ChatReplyStats {
+ duration: number
+ timeToFirstToken?: number
+ prefillTokensPerSecond?: number
+ generateTokensPerSecond?: number
+ tokensCountInput?: number
+ tokensCountOutput?: number
+ constructor(duration: number, timeToFirstToken?: number, prefillTokensPerSecond?: number, generateTokensPerSecond?: number, tokensCountInput?: number, tokensCountOutput?: number)
+ get tokensCount(): number | null
+}
+
+export declare class ChatRoleAssistant {
+
+ constructor()
+}
+
+export declare class ChatRoleCustom {
+ name: string
+ constructor(name: string)
+}
+
+export declare class ChatRoleDeveloper {
+
+ constructor()
+}
+
+export declare class ChatRoleSystem {
+
+ constructor()
+}
+
+export declare class ChatRoleTool {
+
+ constructor()
+}
+
+export declare class ChatRoleUser {
+
+ constructor()
+}
+
+export declare class ChatSpeculationPresetClassification {
+ feature: Feature
+ constructor(feature: Feature)
+}
+
+export declare class ChatSpeculationPresetGeneralChat {
+
+ constructor()
+}
+
+export declare class ChatSpeculationPresetSummarization {
+
+ constructor()
+}
+
+export declare class ClassificationLabel {
+ index: number
+ label: string
+ title: string
+ description: string
+ recommendedThreshold: number
+ constructor(index: number, label: string, title: string, description: string, recommendedThreshold: number)
+}
+
+export declare class ClassificationMessage {
+ role: ClassificationRole
+ content: string
+ constructor(role: ClassificationRole, content: string)
+
+ static user(content: string): ClassificationMessage
+ static assistant(content: string): ClassificationMessage
+}
+
+export declare class ClassificationOutput {
+ logits: Array<number>
+ probabilities: ClassificationOutputProbabilities
+ stats: ClassificationStats
+ constructor(logits: Array<number>, probabilities: ClassificationOutputProbabilities, stats: ClassificationStats)
+}
+
+export declare class ClassificationStats {
+ preprocessingDuration: number
+ forwardPassDuration: number
+ postprocessingDuration: number
+ totalDuration: number
+ tokensCount: number
+ tokensPerSecond: number
+ predictedLabel: string
+ confidence: number
+ constructor(preprocessingDuration: number, forwardPassDuration: number, postprocessingDuration: number, totalDuration: number, tokensCount: number, tokensPerSecond: number, predictedLabel: string, confidence: number)
+}
+
+export declare class ContextLengthCustom {
+ length: number
+ constructor(length: number)
+}
+
+export declare class ContextLengthDefault {
+
+ constructor()
+}
+
+export declare class ContextLengthMaximal {
+
+ constructor()
+}
+
+export declare class Feature {
+ name: string
+ values: Array<string>
+ constructor(name: string, values: Array<string>)
+}
+
+export declare class File {
+ url: string
+ name: string
+ size: number
+ hashes: Array<Hash>
+ constructor(url: string, name: string, size: number, hashes: Array<Hash>)
+ get crc32C(): string | null
+ get md5(): string | null
+}
+
+export declare class GrammarJsonAny {
+
+ constructor()
+}
+
+export declare class GrammarJsonSchema {
+ schema: string
+ constructor(schema: string)
+}
+
+export declare class GrammarRegex {
+ pattern: string
+ constructor(pattern: string)
+}
+
+export declare class Hash {
+ method: HashMethod
+ value: string
+ constructor(method: HashMethod, value: string)
+}
+
+export declare class Image {
+ id: string
+ url: string
+ theme: ImageTheme
+ format: ImageFormat
+ description?: string
+ width?: number
+ height?: number
+ constructor(id: string, url: string, theme: ImageTheme, format: ImageFormat, description?: string, width?: number, height?: number)
+}
+
+export declare class Metadata {
+ identifier: string
+ name: string
+ description?: string
+ icons: Array<Image>
+ constructor(identifier: string, name: string, description?: string, icons: Array<Image>)
+
+ static external(name: string): Metadata
+}
+
+export declare class Model {
+ identifier: string
+ registry: ModelRegistry
+ backends: Array<ModelBackend>
+ family?: ModelFamily
+ properties?: ModelProperties
+ quantization?: ModelQuantization
+ specializations: Array<ModelSpecialization>
+ accessibility: ModelAccessibility
+ constructor(identifier: string, registry: ModelRegistry, backends: Array<ModelBackend>, family?: ModelFamily, properties?: ModelProperties, quantization?: ModelQuantization, specializations: Array<ModelSpecialization>, accessibility: ModelAccessibility)
+ get name(): string
+ get isLocal(): boolean
+ get isRemote(): boolean
+ get isDownloadable(): boolean
+ get isQuantized(): boolean
+ get cacheIdentifier(): string
+ get repoIds(): Array<string>
+ get localExternalPath(): string | null
+ get referenceName(): string | null
+ get checkpointVersion(): string | null
+
+ static external(identifier: string, registryIdentifier: string, registryName: string, backendIdentifier: string, backendName: string, backendVersion: string, specializations: Array<ModelSpecialization>, accessibility: ModelAccessibility): Model
+ get isChatCapable(): boolean
+ get isClassificationCapable(): boolean
+ get isTextToSpeechCapable(): boolean
+ get isTranslationCapable(): boolean
+ get isSpeculationCapable(): boolean
+}
+
+export declare class ModelAccessibilityLocal {
+ reference: ModelReference
+ constructor(reference: ModelReference)
+}
+
+export declare class ModelAccessibilityRemote {
+ repository?: Repository
+ constructor(repository?: Repository)
+}
+
+export declare class ModelBackend {
+ identifier: string
+ version: string
+ metadata: Metadata
+ constructor(identifier: string, version: string, metadata: Metadata)
+ get name(): string
+}
+
+export declare class ModelFamily {
+ identifier: string
+ vendor: ModelVendor
+ metadata: Metadata
+ constructor(identifier: string, vendor: ModelVendor, metadata: Metadata)
+ get name(): string
+}
+
+export declare class ModelProperties {
+ identifier: string
+ size: number
+ version?: string
+ metadata: Metadata
+ constructor(identifier: string, size: number, version?: string, metadata: Metadata)
+ get name(): string
+}
+
+export declare class ModelQuantization {
+ identifier: string
+ method: string
+ bitsPerWeight: number
+ vendor: ModelVendor
+ metadata: Metadata
+ constructor(identifier: string, method: string, bitsPerWeight: number, vendor: ModelVendor, metadata: Metadata)
+ get name(): string
+}
+
+export declare class ModelReferenceHuggingFace {
+ repository: Repository
+ constructor(repository: Repository)
+}
+
+export declare class ModelReferenceLocal {
+ path: string
+ constructor(path: string)
+}
+
+export declare class ModelReferenceMirai {
+ toolchainVersion: string
+ repository?: Repository
+ sourceRepository?: Repository
+ files: Array<File>
+ constructor(toolchainVersion: string, repository?: Repository, sourceRepository?: Repository, files: Array<File>)
+}
+
+export declare class ModelRegistry {
+ identifier: string
+ metadata: Metadata
+ constructor(identifier: string, metadata: Metadata)
+ get name(): string
+}
+
+export declare class ModelSpecializationChat {
+
+ constructor()
+}
+
+export declare class ModelSpecializationClassification {
+
+ constructor()
+}
+
+export declare class ModelSpecializationSpeculation {
+
+ constructor()
+}
+
+export declare class ModelSpecializationTextToSpeech {
+
+ constructor()
+}
+
+export declare class ModelSpecializationTranslation {
+
+ constructor()
+}
+
+export declare class ModelVendor {
+ identifier: string
+ metadata: Metadata
+ constructor(identifier: string, metadata: Metadata)
+ get name(): string
+}
+
+export declare class PcmBatch {
+ samples: Array<number>
+ sampleRate: number
+ channels: number
+ lengths: Array<number>
+ constructor(samples: Array<number>, sampleRate: number, channels: number, lengths: Array<number>)
+ get batchSize(): number
+ get totalFrames(): number
+ get duration(): number
+ saveAsWav(path: string): void
+}
+
+export declare class Repository {
+ identifier: string
+ commitHash?: string
+ paths?: Array<string>
+ constructor(identifier: string, commitHash?: string, paths?: Array<string>)
+}
+
+export declare class SamplingMethodGreedy {
+
+ constructor()
+}
+
+export declare class SamplingMethodStochastic {
+ temperature?: number
+ topK?: number
+ topP?: number
+ minP?: number
+ constructor(temperature?: number, topK?: number, topP?: number, minP?: number)
+}
+
+export declare class SamplingPolicyCustom {
+ method: SamplingMethod
+ constructor(method: SamplingMethod)
+}
+
+export declare class SamplingPolicyDefault {
+
+ constructor()
+}
+
+export declare class SamplingSeedCustom {
+ seed: number
+ constructor(seed: number)
+}
+
+export declare class SamplingSeedDefault {
+
+ constructor()
+}
+
+export declare class TextToSpeechOutput {
+ pcmBatch: PcmBatch
+ stats: TextToSpeechStats
+ constructor(pcmBatch: PcmBatch, stats: TextToSpeechStats)
+}
+
+export declare class TextToSpeechStats {
+ textLength: number
+ firstChunkSeconds: number
+ generationDuration: number
+ audioDuration: number
+ constructor(textLength: number, firstChunkSeconds: number, generationDuration: number, audioDuration: number)
+}
+
+export declare class Token {
+ id: TokenId
+ value: TokenValue
+ isSpecial: boolean
+ constructor(id: TokenId, value: TokenValue, isSpecial: boolean)
+}
+
+export declare class ToolCall {
+ identifier?: string
+ name: string
+ arguments: any
+ constructor(identifier?: string, name: string, arguments: any)
+}
+
+export declare class ToolDescriptionFunction {
+ toolFunction: ToolFunction
+ constructor(toolFunction: ToolFunction)
+}
+
+export declare class ToolFunction {
+ name: string
+ description: string
+ parameters?: any
+ returnDefinition?: any
+ constructor(name: string, description: string, parameters?: any, returnDefinition?: any)
+}
+
+export declare class ToolNamespace {
+ name: string
+ description?: string
+ tools: Array<ToolDescription>
+ constructor(name: string, description?: string, tools: Array<ToolDescription>)
+}
+
+export declare class TranslationPayloadImage {
+ url: string
+ constructor(url: string)
+}
+
+export declare class TranslationPayloadText {
+ text: string
+ constructor(text: string)
+}
+
+export declare class Value {
+ json: string
+ constructor(json: string)
+}
+
+export type ChatContentBlock =
+ ChatContentBlockIdentity | ChatContentBlockReasoningEffort | ChatContentBlockConversationStartDate | ChatContentBlockKnowledgeCutoff | ChatContentBlockBuiltinTools | ChatContentBlockTools | ChatContentBlockText | ChatContentBlockImage | ChatContentBlockVideo | ChatContentBlockAudio | ChatContentBlockFile | ChatContentBlockReasoning | ChatContentBlockToolCall | ChatContentBlockToolCallCandidate | ChatContentBlockToolCallResult | ChatContentBlockTranslation | ChatContentBlockCustom
+
+export declare const enum ChatContentBlockType {
+ Identity = 'Identity',
+ ReasoningEffort = 'ReasoningEffort',
+ ConversationStartDate = 'ConversationStartDate',
+ KnowledgeCutoff = 'KnowledgeCutoff',
+ BuiltinTools = 'BuiltinTools',
+ Tools = 'Tools',
+ Text = 'Text',
+ Image = 'Image',
+ Video = 'Video',
+ Audio = 'Audio',
+ File = 'File',
+ Reasoning = 'Reasoning',
+ ToolCall = 'ToolCall',
+ ToolCallCandidate = 'ToolCallCandidate',
+ ToolCallResult = 'ToolCallResult',
+ Translation = 'Translation',
+ Custom = 'Custom'
+}
+
+export interface ChatMessageMetadata {
+ values: Record<string, any>
+}
+
+export declare const enum ChatReplyFinishReason {
+ Stop = 'Stop',
+ Length = 'Length',
+ Cancelled = 'Cancelled',
+ ContextLimitReached = 'ContextLimitReached',
+ ToolCalls = 'ToolCalls',
+ Rejected = 'Rejected'
+}
+
+export type ChatRole =
+ ChatRoleUser | ChatRoleAssistant | ChatRoleSystem | ChatRoleDeveloper | ChatRoleTool | ChatRoleCustom
+
+export type ChatSpeculationPreset =
+ ChatSpeculationPresetGeneralChat | ChatSpeculationPresetSummarization | ChatSpeculationPresetClassification
+
+export interface ClassificationOutputProbabilities {
+ values: Record<string, number>
+}
+
+export declare const enum ClassificationRole {
+ User = 'User',
+ Assistant = 'Assistant'
+}
+
+export type ContextLength =
+ ContextLengthDefault | ContextLengthMaximal | ContextLengthCustom
+
+export type Grammar =
+ GrammarJsonAny | GrammarJsonSchema | GrammarRegex
+
+export declare const enum HashMethod {
+ CRC32C = 'CRC32C',
+ MD5 = 'MD5'
+}
+
+export declare const enum ImageFormat {
+ Png = 'Png',
+ Webp = 'Webp',
+ Svg = 'Svg'
+}
+
+export declare const enum ImageTheme {
+ Light = 'Light',
+ Dark = 'Dark'
+}
+
+export type ModelAccessibility =
+ ModelAccessibilityLocal | ModelAccessibilityRemote
+
+export type ModelReference =
+ ModelReferenceMirai | ModelReferenceHuggingFace | ModelReferenceLocal
+
+export type ModelSpecialization =
+ ModelSpecializationChat | ModelSpecializationClassification | ModelSpecializationTextToSpeech | ModelSpecializationTranslation | ModelSpecializationSpeculation
+
+export type PcmBatchError =
+ | { type: 'UnableToSaveAsWav', message: string }
+
+export declare const enum ReasoningEffort {
+ Disabled = 'Disabled',
+ Default = 'Default',
+ Low = 'Low',
+ Medium = 'Medium',
+ High = 'High'
+}
+
+export type SamplingMethod =
+ SamplingMethodGreedy | SamplingMethodStochastic
+
+export type SamplingPolicy =
+ SamplingPolicyDefault | SamplingPolicyCustom
+
+export type SamplingSeed =
+ SamplingSeedDefault | SamplingSeedCustom
+
+export type TokenId =
+ number
+
+export type TokenValue =
+ string
+
+export type ToolDescription =
+ ToolDescriptionFunction
+
+export type TranslationPayload =
+ TranslationPayloadText | TranslationPayloadImage
+export declare class CliApplication {
+ run(): Promise<void>
+ static create(config: EngineConfig): Promise<CliApplication>
+}
+
+export declare class Device {
+ osName?: string
+ cpuName?: string
+ memoryTotal: number
+ homePath: string
+ constructor(osName?: string, cpuName?: string, memoryTotal: number, homePath: string)
+
+ static create(): Device
+}
+
+export declare class Downloader {
+ get state(): Promise<DownloadState | null>
+ resume(): Promise<void>
+ pause(): Promise<void>
+ delete(): Promise<void>
+ progress(): Promise<DownloaderStream>
+}
+
+/**
+ * This type implements JavaScript's async iterable protocol.
+ * It can be used with `for await...of` loops.
+ *
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
+ */
+export declare class DownloaderStream {
+ next(): Promise<DownloaderStreamUpdate | null>
+ [Symbol.asyncIterator](): AsyncGenerator<DownloaderStreamUpdate, void, undefined>
+}
+
+export declare class DownloaderStreamUpdate {
+ bytesTotal: number
+ bytesDownloaded: number
+ constructor(bytesTotal: number, bytesDownloaded: number)
+ get progress(): number
+}
+
+export declare class DownloadPhaseDownloaded {
+
+ constructor()
+}
+
+export declare class DownloadPhaseDownloading {
+
+ constructor()
+}
+
+export declare class DownloadPhaseError {
+ message: string
+ constructor(message: string)
+}
+
+export declare class DownloadPhaseLocked {
+
+ constructor()
+}
+
+export declare class DownloadPhaseNotDownloaded {
+
+ constructor()
+}
+
+export declare class DownloadPhasePaused {
+
+ constructor()
+}
+
+export declare class DownloadState {
+ totalBytes: number
+ downloadedBytes: number
+ phase: DownloadPhase
+ constructor(totalBytes: number, downloadedBytes: number, phase: DownloadPhase)
+ get progress(): number
+ get isInProgress(): boolean
+ get canPause(): boolean
+ get canDelete(): boolean
+ get name(): string
+}
+
+export declare class Engine {
+ static create(config: EngineConfig): Promise<Engine>
+ registerCallback(callback: EngineCallback): Promise<void>
+ removeRegistry(registryIdentifier: string): Promise<void>
+ removeBackend(identifier: string): Promise<void>
+ get models(): Promise<Array<Model>>
+ get modelsLocal(): Promise<Array<Model>>
+ get modelsRemote(): Promise<Array<Model>>
+ get modelsDownloadable(): Promise<Array<Model>>
+ get modelsForChat(): Promise<Array<Model>>
+ get modelsForClassification(): Promise<Array<Model>>
+ get modelsForTextToSpeech(): Promise<Array<Model>>
+ get modelsForTranslation(): Promise<Array<Model>>
+ get modelsForSpeculation(): Promise<Array<Model>>
+ get modelRegistries(): Promise<Array<ModelRegistry>>
+ get modelVendors(): Promise<Array<ModelVendor>>
+ modelsByVendor(vendorIdentifier: string): Promise<Array<Model>>
+ get modelFamilies(): Promise<Array<ModelFamily>>
+ modelsByFamily(familyIdentifier: string): Promise<Array<Model>>
+ model(identifier: string): Promise<Model | null>
+ modelByIdentifier(identifier: string): Promise<Model | null>
+ modelByRepoId(repoId: string): Promise<Model | null>
+ modelByPath(path: string): Promise<Model | null>
+ modelPath(model: Model): Promise<string | null>
+ downloader(model: Model): Downloader
+ download(model: Model): Promise<DownloaderStream>
+ downloadState(model: Model): Promise<DownloadState | null>
+ get downloadStates(): Promise<Record<string, DownloadState>>
+ chat(model: Model, config: ChatConfig): Promise<ChatSession>
+ classification(model: Model): Promise<ClassificationSession>
+ textToSpeech(model: Model): Promise<TextToSpeechSession>
+ settings(): Promise<Settings>
+}
+
+export declare class EngineCallback {
+ static create(callback: () => void): EngineCallback
+}
+
+export declare class EngineConfig {
+ applicationIdentifier?: string
+ miraiApiKey?: string
+ lalamoPath?: string
+ huggingfaceApiKey?: string
+ openaiApiKey?: string
+ anthropicApiKey?: string
+ geminiApiKey?: string
+ xaiApiKey?: string
+ basetenApiKey?: string
+ openrouterApiKey?: string
+ allowOllamaUsage: boolean
+ allowLmstudioUsage: boolean
+ downloadManagerType: DownloadManagerType
+ constructor(applicationIdentifier?: string, miraiApiKey?: string, lalamoPath?: string, huggingfaceApiKey?: string, openaiApiKey?: string, anthropicApiKey?: string, geminiApiKey?: string, xaiApiKey?: string, basetenApiKey?: string, openrouterApiKey?: string, allowOllamaUsage: boolean, allowLmstudioUsage: boolean, downloadManagerType: DownloadManagerType)
+
+ static create(): EngineConfig
+ withApplicationIdentifier(applicationIdentifier: string): EngineConfig
+ withMiraiApiKey(miraiApiKey: string): EngineConfig
+ withLalamoPath(lalamoPath: string): EngineConfig
+ withHuggingfaceApiKey(huggingfaceApiKey: string): EngineConfig
+ withOpenaiApiKey(openaiApiKey: string): EngineConfig
+ withAnthropicApiKey(anthropicApiKey: string): EngineConfig
+ withGeminiApiKey(geminiApiKey: string): EngineConfig
+ withXaiApiKey(xaiApiKey: string): EngineConfig
+ withBasetenApiKey(basetenApiKey: string): EngineConfig
+ withOpenrouterApiKey(openrouterApiKey: string): EngineConfig
+ withAllowOllamaUsage(allowOllamaUsage: boolean): EngineConfig
+ withAllowLmstudioUsage(allowLmstudioUsage: boolean): EngineConfig
+ withDownloadManagerType(downloadManagerType: DownloadManagerType): EngineConfig
+}
+
+export declare class Player {
+ appendPcmBatch(batch: PcmBatch): void
+ stop(): void
+ static create(): Promise<Player>
+}
+
+export declare class Settings {
+ save(kind: SettingKind, key: string, value?: string | undefined | null): void
+ load(kind: SettingKind, key: string): string | null
+ clear(): void
+}
+
+export type CliError =
+ | { type: 'Engine', field0: EngineError }
+ | { type: 'Settigs', field0: SettingsError }
+ | { type: 'RenderingError', message: string }
+
+export type DeviceError =
+ | { type: 'UnsupportedDevice' }
+
+export declare const enum DownloadManagerType {
+ Native = 'Native',
+ Universal = 'Universal'
+}
+
+export type DownloadPhase =
+ DownloadPhaseNotDownloaded | DownloadPhaseDownloading | DownloadPhasePaused | DownloadPhaseDownloaded | DownloadPhaseLocked | DownloadPhaseError
+
+export type EngineError =
+ | { type: 'TokioError', message: string }
+ | { type: 'Device', field0: DeviceError }
+ | { type: 'Settings', field0: SettingsError }
+ | { type: 'Storage', field0: StorageError }
+ | { type: 'Registry', field0: RegistryError }
+ | { type: 'UnableToCreateBackend' }
+ | { type: 'BackendNotFound' }
+ | { type: 'UnableToGetDownloaderProgressStream' }
+ | { type: 'ChatSession', field0: ChatSessionError }
+ | { type: 'ClassificationSession', field0: ClassificationSessionError }
+ | { type: 'TextToSpeechSession', field0: TextToSpeechSessionError }
+ | { type: 'SettingsNotAvailable' }
+
+export type PlayerError =
+ | { type: 'RodioError', message: string }
+ | { type: 'InvalidPcmBatch', message: string }
+
+export type RegistryError =
+ | { type: 'UnableToCreate', message: string }
+ | { type: 'UnableToGetModels', message: string }
+ | { type: 'UnableToAddRegistry', identifier: string }
+
+export declare const enum SettingKind {
+ Config = 'Config',
+ Secret = 'Secret'
+}
+
+export type SettingsError =
+ | { type: 'BackendError', message: string }
+
+export type StorageError =
+ | { type: 'UnableToCreateDirectory', path: string }
+ | { type: 'UnableToCreateDownloadManager', message: string }
+ | { type: 'DownloadManager', message: string }
+ | { type: 'HashNotFound', identifier: string, name: string }
+ | { type: 'InvalidStateTransition', from: DownloadPhase, to: DownloadPhase }
+ | { type: 'IO', message: string }
+ | { type: 'ItemNotFound', identifier: string }
+ | { type: 'Registry', field0: RegistryError }
+ | { type: 'UnsupportedItem', identifier: string }