sovkora 0.0.0-stage → 1.1.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.
- package/LICENSE +202 -0
- package/NOTICE +9 -0
- package/README.md +67 -2
- package/dist/commands/agent.command.js +267 -0
- package/dist/commands/chat.command.js +214 -0
- package/dist/commands/chat.handlers.js +150 -0
- package/dist/commands/chat.types.js +44 -0
- package/dist/commands/cinema.command.js +643 -0
- package/dist/commands/config.command.js +228 -0
- package/dist/commands/db.command.js +114 -0
- package/dist/commands/demo.command.js +55 -0
- package/dist/commands/dev.command.js +462 -0
- package/dist/commands/docs.command.js +135 -0
- package/dist/commands/doctor.command.js +119 -0
- package/dist/commands/forgot.command.js +57 -0
- package/dist/commands/generate.command.js +376 -0
- package/dist/commands/graph.command.js +54 -0
- package/dist/commands/init.command.js +380 -0
- package/dist/commands/init.steps.js +115 -0
- package/dist/commands/install.command.js +459 -0
- package/dist/commands/login.command.js +110 -0
- package/dist/commands/logs.command.js +215 -0
- package/dist/commands/logs.steps.js +130 -0
- package/dist/commands/mcp.command.js +104 -0
- package/dist/commands/models.command.js +164 -0
- package/dist/commands/onboard.command.js +236 -0
- package/dist/commands/pack.command.js +255 -0
- package/dist/commands/profile.command.js +51 -0
- package/dist/commands/recover.command.js +489 -0
- package/dist/commands/register.command.js +94 -0
- package/dist/commands/release.command.js +99 -0
- package/dist/commands/reset.command.js +79 -0
- package/dist/commands/runs.command.js +201 -0
- package/dist/commands/settings.command.js +85 -0
- package/dist/commands/start.command.js +590 -0
- package/dist/commands/status.command.js +167 -0
- package/dist/commands/stop.command.js +313 -0
- package/dist/commands/studio.command.js +266 -0
- package/dist/commands/test.command.js +134 -0
- package/dist/commands/verify.command.js +52 -0
- package/dist/commands/video.command.js +73 -0
- package/dist/commands/workspace-guard.js +72 -0
- package/dist/index.js +207 -0
- package/dist/renderers.js +250 -0
- package/dist/services/api-client.js +150 -0
- package/dist/services/auth.api.js +87 -0
- package/dist/services/chat.api.js +117 -0
- package/dist/services/cinema-estimate.json +42 -0
- package/dist/services/cinema.childsafe.js +52 -0
- package/dist/services/cinema.director.js +285 -0
- package/dist/services/cinema.production.js +417 -0
- package/dist/services/cinema.staging.js +323 -0
- package/dist/services/cinema.story.js +758 -0
- package/dist/services/cinema.treatment.js +393 -0
- package/dist/services/composer.run.js +94 -0
- package/dist/services/demo/demo.documents.js +108 -0
- package/dist/services/demo/demo.guard.js +49 -0
- package/dist/services/demo/demo.persona.js +114 -0
- package/dist/services/demo/demo.seed.js +281 -0
- package/dist/services/diagnostics.js +327 -0
- package/dist/services/image-model-recipes.json +93 -0
- package/dist/services/image-models.js +152 -0
- package/dist/services/local-store.js +145 -0
- package/dist/services/mcp.api.js +38 -0
- package/dist/services/model-catalog.js +70 -0
- package/dist/services/notify.js +55 -0
- package/dist/services/pack.api.js +23 -0
- package/dist/services/pack.bundle.js +241 -0
- package/dist/services/pack.sources.js +101 -0
- package/dist/services/release-manifest.js +266 -0
- package/dist/services/runs.view.js +80 -0
- package/dist/services/runs.wait.js +38 -0
- package/dist/services/semver.js +55 -0
- package/dist/services/settings.api.js +108 -0
- package/dist/services/string-utils.js +70 -0
- package/dist/services/studio.api.js +120 -0
- package/dist/services/templates.js +893 -0
- package/dist/services/tool-installer.js +353 -0
- package/dist/services/tool-path.js +72 -0
- package/dist/services/version-manager.js +253 -0
- package/dist/services/workspace-bootstrap.js +68 -0
- package/dist/threads.js +202 -0
- package/dist/types/api.types.js +6 -0
- package/dist/types/local.types.js +6 -0
- package/dist/ui/box.js +46 -0
- package/dist/ui/logger.js +28 -0
- package/dist/ui/platform.js +32 -0
- package/dist/ui/prompts.js +130 -0
- package/dist/ui/table.js +33 -0
- package/dist/utils/config.js +150 -0
- package/dist/utils/development-status.js +22 -0
- package/dist/utils/endpoints.js +41 -0
- package/dist/utils/health.js +94 -0
- package/dist/utils/pid.js +83 -0
- package/dist/utils/platform.js +358 -0
- package/dist/utils/process.js +139 -0
- package/dist/utils/state-dir.js +105 -0
- package/package.json +95 -4
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file diagnostics.ts
|
|
4
|
+
* @description Advanced diagnostic and verification system for detecting issues
|
|
5
|
+
* and suggesting recovery strategies during installation and startup.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.checkHttpEndpoint = exports.checkPortAvailable = void 0;
|
|
42
|
+
exports.detectDockerCompose = detectDockerCompose;
|
|
43
|
+
exports.detectLocalAI = detectLocalAI;
|
|
44
|
+
exports.runDiagnostics = runDiagnostics;
|
|
45
|
+
exports.autoFixIssues = autoFixIssues;
|
|
46
|
+
const fs = __importStar(require("node:fs"));
|
|
47
|
+
const path = __importStar(require("node:path"));
|
|
48
|
+
const node_child_process_1 = require("node:child_process");
|
|
49
|
+
const tool_path_1 = require("./tool-path");
|
|
50
|
+
const platform_1 = require("../utils/platform");
|
|
51
|
+
const config_1 = require("../utils/config");
|
|
52
|
+
// Re-export the shared health primitives so existing importers
|
|
53
|
+
// (`status`, `doctor`) keep importing them from this module.
|
|
54
|
+
var health_1 = require("../utils/health");
|
|
55
|
+
Object.defineProperty(exports, "checkPortAvailable", { enumerable: true, get: function () { return health_1.checkPortAvailable; } });
|
|
56
|
+
Object.defineProperty(exports, "checkHttpEndpoint", { enumerable: true, get: function () { return health_1.checkHttpEndpoint; } });
|
|
57
|
+
/**
|
|
58
|
+
* Detects which Docker Compose is available and its version.
|
|
59
|
+
*/
|
|
60
|
+
function detectDockerCompose() {
|
|
61
|
+
try {
|
|
62
|
+
if ((0, platform_1.hasTool)("docker-compose")) {
|
|
63
|
+
const version = (0, platform_1.getToolVersion)("docker-compose");
|
|
64
|
+
return { available: true, command: "docker-compose", version };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
/* docker-compose standalone not available */
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
if ((0, platform_1.hasTool)("docker")) {
|
|
72
|
+
(0, node_child_process_1.execFileSync)((0, tool_path_1.toolPath)("docker"), ["compose", "version"], { stdio: "ignore" });
|
|
73
|
+
const version = (0, platform_1.getToolVersion)("docker");
|
|
74
|
+
return { available: true, command: "docker compose", version };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
/* docker compose plugin not available */
|
|
79
|
+
}
|
|
80
|
+
return { available: false, command: null, version: null };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Checks if LocalAI is available on the system.
|
|
84
|
+
*/
|
|
85
|
+
function detectLocalAI() {
|
|
86
|
+
try {
|
|
87
|
+
const hasLocalAI = (0, platform_1.hasTool)("local-ai") || (0, platform_1.hasTool)("localai");
|
|
88
|
+
const isMPS = process.platform === "darwin"; // Metal Performance Shaders on macOS
|
|
89
|
+
const version = hasLocalAI ? (0, platform_1.getToolVersion)("local-ai") : null;
|
|
90
|
+
return {
|
|
91
|
+
available: hasLocalAI,
|
|
92
|
+
command: hasLocalAI ? "local-ai" : null,
|
|
93
|
+
version,
|
|
94
|
+
isMPS,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return { available: false, command: null, version: null, isMPS: false };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** Check Node.js version. */
|
|
102
|
+
function checkNodeVersion(issues) {
|
|
103
|
+
try {
|
|
104
|
+
const version = Number.parseInt(process.version.split(".")[0].substring(1));
|
|
105
|
+
if (version < config_1.NODE_MIN_MAJOR) {
|
|
106
|
+
issues.push({
|
|
107
|
+
code: "NODE_VERSION_OLD",
|
|
108
|
+
severity: "error",
|
|
109
|
+
title: "Node.js version too old",
|
|
110
|
+
description: `Found Node.js ${process.version}, but v${String(config_1.NODE_MIN_MAJOR)}.0.0+ is required.`,
|
|
111
|
+
suggestions: [
|
|
112
|
+
`Install Node.js ${String(config_1.NODE_MIN_MAJOR)} or later from https://nodejs.org`,
|
|
113
|
+
`Use nvm (Node Version Manager) for easy switching: nvm install ${String(config_1.NODE_MIN_MAJOR)}`,
|
|
114
|
+
"On macOS: brew install node",
|
|
115
|
+
],
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
/* version parse failed, skip check */
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/** Check Docker availability. */
|
|
124
|
+
function checkDocker(issues) {
|
|
125
|
+
const dockerStatus = detectDockerCompose();
|
|
126
|
+
if (!dockerStatus.available) {
|
|
127
|
+
issues.push({
|
|
128
|
+
code: "DOCKER_MISSING",
|
|
129
|
+
severity: "error",
|
|
130
|
+
title: "Docker not found",
|
|
131
|
+
description: "Docker Compose is required to run database middleware (Postgres, Redis, RabbitMQ).",
|
|
132
|
+
suggestions: [
|
|
133
|
+
"Install Docker Desktop from https://www.docker.com/products/docker-desktop",
|
|
134
|
+
"On macOS: brew install --cask docker",
|
|
135
|
+
"On Linux: sudo apt-get install docker.io docker-compose",
|
|
136
|
+
],
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/** Check Java availability and version. */
|
|
141
|
+
function checkJava(issues) {
|
|
142
|
+
if (!(0, platform_1.hasTool)("java")) {
|
|
143
|
+
issues.push({
|
|
144
|
+
code: "JAVA_MISSING",
|
|
145
|
+
severity: "error",
|
|
146
|
+
title: "Java 21 not found",
|
|
147
|
+
description: "Java 21+ is required to build and run the backend.",
|
|
148
|
+
suggestions: [
|
|
149
|
+
"Install Java 21 from https://adoptium.net",
|
|
150
|
+
"On macOS: brew install openjdk@21",
|
|
151
|
+
"On Linux: sudo apt-get install openjdk-21-jdk",
|
|
152
|
+
],
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const javaVersion = (0, platform_1.getToolVersion)("java");
|
|
157
|
+
if (!javaVersion.includes("21") && !javaVersion.includes("22") && !javaVersion.includes("23")) {
|
|
158
|
+
issues.push({
|
|
159
|
+
code: "JAVA_VERSION_MISMATCH",
|
|
160
|
+
severity: "warning",
|
|
161
|
+
title: "Java version may not be compatible",
|
|
162
|
+
description: `Found: ${javaVersion}. Sovkora requires Java 21+.`,
|
|
163
|
+
suggestions: ["Install Java 21+: https://adoptium.net", "Set JAVA_HOME to the Java 21 installation"],
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/** Check tool availability. */
|
|
169
|
+
function checkTools(issues) {
|
|
170
|
+
// Python
|
|
171
|
+
if (!(0, platform_1.hasTool)("python3")) {
|
|
172
|
+
issues.push({
|
|
173
|
+
code: "PYTHON_MISSING",
|
|
174
|
+
severity: "warning",
|
|
175
|
+
title: "Python 3 not found",
|
|
176
|
+
description: "Python 3.11+ is optional but needed for video rendering.",
|
|
177
|
+
suggestions: [
|
|
178
|
+
"Install Python 3.11+ from https://python.org",
|
|
179
|
+
"On macOS: brew install python@3.11",
|
|
180
|
+
"On Linux: sudo apt-get install python3.11",
|
|
181
|
+
],
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
// Maven
|
|
185
|
+
if (!(0, platform_1.hasTool)("mvn")) {
|
|
186
|
+
issues.push({
|
|
187
|
+
code: "MAVEN_MISSING",
|
|
188
|
+
severity: "warning",
|
|
189
|
+
title: "Maven not found",
|
|
190
|
+
description: "Maven is needed to build Java modules.",
|
|
191
|
+
suggestions: [
|
|
192
|
+
"Install Maven from https://maven.apache.org",
|
|
193
|
+
"On macOS: brew install maven",
|
|
194
|
+
"Or use the included ./mvnw wrapper",
|
|
195
|
+
],
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
// Git
|
|
199
|
+
if (!(0, platform_1.hasTool)("git")) {
|
|
200
|
+
issues.push({
|
|
201
|
+
code: "GIT_MISSING",
|
|
202
|
+
severity: "warning",
|
|
203
|
+
title: "Git not found",
|
|
204
|
+
description: "Git is recommended for version control.",
|
|
205
|
+
suggestions: ["Install Git from https://git-scm.com", "On macOS: brew install git"],
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Runs a comprehensive diagnostic check.
|
|
211
|
+
*/
|
|
212
|
+
async function runDiagnostics() {
|
|
213
|
+
const issues = [];
|
|
214
|
+
const systemInfo = (0, platform_1.getSystemInfo)();
|
|
215
|
+
// 1. Check Node.js version
|
|
216
|
+
checkNodeVersion(issues);
|
|
217
|
+
// 2. Check Docker
|
|
218
|
+
checkDocker(issues);
|
|
219
|
+
// 3. Check Java
|
|
220
|
+
checkJava(issues);
|
|
221
|
+
// 4-6. Check tools (Python, Maven, Git)
|
|
222
|
+
checkTools(issues);
|
|
223
|
+
// 7. Check LocalAI (critical for image generation on macOS M1)
|
|
224
|
+
if (systemInfo.isAppleSilicon) {
|
|
225
|
+
const localAIStatus = detectLocalAI();
|
|
226
|
+
if (!localAIStatus.available) {
|
|
227
|
+
issues.push({
|
|
228
|
+
code: "LOCALAI_MISSING_M1",
|
|
229
|
+
severity: "warning",
|
|
230
|
+
title: "LocalAI not found (Image generation unavailable)",
|
|
231
|
+
description: "On macOS M1/M2/M3, LocalAI is recommended for GPU-accelerated image generation. Image synthesis will fail without it.",
|
|
232
|
+
suggestions: [
|
|
233
|
+
"Install LocalAI: https://localai.io/docs/getting-started/",
|
|
234
|
+
"On macOS: brew install localai",
|
|
235
|
+
"Or download pre-built binary: https://github.com/go-skynet/LocalAI/releases",
|
|
236
|
+
"Verify installation: local-ai --version",
|
|
237
|
+
],
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
else if (localAIStatus.isMPS) {
|
|
241
|
+
// Good: LocalAI is available on Apple Silicon with Metal support
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// 8. Check workspace structure
|
|
245
|
+
const workspaceRoot = (0, platform_1.resolveWorkspaceRoot)();
|
|
246
|
+
const requiredDirs = ["engine", "services", "apps", "infra", "docs"];
|
|
247
|
+
for (const dir of requiredDirs) {
|
|
248
|
+
if (!fs.existsSync(path.join(workspaceRoot, dir))) {
|
|
249
|
+
issues.push({
|
|
250
|
+
code: "WORKSPACE_INVALID",
|
|
251
|
+
severity: "error",
|
|
252
|
+
title: "Invalid workspace structure",
|
|
253
|
+
description: `Missing directory: ${dir}`,
|
|
254
|
+
suggestions: [
|
|
255
|
+
"Run this command from the Sovkora project root directory",
|
|
256
|
+
"Ensure all subdirectories are present",
|
|
257
|
+
],
|
|
258
|
+
});
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
// 8. Check .env file
|
|
263
|
+
const envFile = (0, platform_1.resolveEnvFile)();
|
|
264
|
+
if (!fs.existsSync(envFile)) {
|
|
265
|
+
issues.push({
|
|
266
|
+
code: "ENV_MISSING",
|
|
267
|
+
severity: "warning",
|
|
268
|
+
title: ".env file not found",
|
|
269
|
+
description: "No environment configuration found.",
|
|
270
|
+
suggestions: ["Run: npx sovkora init", "Or manually create a .env file with required variables"],
|
|
271
|
+
autoFixable: true,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
// 9. Check docker-compose.yml
|
|
275
|
+
const composeFile = (0, platform_1.resolveComposeFile)();
|
|
276
|
+
if (!fs.existsSync(composeFile)) {
|
|
277
|
+
issues.push({
|
|
278
|
+
code: "COMPOSE_MISSING",
|
|
279
|
+
severity: "warning",
|
|
280
|
+
title: "docker-compose.yml not found",
|
|
281
|
+
description: "Docker Compose configuration is missing.",
|
|
282
|
+
suggestions: ["Run: npx sovkora init", "Or restore the file from version control"],
|
|
283
|
+
autoFixable: true,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
// 10. Check memory requirements
|
|
287
|
+
const requiredMemoryGb = 8;
|
|
288
|
+
if (systemInfo.totalMemoryGb < requiredMemoryGb) {
|
|
289
|
+
issues.push({
|
|
290
|
+
code: "LOW_MEMORY",
|
|
291
|
+
severity: "warning",
|
|
292
|
+
title: "Insufficient system memory",
|
|
293
|
+
description: `Found ${systemInfo.totalMemoryGb}GB, but ${requiredMemoryGb}GB is recommended.`,
|
|
294
|
+
suggestions: [
|
|
295
|
+
"Close other applications to free up memory",
|
|
296
|
+
"Consider upgrading system RAM",
|
|
297
|
+
"Use the lightweight profile in installation",
|
|
298
|
+
],
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
return {
|
|
302
|
+
timestamp: new Date(),
|
|
303
|
+
systemInfo,
|
|
304
|
+
issues,
|
|
305
|
+
criticalCount: issues.filter((i) => i.severity === "error").length,
|
|
306
|
+
warningCount: issues.filter((i) => i.severity === "warning").length,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Attempts to auto-fix fixable issues.
|
|
311
|
+
*/
|
|
312
|
+
async function autoFixIssues(issues) {
|
|
313
|
+
const fixed = [];
|
|
314
|
+
for (const issue of issues) {
|
|
315
|
+
if (!issue.autoFixable)
|
|
316
|
+
continue;
|
|
317
|
+
if (issue.code === "ENV_MISSING") {
|
|
318
|
+
// env.ts will be initialized by init command
|
|
319
|
+
fixed.push("ENV_MISSING");
|
|
320
|
+
}
|
|
321
|
+
if (issue.code === "COMPOSE_MISSING") {
|
|
322
|
+
// docker-compose.yml will be generated by init command
|
|
323
|
+
fixed.push("COMPOSE_MISSING");
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return fixed;
|
|
327
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "How each local image model is installed and served by stable-diffusion.cpp (sd-server, Metal). The id of a recipe IS the model_name of its orazaka_models row: the catalogue says which model is the image default, this file says how to download and launch it. Only models whose licence allows commercial use are listed. Timings were measured on an M1 Max (64 GB) and are indicative.",
|
|
3
|
+
"models": [
|
|
4
|
+
{
|
|
5
|
+
"id": "flux-2-klein-4b",
|
|
6
|
+
"label": "FLUX.2 [klein] 4B",
|
|
7
|
+
"family": "flux2",
|
|
8
|
+
"licence": "Apache-2.0",
|
|
9
|
+
"licenceUrl": "https://huggingface.co/black-forest-labs/FLUX.2-klein-4B",
|
|
10
|
+
"summary": "Editorial-grade photographs, illustrations and miniatures in 4 steps. The local default.",
|
|
11
|
+
"ramGb": 11,
|
|
12
|
+
"measured": "1024x1024 in ~82 s, 1024x1280 in ~105 s on an M1 Max; peak 10 GB",
|
|
13
|
+
"files": [
|
|
14
|
+
{
|
|
15
|
+
"role": "diffusion-model",
|
|
16
|
+
"path": "flux2-klein-4b/flux-2-klein-4b-Q8_0.gguf",
|
|
17
|
+
"url": "https://huggingface.co/leejet/FLUX.2-klein-4B-GGUF/resolve/main/flux-2-klein-4b-Q8_0.gguf",
|
|
18
|
+
"bytes": 4300629440,
|
|
19
|
+
"sha256": "0bba6951258ec8f92d51114a8fa13e66828297bfff58a738f52729b3ef66fa28"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"role": "llm",
|
|
23
|
+
"path": "flux2-klein-4b/Qwen3-4B-Q8_0.gguf",
|
|
24
|
+
"url": "https://huggingface.co/unsloth/Qwen3-4B-GGUF/resolve/main/Qwen3-4B-Q8_0.gguf",
|
|
25
|
+
"bytes": 4280405792,
|
|
26
|
+
"sha256": "eed555233267a33c7e8ee31682762cc7751b3f6d224039086e0e846f05fffa5d"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"role": "vae",
|
|
30
|
+
"path": "flux2-klein-4b/flux2-vae.safetensors",
|
|
31
|
+
"url": "https://huggingface.co/black-forest-labs/FLUX.2-klein-4B/resolve/main/vae/diffusion_pytorch_model.safetensors",
|
|
32
|
+
"bytes": 168120878,
|
|
33
|
+
"sha256": "ca70d2202afe6415bdbcb8793ba8cd99fd159cfe6192381504d6c4d3036e0f04"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"launch": { "steps": 4, "cfgScale": 1.0, "width": 1024, "height": 1024, "flags": ["--diffusion-fa"] }
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "z-image-turbo",
|
|
40
|
+
"label": "Z-Image Turbo",
|
|
41
|
+
"family": "z-image",
|
|
42
|
+
"licence": "Apache-2.0",
|
|
43
|
+
"licenceUrl": "https://huggingface.co/Tongyi-MAI/Z-Image-Turbo",
|
|
44
|
+
"summary": "The most detailed photographs, at three times FLUX.2 [klein]'s time. Renders lettering readily: keep words out of the prompt.",
|
|
45
|
+
"ramGb": 12,
|
|
46
|
+
"measured": "1024x1024 in ~233 s on an M1 Max; peak 11.4 GB",
|
|
47
|
+
"files": [
|
|
48
|
+
{
|
|
49
|
+
"role": "diffusion-model",
|
|
50
|
+
"path": "z-image-turbo/z_image_turbo-Q8_0.gguf",
|
|
51
|
+
"url": "https://huggingface.co/leejet/Z-Image-Turbo-GGUF/resolve/main/z_image_turbo-Q8_0.gguf",
|
|
52
|
+
"bytes": 6577440704,
|
|
53
|
+
"sha256": "df1c5baa86d1398c979495a6072dbcee79444fdb884a2445582ba0769c44e9a1"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"role": "llm",
|
|
57
|
+
"path": "z-image-turbo/Qwen3-4B-Instruct-2507-Q8_0.gguf",
|
|
58
|
+
"url": "https://huggingface.co/unsloth/Qwen3-4B-Instruct-2507-GGUF/resolve/main/Qwen3-4B-Instruct-2507-Q8_0.gguf",
|
|
59
|
+
"bytes": 4280405600,
|
|
60
|
+
"sha256": "391c1e410fd9f4cf2de2b510273b56a84c19ce18f4fa3bfb3774031dac4ef068"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"role": "vae",
|
|
64
|
+
"path": "z-image-turbo/ae.safetensors",
|
|
65
|
+
"url": "https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/vae/ae.safetensors",
|
|
66
|
+
"bytes": 335304388,
|
|
67
|
+
"sha256": "afc8e28272cd15db3919bacdb6918ce9c1ed22e96cb12c4d5ed0fba823529e38"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"launch": { "steps": 8, "cfgScale": 1.0, "width": 1024, "height": 1024, "flags": ["--diffusion-fa"] }
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": "v1-5-pruned-emaonly",
|
|
74
|
+
"label": "Stable Diffusion 1.5",
|
|
75
|
+
"family": "sd1",
|
|
76
|
+
"licence": "CreativeML OpenRAIL-M",
|
|
77
|
+
"licenceUrl": "https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5",
|
|
78
|
+
"summary": "The former default: 512 px, 77-token prompts. Kept for small machines.",
|
|
79
|
+
"ramGb": 5,
|
|
80
|
+
"measured": "512x512 in ~68 s (20 steps) on an M1 Max; peak 4.2 GB",
|
|
81
|
+
"files": [
|
|
82
|
+
{
|
|
83
|
+
"role": "model",
|
|
84
|
+
"path": "v1-5-pruned-emaonly.safetensors",
|
|
85
|
+
"url": "https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors",
|
|
86
|
+
"bytes": 4265146304,
|
|
87
|
+
"sha256": "6ce0161689b3853acaa03779ec93eafe75a02f4ced659bee03f50797806fa2fa"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"launch": { "steps": 20, "cfgScale": 7.0, "width": 512, "height": 512, "flags": [] }
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file image-models.ts
|
|
4
|
+
* @description The local image models: how each one is downloaded, verified and served by
|
|
5
|
+
* stable-diffusion.cpp's `sd-server` (Metal).
|
|
6
|
+
*
|
|
7
|
+
* The recipes live in `image-model-recipes.json`, not in code. A recipe's `id` is the `model_name` of its
|
|
8
|
+
* `orazaka_models` row: the catalogue decides which model is the image default (data in the DB,
|
|
9
|
+
* AGENTS.md §4), this module only knows how to install and launch it. `sd-server` serves one model
|
|
10
|
+
* at a time, so `sovkora start` launches the catalogue's default and nothing else — serving another
|
|
11
|
+
* model under the default's name would put the wrong model on every bill and every caption.
|
|
12
|
+
*/
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.IMAGE_MODELS = void 0;
|
|
51
|
+
exports.findImageModel = findImageModel;
|
|
52
|
+
exports.downloadBytes = downloadBytes;
|
|
53
|
+
exports.missingFiles = missingFiles;
|
|
54
|
+
exports.isInstalled = isInstalled;
|
|
55
|
+
exports.sdServerArgs = sdServerArgs;
|
|
56
|
+
exports.pullImageModel = pullImageModel;
|
|
57
|
+
const crypto = __importStar(require("node:crypto"));
|
|
58
|
+
const fs = __importStar(require("node:fs"));
|
|
59
|
+
const path = __importStar(require("node:path"));
|
|
60
|
+
const node_stream_1 = require("node:stream");
|
|
61
|
+
const promises_1 = require("node:stream/promises");
|
|
62
|
+
const image_model_recipes_json_1 = __importDefault(require("./image-model-recipes.json"));
|
|
63
|
+
const FLAG = {
|
|
64
|
+
model: "-m",
|
|
65
|
+
"diffusion-model": "--diffusion-model",
|
|
66
|
+
llm: "--llm",
|
|
67
|
+
vae: "--vae",
|
|
68
|
+
clip_l: "--clip_l",
|
|
69
|
+
t5xxl: "--t5xxl",
|
|
70
|
+
};
|
|
71
|
+
/** Every recipe, in order of preference. */
|
|
72
|
+
exports.IMAGE_MODELS = image_model_recipes_json_1.default.models.map((recipe) => Object.freeze(recipe));
|
|
73
|
+
/** @returns the recipe for a catalogue model name, or `undefined` when none is installable. */
|
|
74
|
+
function findImageModel(id) {
|
|
75
|
+
return exports.IMAGE_MODELS.find((recipe) => recipe.id === id.trim());
|
|
76
|
+
}
|
|
77
|
+
/** Total download size of a recipe, in bytes. */
|
|
78
|
+
function downloadBytes(recipe) {
|
|
79
|
+
return recipe.files.reduce((sum, file) => sum + file.bytes, 0);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A file counts as installed when it is there at its declared size. The size is checked on every
|
|
83
|
+
* start (cheap); the checksum only after a download (a 4 GB hash is not a start-up cost).
|
|
84
|
+
*/
|
|
85
|
+
function missingFiles(recipe, modelsDir) {
|
|
86
|
+
return recipe.files.filter((file) => {
|
|
87
|
+
const target = path.join(modelsDir, file.path);
|
|
88
|
+
return !fs.existsSync(target) || fs.statSync(target).size !== file.bytes;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function isInstalled(recipe, modelsDir) {
|
|
92
|
+
return missingFiles(recipe, modelsDir).length === 0;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The sd-server command line for a recipe: its files, then its own sampling recipe as the server's
|
|
96
|
+
* defaults. Requests still send their step count, size, seed and negative prompt (the engine's
|
|
97
|
+
* image adapter); guidance and the model's flags are the recipe's alone.
|
|
98
|
+
*/
|
|
99
|
+
function sdServerArgs(recipe, modelsDir, options) {
|
|
100
|
+
const files = recipe.files.flatMap((file) => [FLAG[file.role], path.join(modelsDir, file.path)]);
|
|
101
|
+
return [
|
|
102
|
+
"--listen-port",
|
|
103
|
+
String(options.port),
|
|
104
|
+
...files,
|
|
105
|
+
"--steps",
|
|
106
|
+
String(recipe.launch.steps),
|
|
107
|
+
"--cfg-scale",
|
|
108
|
+
String(recipe.launch.cfgScale),
|
|
109
|
+
"-W",
|
|
110
|
+
String(recipe.launch.width),
|
|
111
|
+
"-H",
|
|
112
|
+
String(recipe.launch.height),
|
|
113
|
+
"--seed",
|
|
114
|
+
options.seed ?? "-1",
|
|
115
|
+
...recipe.launch.flags,
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Downloads every missing file of a recipe into the models directory and verifies its SHA-256.
|
|
120
|
+
*
|
|
121
|
+
* A file is written to `<path>.part` and renamed only once its checksum matches, so an interrupted
|
|
122
|
+
* or tampered download never looks installed. Files already present at their size are skipped.
|
|
123
|
+
*/
|
|
124
|
+
async function pullImageModel(recipe, modelsDir, deps) {
|
|
125
|
+
const pulled = [];
|
|
126
|
+
for (const file of missingFiles(recipe, modelsDir)) {
|
|
127
|
+
const target = path.join(modelsDir, file.path);
|
|
128
|
+
const partial = `${target}.part`;
|
|
129
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
130
|
+
const response = await deps.fetch(file.url);
|
|
131
|
+
if (!response.ok || !response.body) {
|
|
132
|
+
throw new Error(`Download of ${file.path} failed: HTTP ${String(response.status)}`);
|
|
133
|
+
}
|
|
134
|
+
const hash = crypto.createHash("sha256");
|
|
135
|
+
let received = 0;
|
|
136
|
+
const body = node_stream_1.Readable.fromWeb(response.body);
|
|
137
|
+
body.on("data", (chunk) => {
|
|
138
|
+
hash.update(chunk);
|
|
139
|
+
received += chunk.length;
|
|
140
|
+
deps.onProgress?.({ file, received });
|
|
141
|
+
});
|
|
142
|
+
await (0, promises_1.pipeline)(body, fs.createWriteStream(partial));
|
|
143
|
+
const digest = hash.digest("hex");
|
|
144
|
+
if (digest !== file.sha256 || received !== file.bytes) {
|
|
145
|
+
fs.rmSync(partial, { force: true });
|
|
146
|
+
throw new Error(`${file.path} does not match its recipe (sha256 ${digest}, ${String(received)} bytes): removed`);
|
|
147
|
+
}
|
|
148
|
+
fs.renameSync(partial, target);
|
|
149
|
+
pulled.push(file);
|
|
150
|
+
}
|
|
151
|
+
return pulled;
|
|
152
|
+
}
|