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,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file status.command.ts
|
|
4
|
+
* @description Live dashboard showing all Sovkora service statuses,
|
|
5
|
+
* ports, PIDs, and health indicators.
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.statusCommand = void 0;
|
|
45
|
+
const commander_1 = require("commander");
|
|
46
|
+
const fs = __importStar(require("node:fs"));
|
|
47
|
+
const path = __importStar(require("node:path"));
|
|
48
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
49
|
+
const prompts_1 = require("../ui/prompts");
|
|
50
|
+
const platform_1 = require("../ui/platform");
|
|
51
|
+
const health_1 = require("../utils/health");
|
|
52
|
+
const pid_1 = require("../utils/pid");
|
|
53
|
+
const config_1 = require("../utils/config");
|
|
54
|
+
const development_status_1 = require("../utils/development-status");
|
|
55
|
+
const SERVICES = [
|
|
56
|
+
{ name: "PostgreSQL", port: config_1.PORTS.postgres, category: "middleware", critical: true },
|
|
57
|
+
{ name: "Redis", port: config_1.PORTS.redis, category: "middleware", critical: true },
|
|
58
|
+
{ name: "RabbitMQ", port: config_1.PORTS.rabbitmq, category: "middleware", critical: true },
|
|
59
|
+
{ name: "RabbitMQ Mgmt", port: config_1.PORTS.rabbitmqMgmt, category: "middleware", critical: false },
|
|
60
|
+
{ name: "Ollama", port: config_1.PORTS.ollama, category: "ai", critical: false },
|
|
61
|
+
{ name: "LocalAI", port: config_1.PORTS.localai, category: "worker", critical: false },
|
|
62
|
+
{ name: "Image Gen", port: config_1.PORTS.imageGen, category: "worker", critical: false },
|
|
63
|
+
{ name: "Media Worker", port: config_1.PORTS.mediaWorker, category: "worker", critical: false },
|
|
64
|
+
// Every deployable service, not just the two that predate the microservices split: a
|
|
65
|
+
// `status` that reports green while five services are down is worse than no status.
|
|
66
|
+
{ name: "Edge", port: config_1.PORTS.edge, category: "app", critical: true },
|
|
67
|
+
{ name: "Conversation API", port: config_1.PORTS.router, category: "app", critical: true },
|
|
68
|
+
{ name: "Identity", port: config_1.PORTS.identity, category: "app", critical: true },
|
|
69
|
+
{ name: "Knowledge", port: config_1.PORTS.knowledge, category: "app", critical: false },
|
|
70
|
+
{ name: "Job Orchestration", port: config_1.PORTS.jobService, category: "app", critical: false },
|
|
71
|
+
{ name: "Billing", port: config_1.PORTS.billing, category: "app", critical: false },
|
|
72
|
+
{ name: "Studio", port: config_1.PORTS.studio, category: "app", critical: false },
|
|
73
|
+
{ name: "Frontend UI", port: config_1.PORTS.web, category: "app", critical: true },
|
|
74
|
+
];
|
|
75
|
+
exports.statusCommand = new commander_1.Command("status")
|
|
76
|
+
.description("Show live status of all Sovkora services")
|
|
77
|
+
.option("--json", "Output status as JSON")
|
|
78
|
+
.option("--watch", "Refresh every 5 seconds")
|
|
79
|
+
.action(async (options) => {
|
|
80
|
+
const workspaceRoot = (0, platform_1.resolveWorkspaceRoot)();
|
|
81
|
+
const renderStatus = async () => {
|
|
82
|
+
const pidFile = (0, platform_1.resolvePidFile)();
|
|
83
|
+
const pids = (0, pid_1.readPidFile)(pidFile);
|
|
84
|
+
const results = [];
|
|
85
|
+
for (const svc of SERVICES) {
|
|
86
|
+
const portInUse = await (0, health_1.isPortInUse)(svc.port);
|
|
87
|
+
let pid = null;
|
|
88
|
+
// Try to find PID from pid file
|
|
89
|
+
const pidKeys = [svc.name.toLowerCase().replace(/\s+/g, "-"), svc.name.toLowerCase()];
|
|
90
|
+
for (const key of pidKeys) {
|
|
91
|
+
if (pids.has(key)) {
|
|
92
|
+
const p = pids.get(key);
|
|
93
|
+
if ((0, pid_1.isPidAlive)(p))
|
|
94
|
+
pid = p;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
results.push({
|
|
99
|
+
name: svc.name,
|
|
100
|
+
port: svc.port,
|
|
101
|
+
status: portInUse ? "running" : "stopped",
|
|
102
|
+
pid,
|
|
103
|
+
category: svc.category,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (options.json) {
|
|
107
|
+
console.log(JSON.stringify(results, null, 2));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
// Format table output
|
|
111
|
+
const categoryLabels = {
|
|
112
|
+
middleware: "🐳 Docker Middleware",
|
|
113
|
+
ai: "🤖 AI Engines",
|
|
114
|
+
worker: "🎨 Workers",
|
|
115
|
+
app: "📱 Applications",
|
|
116
|
+
};
|
|
117
|
+
const lines = [];
|
|
118
|
+
let currentCategory = "";
|
|
119
|
+
for (const r of results) {
|
|
120
|
+
if (r.category !== currentCategory) {
|
|
121
|
+
if (currentCategory)
|
|
122
|
+
lines.push("");
|
|
123
|
+
lines.push(chalk_1.default.bold(categoryLabels[r.category] ?? r.category));
|
|
124
|
+
currentCategory = r.category;
|
|
125
|
+
}
|
|
126
|
+
const statusIcon = r.status === "running" ? chalk_1.default.green("● UP ") : chalk_1.default.red("○ DOWN");
|
|
127
|
+
const portStr = chalk_1.default.gray(`:${String(r.port)}`);
|
|
128
|
+
const pidStr = r.pid ? chalk_1.default.gray(`PID ${String(r.pid)}`) : "";
|
|
129
|
+
lines.push(` ${statusIcon} ${r.name.padEnd(18)} ${portStr.padEnd(16)} ${pidStr}`);
|
|
130
|
+
}
|
|
131
|
+
// Summary counts
|
|
132
|
+
const running = results.filter((r) => r.status === "running").length;
|
|
133
|
+
const total = results.length;
|
|
134
|
+
lines.push("", chalk_1.default.gray((0, development_status_1.developmentStatus)()), "", `${chalk_1.default.gray("Summary:")} ${chalk_1.default.green(String(running))}/${String(total)} services running` +
|
|
135
|
+
((0, platform_1.isAppleSilicon)() ? ` ${chalk_1.default.gray("| Apple Silicon ✔")}` : ""));
|
|
136
|
+
await (0, prompts_1.note)(lines.join("\n"), "🥷 Sovkora Service Status");
|
|
137
|
+
};
|
|
138
|
+
if (options.watch) {
|
|
139
|
+
console.log(chalk_1.default.gray("Refreshing every 5s — Ctrl+C to stop\n"));
|
|
140
|
+
const refresh = async () => {
|
|
141
|
+
console.clear();
|
|
142
|
+
await renderStatus();
|
|
143
|
+
};
|
|
144
|
+
await refresh();
|
|
145
|
+
const interval = setInterval(() => {
|
|
146
|
+
refresh().catch(() => { });
|
|
147
|
+
}, 5000);
|
|
148
|
+
await new Promise((resolve) => {
|
|
149
|
+
process.on("SIGINT", () => {
|
|
150
|
+
clearInterval(interval);
|
|
151
|
+
resolve();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
await (0, prompts_1.intro)(chalk_1.default.cyan.bold("🥷 Sovkora Status"));
|
|
157
|
+
await renderStatus();
|
|
158
|
+
const logDir = (0, platform_1.resolveLogDir)();
|
|
159
|
+
if (fs.existsSync(logDir)) {
|
|
160
|
+
const logFiles = fs.readdirSync(logDir).filter((f) => f.endsWith(".log"));
|
|
161
|
+
if (logFiles.length > 0) {
|
|
162
|
+
console.log(`\n ${chalk_1.default.gray("Logs:")} ${chalk_1.default.cyan("npx sovkora logs")} (${String(logFiles.length)} file(s) in ${path.relative(workspaceRoot, logDir)})`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
await (0, prompts_1.outro)(chalk_1.default.gray("Use --watch for live updates"));
|
|
166
|
+
}
|
|
167
|
+
});
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file stop.command.ts
|
|
4
|
+
* @description Teardown command with progressive status and cross-platform cleanup.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.stopCommand = void 0;
|
|
44
|
+
const commander_1 = require("commander");
|
|
45
|
+
const fs = __importStar(require("node:fs"));
|
|
46
|
+
const path = __importStar(require("node:path"));
|
|
47
|
+
const node_child_process_1 = require("node:child_process");
|
|
48
|
+
const tool_path_1 = require("../services/tool-path");
|
|
49
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
50
|
+
const prompts_1 = require("../ui/prompts");
|
|
51
|
+
const platform_1 = require("../ui/platform");
|
|
52
|
+
const config_1 = require("../utils/config");
|
|
53
|
+
const pid_1 = require("../utils/pid");
|
|
54
|
+
function terminateProcess(pid, _name) {
|
|
55
|
+
try {
|
|
56
|
+
process.kill(pid, 0); // Check existence
|
|
57
|
+
process.kill(pid, 15); // SIGTERM
|
|
58
|
+
let alive = true;
|
|
59
|
+
for (let i = 0; i < 5; i++) {
|
|
60
|
+
try {
|
|
61
|
+
process.kill(pid, 0);
|
|
62
|
+
// Small delay without execSync("sleep")
|
|
63
|
+
const start = Date.now();
|
|
64
|
+
while (Date.now() - start < 1000) {
|
|
65
|
+
// Busy wait for 1s — only used during teardown
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
alive = false;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (alive) {
|
|
74
|
+
process.kill(pid, 9); // SIGKILL
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return false; // Already dead
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.stopCommand = new commander_1.Command("stop")
|
|
83
|
+
.description("Teardown the Sovkora infrastructure — containers, workers, and state")
|
|
84
|
+
.option("--purge", "Also purge database data and upload directories")
|
|
85
|
+
.option("-y, --yes", "Skip confirmation prompts")
|
|
86
|
+
.action(async (options) => {
|
|
87
|
+
await (0, prompts_1.intro)(chalk_1.default.red.bold("🛑 Sovkora Infrastructure Teardown"));
|
|
88
|
+
const workspaceRoot = (0, platform_1.resolveWorkspaceRoot)();
|
|
89
|
+
const pidFile = (0, platform_1.resolvePidFile)();
|
|
90
|
+
// Safety confirmation
|
|
91
|
+
if (!options.yes) {
|
|
92
|
+
const shouldContinue = await (0, prompts_1.confirm)({
|
|
93
|
+
message: options.purge
|
|
94
|
+
? "This will stop ALL services AND delete database data. Continue?"
|
|
95
|
+
: "This will stop all running Sovkora services. Continue?",
|
|
96
|
+
initialValue: true,
|
|
97
|
+
active: "Yes, stop everything",
|
|
98
|
+
inactive: "Cancel",
|
|
99
|
+
});
|
|
100
|
+
(0, prompts_1.handleCancel)(shouldContinue);
|
|
101
|
+
if (shouldContinue !== true) {
|
|
102
|
+
await (0, prompts_1.outro)("Teardown cancelled.");
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const spinner = await (0, prompts_1.createSpinner)();
|
|
107
|
+
let stoppedCount = 0;
|
|
108
|
+
// ─── 1: PID-based teardown ──────────────────────────────
|
|
109
|
+
if (fs.existsSync(pidFile)) {
|
|
110
|
+
spinner.start("Terminating tracked processes...");
|
|
111
|
+
for (const [name, pid] of (0, pid_1.readPidFile)(pidFile)) {
|
|
112
|
+
if (terminateProcess(pid, name))
|
|
113
|
+
stoppedCount++;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
fs.unlinkSync(pidFile);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
/* Ignore */
|
|
120
|
+
}
|
|
121
|
+
spinner.stop(`Terminated ${String(stoppedCount)} tracked process(es).`);
|
|
122
|
+
}
|
|
123
|
+
// ─── 2: Port sweep (Unix only) ─────────────────────────
|
|
124
|
+
if (process.platform !== "win32") {
|
|
125
|
+
spinner.start("Sweeping active ports...");
|
|
126
|
+
for (const port of config_1.ALL_PORTS) {
|
|
127
|
+
try {
|
|
128
|
+
const pidsStr = (0, node_child_process_1.execSync)(`lsof -i :${String(port)} -t 2>/dev/null`)
|
|
129
|
+
.toString()
|
|
130
|
+
.trim();
|
|
131
|
+
if (pidsStr) {
|
|
132
|
+
for (const pidStr of pidsStr.split("\n")) {
|
|
133
|
+
const pid = Number.parseInt(pidStr.trim(), 10);
|
|
134
|
+
if (Number.isNaN(pid) || pid === process.pid)
|
|
135
|
+
continue;
|
|
136
|
+
let procName = "";
|
|
137
|
+
try {
|
|
138
|
+
procName = (0, node_child_process_1.execSync)(`ps -p ${String(pid)} -o comm= 2>/dev/null`)
|
|
139
|
+
.toString()
|
|
140
|
+
.trim();
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
/* Ignore */
|
|
144
|
+
}
|
|
145
|
+
// Skip Docker daemon
|
|
146
|
+
if (procName.includes("Docker") || procName.includes("com.docker"))
|
|
147
|
+
continue;
|
|
148
|
+
try {
|
|
149
|
+
process.kill(pid, 9);
|
|
150
|
+
stoppedCount++;
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
/* Ignore */
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
/* No process on port */
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
spinner.stop("Port sweep complete.");
|
|
163
|
+
}
|
|
164
|
+
// ─── 2b: Database purge (optional) ──────────────────────
|
|
165
|
+
if (options.purge) {
|
|
166
|
+
try {
|
|
167
|
+
const dockerPs = (0, node_child_process_1.execFileSync)((0, tool_path_1.toolPath)("docker"), ["ps"]).toString();
|
|
168
|
+
if (dockerPs.includes("orazaka-db-vector")) {
|
|
169
|
+
spinner.start("Purging database tables...");
|
|
170
|
+
const sql = `
|
|
171
|
+
TRUNCATE TABLE QRTZ_FIRED_TRIGGERS CASCADE;
|
|
172
|
+
TRUNCATE TABLE QRTZ_SIMPLE_TRIGGERS CASCADE;
|
|
173
|
+
TRUNCATE TABLE QRTZ_CRON_TRIGGERS CASCADE;
|
|
174
|
+
TRUNCATE TABLE QRTZ_TRIGGERS CASCADE;
|
|
175
|
+
TRUNCATE TABLE QRTZ_JOB_DETAILS CASCADE;
|
|
176
|
+
TRUNCATE TABLE QRTZ_SCHEDULER_STATE CASCADE;
|
|
177
|
+
TRUNCATE TABLE QRTZ_LOCKS CASCADE;
|
|
178
|
+
TRUNCATE TABLE automation_job_execution_log CASCADE;
|
|
179
|
+
TRUNCATE TABLE connector_credentials CASCADE;
|
|
180
|
+
TRUNCATE TABLE orazaka_chat_sessions CASCADE;
|
|
181
|
+
TRUNCATE TABLE orazaka_jobs CASCADE;
|
|
182
|
+
TRUNCATE TABLE user_mcp_servers CASCADE;
|
|
183
|
+
TRUNCATE TABLE platform_mcp_servers CASCADE;
|
|
184
|
+
TRUNCATE TABLE platform_tool_configs CASCADE;
|
|
185
|
+
TRUNCATE TABLE user_credentials CASCADE;
|
|
186
|
+
TRUNCATE TABLE users CASCADE;
|
|
187
|
+
TRUNCATE TABLE user_profiles CASCADE;
|
|
188
|
+
TRUNCATE TABLE verification_tokens CASCADE;
|
|
189
|
+
TRUNCATE TABLE user_interceptions CASCADE;
|
|
190
|
+
TRUNCATE TABLE orazaka_tools_cache CASCADE;
|
|
191
|
+
TRUNCATE TABLE orazaka_tools_rag_source CASCADE;
|
|
192
|
+
TRUNCATE TABLE password_resets CASCADE;
|
|
193
|
+
TRUNCATE TABLE orazaka_ai_mcp_servers CASCADE;
|
|
194
|
+
TRUNCATE TABLE orazaka_ai_rag_stores CASCADE;
|
|
195
|
+
`
|
|
196
|
+
.replace(/\s+/g, " ")
|
|
197
|
+
.trim();
|
|
198
|
+
const dbUser = process.env.SPRING_DATASOURCE_USERNAME ?? "orazaka_admin";
|
|
199
|
+
const dbName = process.env.POSTGRES_DB ?? "orazaka_db";
|
|
200
|
+
(0, node_child_process_1.execSync)(`docker exec -i orazaka-db-vector psql -U ${dbUser} -d ${dbName} -c "${sql}"`, { stdio: "ignore" });
|
|
201
|
+
spinner.stop("Database tables purged.");
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
await (0, prompts_1.logWarning)("Database purge skipped (container may be stopped).");
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// ─── 3: Process pattern sweep (Unix only) ───────────────
|
|
209
|
+
if (process.platform !== "win32") {
|
|
210
|
+
const patterns = [
|
|
211
|
+
"ollama",
|
|
212
|
+
"orazaka-worker-media",
|
|
213
|
+
"orazaka-automation-worker",
|
|
214
|
+
"orazaka-worker-automation",
|
|
215
|
+
"orazaka-workers/automation",
|
|
216
|
+
"sd-server",
|
|
217
|
+
"stable-diffusion",
|
|
218
|
+
"next-dev",
|
|
219
|
+
"next-server",
|
|
220
|
+
"orazaka-conversation-service",
|
|
221
|
+
];
|
|
222
|
+
for (const pattern of patterns) {
|
|
223
|
+
try {
|
|
224
|
+
const pidsStr = (0, node_child_process_1.execSync)(`pgrep -f "${pattern}" || true`).toString().trim();
|
|
225
|
+
if (pidsStr) {
|
|
226
|
+
for (const pidStr of pidsStr.split("\n")) {
|
|
227
|
+
const pid = Number.parseInt(pidStr.trim(), 10);
|
|
228
|
+
if (!Number.isNaN(pid) && pid !== process.pid) {
|
|
229
|
+
try {
|
|
230
|
+
process.kill(pid, 9);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
/* Ignore */
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
/* Ignore */
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// ─── 4: Docker Compose teardown ─────────────────────────
|
|
245
|
+
const composeFile = (0, platform_1.resolveComposeFile)();
|
|
246
|
+
const dockerComposeCmd = (0, platform_1.resolveDockerComposeCmd)();
|
|
247
|
+
if (fs.existsSync(composeFile) && dockerComposeCmd) {
|
|
248
|
+
spinner.start("Stopping Docker containers...");
|
|
249
|
+
try {
|
|
250
|
+
(0, node_child_process_1.execSync)(`${dockerComposeCmd} -p orazaka -f "${composeFile}" stop`, { stdio: "ignore" });
|
|
251
|
+
if (options.purge) {
|
|
252
|
+
(0, node_child_process_1.execSync)(`${dockerComposeCmd} -p orazaka -f "${composeFile}" down --timeout 5 -v`, { stdio: "ignore" });
|
|
253
|
+
await (0, prompts_1.logSuccess)("Docker services and data volumes removed.");
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
(0, node_child_process_1.execSync)(`${dockerComposeCmd} -p orazaka -f "${composeFile}" down --timeout 5`, { stdio: "ignore" });
|
|
257
|
+
await (0, prompts_1.logSuccess)("Docker services stopped (volumes preserved).");
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
await (0, prompts_1.logWarning)("Docker compose teardown had issues (containers may already be stopped).");
|
|
262
|
+
}
|
|
263
|
+
spinner.stop("Docker teardown complete.");
|
|
264
|
+
}
|
|
265
|
+
// ─── 5: Clean local directories ─────────────────────────
|
|
266
|
+
if (options.purge) {
|
|
267
|
+
spinner.start("Cleaning local directories...");
|
|
268
|
+
const dirsToClean = [path.join(workspaceRoot, "var", "orazaka-uploads"), path.join(workspaceRoot, "var", "temp")];
|
|
269
|
+
for (const dir of dirsToClean) {
|
|
270
|
+
if (fs.existsSync(dir)) {
|
|
271
|
+
for (const file of fs.readdirSync(dir)) {
|
|
272
|
+
fs.rmSync(path.join(dir, file), { recursive: true, force: true });
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// Clean PID files
|
|
277
|
+
const varDir = path.join(workspaceRoot, "var");
|
|
278
|
+
if (fs.existsSync(varDir)) {
|
|
279
|
+
for (const file of fs.readdirSync(varDir)) {
|
|
280
|
+
if (file.startsWith(".orazaka") && file.endsWith(".pid")) {
|
|
281
|
+
fs.rmSync(path.join(varDir, file), { force: true });
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
spinner.stop("Local directories cleaned.");
|
|
286
|
+
}
|
|
287
|
+
// ─── 6: Memory flush (macOS) ────────────────────────────
|
|
288
|
+
if (process.platform === "darwin") {
|
|
289
|
+
try {
|
|
290
|
+
(0, node_child_process_1.execFileSync)((0, tool_path_1.toolPath)("purge"), { stdio: "ignore" });
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
try {
|
|
294
|
+
(0, node_child_process_1.execFileSync)((0, tool_path_1.toolPath)("sudo"), ["-n", (0, tool_path_1.toolPath)("purge")], { stdio: "ignore" });
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
/* Ignore */
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// ─── Summary ────────────────────────────────────────────
|
|
302
|
+
console.log("");
|
|
303
|
+
const summaryLines = [
|
|
304
|
+
`${chalk_1.default.red("⏹")} Tracked processes terminated`,
|
|
305
|
+
`${chalk_1.default.red("⏹")} Docker containers stopped`,
|
|
306
|
+
];
|
|
307
|
+
if (options.purge) {
|
|
308
|
+
summaryLines.push(`${chalk_1.default.red("⏹")} Database data purged`, `${chalk_1.default.red("⏹")} Upload and temp directories cleaned`);
|
|
309
|
+
}
|
|
310
|
+
summaryLines.push("", `To restart: ${chalk_1.default.cyan("npx sovkora start")}`);
|
|
311
|
+
await (0, prompts_1.note)(summaryLines.join("\n"), "Teardown Complete");
|
|
312
|
+
await (0, prompts_1.outro)(chalk_1.default.red("All services stopped."));
|
|
313
|
+
});
|