@fugood/buttress-server 2.25.0-beta.9 → 2.25.1-beta.0

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 (72) hide show
  1. package/README.md +506 -35
  2. package/config/function-samples/README.md +37 -0
  3. package/config/function-samples/_auth.ts +48 -0
  4. package/config/function-samples/host-info.ts +25 -0
  5. package/config/function-samples/summarize-text.ts +55 -0
  6. package/config/function-samples/text-to-speech.ts +51 -0
  7. package/config/function-samples/transcribe-media.ts +65 -0
  8. package/config/sample.toml +25 -0
  9. package/lib/autodiscover/index.d.ts +20 -0
  10. package/lib/autodiscover/sign.d.ts +10 -0
  11. package/lib/autodiscover/types.d.ts +32 -0
  12. package/lib/autodiscover/udp.d.ts +22 -0
  13. package/lib/cli.d.ts +3 -0
  14. package/lib/functions/auth.d.ts +28 -0
  15. package/lib/functions/config.d.ts +20 -0
  16. package/lib/functions/constants.d.ts +17 -0
  17. package/lib/functions/executor.d.ts +27 -0
  18. package/lib/functions/files.d.ts +29 -0
  19. package/lib/functions/index.d.ts +50 -0
  20. package/lib/functions/libs.d.ts +10 -0
  21. package/lib/functions/loader.d.ts +48 -0
  22. package/lib/functions/mcp.d.ts +35 -0
  23. package/lib/functions/registry.d.ts +34 -0
  24. package/lib/functions/scaffold.d.ts +18 -0
  25. package/lib/functions/status.d.ts +119 -0
  26. package/lib/functions/templates.d.ts +14 -0
  27. package/lib/functions/transpile.d.ts +23 -0
  28. package/lib/functions/types.d.ts +196 -0
  29. package/lib/functions/uploads.d.ts +42 -0
  30. package/lib/functions/watcher.d.ts +34 -0
  31. package/lib/index.d.ts +36 -0
  32. package/lib/index.mjs +1539 -64
  33. package/lib/package.d.ts +7 -0
  34. package/lib/routes/anthropic-messages.d.ts +55 -0
  35. package/lib/routes/file.d.ts +10 -0
  36. package/lib/routes/functions.check.d.ts +13 -0
  37. package/lib/routes/functions.d.ts +16 -0
  38. package/lib/routes/generator-cache.d.ts +42 -0
  39. package/lib/routes/index.d.ts +6 -0
  40. package/lib/routes/info.check.d.ts +1 -0
  41. package/lib/routes/info.d.ts +4 -0
  42. package/lib/routes/llm-shared.d.ts +57 -0
  43. package/lib/routes/openai-compat.d.ts +17 -0
  44. package/lib/routes/status.d.ts +4 -0
  45. package/lib/routes/stt-shared.d.ts +36 -0
  46. package/lib/routes/tts-shared.d.ts +36 -0
  47. package/lib/services/common.d.ts +29 -0
  48. package/lib/services/create-llm-service.d.ts +24 -0
  49. package/lib/services/create-onnx-init-context.d.ts +10 -0
  50. package/lib/services/ggml-llm.d.ts +5 -0
  51. package/lib/services/ggml-stt.d.ts +26 -0
  52. package/lib/services/index.d.ts +39 -0
  53. package/lib/services/mlx-llm.d.ts +5 -0
  54. package/lib/services/onnx-stt.d.ts +77 -0
  55. package/lib/services/onnx-tts.d.ts +48 -0
  56. package/lib/types.d.ts +181 -0
  57. package/lib/utils/SessionFileManager.d.ts +16 -0
  58. package/lib/utils/buttressAuth.d.ts +25 -0
  59. package/lib/utils/config.d.ts +21 -0
  60. package/lib/utils/functionsAuthGuard.d.ts +12 -0
  61. package/lib/utils/httpAuthGuard.d.ts +1 -0
  62. package/lib/utils/net.d.ts +6 -0
  63. package/lib/utils/router.d.ts +2 -0
  64. package/lib/utils/serialize.d.ts +2 -0
  65. package/lib/utils/serverCaps.d.ts +4 -0
  66. package/lib/utils/sessionGuard.d.ts +33 -0
  67. package/lib/utils/test-caps.d.ts +61 -0
  68. package/lib/utils/workspaceState.d.ts +21 -0
  69. package/package.json +21 -8
  70. package/public/status.html +278 -1
  71. package/lib/chunk-C8PTHxhX.mjs +0 -2
  72. package/lib/index.d.mts +0 -370
@@ -539,6 +539,81 @@
539
539
  </div>
540
540
  </div>
541
541
  </div>
