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,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file onboard.command.ts
|
|
4
|
+
* @description ERR-125 compliant onboarding subcommand for Sovkora CLI.
|
|
5
|
+
* Handles full clone-and-run validation: prerequisite checks, Maven compilation,
|
|
6
|
+
* M2M signed handshake smoke test, local sovereign AI runtime health checks,
|
|
7
|
+
* and hardware accelerator detection with SLA guardrails.
|
|
8
|
+
*
|
|
9
|
+
* Usage: npx sovkora onboard
|
|
10
|
+
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.onboardCommand = exports.PREREQUISITES = void 0;
|
|
16
|
+
const commander_1 = require("commander");
|
|
17
|
+
const node_child_process_1 = require("node:child_process");
|
|
18
|
+
const node_os_1 = require("node:os");
|
|
19
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
20
|
+
const config_1 = require("../utils/config");
|
|
21
|
+
/** Minimum required versions for each prerequisite. */
|
|
22
|
+
exports.PREREQUISITES = [
|
|
23
|
+
{ name: "Java", command: "java -version", regex: /version "(\d{1,9})/, minMajor: 21 },
|
|
24
|
+
{ name: "Node.js", command: "node --version", regex: /v(\d{1,9})/, minMajor: config_1.NODE_MIN_MAJOR },
|
|
25
|
+
{ name: "Python", command: "python3 --version", regex: /(\d{1,9}\.\d{1,9})/, minMajor: 3 },
|
|
26
|
+
{ name: "Docker", command: "docker --version", regex: /(\d{1,9}\.\d{1,9})/, minMajor: 20 },
|
|
27
|
+
{ name: "Ollama", command: "ollama --version", regex: /(\d{1,9}\.\d{1,9})/, minMajor: 0 },
|
|
28
|
+
];
|
|
29
|
+
/** Local sovereign AI runtimes probed for live connectivity. */
|
|
30
|
+
const OLLAMA_TAGS_URL = process.env.OLLAMA_HOST
|
|
31
|
+
? `${process.env.OLLAMA_HOST.replace(/\/$/, "")}/api/tags`
|
|
32
|
+
: "http://localhost:11434/api/tags";
|
|
33
|
+
const LOCALAI_MODELS_URL = process.env.ORAZAKA_LOCALAI_URL
|
|
34
|
+
? `${process.env.ORAZAKA_LOCALAI_URL.replace(/\/$/, "")}/v1/models`
|
|
35
|
+
: undefined;
|
|
36
|
+
function checkPrerequisite(prereq) {
|
|
37
|
+
try {
|
|
38
|
+
const output = (0, node_child_process_1.execSync)(prereq.command, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
39
|
+
const match = output.match(prereq.regex);
|
|
40
|
+
const version = match ? match[1] : "unknown";
|
|
41
|
+
const major = Number.parseInt(version, 10);
|
|
42
|
+
const ok = !Number.isNaN(major) && major >= prereq.minMajor;
|
|
43
|
+
return { name: prereq.name, ok, version };
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return { name: prereq.name, ok: false, version: "not found", error: `${prereq.name} is not installed` };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function runPrerequisiteChecks() {
|
|
50
|
+
console.log(chalk_1.default.cyan.bold("\n🔍 Phase 1: Prerequisite Verification\n"));
|
|
51
|
+
let allPassed = true;
|
|
52
|
+
for (const prereq of exports.PREREQUISITES) {
|
|
53
|
+
const result = checkPrerequisite(prereq);
|
|
54
|
+
const icon = result.ok ? chalk_1.default.green("✔") : chalk_1.default.red("✘");
|
|
55
|
+
const versionText = result.ok
|
|
56
|
+
? chalk_1.default.gray(`(${result.version})`)
|
|
57
|
+
: chalk_1.default.red(`(${result.version} — requires >= ${prereq.minMajor})`);
|
|
58
|
+
console.log(` ${icon} ${chalk_1.default.white(result.name)} ${versionText}`);
|
|
59
|
+
if (!result.ok)
|
|
60
|
+
allPassed = false;
|
|
61
|
+
}
|
|
62
|
+
return allPassed;
|
|
63
|
+
}
|
|
64
|
+
function runCompilation() {
|
|
65
|
+
console.log(chalk_1.default.cyan.bold("\n🔨 Phase 2: Maven Compilation (skipTests)\n"));
|
|
66
|
+
try {
|
|
67
|
+
(0, node_child_process_1.execSync)("./mvnw clean install -DskipTests -q", {
|
|
68
|
+
cwd: process.cwd(),
|
|
69
|
+
stdio: "inherit",
|
|
70
|
+
timeout: 300_000,
|
|
71
|
+
});
|
|
72
|
+
console.log(chalk_1.default.green(" ✔ Compilation succeeded."));
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
console.error(chalk_1.default.red(" ✘ Compilation failed. Check Maven output above."));
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function runHandshakeSmokeTest() {
|
|
81
|
+
console.log(chalk_1.default.cyan.bold("\n🤝 Phase 3: M2M Signed Handshake Smoke Test\n"));
|
|
82
|
+
try {
|
|
83
|
+
// Validate the router's intent endpoint is responding with correct JWT rejection
|
|
84
|
+
const curlCmd = [
|
|
85
|
+
"curl -s -o /dev/null -w '%{http_code}'",
|
|
86
|
+
"-X POST http://localhost:8080/api/v1/intent/route",
|
|
87
|
+
"-H 'Content-Type: application/json'",
|
|
88
|
+
'-d \'{"userId":"smoke-test","rawPrompt":"ping","sessionId":"test"}\'',
|
|
89
|
+
].join(" ");
|
|
90
|
+
const statusCode = (0, node_child_process_1.execSync)(curlCmd, { encoding: "utf-8", timeout: 10_000 }).trim();
|
|
91
|
+
if (statusCode === "401" || statusCode === "403") {
|
|
92
|
+
console.log(chalk_1.default.green(" ✔ Intent router correctly rejected unsigned request (HTTP " + statusCode + ")."));
|
|
93
|
+
console.log(chalk_1.default.gray(" M2M JWT gate is active — handshake validated."));
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
else if (statusCode === "000") {
|
|
97
|
+
console.log(chalk_1.default.yellow(" ⚠ Router is not running. Start with: npx sovkora dev"));
|
|
98
|
+
console.log(chalk_1.default.gray(" Skipping live handshake — prerequisite and compilation passed."));
|
|
99
|
+
return true; // Non-fatal: offline mode
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
console.log(chalk_1.default.red(" ✘ Unexpected status code: " + statusCode));
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
console.log(chalk_1.default.yellow(" ⚠ Could not reach router. Offline mode — skipping handshake."));
|
|
108
|
+
return true; // Non-fatal
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** Probe a JSON HTTP endpoint with a hard timeout — never blocks the shell. */
|
|
112
|
+
async function probeEndpoint(url, timeoutMs = 3_000) {
|
|
113
|
+
const controller = new AbortController();
|
|
114
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
115
|
+
try {
|
|
116
|
+
const response = await fetch(url, { signal: controller.signal });
|
|
117
|
+
if (!response.ok) {
|
|
118
|
+
return { ok: false, detail: `HTTP ${response.status}` };
|
|
119
|
+
}
|
|
120
|
+
const body = (await response.json());
|
|
121
|
+
const count = body.models?.length ?? body.data?.length ?? 0;
|
|
122
|
+
return { ok: true, detail: `${count} model(s) available` };
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
const reason = err instanceof Error && err.name === "AbortError" ? "timeout" : "unreachable";
|
|
126
|
+
return { ok: false, detail: reason };
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
clearTimeout(timer);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** Phase 4 — local sovereign provider connectivity (Ollama + optional LocalAI). */
|
|
133
|
+
async function runLocalRuntimeChecks() {
|
|
134
|
+
console.log(chalk_1.default.cyan.bold("\n🧠 Phase 4: Local Sovereign AI Runtime Health\n"));
|
|
135
|
+
const ollama = await probeEndpoint(OLLAMA_TAGS_URL);
|
|
136
|
+
if (ollama.ok) {
|
|
137
|
+
console.log(` ${chalk_1.default.green("✔")} Ollama daemon responsive ${chalk_1.default.gray("(" + ollama.detail + ")")}`);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
console.log(` ${chalk_1.default.yellow("⚠")} Ollama not reachable at ${chalk_1.default.gray(OLLAMA_TAGS_URL)} ${chalk_1.default.gray("— " + ollama.detail)}`);
|
|
141
|
+
console.log(chalk_1.default.gray(" Start it with: ollama serve"));
|
|
142
|
+
}
|
|
143
|
+
if (LOCALAI_MODELS_URL) {
|
|
144
|
+
const localai = await probeEndpoint(LOCALAI_MODELS_URL);
|
|
145
|
+
if (localai.ok) {
|
|
146
|
+
console.log(` ${chalk_1.default.green("✔")} LocalAI endpoint responsive ${chalk_1.default.gray("(" + localai.detail + ")")}`);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
console.log(` ${chalk_1.default.yellow("⚠")} LocalAI not reachable at ${chalk_1.default.gray(LOCALAI_MODELS_URL)} ${chalk_1.default.gray("— " + localai.detail)}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
console.log(` ${chalk_1.default.gray("○")} LocalAI not configured ${chalk_1.default.gray("(set ORAZAKA_LOCALAI_URL to enable)")}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** Best-effort, non-throwing command probe used for accelerator detection. */
|
|
157
|
+
function tryCommand(command) {
|
|
158
|
+
try {
|
|
159
|
+
return (0, node_child_process_1.execSync)(command, { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"], timeout: 5_000 }).trim();
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/** Phase 5 — hardware accelerator detection guardrail (CUDA / Metal / ROCm). */
|
|
166
|
+
function runAcceleratorDetection() {
|
|
167
|
+
console.log(chalk_1.default.cyan.bold("\n⚡ Phase 5: Hardware Accelerator Detection\n"));
|
|
168
|
+
const detected = [];
|
|
169
|
+
// NVIDIA CUDA — nvidia-smi boundary check.
|
|
170
|
+
const nvidia = tryCommand("nvidia-smi --query-gpu=name --format=csv,noheader");
|
|
171
|
+
if (nvidia) {
|
|
172
|
+
const gpu = nvidia.split("\n")[0].trim();
|
|
173
|
+
detected.push(`NVIDIA CUDA (${gpu})`);
|
|
174
|
+
console.log(` ${chalk_1.default.green("✔")} NVIDIA CUDA detected ${chalk_1.default.gray("(" + gpu + ")")}`);
|
|
175
|
+
}
|
|
176
|
+
// Apple Silicon Metal — macOS system_profiler parsing.
|
|
177
|
+
if ((0, node_os_1.platform)() === "darwin") {
|
|
178
|
+
const chip = tryCommand("system_profiler SPHardwareDataType");
|
|
179
|
+
const isAppleSilicon = chip != null && /Chip:\s*Apple/i.test(chip);
|
|
180
|
+
if (isAppleSilicon) {
|
|
181
|
+
const match = /Chip:\s*(.+)/.exec(chip);
|
|
182
|
+
const chipName = match ? match[1].trim() : "Apple Silicon";
|
|
183
|
+
detected.push(`Apple Metal (${chipName})`);
|
|
184
|
+
console.log(` ${chalk_1.default.green("✔")} Apple Silicon Metal detected ${chalk_1.default.gray("(" + chipName + ")")}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// AMD ROCm / Linux DRI device nodes.
|
|
188
|
+
const rocm = tryCommand("rocminfo");
|
|
189
|
+
if (rocm && /GPU/i.test(rocm)) {
|
|
190
|
+
detected.push("AMD ROCm");
|
|
191
|
+
console.log(` ${chalk_1.default.green("✔")} AMD ROCm runtime detected`);
|
|
192
|
+
}
|
|
193
|
+
else if ((0, node_os_1.platform)() === "linux") {
|
|
194
|
+
const dri = tryCommand("ls /dev/dri/renderD128");
|
|
195
|
+
if (dri) {
|
|
196
|
+
detected.push("Linux DRI render node");
|
|
197
|
+
console.log(` ${chalk_1.default.green("✔")} Linux DRI render node detected ${chalk_1.default.gray("(/dev/dri/renderD128)")}`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (detected.length === 0) {
|
|
201
|
+
console.log(chalk_1.default.red.bold("\n ⛔ WARNING: No GPU/NPU accelerator detected."));
|
|
202
|
+
console.log(chalk_1.default.red(" Local models will fall back to CPU execution, which violates Sovkora synchronous runtime latency SLAs."));
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
console.log(chalk_1.default.gray(`\n Accelerator(s) active: ${detected.join(", ")}`));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
exports.onboardCommand = new commander_1.Command("onboard")
|
|
209
|
+
.description("Full clone-and-run onboarding: verify prerequisites, compile, smoke-test M2M handshake, and probe local AI runtimes")
|
|
210
|
+
.action(async () => {
|
|
211
|
+
console.log(chalk_1.default.cyan.bold("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
|
|
212
|
+
console.log(chalk_1.default.cyan.bold(" 🥷 SOVKORA ONBOARDING — Production Readiness"));
|
|
213
|
+
console.log(chalk_1.default.cyan.bold("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"));
|
|
214
|
+
// Phase 1: Prerequisites
|
|
215
|
+
if (!runPrerequisiteChecks()) {
|
|
216
|
+
console.error(chalk_1.default.red("\n❌ Prerequisites failed. Install missing tools and retry."));
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
// Phase 2: Compilation
|
|
220
|
+
if (!runCompilation()) {
|
|
221
|
+
process.exit(1);
|
|
222
|
+
}
|
|
223
|
+
// Phase 3: Handshake smoke test
|
|
224
|
+
if (!runHandshakeSmokeTest()) {
|
|
225
|
+
process.exit(1);
|
|
226
|
+
}
|
|
227
|
+
// Phase 4: Local sovereign AI runtime health (non-fatal — advisory)
|
|
228
|
+
await runLocalRuntimeChecks();
|
|
229
|
+
// Phase 5: Hardware accelerator detection (non-fatal — SLA guardrail)
|
|
230
|
+
runAcceleratorDetection();
|
|
231
|
+
console.log(chalk_1.default.green.bold("\n✅ Onboarding complete. System is production-ready.\n"));
|
|
232
|
+
console.log(chalk_1.default.gray("Next steps:"));
|
|
233
|
+
console.log(chalk_1.default.white(" $ npx sovkora start ") + chalk_1.default.gray("Launch infrastructure"));
|
|
234
|
+
console.log(chalk_1.default.white(" $ npx sovkora dev ") + chalk_1.default.gray("Launch full dev stack"));
|
|
235
|
+
console.log(chalk_1.default.white(" $ npx sovkora status ") + chalk_1.default.gray("Check service health\n"));
|
|
236
|
+
});
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file pack.command.ts
|
|
4
|
+
* @description `sovkora pack` — validate, install and publish pack bundles (ADR-037, seam S4).
|
|
5
|
+
*
|
|
6
|
+
* The operator's half of the pack manifest. `validate` reads a bundle and checks it, which is
|
|
7
|
+
* the loop a pack author runs; `install` applies it; `publish` puts an installed pack on the
|
|
8
|
+
* shelf. Everything the platform learns about a pack arrives through this command, which is
|
|
9
|
+
* what makes "a new pack is a bundle, not a deploy" true rather than aspirational.
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
+
var ownKeys = function(o) {
|
|
29
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
+
var ar = [];
|
|
31
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
+
return ar;
|
|
33
|
+
};
|
|
34
|
+
return ownKeys(o);
|
|
35
|
+
};
|
|
36
|
+
return function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.packCommand = void 0;
|
|
49
|
+
const fs = __importStar(require("node:fs"));
|
|
50
|
+
const path = __importStar(require("node:path"));
|
|
51
|
+
const commander_1 = require("commander");
|
|
52
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
53
|
+
const threads_1 = require("../threads");
|
|
54
|
+
const prompts_1 = require("../ui/prompts");
|
|
55
|
+
const logger_1 = require("../ui/logger");
|
|
56
|
+
const pack_api_1 = require("../services/pack.api");
|
|
57
|
+
const pack_bundle_1 = require("../services/pack.bundle");
|
|
58
|
+
const pack_sources_1 = require("../services/pack.sources");
|
|
59
|
+
function fail(message, error) {
|
|
60
|
+
const detail = error instanceof Error ? error.message : "Unknown error";
|
|
61
|
+
logger_1.Logger.error(`${message}: ${detail}`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Reads a bundle and stops on a shape problem.
|
|
66
|
+
*
|
|
67
|
+
* Shape is checked locally against `pack.schema.json` because a pack author must be able to fix
|
|
68
|
+
* a malformed manifest without a platform running. What needs the platform — do these
|
|
69
|
+
* capabilities resolve here — is the service's half, and is reported separately.
|
|
70
|
+
*/
|
|
71
|
+
function readOrExit(directory) {
|
|
72
|
+
try {
|
|
73
|
+
const { bundle, problems } = (0, pack_bundle_1.loadBundle)(directory);
|
|
74
|
+
if (problems.length > 0) {
|
|
75
|
+
logger_1.Logger.error(`${path.basename(directory)}/pack.yaml does not match pack.schema.json:`);
|
|
76
|
+
for (const problem of problems) {
|
|
77
|
+
console.log(` ${chalk_1.default.red("✗")} ${problem}`);
|
|
78
|
+
}
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
return bundle;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (error instanceof pack_bundle_1.BundleError) {
|
|
85
|
+
logger_1.Logger.error(error.message);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
return fail("Could not read the bundle", error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Prints what a bundle contains, so `validate` says something useful when it passes. */
|
|
92
|
+
function summarise(bundle) {
|
|
93
|
+
const shelf = bundle.catalog ? chalk_1.default.cyan(bundle.key) : chalk_1.default.dim("(no pack row)");
|
|
94
|
+
console.log(` ${chalk_1.default.bold(bundle.key)} v${bundle.version} ${chalk_1.default.dim(bundle.tier)} ${shelf}`);
|
|
95
|
+
for (const studio of bundle.studios) {
|
|
96
|
+
console.log(` ${chalk_1.default.green("•")} ${studio.key} ${chalk_1.default.dim(`${studio.pricing} · blueprint ${studio.blueprint.version} · ${studio.blueprint.estimatedCredits} credits`)}`);
|
|
97
|
+
}
|
|
98
|
+
const locales = Object.keys(bundle.translations);
|
|
99
|
+
console.log(` ${chalk_1.default.dim(`${bundle.capabilities.length} contributed capability(ies) · locales: ${locales.length > 0 ? locales.join(", ") : "none"}`)}`);
|
|
100
|
+
}
|
|
101
|
+
const validateCommand = new commander_1.Command("validate")
|
|
102
|
+
.description("Check a bundle's manifest, and whether this platform can run it")
|
|
103
|
+
.argument("<directory>", "The bundle directory holding pack.yaml")
|
|
104
|
+
.option("--offline", "Check the manifest's shape only, without asking the platform")
|
|
105
|
+
.action(async (directory, options) => {
|
|
106
|
+
const bundle = readOrExit(directory);
|
|
107
|
+
logger_1.Logger.success(`${path.basename(directory)}/pack.yaml matches pack.schema.json`);
|
|
108
|
+
summarise(bundle);
|
|
109
|
+
if (options.offline) {
|
|
110
|
+
console.log(chalk_1.default.dim("\n --offline: capability resolution not checked."));
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
(0, threads_1.requireAuth)();
|
|
114
|
+
const spinner = await (0, prompts_1.createSpinner)();
|
|
115
|
+
spinner.start("Checking capabilities against the platform...");
|
|
116
|
+
try {
|
|
117
|
+
const result = await pack_api_1.PackApi.validate(bundle);
|
|
118
|
+
if (result.valid) {
|
|
119
|
+
spinner.stop("Every capability this bundle names resolves here.");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
spinner.stop("This platform cannot run the bundle as written:");
|
|
123
|
+
for (const problem of result.problems) {
|
|
124
|
+
console.log(` ${chalk_1.default.red("✗")} ${problem}`);
|
|
125
|
+
}
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
spinner.stop("Validation failed");
|
|
130
|
+
fail("Could not reach the platform (use --offline to check the manifest alone)", error);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
/** Every immediate subdirectory that holds a pack.yaml. A bundle is a directory with a manifest. */
|
|
134
|
+
function bundleDirectories(root) {
|
|
135
|
+
return fs
|
|
136
|
+
.readdirSync(root, { withFileTypes: true })
|
|
137
|
+
.filter((entry) => entry.isDirectory())
|
|
138
|
+
.map((entry) => path.join(root, entry.name))
|
|
139
|
+
.filter((directory) => fs.existsSync(path.join(directory, "pack.yaml")))
|
|
140
|
+
.sort();
|
|
141
|
+
}
|
|
142
|
+
const installCommand = new commander_1.Command("install")
|
|
143
|
+
.description("Install a bundle: capabilities, billing and catalogue, or none of them")
|
|
144
|
+
.argument("<directory>", "The bundle directory holding pack.yaml, or a directory of bundles with --all")
|
|
145
|
+
.option("--all", "Install every bundle in the directory — what a fresh database needs")
|
|
146
|
+
.action(async (directory, options) => {
|
|
147
|
+
// Read and check EVERY bundle before installing ANY of them. Each install is atomic on its
|
|
148
|
+
// own, but a run of three that stops after two leaves a catalogue nobody planned; a manifest
|
|
149
|
+
// typo in the third should cost nothing rather than half a shelf.
|
|
150
|
+
const directories = options.all ? bundleDirectories(directory) : [directory];
|
|
151
|
+
if (directories.length === 0) {
|
|
152
|
+
logger_1.Logger.error(`No bundles in ${directory} (a bundle is a directory holding pack.yaml).`);
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
const bundles = directories.map((bundleDir) => readOrExit(bundleDir));
|
|
156
|
+
(0, threads_1.requireAuth)();
|
|
157
|
+
for (const bundle of bundles) {
|
|
158
|
+
const spinner = await (0, prompts_1.createSpinner)();
|
|
159
|
+
spinner.start(`Installing ${bundle.key} v${bundle.version}...`);
|
|
160
|
+
try {
|
|
161
|
+
const result = await pack_api_1.PackApi.install(bundle);
|
|
162
|
+
spinner.stop(`Installed ${chalk_1.default.bold(result.packKey)} v${result.version} — ${result.studiosInstalled} Studio(s).`);
|
|
163
|
+
summarise(bundle);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
spinner.stop("Install failed");
|
|
167
|
+
fail(`${bundle.key} was not installed`, error);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
const publishCommand = new commander_1.Command("publish")
|
|
172
|
+
.description("Put an installed bundle's pack and Studios on the shelf")
|
|
173
|
+
.argument("<directory>", "The bundle directory holding pack.yaml")
|
|
174
|
+
.action(async (directory) => {
|
|
175
|
+
const bundle = readOrExit(directory);
|
|
176
|
+
const draft = bundle.studios.filter((studio) => studio.status !== "PUBLISHED");
|
|
177
|
+
if (draft.length > 0) {
|
|
178
|
+
// Publishing is a property of the manifest, not a separate lifecycle the CLI can force.
|
|
179
|
+
// A bundle whose Studios say DRAFT installs as DRAFT; making `publish` flip them would
|
|
180
|
+
// mean the shipped artefact and the installed rows disagree about what was published.
|
|
181
|
+
logger_1.Logger.error(`${bundle.key} declares ${draft.length} Studio(s) as DRAFT: ${draft.map((studio) => studio.key).join(", ")}`);
|
|
182
|
+
console.log(chalk_1.default.dim(" Publication is declared in pack.yaml. Set status: PUBLISHED there and re-install,\n" +
|
|
183
|
+
" so the bundle on disk and the rows in the catalogue never disagree."));
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
186
|
+
(0, threads_1.requireAuth)();
|
|
187
|
+
const spinner = await (0, prompts_1.createSpinner)();
|
|
188
|
+
spinner.start(`Publishing ${bundle.key} v${bundle.version}...`);
|
|
189
|
+
try {
|
|
190
|
+
const result = await pack_api_1.PackApi.install(bundle);
|
|
191
|
+
spinner.stop(`${chalk_1.default.bold(result.packKey)} v${result.version} is published — ${result.studiosInstalled} Studio(s) on the shelf.`);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
spinner.stop("Publish failed");
|
|
195
|
+
fail("The bundle was not published", error);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
/** The bundles one explicit directory holds (one sub-folder with a `pack.yaml` each); none when it does not exist. */
|
|
199
|
+
function bundlesIn(directory) {
|
|
200
|
+
if (!fs.existsSync(directory))
|
|
201
|
+
return [];
|
|
202
|
+
return fs
|
|
203
|
+
.readdirSync(directory, { withFileTypes: true })
|
|
204
|
+
.filter((entry) => entry.isDirectory())
|
|
205
|
+
.filter((entry) => fs.existsSync(path.join(directory, entry.name, "pack.yaml")))
|
|
206
|
+
.map((entry) => ({ directory: path.join(directory, entry.name), source: directory }));
|
|
207
|
+
}
|
|
208
|
+
/** Print pack sources to console. */
|
|
209
|
+
function printSources(directory) {
|
|
210
|
+
if (directory)
|
|
211
|
+
return;
|
|
212
|
+
for (const source of (0, pack_sources_1.packSources)()) {
|
|
213
|
+
const mark = source.unavailable ? chalk_1.default.yellow("⚠") : chalk_1.default.dim("•");
|
|
214
|
+
const note = source.unavailable ? chalk_1.default.dim(` — ${source.unavailable}`) : "";
|
|
215
|
+
console.log(` ${mark} ${source.kind} ${source.location}${note}`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/** Display bundle summary or error. */
|
|
219
|
+
function displayBundle(found) {
|
|
220
|
+
try {
|
|
221
|
+
const { bundle, problems } = (0, pack_bundle_1.loadBundle)(found.directory);
|
|
222
|
+
if (problems.length > 0) {
|
|
223
|
+
console.log(` ${chalk_1.default.red("✗")} ${found.directory} ${chalk_1.default.dim("(manifest invalid)")}`);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
summarise(bundle);
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
console.log(` ${chalk_1.default.red("✗")} ${found.directory} ${chalk_1.default.dim("(unreadable)")}`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const listCommand = new commander_1.Command("list")
|
|
233
|
+
.description("List the bundles this deployment's pack sources offer")
|
|
234
|
+
.argument("[directory]", "Look in this directory instead of the configured sources")
|
|
235
|
+
.action((directory) => {
|
|
236
|
+
// No hardcoded default any more: where packs come from is `orazaka.packs.sources`, the one
|
|
237
|
+
// line that separates an OSS deployment from a cloud one (ADR-049). An explicit directory
|
|
238
|
+
// still wins, because installing a bundle you are holding must not require configuration.
|
|
239
|
+
const bundles = directory ? bundlesIn(directory) : (0, pack_sources_1.discoverBundles)();
|
|
240
|
+
printSources(directory);
|
|
241
|
+
if (bundles.length === 0) {
|
|
242
|
+
logger_1.Logger.info("No bundles found (a bundle is a directory holding pack.yaml).");
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
logger_1.Logger.success(`${bundles.length} bundle(s)`);
|
|
246
|
+
for (const found of bundles) {
|
|
247
|
+
displayBundle(found);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
exports.packCommand = new commander_1.Command("pack")
|
|
251
|
+
.description("Validate, install and publish pack bundles")
|
|
252
|
+
.addCommand(listCommand)
|
|
253
|
+
.addCommand(validateCommand)
|
|
254
|
+
.addCommand(installCommand)
|
|
255
|
+
.addCommand(publishCommand);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file profile.command.ts
|
|
4
|
+
* @description Command to display the authenticated user's profile card.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.profileCommand = void 0;
|
|
8
|
+
const commander_1 = require("commander");
|
|
9
|
+
const prompts_1 = require("../ui/prompts");
|
|
10
|
+
const threads_1 = require("../threads");
|
|
11
|
+
const settings_api_1 = require("../services/settings.api");
|
|
12
|
+
const box_1 = require("../ui/box");
|
|
13
|
+
const logger_1 = require("../ui/logger");
|
|
14
|
+
exports.profileCommand = new commander_1.Command("profile")
|
|
15
|
+
.description("Display authenticated user profile information")
|
|
16
|
+
.action(async () => {
|
|
17
|
+
(0, threads_1.requireAuth)();
|
|
18
|
+
const s = await (0, prompts_1.createSpinner)();
|
|
19
|
+
s.start("Loading profile...");
|
|
20
|
+
try {
|
|
21
|
+
const user = await settings_api_1.SettingsApi.getMe();
|
|
22
|
+
s.stop("Profile loaded");
|
|
23
|
+
const items = [
|
|
24
|
+
{ key: "Username", value: user.username },
|
|
25
|
+
{ key: "Email", value: user.email },
|
|
26
|
+
{ key: "ID", value: user.id },
|
|
27
|
+
{ key: "Authorities", value: user.authorities.join(", ") || "None" },
|
|
28
|
+
];
|
|
29
|
+
const prefs = user.preferences || {};
|
|
30
|
+
const entries = Object.entries(prefs);
|
|
31
|
+
if (entries.length > 0) {
|
|
32
|
+
items.push("Preferences:");
|
|
33
|
+
for (const [k, v] of entries) {
|
|
34
|
+
items.push({ key: ` ${k}`, value: String(v) });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
items.push("No preferences configured.");
|
|
39
|
+
}
|
|
40
|
+
box_1.Box.render("🥷 SOVKORA USER PROFILE", items, {
|
|
41
|
+
borderColor: "cyan",
|
|
42
|
+
titleColor: "white",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
s.stop("Failed to load profile");
|
|
47
|
+
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
48
|
+
logger_1.Logger.error(`Failed to retrieve profile: ${msg}`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
});
|