@fugood/buttress-server 2.25.0-beta.64 → 2.25.0-beta.73

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.
Files changed (41) hide show
  1. package/README.md +31 -9
  2. package/config/sample.toml +9 -0
  3. package/lib/autodiscover/index.d.ts +20 -0
  4. package/lib/autodiscover/sign.d.ts +10 -0
  5. package/lib/autodiscover/types.d.ts +32 -0
  6. package/lib/autodiscover/udp.d.ts +22 -0
  7. package/lib/cli.d.ts +3 -0
  8. package/lib/index.d.ts +29 -0
  9. package/lib/index.mjs +677 -199
  10. package/lib/package.d.ts +7 -0
  11. package/lib/routes/anthropic-messages.d.ts +55 -0
  12. package/lib/routes/file.d.ts +10 -0
  13. package/lib/routes/index.d.ts +5 -0
  14. package/lib/routes/info.check.d.ts +1 -0
  15. package/lib/routes/info.d.ts +4 -0
  16. package/lib/routes/llm-shared.d.ts +54 -0
  17. package/lib/routes/openai-compat.d.ts +17 -0
  18. package/lib/routes/status.d.ts +4 -0
  19. package/lib/services/common.d.ts +29 -0
  20. package/lib/services/create-llm-service.d.ts +24 -0
  21. package/lib/services/ggml-llm.d.ts +5 -0
  22. package/lib/services/ggml-stt.d.ts +26 -0
  23. package/lib/services/index.d.ts +39 -0
  24. package/lib/services/mlx-llm.d.ts +5 -0
  25. package/lib/services/onnx-stt.d.ts +77 -0
  26. package/lib/services/onnx-tts.d.ts +48 -0
  27. package/lib/types.d.ts +158 -0
  28. package/lib/utils/SessionFileManager.d.ts +16 -0
  29. package/lib/utils/buttressAuth.d.ts +25 -0
  30. package/lib/utils/config.d.ts +21 -0
  31. package/lib/utils/httpAuthGuard.d.ts +1 -0
  32. package/lib/utils/net.d.ts +6 -0
  33. package/lib/utils/router.d.ts +2 -0
  34. package/lib/utils/serialize.d.ts +2 -0
  35. package/lib/utils/serverCaps.d.ts +4 -0
  36. package/lib/utils/sessionGuard.d.ts +33 -0
  37. package/lib/utils/test-caps.d.ts +61 -0
  38. package/lib/utils/workspaceState.d.ts +21 -0
  39. package/package.json +7 -7
  40. package/lib/chunk-C7Qqr4sF.mjs +0 -2
  41. package/lib/index.d.mts +0 -498
package/README.md CHANGED
@@ -163,7 +163,7 @@ Most ggml-llm `[generators.model]` keys can also live in `[runtime]` as defaults
163
163
  | `no_extra_bufts` | boolean | Disable extra compute buffer types |
164
164
  | `cpu_mask`, `cpu_strict` | string / boolean | CPU affinity (advanced) |
165
165
  | `devices` | string[] | Restrict to specific GGML devices |
166
- | Speculative keys | various | `speculative`, `spec_type`, `spec_draft_n_max/n_min/p_min/p_split` |
166
+ | Speculative keys | various | `speculative`, `spec_type`, `spec_draft_n_max/n_min/p_min/p_split`, plus draft-model GPU/cache settings |
167
167
 
168
168
  ### `[autodiscover]`
169
169
 