542
+
543
+ <!-- ONNX-STT Status (hidden unless active) -->
544
+ <div class="card" id="onnxSttCard" style="display:none">
545
+ <div class="card-header">
546
+ <span class="card-title">ONNX-STT Status</span>
547
+ <span class="badge badge-info" id="onnxSttGeneratorCount">0 generators</span>
548
+ </div>
549
+ <div id="onnxSttGenerators"></div>
550
+ <div class="section">
551
+ <div class="section-title collapsible" onclick="toggleSection(this)">Model Load History</div>
552
+ <div class="collapsible-content" id="onnxSttModelHistory">
553
+ <div class="empty-state">No model load history</div>
554
+ </div>
555
+ </div>
556
+ <div class="section">
557
+ <div class="section-title collapsible" onclick="toggleSection(this)">Transcription History</div>
558
+ <div class="collapsible-content" id="onnxSttTranscriptionHistory">
559
+ <div class="empty-state">No transcription history</div>
560
+ </div>
561
+ </div>
562
+ </div>
563
+
564
+ <!-- ONNX-TTS Status (hidden unless active) -->
565
+ <div class="card" id="onnxTtsCard" style="display:none">
566
+ <div class="card-header">
567
+ <span class="card-title">ONNX-TTS Status</span>
568
+ <span class="badge badge-info" id="onnxTtsGeneratorCount">0 generators</span>
569
+ </div>
570
+ <div id="onnxTtsGenerators"></div>
571
+ <div class="section">
572
+ <div class="section-title collapsible" onclick="toggleSection(this)">Model Load History</div>
573
+ <div class="collapsible-content" id="onnxTtsModelHistory">
574
+ <div class="empty-state">No model load history</div>
575
+ </div>
576
+ </div>
577
+ <div class="section">
578
+ <div class="section-title collapsible" onclick="toggleSection(this)">Synthesis History</div>
579
+ <div class="collapsible-content" id="onnxTtsSynthesisHistory">
580
+ <div class="empty-state">No synthesis history</div>
581
+ </div>
582
+ </div>
583
+ </div>
584
+
585
+ <!-- Local Functions (hidden unless enabled) -->
586
+ <div class="card" id="functionsCard" style="display:none">
587
+ <div class="card-header">
588
+ <span class="card-title">Local Functions <span class="badge badge-warning">experimental</span></span>
589
+ <span class="badge badge-info" id="functionsCount">0 functions</span>
590
+ </div>
591
+ <div id="functionsSummary"></div>
592
+ <div class="section">
593
+ <div class="section-title collapsible" onclick="toggleSection(this)">Call History</div>
594
+ <div class="collapsible-content" id="functionsCallHistory">
595
+ <div class="empty-state">No function calls</div>
596
+ </div>
597
+ </div>
598
+ <div class="section">
599
+ <div class="section-title collapsible" onclick="toggleSection(this)">Upload History</div>
600
+ <div class="collapsible-content" id="functionsUploadHistory">
601
+ <div class="empty-state">No uploads</div>
602
+ </div>
603
+ </div>
604
+ <div class="section">
605
+ <div class="section-title collapsible" onclick="toggleSection(this)">Download History</div>
606
+ <div class="collapsible-content" id="functionsDownloadHistory">
607
+ <div class="empty-state">No downloads</div>
608
+ </div>
609
+ </div>
610
+ <div class="section">
611
+ <div class="section-title collapsible" onclick="toggleSection(this)">Auth History</div>
612
+ <div class="collapsible-content" id="functionsAuthHistory">
613
+ <div class="empty-state">No auth activity</div>
614
+ </div>
615
+ </div>
616
+ </div>
542
617
  </div>
543
618
  </div>
544
619
 
@@ -844,6 +919,59 @@
844
919
  })
845
920
  }
846
921
 
