@fugood/buttress-server 2.25.0-beta.63 → 2.25.0-beta.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/autodiscover/index.d.ts +20 -0
- package/lib/autodiscover/sign.d.ts +10 -0
- package/lib/autodiscover/types.d.ts +32 -0
- package/lib/autodiscover/udp.d.ts +22 -0
- package/lib/cli.d.ts +3 -0
- package/lib/index.d.ts +29 -0
- package/lib/index.mjs +671 -193
- package/lib/package.d.ts +7 -0
- package/lib/routes/anthropic-messages.d.ts +55 -0
- package/lib/routes/file.d.ts +10 -0
- package/lib/routes/index.d.ts +5 -0
- package/lib/routes/info.check.d.ts +1 -0
- package/lib/routes/info.d.ts +4 -0
- package/lib/routes/llm-shared.d.ts +54 -0
- package/lib/routes/openai-compat.d.ts +17 -0
- package/lib/routes/status.d.ts +4 -0
- package/lib/services/common.d.ts +29 -0
- package/lib/services/create-llm-service.d.ts +24 -0
- package/lib/services/ggml-llm.d.ts +5 -0
- package/lib/services/ggml-stt.d.ts +26 -0
- package/lib/services/index.d.ts +39 -0
- package/lib/services/mlx-llm.d.ts +5 -0
- package/lib/services/onnx-stt.d.ts +77 -0
- package/lib/services/onnx-tts.d.ts +48 -0
- package/lib/types.d.ts +158 -0
- package/lib/utils/SessionFileManager.d.ts +16 -0
- package/lib/utils/buttressAuth.d.ts +25 -0
- package/lib/utils/config.d.ts +21 -0
- package/lib/utils/httpAuthGuard.d.ts +1 -0
- package/lib/utils/net.d.ts +6 -0
- package/lib/utils/router.d.ts +2 -0
- package/lib/utils/serialize.d.ts +2 -0
- package/lib/utils/serverCaps.d.ts +4 -0
- package/lib/utils/sessionGuard.d.ts +33 -0
- package/lib/utils/test-caps.d.ts +61 -0
- package/lib/utils/workspaceState.d.ts +21 -0
- package/package.json +6 -6
- package/lib/chunk-C7Qqr4sF.mjs +0 -2
- package/lib/index.d.mts +0 -498
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Session } from '../types';
|
|
2
|
+
type AnyRecord = Record<string, unknown>;
|
|
3
|
+
/**
|
|
4
|
+
* Extract a session id from the `X-Buttress-Sess-Id` request header.
|
|
5
|
+
* Query-param fallback is intentionally not supported: session ids would
|
|
6
|
+
* otherwise show up in proxy access logs and browser history, and there is
|
|
7
|
+
* no transport in our supported clients that can't set custom headers.
|
|
8
|
+
*/
|
|
9
|
+
export declare const extractSessionIdFromRequest: (headers: Record<string, string | undefined> | undefined) => string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Elysia `beforeHandle` guard for HTTP routes that operate on a buttress
|
|
12
|
+
* session (file upload/download). Verifies:
|
|
13
|
+
*
|
|
14
|
+
* 1. A session id is supplied via the `X-Buttress-Sess-Id` header.
|
|
15
|
+
* 2. The session exists in the in-memory map (i.e. `init` has been issued
|
|
16
|
+
* over WS for this client).
|
|
17
|
+
* 3. When the server is bound to a workspace, the request's access token
|
|
18
|
+
* identity matches the identity recorded on the session — preventing
|
|
19
|
+
* one device in a workspace from acting on another device's session.
|
|
20
|
+
*
|
|
21
|
+
* Handlers can re-extract the resolved session via `resolveGuardedSession`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const buttressSessionGuard: any;
|
|
24
|
+
/**
|
|
25
|
+
* Re-resolve the session that `buttressSessionGuard` validated. Returns null
|
|
26
|
+
* only if called outside the guard's protection (programming error). Handlers
|
|
27
|
+
* should treat null as 500 / unreachable.
|
|
28
|
+
*/
|
|
29
|
+
export declare const resolveGuardedSession: (store: AnyRecord, headers: Record<string, string | undefined>) => {
|
|
30
|
+
sessionId: string;
|
|
31
|
+
session: Session;
|
|
32
|
+
} | null;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display model capabilities in a Markdown table format
|
|
3
|
+
* @param {Object} options - Display options
|
|
4
|
+
* @param {Array<string>} options.modelIds - Array of model repository IDs
|
|
5
|
+
* @param {Object|null} options.defaultConfig - Default configuration from TOML
|
|
6
|
+
* @returns {Promise<void>}
|
|
7
|
+
*/
|
|
8
|
+
export declare function showModelsTable({ modelIds, defaultConfig, }?: {
|
|
9
|
+
modelIds?: string[];
|
|
10
|
+
defaultConfig?: any;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Test ggml-llm capabilities for a backend type with optional model configuration
|
|
14
|
+
* @param {Object} options - Test options
|
|
15
|
+
* @param {string|null} options.modelId - Model repository ID
|
|
16
|
+
* @param {Object|null} options.defaultConfig - Default configuration from TOML
|
|
17
|
+
* @returns {Promise<void>}
|
|
18
|
+
*/
|
|
19
|
+
export declare function testGgmlLlmCapabilities({ modelId, defaultConfig, }?: {
|
|
20
|
+
modelId?: string | null;
|
|
21
|
+
defaultConfig?: any;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Display STT model capabilities in a Markdown table format
|
|
25
|
+
* @param {Object} options - Display options
|
|
26
|
+
* @param {Array<string>} options.modelIds - Array of model IDs (format: repo_id:filename)
|
|
27
|
+
* @param {Object|null} options.defaultConfig - Default configuration from TOML
|
|
28
|
+
* @returns {Promise<void>}
|
|
29
|
+
*/
|
|
30
|
+
export declare function showSttModelsTable({ modelIds, defaultConfig, }?: {
|
|
31
|
+
modelIds?: string[];
|
|
32
|
+
defaultConfig?: any;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Test ggml-stt capabilities for a backend type with optional model configuration
|
|
36
|
+
* @param {Object} options - Test options
|
|
37
|
+
* @param {string|null} options.modelId - Model ID (format: repo_id:filename)
|
|
38
|
+
* @param {Object|null} options.defaultConfig - Default configuration from TOML
|
|
39
|
+
* @returns {Promise<void>}
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Display MLX model capabilities in a Markdown table format.
|
|
43
|
+
*
|
|
44
|
+
* MLX getCapabilities is a platform/python check (no per-model GGUF metadata),
|
|
45
|
+
* so the table shows hardware fit based on unified memory and model repo IDs.
|
|
46
|
+
*/
|
|
47
|
+
export declare function showMlxModelsTable({ modelIds, defaultConfig, }?: {
|
|
48
|
+
modelIds?: string[];
|
|
49
|
+
defaultConfig?: any;
|
|
50
|
+
}): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Test MLX LLM capabilities for a single model with detailed output
|
|
53
|
+
*/
|
|
54
|
+
export declare function testMlxLlmCapabilities({ modelId, defaultConfig, }?: {
|
|
55
|
+
modelId?: string | null;
|
|
56
|
+
defaultConfig?: any;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
export declare function testGgmlSttCapabilities({ modelId, defaultConfig, }?: {
|
|
59
|
+
modelId?: string | null;
|
|
60
|
+
defaultConfig?: any;
|
|
61
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface WorkspaceBinding {
|
|
2
|
+
id: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
serverId: string;
|
|
5
|
+
issuerPublicKey: string;
|
|
6
|
+
kid: string;
|
|
7
|
+
boundAt: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ServerKeyPair {
|
|
10
|
+
publicKeySpki: string;
|
|
11
|
+
privateKeyPkcs8: string;
|
|
12
|
+
kid: string;
|
|
13
|
+
}
|
|
14
|
+
export interface WorkspaceState {
|
|
15
|
+
workspace: WorkspaceBinding | null;
|
|
16
|
+
serverKeyPair: ServerKeyPair | null;
|
|
17
|
+
}
|
|
18
|
+
export declare const resolveStateDir: () => string;
|
|
19
|
+
export declare const resolveStatePath: () => string;
|
|
20
|
+
export declare const loadWorkspaceState: () => WorkspaceState;
|
|
21
|
+
export declare const saveWorkspaceState: (state: WorkspaceState) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fugood/buttress-server",
|
|
3
|
-
"version": "2.25.0-beta.
|
|
3
|
+
"version": "2.25.0-beta.70",
|
|
4
4
|
"main": "lib/index.mjs",
|
|
5
|
-
"types": "lib/index.d.
|
|
5
|
+
"types": "lib/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"bricks-buttress": "./bin/bricks-buttress"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
17
|
"typecheck": "tsc --noEmit",
|
|
18
|
-
"build": "tsdown -c rolldown.config.js",
|
|
18
|
+
"build": "tsdown -c rolldown.config.js && tsc --noCheck --emitDeclarationOnly",
|
|
19
19
|
"prepublish": "bun run build",
|
|
20
20
|
"dev": "bun src/index.ts",
|
|
21
21
|
"start": "bun lib/index.mjs",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"zod": "^3.25.76"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"tsdown": "^0.
|
|
48
|
-
"typescript": "^
|
|
47
|
+
"tsdown": "^0.22.4",
|
|
48
|
+
"typescript": "^7.0.2"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "3587a7e806a776b3ecc868738def1d4630f485ec"
|
|
51
51
|
}
|
package/lib/chunk-C7Qqr4sF.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(e,t)=>()=>(e&&(t=e(e=0)),t),a=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),o=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n&&e(r,Symbol.toStringTag,{value:`Module`}),r},s=(i,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(var c=n(a),l=0,u=c.length,d;l<u;l++)d=c[l],!r.call(i,d)&&d!==o&&e(i,d,{get:(e=>a[e]).bind(null,d),enumerable:!(s=t(a,d))||s.enumerable});return i},c=t=>r.call(t,`module.exports`)?t[`module.exports`]:s(e({},`__esModule`,{value:!0}),t);export{c as i,i as n,o as r,a as t};
|
package/lib/index.d.mts
DELETED
|
@@ -1,498 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { AnyElysia, Elysia } from "elysia";
|
|
3
|
-
import * as node_stream_web0 from "node:stream/web";
|
|
4
|
-
import { ReadableStream } from "node:stream/web";
|
|
5
|
-
import crypto from "node:crypto";
|
|
6
|
-
import { EventEmitter } from "node:events";
|
|
7
|
-
import { estimateOnnxRuntimeMemory as estimateRuntimeMemory } from "@fugood/buttress-hardware-guardrails";
|
|
8
|
-
|
|
9
|
-
//#region ../buttress-backend-core/lib/types/test-caps-config.d.ts
|
|
10
|
-
declare function createTestCapsDefaultConfigResolver(defaultConfig: any, type: any): {
|
|
11
|
-
globalDefaults: any;
|
|
12
|
-
resolveDefaultConfig: (modelRepoId: any) => {};
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region ../buttress-backend-core/lib/types/caps.d.ts
|
|
16
|
-
declare function getCapabilities(type: any, currentClientCapabilities?: any, options?: {}): Promise<any>;
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region ../buttress-backend-core/lib/types/status.d.ts
|
|
19
|
-
/**
|
|
20
|
-
* StatusTracker - Manages history with fixed limit using circular buffer pattern
|
|
21
|
-
*/
|
|
22
|
-
declare class StatusTracker {
|
|
23
|
-
constructor(maxEntries?: number);
|
|
24
|
-
maxEntries: number;
|
|
25
|
-
modelLoads: any[];
|
|
26
|
-
completions: any[];
|
|
27
|
-
transcriptions: any[];
|
|
28
|
-
addModelLoad(entry: any): void;
|
|
29
|
-
addCompletion(entry: any): void;
|
|
30
|
-
addTranscription(entry: any): void;
|
|
31
|
-
getModelLoadHistory(): any[];
|
|
32
|
-
getCompletionHistory(): any[];
|
|
33
|
-
getTranscriptionHistory(): any[];
|
|
34
|
-
clear(): void;
|
|
35
|
-
}
|
|
36
|
-
declare const llmStatusTracker: StatusTracker;
|
|
37
|
-
declare const sttStatusTracker: StatusTracker;
|
|
38
|
-
declare const statusEmitter: EventEmitter<[never]>;
|
|
39
|
-
/**
|
|
40
|
-
* Subscribe to all status changes
|
|
41
|
-
* @param {Function} callback - Called with { type, entry } on each change
|
|
42
|
-
* @returns {Function} Unsubscribe function
|
|
43
|
-
*/
|
|
44
|
-
declare function subscribeToStatus(callback: Function): Function;
|
|
45
|
-
/**
|
|
46
|
-
* Subscribe with ID for management
|
|
47
|
-
* @param {Function} callback
|
|
48
|
-
* @returns {{ subscriberId: number, unsubscribe: Function }}
|
|
49
|
-
*/
|
|
50
|
-
declare function subscribeToStatusWithId(callback: Function): {
|
|
51
|
-
subscriberId: number;
|
|
52
|
-
unsubscribe: Function;
|
|
53
|
-
};
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region ../buttress-backend-core/lib/types/test-caps.d.ts
|
|
56
|
-
/**
|
|
57
|
-
* Display model capabilities in a Markdown table format
|
|
58
|
-
* @param {Object} options - Display options
|
|
59
|
-
* @param {Array<string>} options.modelIds - Array of model repository IDs
|
|
60
|
-
* @param {Object|null} options.defaultConfig - Default configuration from TOML
|
|
61
|
-
* @returns {Promise<void>}
|
|
62
|
-
*/
|
|
63
|
-
declare function showModelsTable({
|
|
64
|
-
modelIds,
|
|
65
|
-
defaultConfig
|
|
66
|
-
}?: {
|
|
67
|
-
modelIds: Array<string>;
|
|
68
|
-
defaultConfig: any | null;
|
|
69
|
-
}): Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Test ggml-llm capabilities for a backend type with optional model configuration
|
|
72
|
-
* @param {Object} options - Test options
|
|
73
|
-
* @param {string|null} options.modelId - Model repository ID
|
|
74
|
-
* @param {Object|null} options.defaultConfig - Default configuration from TOML
|
|
75
|
-
* @returns {Promise<void>}
|
|
76
|
-
*/
|
|
77
|
-
declare function testGgmlLlmCapabilities({
|
|
78
|
-
modelId,
|
|
79
|
-
defaultConfig
|
|
80
|
-
}?: {
|
|
81
|
-
modelId: string | null;
|
|
82
|
-
defaultConfig: any | null;
|
|
83
|
-
}): Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
* Display STT model capabilities in a Markdown table format
|
|
86
|
-
* @param {Object} options - Display options
|
|
87
|
-
* @param {Array<string>} options.modelIds - Array of model IDs (format: repo_id:filename)
|
|
88
|
-
* @param {Object|null} options.defaultConfig - Default configuration from TOML
|
|
89
|
-
* @returns {Promise<void>}
|
|
90
|
-
*/
|
|
91
|
-
declare function showSttModelsTable({
|
|
92
|
-
modelIds,
|
|
93
|
-
defaultConfig
|
|
94
|
-
}?: {
|
|
95
|
-
modelIds: Array<string>;
|
|
96
|
-
defaultConfig: any | null;
|
|
97
|
-
}): Promise<void>;
|
|
98
|
-
/**
|
|
99
|
-
* Test ggml-stt capabilities for a backend type with optional model configuration
|
|
100
|
-
* @param {Object} options - Test options
|
|
101
|
-
* @param {string|null} options.modelId - Model ID (format: repo_id:filename)
|
|
102
|
-
* @param {Object|null} options.defaultConfig - Default configuration from TOML
|
|
103
|
-
* @returns {Promise<void>}
|
|
104
|
-
*/
|
|
105
|
-
declare function testGgmlSttCapabilities({
|
|
106
|
-
modelId,
|
|
107
|
-
defaultConfig
|
|
108
|
-
}?: {
|
|
109
|
-
modelId: string | null;
|
|
110
|
-
defaultConfig: any | null;
|
|
111
|
-
}): Promise<void>;
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region ../buttress-backend-core/lib/types/utils/onnx.d.ts
|
|
114
|
-
declare function resolveModelCacheDir(cacheDir: string, repoId: string, revision?: string): string;
|
|
115
|
-
declare function estimateOnnxModelSize({
|
|
116
|
-
repoId,
|
|
117
|
-
revision,
|
|
118
|
-
modelType,
|
|
119
|
-
dtype,
|
|
120
|
-
cacheDir,
|
|
121
|
-
baseUrl,
|
|
122
|
-
subfolder,
|
|
123
|
-
headers,
|
|
124
|
-
configJson
|
|
125
|
-
}: {
|
|
126
|
-
repoId: string;
|
|
127
|
-
revision?: string;
|
|
128
|
-
modelType?: string;
|
|
129
|
-
dtype?: string | Record<string, string>;
|
|
130
|
-
cacheDir?: string;
|
|
131
|
-
baseUrl?: string;
|
|
132
|
-
subfolder?: string;
|
|
133
|
-
headers?: Record<string, string>;
|
|
134
|
-
configJson?: Record<string, any>;
|
|
135
|
-
}): Promise<{
|
|
136
|
-
totalBytes: number;
|
|
137
|
-
files: Array<{
|
|
138
|
-
name: string;
|
|
139
|
-
dtype: string;
|
|
140
|
-
bytes: number;
|
|
141
|
-
}>;
|
|
142
|
-
warnings: string[];
|
|
143
|
-
source: "local" | "remote";
|
|
144
|
-
}>;
|
|
145
|
-
declare function resolveOnnxDownloadManifest({
|
|
146
|
-
repoId,
|
|
147
|
-
revision,
|
|
148
|
-
modelType,
|
|
149
|
-
dtype,
|
|
150
|
-
cacheDir,
|
|
151
|
-
baseUrl,
|
|
152
|
-
subfolder,
|
|
153
|
-
headers,
|
|
154
|
-
configJson
|
|
155
|
-
}: {
|
|
156
|
-
repoId: string;
|
|
157
|
-
revision?: string;
|
|
158
|
-
modelType?: string;
|
|
159
|
-
dtype?: string | Record<string, string>;
|
|
160
|
-
cacheDir: string;
|
|
161
|
-
baseUrl?: string;
|
|
162
|
-
subfolder?: string;
|
|
163
|
-
headers?: Record<string, string>;
|
|
164
|
-
configJson?: Record<string, any>;
|
|
165
|
-
}): Promise<{
|
|
166
|
-
modelDir: string;
|
|
167
|
-
files: Array<{
|
|
168
|
-
rfilename: string;
|
|
169
|
-
url: string;
|
|
170
|
-
localPath: string;
|
|
171
|
-
size: number;
|
|
172
|
-
}>;
|
|
173
|
-
config: Record<string, any> | null;
|
|
174
|
-
}>;
|
|
175
|
-
declare function startOnnxModelDownload(config: object, globalDownloadManager: object, options?: {
|
|
176
|
-
onProgress?: (p: number) => void;
|
|
177
|
-
onComplete?: (info: object) => void;
|
|
178
|
-
onError?: (err: Error) => void;
|
|
179
|
-
}): Promise<{
|
|
180
|
-
started: boolean;
|
|
181
|
-
localPath: string | null;
|
|
182
|
-
repoId: string | null;
|
|
183
|
-
}>;
|
|
184
|
-
declare namespace index_d_exports {
|
|
185
|
-
export { createTestCapsDefaultConfigResolver, estimateOnnxModelSize, estimateRuntimeMemory, finalizeGenerator, generatorRegistry, getCapabilities, getModelIdentifier, ggmlLlm, ggmlStt, globalDownloadManager, mlxLlm, onnxStt, onnxTts, resolveModelCacheDir, resolveOnnxDownloadManifest, showModelsTable, showSttModelsTable, startGenerator, startModelDownload, startOnnxModelDownload, status, testGgmlLlmCapabilities, testGgmlSttCapabilities };
|
|
186
|
-
}
|
|
187
|
-
declare function startGenerator(type: any, config: any): Promise<{
|
|
188
|
-
id: any;
|
|
189
|
-
info: any;
|
|
190
|
-
}>;
|
|
191
|
-
declare function finalizeGenerator(id: any): Promise<boolean>;
|
|
192
|
-
declare function getModelIdentifier(type: any, config: any): any;
|
|
193
|
-
declare namespace ggmlLlm {
|
|
194
|
-
function initContext(id: any, property: any): Promise<any>;
|
|
195
|
-
function completion(id: any, property: any): Promise<any>;
|
|
196
|
-
function tokenize(id: any, property: any): Promise<any>;
|
|
197
|
-
function detokenize(id: any, property: any): Promise<any>;
|
|
198
|
-
function applyChatTemplate(id: any, property: any): Promise<any>;
|
|
199
|
-
function releaseContext(id: any, property: any): Promise<any>;
|
|
200
|
-
}
|
|
201
|
-
declare namespace ggmlStt {
|
|
202
|
-
function initContext(id: any, property: any): Promise<any>;
|
|
203
|
-
function transcribe(id: any, property: any): Promise<any>;
|
|
204
|
-
function transcribeData(id: any, property: any): Promise<any>;
|
|
205
|
-
function releaseContext(id: any, property: any): Promise<any>;
|
|
206
|
-
}
|
|
207
|
-
declare namespace mlxLlm {
|
|
208
|
-
function initContext(id: any, property: any): Promise<any>;
|
|
209
|
-
function completion(id: any, property: any): Promise<any>;
|
|
210
|
-
function tokenize(id: any, property: any): Promise<any>;
|
|
211
|
-
function detokenize(id: any, property: any): Promise<any>;
|
|
212
|
-
function applyChatTemplate(id: any, property: any): Promise<any>;
|
|
213
|
-
function releaseContext(id: any, property: any): Promise<any>;
|
|
214
|
-
}
|
|
215
|
-
declare namespace onnxStt {
|
|
216
|
-
function initContext(id: any, property: any): Promise<any>;
|
|
217
|
-
/**
|
|
218
|
-
* @returns {import('node:stream/web').ReadableStream}
|
|
219
|
-
*/
|
|
220
|
-
function transcribe(id: any, property: any): node_stream_web0.ReadableStream;
|
|
221
|
-
function transcribeData(id: any, property: any): Promise<any>;
|
|
222
|
-
function releaseContext(id: any, property: any): Promise<any>;
|
|
223
|
-
}
|
|
224
|
-
declare namespace onnxTts {
|
|
225
|
-
function initContext(id: any, property: any): Promise<any>;
|
|
226
|
-
function addSpeaker(id: any, speaker: any): Promise<any>;
|
|
227
|
-
function synthesize(id: any, property: any): Promise<any>;
|
|
228
|
-
function releaseContext(id: any, property: any): Promise<any>;
|
|
229
|
-
}
|
|
230
|
-
declare namespace status {
|
|
231
|
-
export function getFullStatus(): {
|
|
232
|
-
timestamp: string;
|
|
233
|
-
ggmlLlm: any;
|
|
234
|
-
ggmlStt: any;
|
|
235
|
-
mlxLlm: any;
|
|
236
|
-
onnxStt: any;
|
|
237
|
-
onnxTts: {
|
|
238
|
-
generators: {
|
|
239
|
-
id: any;
|
|
240
|
-
type: any;
|
|
241
|
-
refCount: any;
|
|
242
|
-
repoId: any;
|
|
243
|
-
dtype: any;
|
|
244
|
-
provider: any;
|
|
245
|
-
device: any;
|
|
246
|
-
modelBytes: any;
|
|
247
|
-
vocoderRepoId: any;
|
|
248
|
-
pipelines: any;
|
|
249
|
-
}[];
|
|
250
|
-
history: {
|
|
251
|
-
modelLoads: any[];
|
|
252
|
-
syntheses: any[];
|
|
253
|
-
};
|
|
254
|
-
};
|
|
255
|
-
};
|
|
256
|
-
export function getGgmlLlmStatus(): any;
|
|
257
|
-
export function getGgmlSttStatus(): any;
|
|
258
|
-
export function getMlxLlmStatus(): any;
|
|
259
|
-
export { subscribeToStatus };
|
|
260
|
-
export { subscribeToStatusWithId };
|
|
261
|
-
export { llmStatusTracker };
|
|
262
|
-
export { sttStatusTracker };
|
|
263
|
-
export { statusEmitter };
|
|
264
|
-
}
|
|
265
|
-
declare const generatorRegistry: Map<any, any>;
|
|
266
|
-
declare namespace globalDownloadManager {
|
|
267
|
-
let downloads: Map<any, any>;
|
|
268
|
-
/**
|
|
269
|
-
* Get an existing download promise for a model path
|
|
270
|
-
* @param {string} localPath - The local path for the model
|
|
271
|
-
* @returns {Promise<void>|null} - The download promise or null if not downloading
|
|
272
|
-
*/
|
|
273
|
-
function getDownload(localPath: string): Promise<void> | null;
|
|
274
|
-
/**
|
|
275
|
-
* Register a download promise for a model path
|
|
276
|
-
* @param {string} localPath - The local path for the model
|
|
277
|
-
* @param {Promise<void>} downloadPromise - The download promise
|
|
278
|
-
*/
|
|
279
|
-
function setDownload(localPath: string, downloadPromise: Promise<void>): void;
|
|
280
|
-
/**
|
|
281
|
-
* Remove a download from tracking
|
|
282
|
-
* @param {string} localPath - The local path for the model
|
|
283
|
-
*/
|
|
284
|
-
function deleteDownload(localPath: string): void;
|
|
285
|
-
/**
|
|
286
|
-
* Check if a model is currently being downloaded
|
|
287
|
-
* @param {string} localPath - The local path for the model
|
|
288
|
-
* @returns {boolean}
|
|
289
|
-
*/
|
|
290
|
-
function isDownloading(localPath: string): boolean;
|
|
291
|
-
/**
|
|
292
|
-
* Get all active downloads
|
|
293
|
-
* @returns {Array<{localPath: string, promise: Promise<void>}>}
|
|
294
|
-
*/
|
|
295
|
-
function getActiveDownloads(): Array<{
|
|
296
|
-
localPath: string;
|
|
297
|
-
promise: Promise<void>;
|
|
298
|
-
}>;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Start downloading a model if download=true in config.
|
|
302
|
-
* This function starts the download in the background and returns immediately.
|
|
303
|
-
* The download will be tracked by the global download manager so that
|
|
304
|
-
* initContext can wait for it if needed.
|
|
305
|
-
*
|
|
306
|
-
* @param {string} type - The generator type ('ggml-llm', 'ggml-stt', etc.)
|
|
307
|
-
* @param {Object} config - The generator configuration
|
|
308
|
-
* @param {Object} options - Options for the download
|
|
309
|
-
* @param {function} options.onProgress - Progress callback (0-1)
|
|
310
|
-
* @param {function} options.onComplete - Called when download completes
|
|
311
|
-
* @param {function} options.onError - Called on error
|
|
312
|
-
* @returns {Promise<{started: boolean, localPath: string|null, repoId: string|null}>}
|
|
313
|
-
*/
|
|
314
|
-
declare function startModelDownload(type: string, config: any, options?: {
|
|
315
|
-
onProgress: Function;
|
|
316
|
-
onComplete: Function;
|
|
317
|
-
onError: Function;
|
|
318
|
-
}): Promise<{
|
|
319
|
-
started: boolean;
|
|
320
|
-
localPath: string | null;
|
|
321
|
-
repoId: string | null;
|
|
322
|
-
}>;
|
|
323
|
-
//#endregion
|
|
324
|
-
//#region src/types.d.ts
|
|
325
|
-
type HumanReadableUnit = number | string;
|
|
326
|
-
type HumanReadableServerConfig = {
|
|
327
|
-
id?: string;
|
|
328
|
-
name?: string;
|
|
329
|
-
port?: number;
|
|
330
|
-
log_level?: 'debug' | 'info' | 'warn' | 'error';
|
|
331
|
-
max_body_size?: HumanReadableUnit;
|
|
332
|
-
session_timeout?: HumanReadableUnit;
|
|
333
|
-
temp_file_dir?: string;
|
|
334
|
-
};
|
|
335
|
-
type SessionCacheConfig = {
|
|
336
|
-
enabled?: boolean;
|
|
337
|
-
max_size_bytes?: HumanReadableUnit;
|
|
338
|
-
max_entries?: number;
|
|
339
|
-
};
|
|
340
|
-
type RuntimeConfig = {
|
|
341
|
-
cache_dir?: string;
|
|
342
|
-
huggingface_token?: string;
|
|
343
|
-
session_cache?: SessionCacheConfig;
|
|
344
|
-
} & Record<string, any>;
|
|
345
|
-
type GeneratorType = 'ggml-llm' | 'ggml-stt' | 'mlx-llm' | 'onnx-stt' | 'onnx-tts';
|
|
346
|
-
type GeneratorConfig = {
|
|
347
|
-
type: GeneratorType;
|
|
348
|
-
} & Record<string, any>;
|
|
349
|
-
type GlobalConfig = {
|
|
350
|
-
runtime?: RuntimeConfig;
|
|
351
|
-
openai_compat?: {
|
|
352
|
-
enabled?: boolean;
|
|
353
|
-
cors_allowed_origins?: string | string[];
|
|
354
|
-
};
|
|
355
|
-
anthropic_messages?: {
|
|
356
|
-
enabled?: boolean;
|
|
357
|
-
cors_allowed_origins?: string | string[];
|
|
358
|
-
};
|
|
359
|
-
} & Record<string, any>;
|
|
360
|
-
type AutodiscoverConfig = {
|
|
361
|
-
udp: {
|
|
362
|
-
port?: number;
|
|
363
|
-
announcements: {
|
|
364
|
-
enabled: boolean;
|
|
365
|
-
interval?: number;
|
|
366
|
-
};
|
|
367
|
-
requests: {
|
|
368
|
-
enabled: boolean;
|
|
369
|
-
responseDelay?: number;
|
|
370
|
-
};
|
|
371
|
-
};
|
|
372
|
-
http: {
|
|
373
|
-
enabled: boolean;
|
|
374
|
-
path?: string;
|
|
375
|
-
cors?: boolean;
|
|
376
|
-
};
|
|
377
|
-
mdns?: {
|
|
378
|
-
enabled: boolean;
|
|
379
|
-
};
|
|
380
|
-
};
|
|
381
|
-
type HumanReadableConfig = {
|
|
382
|
-
autodiscover?: AutodiscoverConfig | boolean;
|
|
383
|
-
server?: HumanReadableServerConfig;
|
|
384
|
-
generators?: GeneratorConfig[];
|
|
385
|
-
} & GlobalConfig;
|
|
386
|
-
type ServerConfig = {
|
|
387
|
-
id: string;
|
|
388
|
-
name: string;
|
|
389
|
-
port: number;
|
|
390
|
-
log_level?: 'debug' | 'info' | 'warn' | 'error';
|
|
391
|
-
max_body_size: number;
|
|
392
|
-
session_timeout: number;
|
|
393
|
-
temp_file_dir: string;
|
|
394
|
-
};
|
|
395
|
-
type Config = {
|
|
396
|
-
autodiscover: AutodiscoverConfig | null;
|
|
397
|
-
server: ServerConfig;
|
|
398
|
-
global: GlobalConfig;
|
|
399
|
-
generators: GeneratorConfig[];
|
|
400
|
-
};
|
|
401
|
-
type GeneratorInfo = {
|
|
402
|
-
type: GeneratorType; /** Performance score 0–100 from buttress-hardware-guardrails. */
|
|
403
|
-
score?: number; /** Whether the host has an accelerator (GPU/Metal/etc) for this backend. */
|
|
404
|
-
hasGpu?: boolean; /** Usable memory in bytes for this backend (GPU when present, else CPU). */
|
|
405
|
-
usableBytes?: number;
|
|
406
|
-
} & Record<string, any>;
|
|
407
|
-
type ServerInfo = {
|
|
408
|
-
id: string;
|
|
409
|
-
name: string;
|
|
410
|
-
version: string;
|
|
411
|
-
address: string;
|
|
412
|
-
addresses?: string[];
|
|
413
|
-
port: number;
|
|
414
|
-
url: string;
|
|
415
|
-
generators: GeneratorInfo[];
|
|
416
|
-
authentication: {
|
|
417
|
-
required: boolean;
|
|
418
|
-
type: string; /** Issuer key id (when type === 'workspace-jwt'). */
|
|
419
|
-
kid?: string; /** True when buttress is paired with a workspace. */
|
|
420
|
-
bound?: boolean;
|
|
421
|
-
}; /** Workspace identity (only present when paired). */
|
|
422
|
-
workspace?: {
|
|
423
|
-
id: string;
|
|
424
|
-
name?: string;
|
|
425
|
-
};
|
|
426
|
-
};
|
|
427
|
-
//#endregion
|
|
428
|
-
//#region src/autodiscover/types.d.ts
|
|
429
|
-
type GetServerInfoFn = () => ServerInfo;
|
|
430
|
-
//#endregion
|
|
431
|
-
//#region src/autodiscover/sign.d.ts
|
|
432
|
-
interface AnnounceSigner {
|
|
433
|
-
kid: string;
|
|
434
|
-
privateKey: crypto.KeyObject;
|
|
435
|
-
}
|
|
436
|
-
//#endregion
|
|
437
|
-
//#region src/autodiscover/index.d.ts
|
|
438
|
-
/**
|
|
439
|
-
* Autodiscover service that manages discovery transports.
|
|
440
|
-
* Currently supports UDP announcements/responses.
|
|
441
|
-
* HTTP discovery is handled by the info route.
|
|
442
|
-
*/
|
|
443
|
-
declare class AutodiscoverService {
|
|
444
|
-
private config;
|
|
445
|
-
private getServerInfo;
|
|
446
|
-
private signer;
|
|
447
|
-
private transports;
|
|
448
|
-
private started;
|
|
449
|
-
constructor(config: AutodiscoverConfig, getServerInfo: GetServerInfoFn, signer: AnnounceSigner | null);
|
|
450
|
-
start(): Promise<void>;
|
|
451
|
-
stop(): Promise<void>;
|
|
452
|
-
}
|
|
453
|
-
//#endregion
|
|
454
|
-
//#region src/utils/config.d.ts
|
|
455
|
-
/**
|
|
456
|
-
* Process raw user config (HumanReadableConfig) into Config.
|
|
457
|
-
* Handles: device defaults, value normalization (bytes/ms), structure splitting.
|
|
458
|
-
*/
|
|
459
|
-
declare const processConfig: (input: HumanReadableConfig | null) => Config;
|
|
460
|
-
//#endregion
|
|
461
|
-
//#region src/index.d.ts
|
|
462
|
-
declare const checkForUpdates: () => Promise<string | null>;
|
|
463
|
-
declare const compareVersions: (current: string, latest: string) => boolean;
|
|
464
|
-
declare const logUpdateMessage: (latestVersion: string) => void;
|
|
465
|
-
declare const checkAndNotifyUpdates: () => Promise<void>;
|
|
466
|
-
type Backend = typeof index_d_exports;
|
|
467
|
-
interface StartServerOptions {
|
|
468
|
-
backend?: Backend;
|
|
469
|
-
router?: AnyElysia;
|
|
470
|
-
config: Config;
|
|
471
|
-
enableOpenAICompat?: boolean;
|
|
472
|
-
enableAnthropicMessages?: boolean;
|
|
473
|
-
}
|
|
474
|
-
declare const createServer: ({
|
|
475
|
-
backend,
|
|
476
|
-
router,
|
|
477
|
-
config,
|
|
478
|
-
enableOpenAICompat,
|
|
479
|
-
enableAnthropicMessages
|
|
480
|
-
}: StartServerOptions) => Promise<{
|
|
481
|
-
app: AnyElysia;
|
|
482
|
-
config: Config;
|
|
483
|
-
}>;
|
|
484
|
-
declare const startServer: ({
|
|
485
|
-
backend,
|
|
486
|
-
router,
|
|
487
|
-
config,
|
|
488
|
-
enableOpenAICompat,
|
|
489
|
-
enableAnthropicMessages
|
|
490
|
-
}: StartServerOptions) => Promise<{
|
|
491
|
-
app: AnyElysia;
|
|
492
|
-
port: number;
|
|
493
|
-
openaiEnabled: boolean;
|
|
494
|
-
anthropicMessagesEnabled: boolean;
|
|
495
|
-
autoDiscover: AutodiscoverService | null;
|
|
496
|
-
}>;
|
|
497
|
-
//#endregion
|
|
498
|
-
export { Backend, StartServerOptions, checkAndNotifyUpdates, checkForUpdates, compareVersions, createServer, logUpdateMessage, processConfig, startModelDownload, startServer };
|