@@ -257,14 +257,23 @@ Loads a GGUF LLM. Runtime keys above can be overridden per-generator under `[gen
257
257
 
258
258
  **Speculative decoding**
259
259
 
260
- | Key | Type | Notes |
261
- | -------------------- | ------ | -------------------------------------------------- |
262
- | `speculative` | string | Draft model identifier |
263
- | `spec_type` | string | Strategy (backend-defined) |
264
- | `spec_draft_n_max` | int | Max drafted tokens per step |
265
- | `spec_draft_n_min` | int | Min drafted tokens |
266
- | `spec_draft_p_min` | number | Min acceptance probability |
267
- | `spec_draft_p_split` | number | Split threshold |
260
+ `model_draft` may be a direct URL/path string or a table with the same
261
+ `repo_id`/`filename`/`url`/`local_path` model keys described above. Local draft paths require
262
+ `allow_local_file = true`. When `download = true`, Buttress pre-downloads both target and draft
263
+ models and includes both in its memory plan.
264
+
265
+ | Key | Type | Notes |
266
+ | -------------------------- | --------------- | ------------------------------------------------------------ |
267
+ | `model_draft` | string \| table | Optional separate GGUF draft model |
268
+ | `speculative` | bool \| string \| table | Enable speculative decoding and optionally select a strategy |
269
+ | `spec_type` | string | Strategy, such as `"draft-mtp"` |
270
+ | `spec_draft_n_max` | int | Max drafted tokens per step |
271
+ | `spec_draft_n_min` | int | Min drafted tokens |
272
+ | `spec_draft_p_min` | number | Min acceptance probability |
273
+ | `spec_draft_p_split` | number | Split threshold |
274
+ | `spec_draft_n_gpu_layers` | int | Draft-model layers offloaded to GPU (`-1` auto, `-2` all) |
275
+ | `spec_draft_cache_type_k` | string | Draft-model K-cache dtype |
276
+ | `spec_draft_cache_type_v` | string | Draft-model V-cache dtype |
268
277
 
269
278
  **Example**
270
279
 
@@ -281,6 +290,19 @@ n_ctx = 12800
281
290
  download = true
282
291
  ```
283
292
 
293
+ A separate draft model can be configured inline:
294
+
295
+ ```toml
296
+ [generators.model]
297
+ repo_id = "org/target-model-GGUF"
298
+ model_draft = { repo_id = "org/draft-model-GGUF", filename = "draft-q8_0.gguf" }
299
+ speculative = { type = "draft-mtp" }
300
+ spec_draft_n_max = 4
301
+ spec_draft_n_gpu_layers = -1
302
+ spec_draft_cache_type_k = "f16"
303
+ spec_draft_cache_type_v = "f16"
304
+ ```
305
+
284
306
  ---
285
307
 
286
308
  ### `ggml-stt` (whisper.cpp via `@fugood/whisper.node`)
@@ -73,6 +73,15 @@ quantization = "mxfp4"
73
73
  download = true
74
74
  n_ctx = 12800 # Max: 131072
75
75
 
76
+ # Optional separate draft model for speculative decoding. Buttress includes the
77
+ # draft model in pre-downloads and memory planning.
78
+ # model_draft = { repo_id = "org/draft-model-GGUF", filename = "draft-q8_0.gguf" }
79
+ # speculative = { type = "draft-mtp" }
80
+ # spec_draft_n_max = 4
81
+ # spec_draft_n_gpu_layers = -1
82
+ # spec_draft_cache_type_k = "f16"
83
+ # spec_draft_cache_type_v = "f16"
84
+
76
85
  [[generators]]
77
86
  type = "ggml-llm"
78
87
  [generators.backend]