922
+ function formatBytes(bytes) {
923
+ if (!bytes || bytes === 0) return '-'
924
+ if (bytes < 1024) return bytes + ' B'
925
+ if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB'
926
+ if (bytes < 1024 * 1024 * 1024) return (bytes / (1024 * 1024)).toFixed(1) + ' MB'
927
+ return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB'
928
+ }
929
+
930
+ function renderOnnxGenerators(containerId, countId, generators, label) {
931
+ const container = document.getElementById(containerId)
932
+ document.getElementById(countId).textContent = `${generators.length} generator${generators.length !== 1 ? 's' : ''}`
933
+
934
+ withScrollPreserve(container, () => {
935
+ if (generators.length === 0) {
936
+ container.innerHTML = `<div class="empty-state">No ${label} generators loaded</div>`
937
+ return
938
+ }
939
+
940
+ container.innerHTML = `
941
+ <div class="table-wrapper">
942
+ <div class="table-inner">
943
+ <table>
944
+ <thead>
945
+ <tr>
946
+ <th>ID</th>
947
+ <th>Model</th>
948
+ <th>DType</th>
949
+ <th>Provider</th>
950
+ <th>Device</th>
951
+ <th>Model Size</th>
952
+ <th>Pipelines</th>
953
+ </tr>
954
+ </thead>
955
+ <tbody>
956
+ ${generators.map(g => `
957
+ <tr>
958
+ <td class="mono">${escapeHtml(g.id?.slice(0, 8) || '-')}</td>
959
+ <td>${formatModelName(g.repoId)}${g.vocoderRepoId ? '<br><span style="font-size:11px;color:var(--text-muted)">+ ' + formatModelName(g.vocoderRepoId) + '</span>' : ''}</td>
960
+ <td>${escapeHtml(typeof g.dtype === 'object' ? JSON.stringify(g.dtype) : g.dtype || '-')}</td>
961
+ <td><span class="badge ${g.provider === 'cpu' ? 'badge-info' : 'badge-success'}">${escapeHtml(g.provider || '-')}</span></td>
962
+ <td>${escapeHtml(g.device || '-')}</td>
963
+ <td>${formatBytes(g.modelBytes)}</td>
964
+ <td>${g.pipelines ?? 0}</td>
965
+ </tr>
966
+ `).join('')}
967
+ </tbody>
968
+ </table>
969
+ </div>
970
+ </div>
971
+ `
972
+ })
973
+ }
974
+
847
975
  // Escape HTML
848
976
  function escapeHtml(str) {
849
977
  if (str == null) return ''
@@ -869,6 +997,8 @@
869
997
  const llm = status.ggmlLlm || {}
870
998
  const stt = status.ggmlStt || {}
871
999
  const mlx = status.mlxLlm || {}
1000
+ const onnxStt = status.onnxStt || {}
1001
+ const onnxTts = status.onnxTts || {}
872
1002
 
873
1003
  // LLM
874
1004
  renderLlmGenerators(llm.generators || [])
@@ -983,6 +1113,153 @@
983
1113
  }
984
1114
  },
985
1115
  ])
