genai-electron 0.3.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 (151) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +84 -0
  3. package/dist/config/defaults.d.ts +130 -0
  4. package/dist/config/defaults.d.ts.map +1 -0
  5. package/dist/config/defaults.js +146 -0
  6. package/dist/config/defaults.js.map +1 -0
  7. package/dist/config/paths.d.ts +22 -0
  8. package/dist/config/paths.d.ts.map +1 -0
  9. package/dist/config/paths.js +49 -0
  10. package/dist/config/paths.js.map +1 -0
  11. package/dist/config/reasoning-models.d.ts +3 -0
  12. package/dist/config/reasoning-models.d.ts.map +1 -0
  13. package/dist/config/reasoning-models.js +10 -0
  14. package/dist/config/reasoning-models.js.map +1 -0
  15. package/dist/download/Downloader.d.ts +16 -0
  16. package/dist/download/Downloader.d.ts.map +1 -0
  17. package/dist/download/Downloader.js +102 -0
  18. package/dist/download/Downloader.js.map +1 -0
  19. package/dist/download/checksum.d.ts +4 -0
  20. package/dist/download/checksum.d.ts.map +1 -0
  21. package/dist/download/checksum.js +16 -0
  22. package/dist/download/checksum.js.map +1 -0
  23. package/dist/download/huggingface.d.ts +7 -0
  24. package/dist/download/huggingface.d.ts.map +1 -0
  25. package/dist/download/huggingface.js +40 -0
  26. package/dist/download/huggingface.js.map +1 -0
  27. package/dist/errors/index.d.ts +37 -0
  28. package/dist/errors/index.d.ts.map +1 -0
  29. package/dist/errors/index.js +71 -0
  30. package/dist/errors/index.js.map +1 -0
  31. package/dist/index.d.ts +42 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +36 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/managers/BinaryManager.d.ts +25 -0
  36. package/dist/managers/BinaryManager.d.ts.map +1 -0
  37. package/dist/managers/BinaryManager.js +436 -0
  38. package/dist/managers/BinaryManager.js.map +1 -0
  39. package/dist/managers/DiffusionServerManager.d.ts +56 -0
  40. package/dist/managers/DiffusionServerManager.d.ts.map +1 -0
  41. package/dist/managers/DiffusionServerManager.js +649 -0
  42. package/dist/managers/DiffusionServerManager.js.map +1 -0
  43. package/dist/managers/GenerationRegistry.d.ts +21 -0
  44. package/dist/managers/GenerationRegistry.d.ts.map +1 -0
  45. package/dist/managers/GenerationRegistry.js +67 -0
  46. package/dist/managers/GenerationRegistry.js.map +1 -0
  47. package/dist/managers/LlamaServerManager.d.ts +23 -0
  48. package/dist/managers/LlamaServerManager.d.ts.map +1 -0
  49. package/dist/managers/LlamaServerManager.js +226 -0
  50. package/dist/managers/LlamaServerManager.js.map +1 -0
  51. package/dist/managers/ModelManager.d.ts +28 -0
  52. package/dist/managers/ModelManager.d.ts.map +1 -0
  53. package/dist/managers/ModelManager.js +356 -0
  54. package/dist/managers/ModelManager.js.map +1 -0
  55. package/dist/managers/ResourceOrchestrator.d.ts +28 -0
  56. package/dist/managers/ResourceOrchestrator.d.ts.map +1 -0
  57. package/dist/managers/ResourceOrchestrator.js +204 -0
  58. package/dist/managers/ResourceOrchestrator.js.map +1 -0
  59. package/dist/managers/ServerManager.d.ts +35 -0
  60. package/dist/managers/ServerManager.d.ts.map +1 -0
  61. package/dist/managers/ServerManager.js +171 -0
  62. package/dist/managers/ServerManager.js.map +1 -0
  63. package/dist/managers/StorageManager.d.ts +20 -0
  64. package/dist/managers/StorageManager.d.ts.map +1 -0
  65. package/dist/managers/StorageManager.js +159 -0
  66. package/dist/managers/StorageManager.js.map +1 -0
  67. package/dist/process/ProcessManager.d.ts +19 -0
  68. package/dist/process/ProcessManager.d.ts.map +1 -0
  69. package/dist/process/ProcessManager.js +112 -0
  70. package/dist/process/ProcessManager.js.map +1 -0
  71. package/dist/process/health-check.d.ts +9 -0
  72. package/dist/process/health-check.d.ts.map +1 -0
  73. package/dist/process/health-check.js +91 -0
  74. package/dist/process/health-check.js.map +1 -0
  75. package/dist/process/llama-log-parser.d.ts +5 -0
  76. package/dist/process/llama-log-parser.d.ts.map +1 -0
  77. package/dist/process/llama-log-parser.js +69 -0
  78. package/dist/process/llama-log-parser.js.map +1 -0
  79. package/dist/process/log-manager.d.ts +18 -0
  80. package/dist/process/log-manager.d.ts.map +1 -0
  81. package/dist/process/log-manager.js +73 -0
  82. package/dist/process/log-manager.js.map +1 -0
  83. package/dist/system/SystemInfo.d.ts +26 -0
  84. package/dist/system/SystemInfo.d.ts.map +1 -0
  85. package/dist/system/SystemInfo.js +162 -0
  86. package/dist/system/SystemInfo.js.map +1 -0
  87. package/dist/system/cpu-detect.d.ts +7 -0
  88. package/dist/system/cpu-detect.d.ts.map +1 -0
  89. package/dist/system/cpu-detect.js +61 -0
  90. package/dist/system/cpu-detect.js.map +1 -0
  91. package/dist/system/gpu-detect.d.ts +4 -0
  92. package/dist/system/gpu-detect.d.ts.map +1 -0
  93. package/dist/system/gpu-detect.js +183 -0
  94. package/dist/system/gpu-detect.js.map +1 -0
  95. package/dist/system/memory-detect.d.ts +6 -0
  96. package/dist/system/memory-detect.d.ts.map +1 -0
  97. package/dist/system/memory-detect.js +75 -0
  98. package/dist/system/memory-detect.js.map +1 -0
  99. package/dist/types/images.d.ts +73 -0
  100. package/dist/types/images.d.ts.map +1 -0
  101. package/dist/types/images.js +2 -0
  102. package/dist/types/images.js.map +1 -0
  103. package/dist/types/index.d.ts +19 -0
  104. package/dist/types/index.d.ts.map +1 -0
  105. package/dist/types/index.js +2 -0
  106. package/dist/types/index.js.map +1 -0
  107. package/dist/types/models.d.ts +57 -0
  108. package/dist/types/models.d.ts.map +1 -0
  109. package/dist/types/models.js +2 -0
  110. package/dist/types/models.js.map +1 -0
  111. package/dist/types/servers.d.ts +40 -0
  112. package/dist/types/servers.d.ts.map +1 -0
  113. package/dist/types/servers.js +2 -0
  114. package/dist/types/servers.js.map +1 -0
  115. package/dist/types/system.d.ts +37 -0
  116. package/dist/types/system.d.ts.map +1 -0
  117. package/dist/types/system.js +2 -0
  118. package/dist/types/system.js.map +1 -0
  119. package/dist/utils/electron-lifecycle.d.ts +9 -0
  120. package/dist/utils/electron-lifecycle.d.ts.map +1 -0
  121. package/dist/utils/electron-lifecycle.js +30 -0
  122. package/dist/utils/electron-lifecycle.js.map +1 -0
  123. package/dist/utils/error-helpers.d.ts +8 -0
  124. package/dist/utils/error-helpers.d.ts.map +1 -0
  125. package/dist/utils/error-helpers.js +96 -0
  126. package/dist/utils/error-helpers.js.map +1 -0
  127. package/dist/utils/file-utils.d.ts +11 -0
  128. package/dist/utils/file-utils.d.ts.map +1 -0
  129. package/dist/utils/file-utils.js +113 -0
  130. package/dist/utils/file-utils.js.map +1 -0
  131. package/dist/utils/generation-id.d.ts +2 -0
  132. package/dist/utils/generation-id.d.ts.map +1 -0
  133. package/dist/utils/generation-id.js +6 -0
  134. package/dist/utils/generation-id.js.map +1 -0
  135. package/dist/utils/gguf-parser.d.ts +9 -0
  136. package/dist/utils/gguf-parser.d.ts.map +1 -0
  137. package/dist/utils/gguf-parser.js +64 -0
  138. package/dist/utils/gguf-parser.js.map +1 -0
  139. package/dist/utils/model-metadata-helpers.d.ts +9 -0
  140. package/dist/utils/model-metadata-helpers.d.ts.map +1 -0
  141. package/dist/utils/model-metadata-helpers.js +92 -0
  142. package/dist/utils/model-metadata-helpers.js.map +1 -0
  143. package/dist/utils/platform-utils.d.ts +18 -0
  144. package/dist/utils/platform-utils.d.ts.map +1 -0
  145. package/dist/utils/platform-utils.js +61 -0
  146. package/dist/utils/platform-utils.js.map +1 -0
  147. package/dist/utils/zip-utils.d.ts +3 -0
  148. package/dist/utils/zip-utils.d.ts.map +1 -0
  149. package/dist/utils/zip-utils.js +72 -0
  150. package/dist/utils/zip-utils.js.map +1 -0
  151. package/package.json +72 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Luigi Acerbi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # genai-electron