@@ -0,0 +1,20 @@
1
+ import type { AutodiscoverConfig } from '../types';
2
+ import type { GetServerInfoFn } from './types';
3
+ import { type AnnounceSigner } from './udp';
4
+ export type { GetServerInfoFn } from './types';
5
+ export { signEnvelope, buildAnnounceSigner, type AnnounceSigner } from './sign';
6
+ /**
7
+ * Autodiscover service that manages discovery transports.
8
+ * Currently supports UDP announcements/responses.
9
+ * HTTP discovery is handled by the info route.
10
+ */
11
+ export declare class AutodiscoverService {
12
+ private config;
13
+ private getServerInfo;
14
+ private signer;
15
+ private transports;
16
+ private started;
17
+ constructor(config: AutodiscoverConfig, getServerInfo: GetServerInfoFn, signer: AnnounceSigner | null);
18
+ start(): Promise<void>;
19
+ stop(): Promise<void>;
20
+ }
@@ -0,0 +1,10 @@
1
+ import crypto from 'node:crypto';
2
+ import type { WorkspaceState } from '../utils/workspaceState';
3
+ import { type IDiscoveryProtocol } from './types';
4
+ export interface AnnounceSigner {
5
+ kid: string;
6
+ privateKey: crypto.KeyObject;
7
+ }
8
+ export declare const canonicalBytes: (t: 'ANNOUNCE' | 'RESPONSE', d: unknown, ts: number) => Buffer;
9
+ export declare const signEnvelope: (signer: AnnounceSigner | null, t: 'ANNOUNCE' | 'RESPONSE', d: IDiscoveryProtocol['d']) => IDiscoveryProtocol | null;
10
+ export declare const buildAnnounceSigner: (workspaceState: WorkspaceState) => AnnounceSigner | null;
@@ -0,0 +1,32 @@
1
+ import type { ServerInfo } from '../types';
2
+ export declare const PROTOCOL_VERSION = "2.0";
3
+ export declare const DEFAULT_PORT = 8089;
4
+ export interface ITransport {
5
+ name: string;
6
+ start(): Promise<void>;
7
+ stop(): Promise<void>;
8
+ }
9
+ interface DiscoveryAnnounce {
10
+ info: Partial<ServerInfo>;
11
+ }
12
+ export interface DiscoveryRequest {
13
+ id: string;
14
+ filters?: {
15
+ generators?: string[];
16
+ min_version?: string;
17
+ };
18
+ }
19
+ interface DiscoveryResponse {
20
+ request_id: string;
21
+ info: Partial<ServerInfo>;
22
+ }
23
+ export interface IDiscoveryProtocol {
24
+ t: 'ANNOUNCE' | 'QUERY' | 'RESPONSE';
25
+ v: string;
26
+ d: DiscoveryAnnounce | DiscoveryRequest | DiscoveryResponse;
27
+ ts?: number;
28
+ kid?: string;
29
+ sig?: string;
30
+ }
31
+ export type GetServerInfoFn = () => ServerInfo;
32
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { AutodiscoverConfig } from '../types';
2
+ import { ITransport, GetServerInfoFn } from './types';
3
+ import { type AnnounceSigner } from './sign';
4
+ export type { AnnounceSigner } from './sign';
5
+ export declare class UdpTransport implements ITransport {
6
+ name: string;
7
+ private receiver;
8
+ private senders;
9
+ private announcementTimer;
10
+ private config;
11
+ private getServerInfo;
12
+ private port;
13
+ private signer;
14
+ constructor(config: AutodiscoverConfig['udp'], getServerInfo: GetServerInfoFn, signer: AnnounceSigner | null);
15
+ start(): Promise<void>;
16
+ stop(): Promise<void>;
17
+ private bindReceiver;
18
+ private createSenders;
19
+ private handleMessage;
20
+ private sendAnnouncement;
21
+ private sendResponse;
22
+ }
package/lib/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export default _default;
3
+ declare function _default(): Promise<void>;
package/lib/index.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ import type { AnyElysia } from 'elysia';
2
+ import * as backendCore from '@fugood/buttress-backend-core';
3
+ import { AutodiscoverService } from './autodiscover';
4
+ import type { Config } from './types';
5
+ export { startModelDownload } from '@fugood/buttress-backend-core';
6
+ export { processConfig } from './utils/config';
7
+ export declare const checkForUpdates: () => Promise<string | null>;
8
+ export declare const compareVersions: (current: string, latest: string) => boolean;
9
+ export declare const logUpdateMessage: (latestVersion: string) => void;
10
+ export declare const checkAndNotifyUpdates: () => Promise<void>;
11
+ export type Backend = typeof backendCore;
12
+ export interface StartServerOptions {
13
+ backend?: Backend;
14
+ router?: AnyElysia;
15
+ config: Config;
16
+ enableOpenAICompat?: boolean;
17
+ enableAnthropicMessages?: boolean;
18
+ }
19
+ export declare const createServer: ({ backend, router, config, enableOpenAICompat, enableAnthropicMessages, }: StartServerOptions) => Promise<{
20
+ app: AnyElysia;
21
+ config: Config;
22
+ }>;
23
+ export declare const startServer: ({ backend, router, config, enableOpenAICompat, enableAnthropicMessages, }: StartServerOptions) => Promise<{
24
+ app: AnyElysia;
25
+ port: number;
26
+ openaiEnabled: boolean;
27
+ anthropicMessagesEnabled: boolean;
28
+ autoDiscover: AutodiscoverService | null;
29
+ }>;