1116
+
1117
+ // ONNX-STT
1118
+ const hasOnnxStt = (onnxStt.generators?.length > 0) ||
1119
+ (onnxStt.history?.modelLoads?.length > 0) ||
1120
+ (onnxStt.history?.transcriptions?.length > 0)
1121
+ document.getElementById('onnxSttCard').style.display = hasOnnxStt ? '' : 'none'
1122
+ renderOnnxGenerators('onnxSttGenerators', 'onnxSttGeneratorCount', onnxStt.generators || [], 'ONNX STT')
1123
+
1124
+ renderHistory('onnxSttModelHistory', onnxStt.history?.modelLoads || [], [
1125
+ { label: 'Time', render: i => `<span class="timestamp">${formatRelativeTime(i.timestamp)}</span>` },
1126
+ { label: 'Model', render: i => formatModelName(i.repoId) },
1127
+ { label: 'DType', render: i => escapeHtml(typeof i.dtype === 'object' ? JSON.stringify(i.dtype) : i.dtype || '-') },
1128
+ { label: 'Provider', render: i => `<span class="badge ${i.provider === 'cpu' ? 'badge-info' : 'badge-success'}">${escapeHtml(i.provider || '-')}</span>` },
1129
+ { label: 'Duration', render: i => `${(i.durationMs / 1000).toFixed(1)}s` },
1130
+ { label: 'Status', render: i => i.success ?
1131
+ '<span class="badge badge-success">Success</span>' :
1132
+ `<span class="badge badge-error">Failed: ${escapeHtml(i.error || 'Unknown')}</span>`
1133
+ },
1134
+ ])
1135
+
1136
+ renderHistory('onnxSttTranscriptionHistory', onnxStt.history?.transcriptions || [], [
1137
+ { label: 'Time', render: i => `<span class="timestamp">${formatRelativeTime(i.timestamp)}</span>` },
1138
+ { label: 'Model', render: i => formatModelName(i.repoId) },
1139
+ { label: 'Provider', render: i => escapeHtml(i.provider || '-') },
1140
+ { label: 'Segments', render: i => i.segmentCount ?? '-' },
1141
+ { label: 'Text Len', render: i => i.textLength ?? '-' },
1142
+ { label: 'Duration', render: i => `${(i.durationMs / 1000).toFixed(1)}s` },
1143
+ { label: 'Status', render: i => i.success ?
1144
+ '<span class="badge badge-success">Success</span>' :
1145
+ `<span class="badge badge-error">Failed</span>`
1146
+ },
1147
+ ])
1148
+
1149
+ // ONNX-TTS
1150
+ const hasOnnxTts = (onnxTts.generators?.length > 0) ||
1151
+ (onnxTts.history?.modelLoads?.length > 0) ||
1152
+ (onnxTts.history?.syntheses?.length > 0)
1153
+ document.getElementById('onnxTtsCard').style.display = hasOnnxTts ? '' : 'none'
1154
+ renderOnnxGenerators('onnxTtsGenerators', 'onnxTtsGeneratorCount', onnxTts.generators || [], 'ONNX TTS')
1155
+
1156
+ renderHistory('onnxTtsModelHistory', onnxTts.history?.modelLoads || [], [
1157
+ { label: 'Time', render: i => `<span class="timestamp">${formatRelativeTime(i.timestamp)}</span>` },
1158
+ { label: 'Model', render: i => formatModelName(i.repoId) },
1159
+ { label: 'DType', render: i => escapeHtml(typeof i.dtype === 'object' ? JSON.stringify(i.dtype) : i.dtype || '-') },
1160
+ { label: 'Provider', render: i => `<span class="badge ${i.provider === 'cpu' ? 'badge-info' : 'badge-success'}">${escapeHtml(i.provider || '-')}</span>` },
1161
+ { label: 'Vocoder', render: i => i.vocoderRepoId ? formatModelName(i.vocoderRepoId) : '-' },
1162
+ { label: 'Duration', render: i => `${(i.durationMs / 1000).toFixed(1)}s` },
1163
+ { label: 'Status', render: i => i.success ?
1164
+ '<span class="badge badge-success">Success</span>' :
1165
+ `<span class="badge badge-error">Failed: ${escapeHtml(i.error || 'Unknown')}</span>`
1166
+ },
1167
+ ])
1168
+
1169
+ renderHistory('onnxTtsSynthesisHistory', onnxTts.history?.syntheses || [], [
1170
+ { label: 'Time', render: i => `<span class="timestamp">${formatRelativeTime(i.timestamp)}</span>` },
1171
+ { label: 'Model', render: i => formatModelName(i.repoId) },
1172
+ { label: 'Provider', render: i => escapeHtml(i.provider || '-') },
1173
+ { label: 'Text Len', render: i => i.textLength ?? '-' },
1174
+ { label: 'Duration', render: i => i.cached ? '<span class="badge badge-info">Cached</span>' : `${(i.durationMs / 1000).toFixed(1)}s` },
1175
+ { label: 'Status', render: i => i.success ?
1176
+ '<span class="badge badge-success">Success</span>' :
1177
+ `<span class="badge badge-error">Failed</span>`
1178
+ },
1179
+ ])
1180
+
1181
+ renderFunctionsStatus(status.functions || {})
1182
+ }
1183
+
1184
+ // Local Functions activity (calls, uploads, downloads, auth)
1185
+ function renderFunctionsStatus(fns) {
1186
+ document.getElementById('functionsCard').style.display = fns.enabled ? '' : 'none'
1187
+ if (!fns.enabled) return
1188
+
1189
+ const count = fns.count ?? 0
1190
+ document.getElementById('functionsCount').textContent =
1191
+ `${count} function${count !== 1 ? 's' : ''}`
1192
+
1193
+ const c = fns.counters || {}
1194
+ const summary = document.getElementById('functionsSummary')
1195
+ const stat = (label, value, bad) => `
1196
+ <tr>
1197
+ <td>${label}</td>
1198
+ <td>${value}</td>
1199
+ <td>${bad ? `<span class="badge badge-error">${bad}</span>` : '-'}</td>
1200
+ </tr>
1201
+ `
1202
+ withScrollPreserve(summary, () => {
1203
+ summary.innerHTML = `
1204
+ <div class="table-wrapper">
1205
+ <div class="table-inner">
1206
+ <table>
1207
+ <thead>
1208
+ <tr><th>Activity</th><th>Total</th><th>Problems</th></tr>
1209
+ </thead>
1210
+ <tbody>
1211
+ ${stat('Calls', c.calls?.total ?? 0, c.calls?.failed ? `${c.calls.failed} failed` : '')}
1212
+ ${stat('Uploads', `${c.uploads?.total ?? 0} (${formatBytes(c.uploads?.bytes ?? 0)})`, c.uploads?.failed ? `${c.uploads.failed} failed` : '')}
1213
+ ${stat('Downloads', `${c.downloads?.total ?? 0} (${formatBytes(c.downloads?.bytes ?? 0)})`, c.downloads?.missed ? `${c.downloads.missed} missed` : '')}
1214
+ ${stat('Auth checks', c.auth?.total ?? 0, c.auth?.denied ? `${c.auth.denied} denied` : '')}
1215
+ </tbody>
1216
+ </table>
1217
+ </div>
1218
+ </div>
1219
+ `
1220
+ })
1221
+
1222
+ const history = fns.history || {}
1223
+ const statusBadge = i => i.success ?
1224
+ '<span class="badge badge-success">Success</span>' :
1225
+ `<span class="badge badge-error">Failed: ${escapeHtml(i.error || 'Unknown')}</span>`
1226
+
1227
+ renderHistory('functionsCallHistory', history.calls || [], [
1228
+ { label: 'Time', render: i => `<span class="timestamp">${formatRelativeTime(i.timestamp)}</span>` },
1229
+ { label: 'Function', render: i => escapeHtml(i.name) },
1230
+ { label: 'Surface', render: i => `<span class="badge badge-info">${escapeHtml(i.surface || '-')}</span>` },
1231
+ { label: 'Duration', render: i => `${(i.durationMs / 1000).toFixed(2)}s` },
1232
+ { label: 'Status', render: statusBadge },
1233
+ ])
1234
+
1235
+ renderHistory('functionsUploadHistory', history.uploads || [], [
1236
+ { label: 'Time', render: i => `<span class="timestamp">${formatRelativeTime(i.timestamp)}</span>` },
1237
+ { label: 'Name', render: i => escapeHtml(i.name) },
1238
+ { label: 'Via', render: i => `<span class="badge badge-info">${i.source === 'call' ? 'multipart call' : 'upload'}</span>` },
1239
+ { label: 'Size', render: i => formatBytes(i.size ?? 0) },
1240
+ { label: 'Status', render: statusBadge },
1241
+ ])
1242
+
1243
+ renderHistory('functionsDownloadHistory', history.downloads || [], [
1244
+ { label: 'Time', render: i => `<span class="timestamp">${formatRelativeTime(i.timestamp)}</span>` },
1245
+ { label: 'Path', render: i => escapeHtml(i.path) },
1246
+ { label: 'Size', render: i => i.success ? formatBytes(i.size ?? 0) : '-' },
1247
+ { label: 'Status', render: i => i.success ?
1248
+ '<span class="badge badge-success">Served</span>' :
1249
+ '<span class="badge badge-error">Not found</span>'
1250
+ },
1251
+ ])
1252
+
1253
+ renderHistory('functionsAuthHistory', history.auth || [], [
1254
+ { label: 'Time', render: i => `<span class="timestamp">${formatRelativeTime(i.timestamp)}</span>` },
1255
+ { label: 'Request', render: i => escapeHtml(`${i.method || ''} ${i.path || ''}`.trim()) },
1256
+ { label: 'Mode', render: i => escapeHtml(i.mode || '-') },
1257
+ { label: 'Subject', render: i => escapeHtml(i.subject || '-') },
1258
+ { label: 'Outcome', render: i => i.outcome === 'allowed' ?
1259
+ '<span class="badge badge-success">Allowed</span>' :
1260
+ `<span class="badge badge-error">${escapeHtml(i.outcome || 'denied')}</span>`
1261
+ },
1262
+ ])
986
1263
  }
