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,489 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file recover.command.ts
|
|
4
|
+
* @description Recovery and troubleshooting command with guided problem resolution.
|
|
5
|
+
* Includes service restart, tool reinstallation, venv recreation, port conflict
|
|
6
|
+
* resolution, and .env validation.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
42
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.recoverCommand = void 0;
|
|
46
|
+
const commander_1 = require("commander");
|
|
47
|
+
const fs = __importStar(require("node:fs"));
|
|
48
|
+
const path = __importStar(require("node:path"));
|
|
49
|
+
const node_child_process_1 = require("node:child_process");
|
|
50
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
51
|
+
const prompts_1 = require("../ui/prompts");
|
|
52
|
+
const platform_1 = require("../ui/platform");
|
|
53
|
+
const tool_installer_1 = require("../services/tool-installer");
|
|
54
|
+
const tool_path_1 = require("../services/tool-path");
|
|
55
|
+
const process_1 = require("../utils/process");
|
|
56
|
+
const config_1 = require("../utils/config");
|
|
57
|
+
const recoveryOptions = [
|
|
58
|
+
{
|
|
59
|
+
id: "restart-service",
|
|
60
|
+
label: "🔄 Restart a Service",
|
|
61
|
+
hint: "Restart a specific service without full reset",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: "port-fix",
|
|
65
|
+
label: "🔌 Fix Port Conflicts",
|
|
66
|
+
hint: "Auto-detect and kill processes blocking critical ports",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "env-validate",
|
|
70
|
+
label: "📋 Validate .env Completeness",
|
|
71
|
+
hint: "Check all required keys are present and add missing ones",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: "venv-recreate",
|
|
75
|
+
label: "🐍 Recreate Media Worker venv",
|
|
76
|
+
hint: "Delete and recreate the Python virtual environment",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: "reinstall-localai",
|
|
80
|
+
label: "🎨 Reinstall LocalAI",
|
|
81
|
+
hint: "Reinstall LocalAI via Homebrew (macOS)",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: "docker-clean",
|
|
85
|
+
label: "🐳 Clean Docker Environment",
|
|
86
|
+
hint: "Remove stopped containers and orphaned volumes",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: "env-reset",
|
|
90
|
+
label: "🔑 Reset Environment Variables",
|
|
91
|
+
hint: "Regenerate .env file with secure defaults",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: "pid-cleanup",
|
|
95
|
+
label: "💀 Cleanup Process IDs",
|
|
96
|
+
hint: "Remove stale PID references and orphaned processes",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: "log-cleanup",
|
|
100
|
+
label: "🗑️ Clear Logs",
|
|
101
|
+
hint: "Wipe previous logs to reduce disk usage",
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: "full-reset",
|
|
105
|
+
label: "💣 Full System Reset",
|
|
106
|
+
hint: "Wipe databases and restart from clean state",
|
|
107
|
+
dangerous: true,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: "diagnose-all",
|
|
111
|
+
label: "🔍 Full Diagnostic Report",
|
|
112
|
+
hint: "Run comprehensive system analysis",
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
exports.recoverCommand = new commander_1.Command("recover")
|
|
116
|
+
.description("Diagnose and recover from common issues")
|
|
117
|
+
.action(async () => {
|
|
118
|
+
await (0, prompts_1.intro)(chalk_1.default.cyan.bold("🥷 Sovkora Recovery & Troubleshooting"));
|
|
119
|
+
const issue = await (0, prompts_1.select)({
|
|
120
|
+
message: "What would you like to do?",
|
|
121
|
+
options: recoveryOptions.map((opt) => ({
|
|
122
|
+
value: opt.id,
|
|
123
|
+
label: opt.label,
|
|
124
|
+
hint: opt.hint,
|
|
125
|
+
})),
|
|
126
|
+
});
|
|
127
|
+
const workspaceRoot = (0, platform_1.resolveWorkspaceRoot)();
|
|
128
|
+
const spinner = await (0, prompts_1.createSpinner)();
|
|
129
|
+
switch (issue) {
|
|
130
|
+
// ─── Restart a specific service ─────────────────────────
|
|
131
|
+
case "restart-service": {
|
|
132
|
+
const service = await (0, prompts_1.select)({
|
|
133
|
+
message: "Which service to restart?",
|
|
134
|
+
options: [
|
|
135
|
+
{
|
|
136
|
+
value: "docker",
|
|
137
|
+
label: "Docker Middleware (Postgres, Redis, RabbitMQ)",
|
|
138
|
+
hint: "Restart all Docker containers",
|
|
139
|
+
},
|
|
140
|
+
{ value: "ollama", label: "Ollama (LLM Engine)", hint: "Restart Ollama serve" },
|
|
141
|
+
{ value: "localai", label: "LocalAI (Image Worker)", hint: "Restart LocalAI process" },
|
|
142
|
+
{ value: "media", label: "Media Worker", hint: "Restart the Python media worker" },
|
|
143
|
+
],
|
|
144
|
+
});
|
|
145
|
+
if (service === "docker") {
|
|
146
|
+
const composeFile = (0, platform_1.resolveComposeFile)();
|
|
147
|
+
const dockerComposeCmd = (0, platform_1.resolveDockerComposeCmd)();
|
|
148
|
+
if (dockerComposeCmd && fs.existsSync(composeFile)) {
|
|
149
|
+
spinner.start("Restarting Docker containers...");
|
|
150
|
+
try {
|
|
151
|
+
(0, node_child_process_1.execSync)(`${dockerComposeCmd} -p orazaka -f "${composeFile}" restart`, { stdio: "ignore" });
|
|
152
|
+
spinner.stop("Docker containers restarted.");
|
|
153
|
+
await (0, prompts_1.logSuccess)("✔ Docker middleware restarted");
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
spinner.stop("Restart failed", 1);
|
|
157
|
+
await (0, prompts_1.logError)("Failed to restart Docker containers");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else if (service === "ollama") {
|
|
162
|
+
spinner.start("Restarting Ollama...");
|
|
163
|
+
try {
|
|
164
|
+
(0, process_1.stopMatching)("ollama serve");
|
|
165
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
166
|
+
if (process.platform === "darwin") {
|
|
167
|
+
(0, node_child_process_1.execFileSync)((0, tool_path_1.toolPath)("open"), ["-a", "Ollama"], { stdio: "ignore" });
|
|
168
|
+
}
|
|
169
|
+
else if ((0, platform_1.hasTool)("ollama")) {
|
|
170
|
+
(0, node_child_process_1.spawn)((0, tool_path_1.toolPath)("ollama"), ["serve"], { detached: true, stdio: "ignore" }).unref();
|
|
171
|
+
}
|
|
172
|
+
spinner.stop("Ollama restarted.");
|
|
173
|
+
await (0, prompts_1.logSuccess)("✔ Ollama restarted");
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
spinner.stop("Restart failed", 1);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else if (service === "localai") {
|
|
180
|
+
spinner.start("Restarting LocalAI...");
|
|
181
|
+
try {
|
|
182
|
+
(0, process_1.stopMatching)("local-ai");
|
|
183
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
184
|
+
await (0, prompts_1.logInfo)("LocalAI stopped. Restart via: npx sovkora start --only localai");
|
|
185
|
+
spinner.stop("LocalAI stopped.");
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
spinner.stop("Restart failed", 1);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else if (service === "media") {
|
|
192
|
+
spinner.start("Restarting Media Worker...");
|
|
193
|
+
try {
|
|
194
|
+
(0, process_1.stopMatching)("orazaka-worker-media.*main.py");
|
|
195
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
196
|
+
await (0, prompts_1.logInfo)("Media Worker stopped. Restart via: npx sovkora start --only media-worker");
|
|
197
|
+
spinner.stop("Media Worker stopped.");
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
spinner.stop("Restart failed", 1);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
// ─── Fix port conflicts (auto-kill) ─────────────────────
|
|
206
|
+
case "port-fix": {
|
|
207
|
+
spinner.start("Scanning for port conflicts...");
|
|
208
|
+
const criticalPorts = [
|
|
209
|
+
{ port: config_1.PORTS.postgres, name: "PostgreSQL" },
|
|
210
|
+
{ port: config_1.PORTS.redis, name: "Redis" },
|
|
211
|
+
{ port: config_1.PORTS.rabbitmq, name: "RabbitMQ" },
|
|
212
|
+
{ port: config_1.PORTS.router, name: "Router API" },
|
|
213
|
+
{ port: config_1.PORTS.web, name: "Frontend UI" },
|
|
214
|
+
{ port: config_1.PORTS.ollama, name: "Ollama" },
|
|
215
|
+
{ port: config_1.PORTS.localai, name: "LocalAI" },
|
|
216
|
+
{ port: config_1.PORTS.mediaWorker, name: "Media Worker" },
|
|
217
|
+
];
|
|
218
|
+
const conflicts = [];
|
|
219
|
+
for (const service of criticalPorts) {
|
|
220
|
+
try {
|
|
221
|
+
if (process.platform !== "win32") {
|
|
222
|
+
const pids = (0, node_child_process_1.execSync)(`lsof -i :${String(service.port)} -t 2>/dev/null || true`)
|
|
223
|
+
.toString()
|
|
224
|
+
.trim();
|
|
225
|
+
if (pids) {
|
|
226
|
+
conflicts.push({ ...service, pid: pids.split("\n")[0] });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
/* no conflict */
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
spinner.stop();
|
|
235
|
+
if (conflicts.length === 0) {
|
|
236
|
+
await (0, prompts_1.logSuccess)("✔ No port conflicts detected.");
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
await (0, prompts_1.logWarning)(`Found ${String(conflicts.length)} port conflict(s):`);
|
|
240
|
+
for (const c of conflicts) {
|
|
241
|
+
console.log(` ${chalk_1.default.red("✖")} Port ${String(c.port)} (${c.name}) — PID ${c.pid}`);
|
|
242
|
+
}
|
|
243
|
+
const shouldKill = await (0, prompts_1.confirm)({
|
|
244
|
+
message: "Kill all conflicting processes?",
|
|
245
|
+
initialValue: false,
|
|
246
|
+
});
|
|
247
|
+
if (shouldKill === true) {
|
|
248
|
+
for (const c of conflicts) {
|
|
249
|
+
try {
|
|
250
|
+
(0, node_child_process_1.execSync)(`kill -9 ${c.pid}`, { stdio: "ignore" });
|
|
251
|
+
await (0, prompts_1.logSuccess)(`Killed PID ${c.pid} (port ${String(c.port)})`);
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
await (0, prompts_1.logWarning)(`Could not kill PID ${c.pid}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
// ─── Validate .env completeness ─────────────────────────
|
|
262
|
+
case "env-validate": {
|
|
263
|
+
const envFile = (0, platform_1.resolveEnvFile)();
|
|
264
|
+
if (!fs.existsSync(envFile)) {
|
|
265
|
+
await (0, prompts_1.logError)(".env not found. Run npx sovkora init first.");
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
spinner.start("Validating .env...");
|
|
269
|
+
const requiredKeys = [
|
|
270
|
+
"PORT",
|
|
271
|
+
"SPRING_DATASOURCE_URL",
|
|
272
|
+
"SPRING_DATASOURCE_USERNAME",
|
|
273
|
+
"SPRING_DATASOURCE_PASSWORD",
|
|
274
|
+
"REDIS_URL",
|
|
275
|
+
"RABBITMQ_HOST",
|
|
276
|
+
"RABBITMQ_PORT",
|
|
277
|
+
"DEFAULT_PROVIDER",
|
|
278
|
+
"OLLAMA_BASE_URL",
|
|
279
|
+
"OLLAMA_MODEL",
|
|
280
|
+
"CRYPTO_KEY",
|
|
281
|
+
"CRYPTO_SALT",
|
|
282
|
+
"VIDEO_WORKER_PORT",
|
|
283
|
+
"IMAGE_WORKER_PORT",
|
|
284
|
+
"LOCALAI_PORT",
|
|
285
|
+
"LOG_DIR",
|
|
286
|
+
"UPLOAD_DIR",
|
|
287
|
+
];
|
|
288
|
+
const defaults = {};
|
|
289
|
+
for (const key of requiredKeys) {
|
|
290
|
+
defaults[key] = `PLACEHOLDER_${key}`;
|
|
291
|
+
}
|
|
292
|
+
// Use meaningful defaults
|
|
293
|
+
defaults["PORT"] = "8080";
|
|
294
|
+
defaults["VIDEO_WORKER_PORT"] = "8188";
|
|
295
|
+
defaults["IMAGE_WORKER_PORT"] = "8085";
|
|
296
|
+
defaults["LOCALAI_PORT"] = "8085";
|
|
297
|
+
defaults["LOG_DIR"] = "var/logs";
|
|
298
|
+
defaults["UPLOAD_DIR"] = "var/orazaka-uploads";
|
|
299
|
+
defaults["DEFAULT_PROVIDER"] = "ollama";
|
|
300
|
+
defaults["OLLAMA_BASE_URL"] = "http://localhost:11434";
|
|
301
|
+
defaults["OLLAMA_MODEL"] = "phi3:mini";
|
|
302
|
+
defaults["RABBITMQ_PORT"] = "5672";
|
|
303
|
+
defaults["RABBITMQ_HOST"] = "localhost";
|
|
304
|
+
defaults["REDIS_URL"] = "redis://localhost:6379";
|
|
305
|
+
const added = (0, platform_1.mergeEnvFile)(envFile, defaults);
|
|
306
|
+
spinner.stop();
|
|
307
|
+
if (added.length === 0) {
|
|
308
|
+
await (0, prompts_1.logSuccess)("✔ .env is complete — all required keys present");
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
await (0, prompts_1.logSuccess)(`Added ${String(added.length)} missing key(s): ${chalk_1.default.gray(added.join(", "))}`);
|
|
312
|
+
await (0, prompts_1.logWarning)("Review the added keys and update placeholder values.");
|
|
313
|
+
}
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
// ─── Recreate media worker venv ─────────────────────────
|
|
317
|
+
case "venv-recreate": {
|
|
318
|
+
const venvPath = path.join(workspaceRoot, "workers", "media", ".venv");
|
|
319
|
+
if (fs.existsSync(venvPath)) {
|
|
320
|
+
const shouldDelete = await (0, prompts_1.confirm)({
|
|
321
|
+
message: `Delete existing venv at ${path.relative(workspaceRoot, venvPath)}?`,
|
|
322
|
+
initialValue: true,
|
|
323
|
+
});
|
|
324
|
+
if (shouldDelete === true) {
|
|
325
|
+
spinner.start("Removing existing venv...");
|
|
326
|
+
fs.rmSync(venvPath, { recursive: true, force: true });
|
|
327
|
+
spinner.stop("Old venv removed.");
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
spinner.start("Creating new Python venv...");
|
|
334
|
+
const result = (0, tool_installer_1.setupMediaWorkerVenv)(workspaceRoot);
|
|
335
|
+
if (result.success) {
|
|
336
|
+
spinner.stop("Venv created.");
|
|
337
|
+
await (0, prompts_1.logSuccess)(`✔ Media worker venv ready at ${path.relative(workspaceRoot, result.venvPath)}`);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
spinner.stop("Failed", 1);
|
|
341
|
+
await (0, prompts_1.logError)(`Could not create venv: ${result.error ?? "unknown error"}`);
|
|
342
|
+
}
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
// ─── Reinstall LocalAI ──────────────────────────────────
|
|
346
|
+
case "reinstall-localai": {
|
|
347
|
+
if (process.platform !== "darwin") {
|
|
348
|
+
await (0, prompts_1.logWarning)("LocalAI Homebrew installation is only available on macOS.");
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
if (!(0, platform_1.hasTool)("brew")) {
|
|
352
|
+
await (0, prompts_1.logError)("Homebrew not found. Install from https://brew.sh");
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
spinner.start("Reinstalling LocalAI...");
|
|
356
|
+
try {
|
|
357
|
+
(0, node_child_process_1.execFileSync)((0, tool_path_1.toolPath)("brew"), ["reinstall", "localai"], { stdio: "inherit" });
|
|
358
|
+
spinner.stop("LocalAI reinstalled.");
|
|
359
|
+
await (0, prompts_1.logSuccess)("✔ LocalAI reinstalled via Homebrew");
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
spinner.stop("Reinstall failed", 1);
|
|
363
|
+
await (0, prompts_1.logError)("Failed to reinstall LocalAI");
|
|
364
|
+
}
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
// ─── Docker clean ───────────────────────────────────────
|
|
368
|
+
case "docker-clean": {
|
|
369
|
+
spinner.start("Cleaning Docker environment...");
|
|
370
|
+
try {
|
|
371
|
+
(0, node_child_process_1.execFileSync)((0, tool_path_1.toolPath)("docker"), ["container", "prune", "-f"], { stdio: "ignore" });
|
|
372
|
+
(0, node_child_process_1.execFileSync)((0, tool_path_1.toolPath)("docker"), ["volume", "prune", "-f"], { stdio: "ignore" });
|
|
373
|
+
spinner.stop("Docker environment cleaned.");
|
|
374
|
+
await (0, prompts_1.logSuccess)("✔ Removed orphaned containers and volumes.");
|
|
375
|
+
}
|
|
376
|
+
catch {
|
|
377
|
+
spinner.stop("Cleanup failed", 1);
|
|
378
|
+
}
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
// ─── Env reset ──────────────────────────────────────────
|
|
382
|
+
case "env-reset": {
|
|
383
|
+
const envFile = (0, platform_1.resolveEnvFile)();
|
|
384
|
+
const backup = `${envFile}.backup`;
|
|
385
|
+
if (fs.existsSync(envFile)) {
|
|
386
|
+
fs.copyFileSync(envFile, backup);
|
|
387
|
+
await (0, prompts_1.logSuccess)(`✔ Backed up existing .env to ${path.basename(backup)}`);
|
|
388
|
+
}
|
|
389
|
+
spinner.start("Regenerating .env...");
|
|
390
|
+
try {
|
|
391
|
+
(0, node_child_process_1.execFileSync)((0, tool_path_1.toolPath)("npx"), ["sovkora", "init", "--force", "--yes"], { stdio: "ignore" });
|
|
392
|
+
spinner.stop(".env regenerated.");
|
|
393
|
+
await (0, prompts_1.logSuccess)("✔ Environment reset complete.");
|
|
394
|
+
}
|
|
395
|
+
catch {
|
|
396
|
+
spinner.stop("Reset failed", 1);
|
|
397
|
+
await (0, prompts_1.logError)("Could not regenerate .env file.");
|
|
398
|
+
}
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
// ─── PID cleanup ────────────────────────────────────────
|
|
402
|
+
case "pid-cleanup": {
|
|
403
|
+
const pidFile = (0, platform_1.resolvePidFile)();
|
|
404
|
+
spinner.start("Cleaning up process IDs...");
|
|
405
|
+
if (fs.existsSync(pidFile)) {
|
|
406
|
+
const pids = fs.readFileSync(pidFile, "utf-8").split("\n");
|
|
407
|
+
let killed = 0;
|
|
408
|
+
for (const pidEntry of pids) {
|
|
409
|
+
if (!pidEntry.trim())
|
|
410
|
+
continue;
|
|
411
|
+
const pidNum = pidEntry.split("=")[1];
|
|
412
|
+
if (!pidNum)
|
|
413
|
+
continue;
|
|
414
|
+
try {
|
|
415
|
+
process.kill(Number.parseInt(pidNum), "SIGTERM");
|
|
416
|
+
killed++;
|
|
417
|
+
}
|
|
418
|
+
catch {
|
|
419
|
+
/* already dead */
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
fs.unlinkSync(pidFile);
|
|
423
|
+
spinner.stop(`Cleaned up ${String(killed)} process(es).`);
|
|
424
|
+
await (0, prompts_1.logSuccess)(`✔ Removed ${String(killed)} stale process references.`);
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
spinner.stop("No PID file found.");
|
|
428
|
+
await (0, prompts_1.logWarning)("No stale processes to clean.");
|
|
429
|
+
}
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
// ─── Log cleanup ────────────────────────────────────────
|
|
433
|
+
case "log-cleanup": {
|
|
434
|
+
const logDir = (0, platform_1.resolveLogDir)();
|
|
435
|
+
spinner.start("Clearing logs...");
|
|
436
|
+
if (fs.existsSync(logDir)) {
|
|
437
|
+
const files = fs.readdirSync(logDir);
|
|
438
|
+
let deleted = 0;
|
|
439
|
+
for (const file of files) {
|
|
440
|
+
fs.unlinkSync(path.join(logDir, file));
|
|
441
|
+
deleted++;
|
|
442
|
+
}
|
|
443
|
+
spinner.stop(`Deleted ${String(deleted)} log file(s).`);
|
|
444
|
+
await (0, prompts_1.logSuccess)(`✔ Cleaned ${String(deleted)} log file(s).`);
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
spinner.stop("Log directory not found.");
|
|
448
|
+
}
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
// ─── Full reset ─────────────────────────────────────────
|
|
452
|
+
case "full-reset": {
|
|
453
|
+
await (0, prompts_1.logWarning)("This will delete all databases and application state.");
|
|
454
|
+
const confirmed = await (0, prompts_1.confirm)({
|
|
455
|
+
message: "Are you absolutely sure?",
|
|
456
|
+
initialValue: false,
|
|
457
|
+
});
|
|
458
|
+
if (confirmed !== true) {
|
|
459
|
+
await (0, prompts_1.outro)(chalk_1.default.yellow("Reset cancelled."));
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
spinner.start("Removing Docker volumes and databases...");
|
|
463
|
+
try {
|
|
464
|
+
(0, node_child_process_1.execFileSync)((0, tool_path_1.toolPath)("docker"), ["volume", "prune", "-f"], { stdio: "ignore" });
|
|
465
|
+
(0, node_child_process_1.execFileSync)((0, tool_path_1.toolPath)("docker"), ["system", "prune", "-f"], { stdio: "ignore" });
|
|
466
|
+
spinner.stop("Docker cleanup complete.");
|
|
467
|
+
await (0, prompts_1.logSuccess)("✔ Full reset complete. Run npx sovkora start to rebuild.");
|
|
468
|
+
}
|
|
469
|
+
catch {
|
|
470
|
+
spinner.stop("Cleanup failed", 1);
|
|
471
|
+
await (0, prompts_1.logError)("Some cleanup operations failed.");
|
|
472
|
+
}
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
// ─── Diagnose all ───────────────────────────────────────
|
|
476
|
+
case "diagnose-all": {
|
|
477
|
+
spinner.start("Running full diagnostics...");
|
|
478
|
+
try {
|
|
479
|
+
(0, node_child_process_1.execFileSync)((0, tool_path_1.toolPath)("npx"), ["sovkora", "doctor", "--verbose"], { stdio: "inherit" });
|
|
480
|
+
spinner.stop();
|
|
481
|
+
}
|
|
482
|
+
catch {
|
|
483
|
+
spinner.stop("Diagnostics failed", 1);
|
|
484
|
+
}
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
await (0, prompts_1.outro)(chalk_1.default.cyan("Recovery operations complete."));
|
|
489
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerCommand = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const prompts_1 = require("../ui/prompts");
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const auth_api_1 = require("../services/auth.api");
|
|
11
|
+
async function promptUsername(usernameArg) {
|
|
12
|
+
if (usernameArg)
|
|
13
|
+
return usernameArg;
|
|
14
|
+
const usernameInput = await (0, prompts_1.text)({
|
|
15
|
+
message: "Choose Username:",
|
|
16
|
+
validate: (val) => (val.trim().length === 0 ? "Username is required" : undefined),
|
|
17
|
+
});
|
|
18
|
+
if ((0, prompts_1.isCancel)(usernameInput)) {
|
|
19
|
+
throw new Error("CANCELLED");
|
|
20
|
+
}
|
|
21
|
+
return usernameInput;
|
|
22
|
+
}
|
|
23
|
+
async function promptEmail(emailArg) {
|
|
24
|
+
if (emailArg)
|
|
25
|
+
return emailArg;
|
|
26
|
+
const emailInput = await (0, prompts_1.text)({
|
|
27
|
+
message: "Enter Email:",
|
|
28
|
+
validate: (val) => (val.includes("@") ? undefined : "Invalid email address"),
|
|
29
|
+
});
|
|
30
|
+
if ((0, prompts_1.isCancel)(emailInput)) {
|
|
31
|
+
throw new Error("CANCELLED");
|
|
32
|
+
}
|
|
33
|
+
return emailInput;
|
|
34
|
+
}
|
|
35
|
+
async function promptPassword() {
|
|
36
|
+
const pwdInput = await (0, prompts_1.password)({
|
|
37
|
+
message: "Choose Password:",
|
|
38
|
+
validate: (val) => (val.length < 8 ? "Password must be at least 8 characters" : undefined),
|
|
39
|
+
});
|
|
40
|
+
if ((0, prompts_1.isCancel)(pwdInput)) {
|
|
41
|
+
throw new Error("CANCELLED");
|
|
42
|
+
}
|
|
43
|
+
return pwdInput;
|
|
44
|
+
}
|
|
45
|
+
async function promptConfirmPassword(pwdInput) {
|
|
46
|
+
const pwdConfirm = await (0, prompts_1.password)({
|
|
47
|
+
message: "Confirm Password:",
|
|
48
|
+
validate: (val) => (val === pwdInput ? undefined : "Passwords do not match"),
|
|
49
|
+
});
|
|
50
|
+
if ((0, prompts_1.isCancel)(pwdConfirm)) {
|
|
51
|
+
throw new Error("CANCELLED");
|
|
52
|
+
}
|
|
53
|
+
return pwdConfirm;
|
|
54
|
+
}
|
|
55
|
+
exports.registerCommand = new commander_1.Command("register")
|
|
56
|
+
.description("Register a new user account")
|
|
57
|
+
.argument("[username]", "Desired username")
|
|
58
|
+
.argument("[email]", "Account email address")
|
|
59
|
+
.option("-l, --language <lang>", "BCP 47 language tag (e.g. en, ja)")
|
|
60
|
+
.action(async (usernameArg, emailArg, options) => {
|
|
61
|
+
try {
|
|
62
|
+
await (0, prompts_1.intro)(chalk_1.default.cyan("Sovkora Account Registration"));
|
|
63
|
+
const username = await promptUsername(usernameArg);
|
|
64
|
+
const email = await promptEmail(emailArg);
|
|
65
|
+
const pwd = await promptPassword();
|
|
66
|
+
await promptConfirmPassword(pwd);
|
|
67
|
+
const s = await (0, prompts_1.createSpinner)();
|
|
68
|
+
s.start(`Registering user "${username}"...`);
|
|
69
|
+
try {
|
|
70
|
+
const result = await auth_api_1.AuthApi.register(username, email, pwd, options?.language);
|
|
71
|
+
if (result.error) {
|
|
72
|
+
s.stop("Registration failed");
|
|
73
|
+
await (0, prompts_1.outro)(chalk_1.default.red(`❌ Registration Failed: ${result.error}`));
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
s.stop("Registration success!");
|
|
77
|
+
await (0, prompts_1.outro)(chalk_1.default.green(`✓ Registration successful for: ${result.user?.username || username}`));
|
|
78
|
+
await (0, prompts_1.outro)(chalk_1.default.yellow("If email verification is enabled, run: sovkora verify <token>"));
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
s.stop("Registration failed");
|
|
82
|
+
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
83
|
+
await (0, prompts_1.outro)(chalk_1.default.red(`❌ Registration Failed: ${msg}`));
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
if (err instanceof Error && err.message === "CANCELLED") {
|
|
89
|
+
await (0, prompts_1.outro)(chalk_1.default.red("Registration cancelled."));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file release.command.ts
|
|
4
|
+
* @description `sovkora release verify` — checks a release manifest (one version for the whole Sovkora
|
|
5
|
+
* bundle, docs/DELIVERY.md in krizaka/orazaka) and, with `--dir`, the artefacts of an offline bundle
|
|
6
|
+
* against it. Exit code 1 on any problem, so a release pipeline or an installer can gate on it.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
42
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.releaseCommand = void 0;
|
|
46
|
+
const path = __importStar(require("node:path"));
|
|
47
|
+
const commander_1 = require("commander");
|
|
48
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
49
|
+
const prompts_1 = require("../ui/prompts");
|
|
50
|
+
const release_manifest_1 = require("../services/release-manifest");
|
|
51
|
+
function verify(file, options) {
|
|
52
|
+
if (options.target && !release_manifest_1.RELEASE_TARGETS.includes(options.target)) {
|
|
53
|
+
return { problems: [`unknown target '${options.target}' (one of ${release_manifest_1.RELEASE_TARGETS.join(", ")})`] };
|
|
54
|
+
}
|
|
55
|
+
const read = (0, release_manifest_1.readReleaseManifest)(path.resolve(file));
|
|
56
|
+
if (read.problems.length > 0)
|
|
57
|
+
return { problems: read.problems };
|
|
58
|
+
const problems = (0, release_manifest_1.validateReleaseManifest)(read.manifest);
|
|
59
|
+
if (problems.length > 0)
|
|
60
|
+
return { problems };
|
|
61
|
+
const manifest = read.manifest;
|
|
62
|
+
const artefactProblems = options.dir
|
|
63
|
+
? (0, release_manifest_1.verifyArtefacts)(manifest, path.resolve(options.dir), options.target)
|
|
64
|
+
: [];
|
|
65
|
+
return { manifest, problems: artefactProblems };
|
|
66
|
+
}
|
|
67
|
+
const verifyCommand = new commander_1.Command("verify")
|
|
68
|
+
.description("Check a release manifest, and with --dir the artefacts of an offline bundle against it")
|
|
69
|
+
.argument("<manifest>", "Path to the release manifest (orazaka-release.json)")
|
|
70
|
+
.option("--dir <path>", "Offline bundle directory whose artefacts are checked (size and SHA-256)")
|
|
71
|
+
.option("--target <target>", "Only the artefacts of one target: mac-arm64, linux-amd64 or linux-arm64")
|
|
72
|
+
.option("--json", "Print the result as JSON")
|
|
73
|
+
.action(async (file, options) => {
|
|
74
|
+
const { manifest, problems } = verify(file, options);
|
|
75
|
+
if (options.json) {
|
|
76
|
+
console.log(JSON.stringify({ version: manifest?.version ?? null, ok: problems.length === 0, problems }, null, 2));
|
|
77
|
+
if (problems.length > 0)
|
|
78
|
+
process.exitCode = 1;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
await (0, prompts_1.intro)(chalk_1.default.cyan.bold("🥷 Sovkora release"));
|
|
82
|
+
if (problems.length > 0) {
|
|
83
|
+
for (const problem of problems)
|
|
84
|
+
await (0, prompts_1.logError)(problem);
|
|
85
|
+
await (0, prompts_1.outro)(chalk_1.default.red(`${String(problems.length)} problem(s): this release cannot be installed.`));
|
|
86
|
+
process.exitCode = 1;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (manifest) {
|
|
90
|
+
await (0, prompts_1.logInfo)(`Sovkora ${manifest.version} (${manifest.channel}) · ${manifest.targets.join(", ")} · ` +
|
|
91
|
+
`${String(manifest.images.length)} image(s), ${String(manifest.artefacts.length)} artefact(s), ` +
|
|
92
|
+
`${String(manifest.models.length)} model(s), ${String(manifest.packs.length)} pack(s)`);
|
|
93
|
+
}
|
|
94
|
+
await (0, prompts_1.logSuccess)(options.dir ? "Manifest valid; every artefact matches it." : "Manifest valid.");
|
|
95
|
+
await (0, prompts_1.outro)(chalk_1.default.cyan("Ready to install."));
|
|
96
|
+
});
|
|
97
|
+
exports.releaseCommand = new commander_1.Command("release")
|
|
98
|
+
.description("Release bundles — check a release manifest and an offline bundle before installing it")
|
|
99
|
+
.addCommand(verifyCommand);
|