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,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file reset.command.ts
|
|
4
|
+
* @description Command to execute a password reset using a valid token.
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.resetCommand = void 0;
|
|
11
|
+
const commander_1 = require("commander");
|
|
12
|
+
const prompts_1 = require("../ui/prompts");
|
|
13
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
+
const auth_api_1 = require("../services/auth.api");
|
|
15
|
+
async function promptToken(tokenArg) {
|
|
16
|
+
if (tokenArg)
|
|
17
|
+
return tokenArg;
|
|
18
|
+
const tokenInput = await (0, prompts_1.text)({
|
|
19
|
+
message: "Enter Reset Token:",
|
|
20
|
+
placeholder: "Paste the token from your email",
|
|
21
|
+
validate: (val) => (val.trim().length === 0 ? "Token is required" : undefined),
|
|
22
|
+
});
|
|
23
|
+
if ((0, prompts_1.isCancel)(tokenInput)) {
|
|
24
|
+
throw new Error("CANCELLED");
|
|
25
|
+
}
|
|
26
|
+
return tokenInput;
|
|
27
|
+
}
|
|
28
|
+
async function promptNewPassword() {
|
|
29
|
+
const pwdInput = await (0, prompts_1.password)({
|
|
30
|
+
message: "Enter New Password:",
|
|
31
|
+
validate: (val) => (val.length < 8 ? "Password must be at least 8 characters" : undefined),
|
|
32
|
+
});
|
|
33
|
+
if ((0, prompts_1.isCancel)(pwdInput)) {
|
|
34
|
+
throw new Error("CANCELLED");
|
|
35
|
+
}
|
|
36
|
+
return pwdInput;
|
|
37
|
+
}
|
|
38
|
+
async function promptConfirmPassword(pwdInput) {
|
|
39
|
+
const pwdConfirm = await (0, prompts_1.password)({
|
|
40
|
+
message: "Confirm New Password:",
|
|
41
|
+
validate: (val) => (val === pwdInput ? undefined : "Passwords do not match"),
|
|
42
|
+
});
|
|
43
|
+
if ((0, prompts_1.isCancel)(pwdConfirm)) {
|
|
44
|
+
throw new Error("CANCELLED");
|
|
45
|
+
}
|
|
46
|
+
return pwdConfirm;
|
|
47
|
+
}
|
|
48
|
+
exports.resetCommand = new commander_1.Command("reset")
|
|
49
|
+
.description("Reset account password using a valid reset token")
|
|
50
|
+
.argument("[token]", "Password reset token")
|
|
51
|
+
.action(async (tokenArg) => {
|
|
52
|
+
try {
|
|
53
|
+
await (0, prompts_1.intro)(chalk_1.default.cyan("Sovkora Password Reset"));
|
|
54
|
+
const token = await promptToken(tokenArg);
|
|
55
|
+
const pwd = await promptNewPassword();
|
|
56
|
+
await promptConfirmPassword(pwd);
|
|
57
|
+
const s = await (0, prompts_1.createSpinner)();
|
|
58
|
+
s.start("Resetting password...");
|
|
59
|
+
try {
|
|
60
|
+
const result = await auth_api_1.AuthApi.resetPassword(token, pwd);
|
|
61
|
+
s.stop("Password reset success!");
|
|
62
|
+
await (0, prompts_1.outro)(chalk_1.default.green(`✓ ${result.message}`));
|
|
63
|
+
await (0, prompts_1.outro)(chalk_1.default.yellow("You can now login with your new password: sovkora login"));
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
s.stop("Password reset failed");
|
|
67
|
+
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
68
|
+
await (0, prompts_1.outro)(chalk_1.default.red(`❌ Password Reset Failed: ${msg}`));
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
if (err instanceof Error && err.message === "CANCELLED") {
|
|
74
|
+
await (0, prompts_1.outro)(chalk_1.default.red("Password reset cancelled."));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
throw err;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file runs.command.ts
|
|
4
|
+
* @description `sovkora runs` - the runs of the workspace as background tasks (ADR-088, orazaka-cli#90):
|
|
5
|
+
* `runs ls [--watch] [--json]` and `runs show <name|id> [--steps] [--json]`. A run is addressed by its id or its
|
|
6
|
+
* name (the server resolves both, ADR-088 point 1). `--watch` re-reads the list every few seconds; `runs stop|approve|deny|send|resume`
|
|
7
|
+
* steer a run through the endpoints the Studio serves; `runs wait <ref> [--notify]` follows one run to its end.
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.runsCommand = void 0;
|
|
14
|
+
const commander_1 = require("commander");
|
|
15
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
16
|
+
const threads_1 = require("../threads");
|
|
17
|
+
const logger_1 = require("../ui/logger");
|
|
18
|
+
const studio_api_1 = require("../services/studio.api");
|
|
19
|
+
const runs_wait_1 = require("../services/runs.wait");
|
|
20
|
+
const notify_1 = require("../services/notify");
|
|
21
|
+
const runs_view_1 = require("../services/runs.view");
|
|
22
|
+
const WATCH_INTERVAL_MS = 3000; // @fixed: a terminal refresh rate, not a business parameter
|
|
23
|
+
function fail(message, error) {
|
|
24
|
+
logger_1.Logger.error(`${message}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
async function render(json) {
|
|
28
|
+
const runs = (0, runs_view_1.sortRuns)((await studio_api_1.StudioApi.runs()));
|
|
29
|
+
const rows = runs.map((run) => (0, runs_view_1.toRow)(run, new Date()));
|
|
30
|
+
if (json) {
|
|
31
|
+
console.log(JSON.stringify(rows, null, 2));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (rows.length === 0) {
|
|
35
|
+
console.log(chalk_1.default.gray("No runs yet."));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
console.log(chalk_1.default.bold(["NAME".padEnd(20), "STATUS".padEnd(10), "STEP".padEnd(18), "ELAPSED".padEnd(8), "COST"].join(" ")));
|
|
39
|
+
for (const row of rows)
|
|
40
|
+
console.log((0, runs_view_1.rowLine)(row));
|
|
41
|
+
}
|
|
42
|
+
const lsCommand = new commander_1.Command("ls")
|
|
43
|
+
.alias("list")
|
|
44
|
+
.description("List the runs: name, status, current step, elapsed time, cost against the budget")
|
|
45
|
+
.option("--watch", "Refresh the list every few seconds")
|
|
46
|
+
.option("--json", "Output the rows as JSON")
|
|
47
|
+
.action(async (options) => {
|
|
48
|
+
(0, threads_1.requireAuth)();
|
|
49
|
+
try {
|
|
50
|
+
await render(Boolean(options.json));
|
|
51
|
+
if (options.watch) {
|
|
52
|
+
setInterval(() => {
|
|
53
|
+
if (!options.json)
|
|
54
|
+
console.clear();
|
|
55
|
+
render(Boolean(options.json)).catch(() => { });
|
|
56
|
+
}, WATCH_INTERVAL_MS);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
fail("Could not list the runs", error);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const showCommand = new commander_1.Command("show")
|
|
64
|
+
.description("Show one run, by name or id")
|
|
65
|
+
.argument("<ref>", "The run name or id")
|
|
66
|
+
.option("--steps", "Show the folded timeline, one line per step")
|
|
67
|
+
.option("--json", "Output the run as JSON")
|
|
68
|
+
.action(async (ref, options) => {
|
|
69
|
+
(0, threads_1.requireAuth)();
|
|
70
|
+
try {
|
|
71
|
+
const run = (await studio_api_1.StudioApi.runDetail((0, runs_view_1.normaliseRef)(ref)));
|
|
72
|
+
if (options.json) {
|
|
73
|
+
console.log(JSON.stringify({ ...(0, runs_view_1.toRow)(run, new Date()), steps: run.steps ?? [] }, null, 2));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const row = (0, runs_view_1.toRow)(run, new Date());
|
|
77
|
+
console.log(`${chalk_1.default.bold(row.name ?? row.id)} ${row.status} ${row.studioKey}`);
|
|
78
|
+
console.log(chalk_1.default.gray(`elapsed ${(0, runs_view_1.formatElapsed)(row.elapsedSeconds)}, cost ${(0, runs_view_1.costAgainstBudget)(row)}`));
|
|
79
|
+
if (run.errorMessage)
|
|
80
|
+
console.log(chalk_1.default.red(run.errorMessage));
|
|
81
|
+
if (options.steps)
|
|
82
|
+
for (const line of (0, runs_view_1.timelineLines)(run))
|
|
83
|
+
console.log(line);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
fail("Could not load the run", error);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
/** A steering action that takes only the run (stop, approve). */
|
|
90
|
+
function steerCommand(name, description, done, call) {
|
|
91
|
+
return new commander_1.Command(name)
|
|
92
|
+
.description(description)
|
|
93
|
+
.argument("<ref>", "The run name or id")
|
|
94
|
+
.option("--json", "Output the result as JSON")
|
|
95
|
+
.action(async (ref, options) => {
|
|
96
|
+
(0, threads_1.requireAuth)();
|
|
97
|
+
try {
|
|
98
|
+
const id = (0, runs_view_1.normaliseRef)(ref);
|
|
99
|
+
const result = await call(id);
|
|
100
|
+
if (options.json)
|
|
101
|
+
console.log(JSON.stringify({ id, action: name, result: result ?? null }, null, 2));
|
|
102
|
+
else
|
|
103
|
+
console.log(done);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
fail(`Could not ${name} the run`, error);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const stopCommand = steerCommand("stop", "Stop a run and release its hold", "stopped", (id) => studio_api_1.StudioApi.cancelRun(id));
|
|
111
|
+
const approveCommand = steerCommand("approve", "Approve the step a run is waiting on", "approved, the run continues", (id) => studio_api_1.StudioApi.approveRun(id));
|
|
112
|
+
const sendCommand = new commander_1.Command("send")
|
|
113
|
+
.description("Answer a run that is waiting for input: the message becomes the output of the step it waits on")
|
|
114
|
+
.argument("<ref>", "The run name or id")
|
|
115
|
+
.argument("<message>", "What to say to the run")
|
|
116
|
+
.option("--json", "Output the run as JSON")
|
|
117
|
+
.action(async (ref, message, options) => {
|
|
118
|
+
(0, threads_1.requireAuth)();
|
|
119
|
+
try {
|
|
120
|
+
const run = (await studio_api_1.StudioApi.sendRun((0, runs_view_1.normaliseRef)(ref), message));
|
|
121
|
+
if (options.json)
|
|
122
|
+
console.log(JSON.stringify((0, runs_view_1.toRow)(run, new Date()), null, 2));
|
|
123
|
+
else
|
|
124
|
+
console.log(`sent, the run continues (${run.status})`);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
fail("Could not send the message", error);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const denyCommand = new commander_1.Command("deny")
|
|
131
|
+
.description("Refuse the approval a run is waiting on: the run stops without the step and its hold is released")
|
|
132
|
+
.argument("<ref>", "The run name or id")
|
|
133
|
+
.option("--reason <text>", "Why the approval is refused")
|
|
134
|
+
.option("--json", "Output the run as JSON")
|
|
135
|
+
.action(async (ref, options) => {
|
|
136
|
+
(0, threads_1.requireAuth)();
|
|
137
|
+
try {
|
|
138
|
+
const run = (await studio_api_1.StudioApi.denyRun((0, runs_view_1.normaliseRef)(ref), options.reason));
|
|
139
|
+
if (options.json)
|
|
140
|
+
console.log(JSON.stringify((0, runs_view_1.toRow)(run, new Date()), null, 2));
|
|
141
|
+
else
|
|
142
|
+
console.log(`denied, the run is ${run.status.toLowerCase()}`);
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
fail("Could not deny the run", error);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const waitCommand = new commander_1.Command("wait")
|
|
149
|
+
.description("Follow a run until it ends or needs your approval")
|
|
150
|
+
.argument("<ref>", "The run name or id")
|
|
151
|
+
.option("--notify", "Send a desktop notification when it ends or needs approval")
|
|
152
|
+
.option("--json", "Output the final row as JSON")
|
|
153
|
+
.action(async (ref, options) => {
|
|
154
|
+
(0, threads_1.requireAuth)();
|
|
155
|
+
try {
|
|
156
|
+
const { outcome, run } = await (0, runs_wait_1.waitForRun)((0, runs_view_1.normaliseRef)(ref), {
|
|
157
|
+
onStatus: (status) => {
|
|
158
|
+
if (!options.json)
|
|
159
|
+
console.log(chalk_1.default.gray(status.toLowerCase()));
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
const row = (0, runs_view_1.toRow)(run, new Date());
|
|
163
|
+
if (options.notify)
|
|
164
|
+
(0, notify_1.notify)("Sovkora", (0, notify_1.outcomeMessage)(outcome, row.name ?? row.id));
|
|
165
|
+
if (options.json)
|
|
166
|
+
console.log(JSON.stringify({ ...row, outcome }, null, 2));
|
|
167
|
+
else
|
|
168
|
+
console.log((0, notify_1.outcomeMessage)(outcome, row.name ?? row.id));
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
fail("Could not follow the run", error);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
const resumeCommand = new commander_1.Command("resume")
|
|
175
|
+
.description("Start a new run from a step of a finished one; the steps before it keep their outputs")
|
|
176
|
+
.argument("<ref>", "The run name or id")
|
|
177
|
+
.requiredOption("--from <step>", "The step to run again")
|
|
178
|
+
.option("--json", "Output the new run as JSON")
|
|
179
|
+
.action(async (ref, options) => {
|
|
180
|
+
(0, threads_1.requireAuth)();
|
|
181
|
+
try {
|
|
182
|
+
const run = (await studio_api_1.StudioApi.resumeRun((0, runs_view_1.normaliseRef)(ref), options.from));
|
|
183
|
+
if (options.json)
|
|
184
|
+
console.log(JSON.stringify((0, runs_view_1.toRow)(run, new Date()), null, 2));
|
|
185
|
+
else
|
|
186
|
+
console.log(`resumed from ${options.from}: new run ${run.name ?? run.id}`);
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
fail("Could not resume the run", error);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
exports.runsCommand = new commander_1.Command("runs")
|
|
193
|
+
.description("Runs as background tasks: list and inspect them by name or id")
|
|
194
|
+
.addCommand(lsCommand)
|
|
195
|
+
.addCommand(showCommand)
|
|
196
|
+
.addCommand(stopCommand)
|
|
197
|
+
.addCommand(approveCommand)
|
|
198
|
+
.addCommand(denyCommand)
|
|
199
|
+
.addCommand(sendCommand)
|
|
200
|
+
.addCommand(waitCommand)
|
|
201
|
+
.addCommand(resumeCommand);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file settings.command.ts
|
|
4
|
+
* @description Command to query and modify user settings/preferences.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.settingsCommand = 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 logger_1 = require("../ui/logger");
|
|
13
|
+
const box_1 = require("../ui/box");
|
|
14
|
+
exports.settingsCommand = new commander_1.Command("settings").description("Manage user settings and preferences");
|
|
15
|
+
exports.settingsCommand
|
|
16
|
+
.command("get")
|
|
17
|
+
.description("Get all settings and preferences")
|
|
18
|
+
.action(async () => {
|
|
19
|
+
(0, threads_1.requireAuth)();
|
|
20
|
+
const s = await (0, prompts_1.createSpinner)();
|
|
21
|
+
s.start("Retrieving settings...");
|
|
22
|
+
try {
|
|
23
|
+
const user = await settings_api_1.SettingsApi.getMe();
|
|
24
|
+
s.stop("Settings retrieved");
|
|
25
|
+
const items = [
|
|
26
|
+
{ key: "User ID", value: user.id },
|
|
27
|
+
{ key: "Email", value: user.email },
|
|
28
|
+
{ key: "Authorities", value: user.authorities?.join(", ") || "None" },
|
|
29
|
+
];
|
|
30
|
+
const prefs = user.preferences || {};
|
|
31
|
+
const entries = Object.entries(prefs);
|
|
32
|
+
if (entries.length > 0) {
|
|
33
|
+
items.push("Preferences:");
|
|
34
|
+
for (const [k, v] of entries) {
|
|
35
|
+
items.push({ key: ` ${k}`, value: String(v) });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
items.push("No preferences configured.");
|
|
40
|
+
}
|
|
41
|
+
box_1.Box.render(`Sovkora Settings for User: ${user.username}`, items, {
|
|
42
|
+
borderColor: "yellow",
|
|
43
|
+
titleColor: "white",
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
s.stop("Failed to retrieve settings");
|
|
48
|
+
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
49
|
+
logger_1.Logger.error(`Failed to retrieve settings: ${msg}`);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
exports.settingsCommand
|
|
54
|
+
.command("set")
|
|
55
|
+
.description("Set a user preference key-value pair")
|
|
56
|
+
.argument("<key>", "Preference key to set")
|
|
57
|
+
.argument("<value>", "Preference value to set")
|
|
58
|
+
.action(async (key, rawValue) => {
|
|
59
|
+
(0, threads_1.requireAuth)();
|
|
60
|
+
const s = await (0, prompts_1.createSpinner)();
|
|
61
|
+
s.start(`Updating preference "${key}"...`);
|
|
62
|
+
// Coerce boolean and numeric strings to native types
|
|
63
|
+
const coerceValue = (val) => {
|
|
64
|
+
if (val.toLowerCase() === "true")
|
|
65
|
+
return true;
|
|
66
|
+
if (val.toLowerCase() === "false")
|
|
67
|
+
return false;
|
|
68
|
+
if (!Number.isNaN(Number(val)))
|
|
69
|
+
return Number(val);
|
|
70
|
+
return val;
|
|
71
|
+
};
|
|
72
|
+
const typedValue = coerceValue(rawValue);
|
|
73
|
+
try {
|
|
74
|
+
// Direct atomic merge
|
|
75
|
+
await settings_api_1.SettingsApi.updatePreferences({ [key]: typedValue });
|
|
76
|
+
s.stop("Preference updated");
|
|
77
|
+
logger_1.Logger.success(`Preference "${key}" updated to: ${rawValue}`);
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
s.stop("Failed to update preference");
|
|
81
|
+
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
82
|
+
logger_1.Logger.error(`Failed to update preference: ${msg}`);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
});
|