2
+
3
+ > **Version**: 0.3.0 | **Status**: Production Ready - LLM & Image Generation
4
+
5
+ Electron-specific library for managing local AI model servers (llama.cpp, stable-diffusion.cpp). Handles platform-specific operations to run AI models locally. Complements [genai-lite](https://github.com/lacerbi/genai-lite) for API abstraction.
6
+
7
+ ## Features
8
+
9
+ - ✅ **System detection** - Auto-detect RAM, CPU, GPU, VRAM capabilities
10
+ - ✅ **Model management** - Download GGUF models with progress tracking and metadata extraction
11
+ - ✅ **LLM server** - Manage llama-server lifecycle with auto-configuration
12
+ - ✅ **Image generation** - Local image generation via stable-diffusion.cpp
13
+ - ✅ **Resource orchestration** - Automatic LLM offload/reload when memory constrained
14
+ - ✅ **Binary management** - Automatic binary download with GPU variant testing (CUDA→Vulkan→CPU)
15
+ - ✅ **TypeScript-first** - Full type safety, zero runtime dependencies
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install genai-electron
21
+ npm install electron@>=25.0.0 # Peer dependency
22
+ ```
23
+
24
+ ## Quick Start
25
+
26
+ ```typescript
27
+ import { app } from 'electron';
28
+ import { systemInfo, modelManager, llamaServer } from 'genai-electron';
29
+
30
+ app.whenReady().then(async () => {
31
+ // Detect capabilities
32
+ const caps = await systemInfo.detect();
33
+ console.log('RAM:', (caps.memory.total / 1024 ** 3).toFixed(1), 'GB');
34
+
35
+ // Download model (if needed)
36
+ await modelManager.downloadModel({
37
+ source: 'url',
38
+ url: 'https://huggingface.co/TheBloke/Llama-2-7B-GGUF/resolve/main/llama-2-7b.Q4_K_M.gguf',
39
+ name: 'Llama 2 7B',
40
+ type: 'llm'
41
+ });
42
+
43
+ // Start server with auto-config
44
+ await llamaServer.start({
45
+ modelId: 'llama-2-7b',
46
+ port: 8080
47
+ });
48
+
49
+ console.log('Server ready on port 8080');
50
+ });
51
+ ```
52
+
53
+ Use with [genai-lite](https://github.com/lacerbi/genai-lite) for AI interactions (chat, image generation).
54
+
55
+ ## Documentation
56
+
57
+ 📚 **[Complete Documentation](genai-electron-docs/index.md)** - Full API reference, guides, and examples
58
+
59
+ **Quick Links**:
60
+ - [Installation & Setup](genai-electron-docs/installation-and-setup.md)
61
+ - [System Detection](genai-electron-docs/system-detection.md)
62
+ - [Model Management](genai-electron-docs/model-management.md)
63
+ - [LLM Server](genai-electron-docs/llm-server.md)
64
+ - [Image Generation](genai-electron-docs/image-generation.md)
65
+ - [TypeScript Reference](genai-electron-docs/typescript-reference.md)
66
+ - [Troubleshooting](genai-electron-docs/troubleshooting.md)
67
+
68
+ ## Example App
69
+
70
+ See **[electron-control-panel](examples/electron-control-panel/)** for a full-featured reference implementation.
71
+
72
+ ## Platform Support
73
+
74
+ - **macOS**: 11+ (Intel, Apple Silicon with Metal)
75
+ - **Windows**: 10+ (64-bit, CPU and CUDA)
76
+ - **Linux**: Ubuntu 20.04+, Debian 11+, Fedora 35+ (CPU, CUDA, ROCm)
77
+
78
+ ## License
79
+
80
+ MIT License - see [LICENSE](LICENSE) file for details.
81
+
82
+ ## Related Projects
83
+
84
+ - **[genai-lite](https://github.com/lacerbi/genai-lite)** - Lightweight API abstraction for AI providers (cloud and local)
@@ -0,0 +1,130 @@
1
+ import type { ServerConfig } from '../types/index.js';
2
+ export declare const DEFAULT_PORTS: {
3
+ readonly llama: 8080;
4
+ readonly diffusion: 8081;
5
+ };
6
+ export declare const DEFAULT_TIMEOUTS: {
7
+ readonly download: 300000;
8
+ readonly serverStart: 60000;
9
+ readonly serverStop: 10000;
10
+ readonly healthCheck: 5000;
11
+ };
12
+ export declare const DEFAULT_SERVER_CONFIG: Partial<ServerConfig>;
13
+ export type BinaryVariant = 'cuda' | 'vulkan' | 'metal' | 'cpu';
14
+ export interface BinaryDependency {
15
+ url: string;
16
+ checksum: string;
17
+ description?: string;
18
+ }
19
+ export interface BinaryVariantConfig {
20
+ type: BinaryVariant;
21
+ url: string;
22
+ checksum: string;
23
+ dependencies?: readonly BinaryDependency[];
24
+ }
25
+ export declare const BINARY_VERSIONS: {
26
+ readonly llamaServer: {
27
+ readonly version: "b6784";
28
+ readonly variants: {
29
+ readonly 'darwin-arm64': readonly [{
30
+ readonly type: BinaryVariant;
31
+ readonly url: "https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-macos-arm64.zip";
32
+ readonly checksum: "ea4be04a6de5348868730eb8665e62de40c469bc53d78ec44295ce29cf08fea1";
33
+ }];
34
+ readonly 'darwin-x64': readonly [{
35
+ readonly type: BinaryVariant;
36
+ readonly url: "https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-macos-x64.zip";
37
+ readonly checksum: "56d5c1c629c7bdcdbdb17c5a03fcec8cfabe2136f9ba8938cb22df6cdb5192cb";
38
+ }];
39
+ readonly 'win32-x64': readonly [{
40
+ readonly type: BinaryVariant;
41
+ readonly url: "https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-win-cuda-12.4-x64.zip";
42
+ readonly checksum: "a7a8981f742cdc0e1c93c02caa955fb2ad2716407fb3556cbc71e7e4e44f7d72";
43
+ readonly dependencies: readonly [{
44
+ readonly url: "https://github.com/ggml-org/llama.cpp/releases/download/b6784/cudart-llama-bin-win-cuda-12.4-x64.zip";
45
+ readonly checksum: "8c79a9b226de4b3cacfd1f83d24f962d0773be79f1e7b75c6af4ded7e32ae1d6";
46
+ readonly description: "CUDA 12.4 runtime libraries required for NVIDIA GPU acceleration";
47
+ }];
48
+ }, {
49
+ readonly type: BinaryVariant;
50
+ readonly url: "https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-win-vulkan-x64.zip";
51
+ readonly checksum: "b1e3cfa3a248424b171a9fa58ca2fe69f988516d03881270c116760566c95540";
52
+ }, {
53
+ readonly type: BinaryVariant;
54
+ readonly url: "https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-win-cpu-x64.zip";
55
+ readonly checksum: "b6523cd0e87f2508a7b9d3f542850c0d04ffdeb143c79ca938b7d6fa28e2e15d";
56
+ }];
57
+ readonly 'linux-x64': readonly [{
58
+ readonly type: BinaryVariant;
59
+ readonly url: "https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-ubuntu-x64.zip";
60
+ readonly checksum: "c853d5e85e012d869f308d4a329c8ccfd762dc600f44a7abdbae315b4f14d823";
61
+ }, {
62
+ readonly type: BinaryVariant;
63
+ readonly url: "https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-ubuntu-vulkan-x64.zip";
64
+ readonly checksum: "3f1ba3be1dd9beda20989348cf881d725b33a8b04c74d7beefc98aa77ace6e7c";
65
+ }];
66
+ };
67
+ };
68
+ readonly diffusionCpp: {
69
+ readonly version: "master-330-db6f479";
70
+ readonly variants: {
71
+ readonly 'darwin-arm64': readonly [{
72
+ readonly type: BinaryVariant;
73
+ readonly url: "https://github.com/leejet/stable-diffusion.cpp/releases/download/master-330-db6f479/sd-master--bin-Darwin-macOS-15.6.1-arm64.zip";
74
+ readonly checksum: "63be1220757cb895432847967c3e17dd1fbcac8abdd77c100bee46c7d1a7c2a2";
75
+ }];
76
+ readonly 'darwin-x64': readonly [];
77
+ readonly 'win32-x64': readonly [{
78
+ readonly type: BinaryVariant;
79
+ readonly url: "https://github.com/leejet/stable-diffusion.cpp/releases/download/master-330-db6f479/sd-master-db6f479-bin-win-cuda12-x64.zip";
80
+ readonly checksum: "5f15a0f08e2b34eaf8aa8b1bb50dd0b6a194bf21176ab9512ecacf0ccc8f1532";
81
+ readonly dependencies: readonly [{
82
+ readonly url: "https://github.com/leejet/stable-diffusion.cpp/releases/download/master-330-db6f479/cudart-sd-bin-win-cu12-x64.zip";
83
+ readonly checksum: "cacc1f7e1e7b53ba310a6769893b8184de2afd5690aa2233d1416e84d3efccd6";
84
+ readonly description: "CUDA 12 runtime libraries required for NVIDIA GPU acceleration";
85
+ }];
86
+ }, {
87
+ readonly type: BinaryVariant;
88
+ readonly url: "https://github.com/leejet/stable-diffusion.cpp/releases/download/master-330-db6f479/sd-master-db6f479-bin-win-vulkan-x64.zip";
89
+ readonly checksum: "fbd737e427741d36abd5807b4b06920d0c4fa66423a0fc257e16586ed255621d";
90
+ }, {
91
+ readonly type: BinaryVariant;
92
+ readonly url: "https://github.com/leejet/stable-diffusion.cpp/releases/download/master-330-db6f479/sd-master-db6f479-bin-win-avx2-x64.zip";
93
+ readonly checksum: "908428c5f4e3743ceba5958157fc397c2a588acbf85d339ef0108a0a05611786";
94
+ }];
95
+ readonly 'linux-x64': readonly [{
96
+ readonly type: BinaryVariant;
97
+ readonly url: "https://github.com/leejet/stable-diffusion.cpp/releases/download/master-330-db6f479/sd-master--bin-Linux-Ubuntu-24.04-x86_64.zip";
98
+ readonly checksum: "eb886cbd37cf927095255bc406858a5a131fcc141e04e68007be80a9156566c3";
99
+ }];
100
+ };
101
+ };
102
+ };
103
+ export declare const HEALTH_CHECK_CONFIG: {
104
+ readonly initialDelay: 500;
105
+ readonly maxDelay: 5000;
106
+ readonly backoffMultiplier: 1.5;
107
+ readonly maxRetries: 10;
108
+ };
109
+ export declare const MODEL_SIZE_ESTIMATES: {
110
+ readonly '7B': {
111
+ readonly Q4_K_M: 4.4;
112
+ readonly Q5_K_M: 5.2;
113
+ readonly Q8_0: 7.2;
114
+ };
115
+ readonly '13B': {
116
+ readonly Q4_K_M: 8.1;
117
+ readonly Q5_K_M: 9.5;
118
+ readonly Q8_0: 13.5;
119
+ };
120
+ readonly '70B': {
121
+ readonly Q4_K_M: 41;
122
+ readonly Q5_K_M: 48;
123
+ };
124
+ };
125
+ export declare const RECOMMENDED_QUANTIZATIONS: {
126
+ readonly quality: readonly ["Q8_0", "Q6_K", "Q5_K_M"];
127
+ readonly balanced: readonly ["Q5_K_M", "Q4_K_M"];
128
+ readonly compact: readonly ["Q4_K_M", "Q4_K_S", "Q3_K_M"];
129
+ };
130
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAKtD,eAAO,MAAM,aAAa;;;CAKhB,CAAC;AAKX,eAAO,MAAM,gBAAgB;;;;;CASnB,CAAC;AAMX,eAAO,MAAM,qBAAqB,EAAE,OAAO,CAAC,YAAY,CAM9C,CAAC;AAKX,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;AAMhE,MAAM,WAAW,gBAAgB;IAE/B,GAAG,EAAE,MAAM,CAAC;IAEZ,QAAQ,EAAE,MAAM,CAAC;IAEjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAKD,MAAM,WAAW,mBAAmB;IAElC,IAAI,EAAE,aAAa,CAAC;IAEpB,GAAG,EAAE,MAAM,CAAC;IAEZ,QAAQ,EAAE,MAAM,CAAC;IAEjB,YAAY,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CAC5C;AAWD,eAAO,MAAM,eAAe;;;;;+BASD,aAAa;;;;;+BAOf,aAAa;;;;;+BAOZ,aAAa;;;;;;;;;+BAYX,aAAa;;;;+BAKhB,aAAa;;;;;+BAOZ,aAAa;;;;+BAKX,aAAa;;;;;;;;;;+BAed,aAAa;;;;;;+BAWd,aAAa;;;;;;;;;+BAYX,aAAa;;;;+BAKhB,aAAa;;;;;+BAWb,aAAa;;;;;;CAO5B,CAAC;AAKX,eAAO,MAAM,mBAAmB;;;;;CAStB,CAAC;AAMX,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;CAkBvB,CAAC;AAKX,eAAO,MAAM,yBAAyB;;;;CAO5B,CAAC"}
@@ -0,0 +1,146 @@
1
+ export const DEFAULT_PORTS = {
2
+ llama: 8080,
3
+ diffusion: 8081,
4
+ };
5
+ export const DEFAULT_TIMEOUTS = {
6
+ download: 300000,
7
+ serverStart: 60000,
8
+ serverStop: 10000,
9
+ healthCheck: 5000,
10
+ };
11
+ export const DEFAULT_SERVER_CONFIG = {
12
+ threads: -1,
13
+ contextSize: 4096,
14
+ gpuLayers: -1,
15
+ parallelRequests: 4,
16
+ flashAttention: false,
17
+ };
18
+ export const BINARY_VERSIONS = {
19
+ llamaServer: {
20
+ version: 'b6784',
21
+ variants: {
22
+ 'darwin-arm64': [
23
+ {
24
+ type: 'metal',
25
+ url: 'https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-macos-arm64.zip',
26
+ checksum: 'ea4be04a6de5348868730eb8665e62de40c469bc53d78ec44295ce29cf08fea1',
27
+ },
28
+ ],
29
+ 'darwin-x64': [
30
+ {
31
+ type: 'cpu',
32
+ url: 'https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-macos-x64.zip',
33
+ checksum: '56d5c1c629c7bdcdbdb17c5a03fcec8cfabe2136f9ba8938cb22df6cdb5192cb',
34
+ },
35
+ ],
36
+ 'win32-x64': [
37
+ {
38
+ type: 'cuda',
39
+ url: 'https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-win-cuda-12.4-x64.zip',
40
+ checksum: 'a7a8981f742cdc0e1c93c02caa955fb2ad2716407fb3556cbc71e7e4e44f7d72',
41
+ dependencies: [
42
+ {
43
+ url: 'https://github.com/ggml-org/llama.cpp/releases/download/b6784/cudart-llama-bin-win-cuda-12.4-x64.zip',
44
+ checksum: '8c79a9b226de4b3cacfd1f83d24f962d0773be79f1e7b75c6af4ded7e32ae1d6',
45
+ description: 'CUDA 12.4 runtime libraries required for NVIDIA GPU acceleration',
46
+ },
47
+ ],
48
+ },
49
+ {
50
+ type: 'vulkan',
51
+ url: 'https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-win-vulkan-x64.zip',
52
+ checksum: 'b1e3cfa3a248424b171a9fa58ca2fe69f988516d03881270c116760566c95540',
53
+ },
54
+ {
55
+ type: 'cpu',
56
+ url: 'https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-win-cpu-x64.zip',
57
+ checksum: 'b6523cd0e87f2508a7b9d3f542850c0d04ffdeb143c79ca938b7d6fa28e2e15d',
58
+ },
59
+ ],
60
+ 'linux-x64': [
61
+ {
62
+ type: 'cuda',
63
+ url: 'https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-ubuntu-x64.zip',
64
+ checksum: 'c853d5e85e012d869f308d4a329c8ccfd762dc600f44a7abdbae315b4f14d823',
65
+ },
66
+ {
67
+ type: 'vulkan',
68
+ url: 'https://github.com/ggml-org/llama.cpp/releases/download/b6784/llama-b6784-bin-ubuntu-vulkan-x64.zip',
69
+ checksum: '3f1ba3be1dd9beda20989348cf881d725b33a8b04c74d7beefc98aa77ace6e7c',
70
+ },
71
+ ],
72
+ },
73
+ },
74
+ diffusionCpp: {
75
+ version: 'master-330-db6f479',
76
+ variants: {
77
+ 'darwin-arm64': [
78
+ {
79
+ type: 'metal',
80
+ url: 'https://github.com/leejet/stable-diffusion.cpp/releases/download/master-330-db6f479/sd-master--bin-Darwin-macOS-15.6.1-arm64.zip',
81
+ checksum: '63be1220757cb895432847967c3e17dd1fbcac8abdd77c100bee46c7d1a7c2a2',
82
+ },
83
+ ],
84
+ 'darwin-x64': [],
85
+ 'win32-x64': [
86
+ {
87
+ type: 'cuda',
88
+ url: 'https://github.com/leejet/stable-diffusion.cpp/releases/download/master-330-db6f479/sd-master-db6f479-bin-win-cuda12-x64.zip',
89
+ checksum: '5f15a0f08e2b34eaf8aa8b1bb50dd0b6a194bf21176ab9512ecacf0ccc8f1532',
90
+ dependencies: [
91
+ {
92
+ url: 'https://github.com/leejet/stable-diffusion.cpp/releases/download/master-330-db6f479/cudart-sd-bin-win-cu12-x64.zip',
93
+ checksum: 'cacc1f7e1e7b53ba310a6769893b8184de2afd5690aa2233d1416e84d3efccd6',
94
+ description: 'CUDA 12 runtime libraries required for NVIDIA GPU acceleration',
95
+ },
96
+ ],
97
+ },
98
+ {
99
+ type: 'vulkan',
100
+ url: 'https://github.com/leejet/stable-diffusion.cpp/releases/download/master-330-db6f479/sd-master-db6f479-bin-win-vulkan-x64.zip',
101
+ checksum: 'fbd737e427741d36abd5807b4b06920d0c4fa66423a0fc257e16586ed255621d',
102
+ },
103
+ {
104
+ type: 'cpu',
105
+ url: 'https://github.com/leejet/stable-diffusion.cpp/releases/download/master-330-db6f479/sd-master-db6f479-bin-win-avx2-x64.zip',
106
+ checksum: '908428c5f4e3743ceba5958157fc397c2a588acbf85d339ef0108a0a05611786',
107
+ },
108
+ ],
109
+ 'linux-x64': [
110
+ {
111
+ type: 'cpu',
112
+ url: 'https://github.com/leejet/stable-diffusion.cpp/releases/download/master-330-db6f479/sd-master--bin-Linux-Ubuntu-24.04-x86_64.zip',
113
+ checksum: 'eb886cbd37cf927095255bc406858a5a131fcc141e04e68007be80a9156566c3',
114
+ },
115
+ ],
116
+ },
117
+ },
118
+ };
119
+ export const HEALTH_CHECK_CONFIG = {
120
+ initialDelay: 500,
121
+ maxDelay: 5000,
122
+ backoffMultiplier: 1.5,
123
+ maxRetries: 10,
124
+ };
125
+ export const MODEL_SIZE_ESTIMATES = {
126
+ '7B': {
127
+ Q4_K_M: 4.4,
128
+ Q5_K_M: 5.2,
129
+ Q8_0: 7.2,
130
+ },
131
+ '13B': {
132
+ Q4_K_M: 8.1,
133
+ Q5_K_M: 9.5,
134
+ Q8_0: 13.5,
135
+ },
136
+ '70B': {
137
+ Q4_K_M: 41.0,
138
+ Q5_K_M: 48.0,
139
+ },
140
+ };
141
+ export const RECOMMENDED_QUANTIZATIONS = {
142
+ quality: ['Q8_0', 'Q6_K', 'Q5_K_M'],
143
+ balanced: ['Q5_K_M', 'Q4_K_M'],
144
+ compact: ['Q4_K_M', 'Q4_K_S', 'Q3_K_M'],
145
+ };
146
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,aAAa,GAAG;IAE3B,KAAK,EAAE,IAAI;IAEX,SAAS,EAAE,IAAI;CACP,CAAC;AAKX,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAE9B,QAAQ,EAAE,MAAM;IAEhB,WAAW,EAAE,KAAK;IAElB,UAAU,EAAE,KAAK;IAEjB,WAAW,EAAE,IAAI;CACT,CAAC;AAMX,MAAM,CAAC,MAAM,qBAAqB,GAA0B;IAC1D,OAAO,EAAE,CAAC,CAAC;IACX,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,CAAC,CAAC;IACb,gBAAgB,EAAE,CAAC;IACnB,cAAc,EAAE,KAAK;CACb,CAAC;AA2CX,MAAM,CAAC,MAAM,eAAe,GAAG;IAE7B,WAAW,EAAE;QAEX,OAAO,EAAE,OAAO;QAEhB,QAAQ,EAAE;YACR,cAAc,EAAE;gBACd;oBACE,IAAI,EAAE,OAAwB;oBAC9B,GAAG,EAAE,+FAA+F;oBACpG,QAAQ,EAAE,kEAAkE;iBAC7E;aACF;YACD,YAAY,EAAE;gBACZ;oBACE,IAAI,EAAE,KAAsB;oBAC5B,G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H;oBACnI,QAAQ,EAAE,kEAAkE;iBAC7E;gBACD;oBACE,IAAI,EAAE,KAAsB;oBAC5B,GAAG,EAAE,4HAA4H;oBACjI,QAAQ,EAAE,kEAAkE;iBAC7E;aAKF;YACD,WAAW,EAAE;gBACX;oBACE,IAAI,EAAE,KAAsB;oBAC5B,GAAG,EAAE,kIAAkI;oBACvI,QAAQ,EAAE,kEAAkE;iBAC7E;aACF;SACF;KACF;CACO,CAAC;AAKX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAEjC,YAAY,EAAE,GAAG;IAEjB,QAAQ,EAAE,IAAI;IAEd,iBAAiB,EAAE,GAAG;IAEtB,UAAU,EAAE,EAAE;CACN,CAAC;AAMX,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAElC,IAAI,EAAE;QACJ,MAAM,EAAE,GAAG;QACX,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,GAAG;KACV;IAED,KAAK,EAAE;QACL,MAAM,EAAE,GAAG;QACX,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,IAAI;KACX;IAED,KAAK,EAAE;QACL,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,IAAI;KACb;CACO,CAAC;AAKX,MAAM,CAAC,MAAM,yBAAyB,GAAG;IAEvC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;IAEnC,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAE9B,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;CAC/B,CAAC"}
@@ -0,0 +1,22 @@
1
+ export declare const BASE_DIR: string;
2
+ export declare const PATHS: {
3
+ readonly models: {
4
+ readonly llm: string;
5
+ readonly diffusion: string;
6
+ };
7
+ readonly binaries: {
8
+ readonly llama: string;
9
+ readonly diffusion: string;
10
+ };
11
+ readonly logs: string;
12
+ readonly config: string;
13
+ readonly temp: string;
14
+ };
15
+ export declare function ensureDirectories(): Promise<void>;
16
+ export declare function getModelMetadataPath(type: 'llm' | 'diffusion', modelId: string): string;
17
+ export declare function getModelFilePath(type: 'llm' | 'diffusion', filename: string): string;
18
+ export declare function getBinaryPath(type: 'llama' | 'diffusion', binaryName: string): string;
19
+ export declare function getLogPath(logName: string): string;
20
+ export declare function getConfigPath(configName: string): string;
21
+ export declare function getTempPath(filename: string): string;
22
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/config/paths.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,QAAQ,QAA0B,CAAC;AAKhD,eAAO,MAAM,KAAK;;;;;;;;;;;;CAqBR,CAAC;AAcX,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAYvD;AAeD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,KAAK,GAAG,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEvF;AAeD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,GAAG,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpF;AAkBD,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAIrF;AAcD,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD;AAcD,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAExD;AAcD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpD"}
@@ -0,0 +1,49 @@
1
+ import { app } from 'electron';
2
+ import path from 'node:path';
3
+ import { mkdir } from 'node:fs/promises';
4
+ export const BASE_DIR = app.getPath('userData');
5
+ export const PATHS = {
6
+ models: {
7
+ llm: path.join(BASE_DIR, 'models', 'llm'),
8
+ diffusion: path.join(BASE_DIR, 'models', 'diffusion'),
9
+ },
10
+ binaries: {
11
+ llama: path.join(BASE_DIR, 'binaries', 'llama'),
12
+ diffusion: path.join(BASE_DIR, 'binaries', 'diffusion'),
13
+ },
14
+ logs: path.join(BASE_DIR, 'logs'),
15
+ config: path.join(BASE_DIR, 'config'),
16
+ temp: path.join(BASE_DIR, 'temp'),
17
+ };
18
+ export async function ensureDirectories() {
19
+ const directories = [
20
+ PATHS.models.llm,
21
+ PATHS.models.diffusion,
22
+ PATHS.binaries.llama,
23
+ PATHS.binaries.diffusion,
24
+ PATHS.logs,
25
+ PATHS.config,
26
+ PATHS.temp,
27
+ ];
28
+ await Promise.all(directories.map((dir) => mkdir(dir, { recursive: true })));
29
+ }
30
+ export function getModelMetadataPath(type, modelId) {
31
+ return path.join(PATHS.models[type], `${modelId}.json`);
32
+ }
33
+ export function getModelFilePath(type, filename) {
34
+ return path.join(PATHS.models[type], filename);
35
+ }
36
+ export function getBinaryPath(type, binaryName) {
37
+ const filename = process.platform === 'win32' ? `${binaryName}.exe` : binaryName;
38
+ return path.join(PATHS.binaries[type], filename);
39
+ }
40
+ export function getLogPath(logName) {
41
+ return path.join(PATHS.logs, logName);
42
+ }
43
+ export function getConfigPath(configName) {
44
+ return path.join(PATHS.config, configName);
45
+ }
46
+ export function getTempPath(filename) {
47
+ return path.join(PATHS.temp, filename);
48
+ }
49
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/config/paths.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAMzC,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAKhD,MAAM,CAAC,MAAM,KAAK,GAAG;IAEnB,MAAM,EAAE;QAEN,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAA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,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC;AAkBD,MAAM,UAAU,aAAa,CAAC,IAA2B,EAAE,UAAkB;IAE3E,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,UAAU,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC;IACjF,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;AACnD,CAAC;AAcD,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AAcD,MAAM,UAAU,aAAa,CAAC,UAAkB;IAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC7C,CAAC;AAcD,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const REASONING_MODEL_PATTERNS: readonly string[];
2
+ export declare function detectReasoningSupport(filename: string): boolean;
3
+ //# sourceMappingURL=reasoning-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reasoning-models.d.ts","sourceRoot":"","sources":["../../src/config/reasoning-models.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAIrD,CAAC;AAmBF,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGhE"}
@@ -0,0 +1,10 @@
1
+ export const REASONING_MODEL_PATTERNS = [
2
+ 'qwen3',
3
+ 'deepseek-r1',
4
+ 'gpt-oss',
5
+ ];
6
+ export function detectReasoningSupport(filename) {
7
+ const lowerFilename = filename.toLowerCase();
8
+ return REASONING_MODEL_PATTERNS.some((pattern) => lowerFilename.includes(pattern));
9
+ }
10
+ //# sourceMappingURL=reasoning-models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reasoning-models.js","sourceRoot":"","sources":["../../src/config/reasoning-models.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAC,MAAM,wBAAwB,GAAsB;IACzD,OAAO;IACP,aAAa;IACb,SAAS;CACV,CAAC;AAmBF,MAAM,UAAU,sBAAsB,CAAC,QAAgB;IACrD,MAAM,aAAa,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAC7C,OAAO,wBAAwB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AACrF,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { DownloadProgressCallback } from '../types/index.js';
2
+ export interface DownloadOptions {
3
+ url: string;
4
+ destination: string;
5
+ onProgress?: DownloadProgressCallback;
6
+ timeout?: number;
7
+ headers?: Record<string, string>;
8
+ }
9
+ export declare class Downloader {
10
+ private abortController;
11
+ private isDownloading;
12
+ download(options: DownloadOptions): Promise<void>;
13
+ cancel(): void;
14
+ get downloading(): boolean;
15
+ }
16
+ //# sourceMappingURL=Downloader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Downloader.d.ts","sourceRoot":"","sources":["../../src/download/Downloader.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAOlE,MAAM,WAAW,eAAe;IAE9B,GAAG,EAAE,MAAM,CAAC;IAGZ,WAAW,EAAE,MAAM,CAAC;IAGpB,UAAU,CAAC,EAAE,wBAAwB,CAAC;IAGtC,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAiBD,qBAAa,UAAU;IACrB,OAAO,CAAC,eAAe,CAAgC;IACvD,OAAO,CAAC,aAAa,CAAS;IAiBjB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAiIvD,MAAM,IAAI,IAAI;IAWrB,IAAW,WAAW,IAAI,OAAO,CAEhC;CACF"}
@@ -0,0 +1,102 @@
1
+ import { createWriteStream } from 'node:fs';
2
+ import { pipeline } from 'node:stream/promises';
3
+ import { Readable } from 'node:stream';
4
+ import { DownloadError } from '../errors/index.js';
5
+ import { moveFile, deleteFile, fileExists } from '../utils/file-utils.js';
6
+ export class Downloader {
7
+ abortController = null;
8
+ isDownloading = false;
9
+ async download(options) {
10
+ const { url, destination, onProgress, headers } = options;
11
+ if (this.isDownloading) {
12
+ throw new DownloadError('Download already in progress');
13
+ }
14
+ this.isDownloading = true;
15
+ this.abortController = new AbortController();
16
+ const partialPath = `${destination}.partial`;
17
+ try {
18
+ const response = await fetch(url, {
19
+ signal: this.abortController.signal,
20
+ headers: headers || {},
21
+ });
22
+ if (!response.ok) {
23
+ throw new DownloadError(`HTTP error: ${response.status} ${response.statusText}`, {
24
+ status: response.status,
25
+ url,
26
+ });
27
+ }
28
+ if (!response.body) {
29
+ throw new DownloadError('Response body is null', { url });
30
+ }
31
+ const totalSize = parseInt(response.headers.get('content-length') || '0', 10);
32
+ let downloadedSize = 0;
33
+ const fileStream = createWriteStream(partialPath);
34
+ const trackingStream = new Readable({
35
+ async read() {
36
+ },
37
+ });
38
+ const reader = response.body.getReader();
39
+ let lastProgressUpdate = Date.now();
40
+ const progressInterval = 100;
41
+ const readChunk = async () => {
42
+ const { done, value } = await reader.read();
43
+ if (done) {
44
+ trackingStream.push(null);
45
+ return;
46
+ }
47
+ trackingStream.push(value);
48
+ downloadedSize += value.length;
49
+ const now = Date.now();
50
+ if (onProgress && now - lastProgressUpdate >= progressInterval) {
51
+ try {
52
+ onProgress(downloadedSize, totalSize);
53
+ }
54
+ catch {
55
+ }
56
+ lastProgressUpdate = now;
57
+ }
58
+ await readChunk();
59
+ };
60
+ const readPromise = readChunk();
61
+ await Promise.all([readPromise, pipeline(trackingStream, fileStream)]);
62
+ if (onProgress && totalSize > 0) {
63
+ try {
64
+ onProgress(totalSize, totalSize);
65
+ }
66
+ catch {
67
+ }
68
+ }
69
+ await moveFile(partialPath, destination);
70
+ }
71
+ catch (error) {
72
+ const partialExists = await fileExists(partialPath);
73
+ if (partialExists) {
74
+ try {
75
+ await deleteFile(partialPath);
76
+ }
77
+ catch {
78
+ }
79
+ }
80
+ if (error instanceof Error && error.name === 'AbortError') {
81
+ throw new DownloadError('Download cancelled', { url });
82
+ }
83
+ if (error instanceof DownloadError) {
84
+ throw error;
85
+ }
86
+ throw new DownloadError('Download failed', { url, error });
87
+ }
88
+ finally {
89
+ this.isDownloading = false;
90
+ this.abortController = null;
91
+ }
92
+ }
93
+ cancel() {
94
+ if (this.abortController && this.isDownloading) {
95
+ this.abortController.abort();
96
+ }
97
+ }
98
+ get downloading() {
99
+ return this.isDownloading;
100
+ }
101
+ }
102
+ //# sourceMappingURL=Downloader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Downloader.js","sourceRoot":"","sources":["../../src/download/Downloader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAqC1E,MAAM,OAAO,UAAU;IACb,eAAe,GAA2B,IAAI,CAAC;IAC/C,aAAa,GAAG,KAAK,CAAC;IAiBvB,KAAK,CAAC,QAAQ,CAAC,OAAwB;QAC5C,MAAM,EA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AAG,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC;YACpD,IAAI,aAAa,EAAE,CAAC;gBAClB,IAAI,CAAC;oBACH,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC;gBAChC,CAAC;gBAAC,MAAM,CAAC;gBAET,CAAC;YACH,CAAC;YAGD,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC1D,MAAM,IAAI,aAAa,CAAC,oBAAoB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACzD,CAAC;YAGD,IAAI,KAAK,YAAY,aAAa,EAAE,CAAC;gBACnC,MAAM,KAAK,CAAC;YACd,CAAC;YAED,MAAM,IAAI,aAAa,CAAC,iBAAiB,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7D,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;YAC3B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC9B,CAAC;IACH,CAAC;IAUM,MAAM;QACX,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC/C,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAC/B,CAAC;IACH,CAAC;IAOD,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export declare function calculateSHA256(filePath: string): Promise<string>;
2
+ export declare function verifyChecksum(filePath: string, expectedChecksum: string): Promise<boolean>;
3
+ export declare function formatChecksum(checksum: string): string;
4
+ //# sourceMappingURL=checksum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checksum.d.ts","sourceRoot":"","sources":["../../src/download/checksum.ts"],"names":[],"mappings":"AAoBA,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEvE;AAiBD,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAKjG;AAcD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKvD"}