987
1264
 
988
1265
  // Fallback: Fetch status via HTTP polling
@@ -994,7 +1271,7 @@
994
1271
  const response = await fetch('/buttress/status')
995
1272
  const data = await response.json()
996
1273
  // Direct JSON response (not tRPC wrapped)
997
- if (data.ggmlLlm || data.ggmlStt || data.mlxLlm) {
1274
+ if (data.ggmlLlm || data.ggmlStt || data.mlxLlm || data.onnxStt || data.onnxTts) {
998
1275
  updateUI(data)
999
1276
  setConnectionStatus('connected')
1000
1277
  }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- var e=Object.defineProperty,t=(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};export{t};
package/lib/index.d.mts DELETED
@@ -1,370 +0,0 @@
1
-
2
- import { AnyElysia, Elysia } from "elysia";
3
- import { ReadableStream } from "node:stream/web";
4
- import { EventEmitter } from "node:events";
5
-
6
- //#region ../buttress-backend-core/lib/types/caps.d.ts
7
- declare function getCapabilities(type: any, currentClientCapabilities?: any, options?: {}): Promise<any>;
8
- //#endregion
9
- //#region ../buttress-backend-core/lib/types/status.d.ts
10
- /**
11
- * StatusTracker - Manages history with fixed limit using circular buffer pattern
12
- */
13
- declare class StatusTracker {
14
- constructor(maxEntries?: number);
15
- maxEntries: number;
16
- modelLoads: any[];
17
- completions: any[];
18
- transcriptions: any[];
19
- addModelLoad(entry: any): void;
20
- addCompletion(entry: any): void;
21
- addTranscription(entry: any): void;
22
- getModelLoadHistory(): any[];
23
- getCompletionHistory(): any[];
24
- getTranscriptionHistory(): any[];
25
- clear(): void;
26
- }
27
- declare const llmStatusTracker: StatusTracker;
28
- declare const sttStatusTracker: StatusTracker;
29
- declare const statusEmitter: EventEmitter<[never]>;
30
- /**
31
- * Subscribe to all status changes
32
- * @param {Function} callback - Called with { type, entry } on each change
33
- * @returns {Function} Unsubscribe function
34
- */
35
- declare function subscribeToStatus(callback: Function): Function;
36
- /**
37
- * Subscribe with ID for management
38
- * @param {Function} callback
39
- * @returns {{ subscriberId: number, unsubscribe: Function }}
40
- */
41
- declare function subscribeToStatusWithId(callback: Function): {
42
- subscriberId: number;
43
- unsubscribe: Function;
44
- };
45
- //#endregion
46
- //#region ../buttress-backend-core/lib/types/test-caps.d.ts
47
- /**
48
- * Display model capabilities in a Markdown table format
49
- * @param {Object} options - Display options
50
- * @param {Array<string>} options.modelIds - Array of model repository IDs
51
- * @param {Object|null} options.defaultConfig - Default configuration from TOML
52
- * @returns {Promise<void>}
53
- */
54
- declare function showModelsTable({
55
- modelIds,
56
- defaultConfig
57
- }?: {
58
- modelIds: Array<string>;
59
- defaultConfig: any | null;
60
- }): Promise<void>;
61
- /**
62
- * Test ggml-llm capabilities for a backend type with optional model configuration
63
- * @param {Object} options - Test options
64
- * @param {string|null} options.modelId - Model repository ID
65
- * @param {Object|null} options.defaultConfig - Default configuration from TOML
66
- * @returns {Promise<void>}
67
- */
68
- declare function testGgmlLlmCapabilities({
69
- modelId,
70
- defaultConfig
71
- }?: {
72
- modelId: string | null;
73
- defaultConfig: any | null;
74
- }): Promise<void>;
75
- /**
76
- * Display STT model capabilities in a Markdown table format
77
- * @param {Object} options - Display options
78
- * @param {Array<string>} options.modelIds - Array of model IDs (format: repo_id:filename)
79
- * @param {Object|null} options.defaultConfig - Default configuration from TOML
80
- * @returns {Promise<void>}
81
- */
82
- declare function showSttModelsTable({
83
- modelIds,
84
- defaultConfig
85
- }?: {
86
- modelIds: Array<string>;
87
- defaultConfig: any | null;
88
- }): Promise<void>;
89
- /**
90
- * Test ggml-stt capabilities for a backend type with optional model configuration
91
- * @param {Object} options - Test options
92
- * @param {string|null} options.modelId - Model ID (format: repo_id:filename)
93
- * @param {Object|null} options.defaultConfig - Default configuration from TOML
94
- * @returns {Promise<void>}
95
- */
96
- declare function testGgmlSttCapabilities({
97
- modelId,
98
- defaultConfig
99
- }?: {
100
- modelId: string | null;
101
- defaultConfig: any | null;
102
- }): Promise<void>;
103
- declare namespace index_d_exports {
104
- export { finalizeGenerator, generatorRegistry, getCapabilities, getModelIdentifier, ggmlLlm, ggmlStt, globalDownloadManager, mlxLlm, showModelsTable, showSttModelsTable, startGenerator, startModelDownload, status, testGgmlLlmCapabilities, testGgmlSttCapabilities };
105
- }
106
- declare function startGenerator(type: any, config: any): Promise<{
107
- id: any;
108
- info: any;
109
- }>;
110
- declare function finalizeGenerator(id: any): Promise<boolean>;
111
- declare function getModelIdentifier(type: any, config: any): any;
112
- declare namespace ggmlLlm {
113
- function initContext(id: any, property: any): Promise<any>;
114
- function completion(id: any, property: any): Promise<any>;
115
- function tokenize(id: any, property: any): Promise<any>;
116
- function detokenize(id: any, property: any): Promise<any>;
117
- function applyChatTemplate(id: any, property: any): Promise<any>;
118
- function releaseContext(id: any, property: any): Promise<any>;
119
- }
120
- declare namespace ggmlStt {
121
- function initContext(id: any, property: any): Promise<any>;
122
- function transcribe(id: any, property: any): Promise<any>;
123
- function transcribeData(id: any, property: any): Promise<any>;
124
- function releaseContext(id: any, property: any): Promise<any>;
125
- }
126
- declare namespace mlxLlm {
127
- function initContext(id: any, property: any): Promise<any>;
128
- function completion(id: any, property: any): Promise<any>;
129
- function tokenize(id: any, property: any): Promise<any>;
130
- function detokenize(id: any, property: any): Promise<any>;
131
- function applyChatTemplate(id: any, property: any): Promise<any>;
132
- function releaseContext(id: any, property: any): Promise<any>;
133
- }
134
- declare namespace status {
135
- export function getFullStatus(): any;
136
- export function getGgmlLlmStatus(): any;
137
- export function getGgmlSttStatus(): any;
138
- export function getMlxLlmStatus(): any;
139
- export { subscribeToStatus };
140
- export { subscribeToStatusWithId };
141
- export { llmStatusTracker };
142
- export { sttStatusTracker };
143
- export { statusEmitter };
144
- }
145
- declare const generatorRegistry: Map<any, any>;
146
- declare namespace globalDownloadManager {
147
- let downloads: Map<any, any>;
148
- /**
149
- * Get an existing download promise for a model path
150
- * @param {string} localPath - The local path for the model
151
- * @returns {Promise<void>|null} - The download promise or null if not downloading
152
- */
153
- function getDownload(localPath: string): Promise<void> | null;
154
- /**
155
- * Register a download promise for a model path
156
- * @param {string} localPath - The local path for the model
157
- * @param {Promise<void>} downloadPromise - The download promise
158
- */
159
- function setDownload(localPath: string, downloadPromise: Promise<void>): void;
160
- /**
161
- * Remove a download from tracking
162
- * @param {string} localPath - The local path for the model
163
- */
164
- function deleteDownload(localPath: string): void;
165
- /**
166
- * Check if a model is currently being downloaded
167
- * @param {string} localPath - The local path for the model
168
- * @returns {boolean}
169
- */
170
- function isDownloading(localPath: string): boolean;
171
- /**
172
- * Get all active downloads
173
- * @returns {Array<{localPath: string, promise: Promise<void>}>}
174
- */
175
- function getActiveDownloads(): Array<{
176
- localPath: string;
177
- promise: Promise<void>;
178
- }>;
179
- }
180
- /**
181
- * Start downloading a model if download=true in config.
182
- * This function starts the download in the background and returns immediately.
183
- * The download will be tracked by the global download manager so that
184
- * initContext can wait for it if needed.
185
- *
186
- * @param {string} type - The generator type ('ggml-llm' or 'ggml-stt')
187
- * @param {Object} config - The generator configuration
188
- * @param {Object} options - Options for the download
189
- * @param {function} options.onProgress - Progress callback (0-1)
190
- * @param {function} options.onComplete - Called when download completes
191
- * @param {function} options.onError - Called on error
192
- * @returns {Promise<{started: boolean, localPath: string|null, repoId: string|null}>}
193
- */
194
- declare function startModelDownload(type: string, config: any, options?: {
195
- onProgress: Function;
196
- onComplete: Function;
197
- onError: Function;
198
- }): Promise<{
199
- started: boolean;
200
- localPath: string | null;
201
- repoId: string | null;
202
- }>;
203
- //#endregion
204
- //#region src/types.d.ts
205
- type HumanReadableUnit = number | string;
206
- type HumanReadableServerConfig = {
207
- id?: string;
208
- name?: string;
209
- port?: number;
210
- log_level?: 'debug' | 'info' | 'warn' | 'error';
211
- max_body_size?: HumanReadableUnit;
212
- session_timeout?: HumanReadableUnit;
213
- temp_file_dir?: string;
214
- };
215
- type SessionCacheConfig = {
216
- enabled?: boolean;
217
- max_size_bytes?: HumanReadableUnit;
218
- max_entries?: number;
219
- };
220
- type RuntimeConfig = {
221
- cache_dir?: string;
222
- huggingface_token?: string;
223
- session_cache?: SessionCacheConfig;
224
- } & Record<string, any>;
225
- type GeneratorType = 'ggml-llm' | 'ggml-stt' | 'mlx-llm';
226
- type GeneratorConfig = {
227
- type: GeneratorType;
228
- } & Record<string, any>;
229
- type GlobalConfig = {
230
- runtime?: RuntimeConfig;
231
- openai_compat?: {
232
- enabled?: boolean;
233
- cors_allowed_origins?: string | string[];
234
- };
235
- anthropic_messages?: {
236
- enabled?: boolean;
237
- cors_allowed_origins?: string | string[];
238
- };
239
- } & Record<string, any>;
240
- type AutodiscoverConfig = {
241
- udp: {
242
- port?: number;
243
- announcements: {
244
- enabled: boolean;
245
- interval?: number;
246
- };
247
- requests: {
248
- enabled: boolean;
249
- responseDelay?: number;
250
- };
251
- };
252
- http: {
253
- enabled: boolean;
254
- path?: string;
255
- cors?: boolean;
256
- };
257
- mdns?: {
258
- enabled: boolean;
259
- };
260
- };
261
- type HumanReadableConfig = {
262
- autodiscover?: AutodiscoverConfig | boolean;
263
- server?: HumanReadableServerConfig;
264
- generators?: GeneratorConfig[];
265
- } & GlobalConfig;
266
- type ServerConfig = {
267
- id: string;
268
- name: string;
269
- port: number;
270
- log_level?: 'debug' | 'info' | 'warn' | 'error';
271
- max_body_size: number;
272
- session_timeout: number;
273
- temp_file_dir: string;
274
- };
275
- type Config = {
276
- autodiscover: AutodiscoverConfig | null;
277
- server: ServerConfig;
278
- global: GlobalConfig;
279
- generators: GeneratorConfig[];
280
- };
281
- type GeneratorInfo = {
282
- type: GeneratorType; /** Performance score 0–100 from buttress-hardware-guardrails. */
283
- score?: number; /** Whether the host has an accelerator (GPU/Metal/etc) for this backend. */
284
- hasGpu?: boolean; /** Usable memory in bytes for this backend (GPU when present, else CPU). */
285
- usableBytes?: number;
286
- } & Record<string, any>;
287
- type ServerInfo = {
288
- id: string;
289
- name: string;
290
- version: string;
291
- address: string;
292
- port: number;
293
- url: string;
294
- generators: GeneratorInfo[];
295
- authentication: {
296
- required: boolean;
297
- type: string; /** Issuer key id (when type === 'workspace-jwt'). */
298
- kid?: string; /** True when buttress is paired with a workspace. */
299
- bound?: boolean;
300
- }; /** Workspace identity (only present when paired). */
301
- workspace?: {
302
- id: string;
303
- name?: string;
304
- };
305
- };
306
- //#endregion
307
- //#region src/autodiscover/types.d.ts
308
- type GetServerInfoFn = () => ServerInfo;
309
- //#endregion
310
- //#region src/autodiscover/index.d.ts
311
- /**
312
- * Autodiscover service that manages discovery transports.
313
- * Currently supports UDP announcements/responses.
314
- * HTTP discovery is handled by the info route.
315
- */
316
- declare class AutodiscoverService {
317
- private config;
318
- private getServerInfo;
319
- private transports;
320
- private started;
321
- constructor(config: AutodiscoverConfig, getServerInfo: GetServerInfoFn);
322
- start(): Promise<void>;
323
- stop(): Promise<void>;
324
- }
325
- //#endregion
326
- //#region src/utils/config.d.ts
327
- /**
328
- * Process raw user config (HumanReadableConfig) into Config.
329
- * Handles: device defaults, value normalization (bytes/ms), structure splitting.
330
- */
331
- declare const processConfig: (input: HumanReadableConfig | null) => Config;
332
- //#endregion
333
- //#region src/index.d.ts
334
- declare const checkForUpdates: () => Promise<string | null>;
335
- declare const compareVersions: (current: string, latest: string) => boolean;
336
- declare const logUpdateMessage: (latestVersion: string) => void;
337
- declare const checkAndNotifyUpdates: () => Promise<void>;
338
- type Backend = typeof index_d_exports;
339
- interface StartServerOptions {
340
- backend?: Backend;
341
- router?: AnyElysia;
342
- config: Config;
343
- enableOpenAICompat?: boolean;
344
- enableAnthropicMessages?: boolean;
345
- }
346
- declare const createServer: ({
347
- backend,
348
- router,
349
- config,
350
- enableOpenAICompat,
351
- enableAnthropicMessages
352
- }: StartServerOptions) => Promise<{
353
- app: AnyElysia;
354
- config: Config;
355
- }>;
356
- declare const startServer: ({
357
- backend,
358
- router,
359
- config,
360
- enableOpenAICompat,
361
- enableAnthropicMessages
362
- }: StartServerOptions) => Promise<{
363
- app: AnyElysia;
364
- port: number;
365
- openaiEnabled: boolean;
366
- anthropicMessagesEnabled: boolean;
367
- autoDiscover: AutodiscoverService | null;
368
- }>;
369
- //#endregion
370
- export { Backend, StartServerOptions, checkAndNotifyUpdates, checkForUpdates, compareVersions, createServer, logUpdateMessage, processConfig, startModelDownload, startServer };