saros-proxy 1.0.0 → 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/README.md +63 -11
- package/assets/models.json +3349 -0
- package/dist/cli/autostart.d.ts +13 -6
- package/dist/cli/autostart.js +317 -60
- package/dist/cli/autostart.js.map +1 -1
- package/dist/cli/daemon.js +66 -8
- package/dist/cli/daemon.js.map +1 -1
- package/dist/cli/harness-models.d.ts +5 -4
- package/dist/cli/harness-models.js +77 -30
- package/dist/cli/harness-models.js.map +1 -1
- package/dist/cli/help.js +5 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/opencode-config.d.ts +1 -0
- package/dist/cli/opencode-config.js +7 -6
- package/dist/cli/opencode-config.js.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -1
- package/dist/index.js +29 -36
- package/dist/index.js.map +1 -1
- package/dist/model-ladder.d.ts +30 -0
- package/dist/model-ladder.js +45 -0
- package/dist/model-ladder.js.map +1 -0
- package/dist/models-catalog.d.ts +25 -4
- package/dist/models-catalog.js +41 -12
- package/dist/models-catalog.js.map +1 -1
- package/dist/models-dev.d.ts +72 -0
- package/dist/models-dev.js +196 -0
- package/dist/models-dev.js.map +1 -0
- package/dist/models-refresh.d.ts +144 -0
- package/dist/models-refresh.js +522 -0
- package/dist/models-refresh.js.map +1 -0
- package/dist/models-sync.d.ts +6 -10
- package/dist/models-sync.js +26 -60
- package/dist/models-sync.js.map +1 -1
- package/package.json +5 -4
- package/models.json +0 -1440
package/dist/cli/autostart.d.ts
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
* autostart.ts — Register/unregister the daemon to start on user login.
|
|
3
3
|
*
|
|
4
4
|
* Methods:
|
|
5
|
-
* registry — HKCU\Software\Microsoft\Windows\CurrentVersion\Run
|
|
5
|
+
* registry — HKCU\Software\Microsoft\Windows\CurrentVersion\Run
|
|
6
6
|
* vbs — VBScript in Windows Startup folder (legacy, may trigger AV)
|
|
7
|
-
*
|
|
7
|
+
* systemd — ~/.config/systemd/user/saros-proxy.service (Linux default)
|
|
8
|
+
* auto — platform default: systemd on Linux, AV-aware vbs/registry on Windows
|
|
8
9
|
*
|
|
9
|
-
* macOS:
|
|
10
|
-
* Linux: creates a systemd --user service (TODO)
|
|
10
|
+
* macOS: not implemented (reported as unsupported, never a silent no-op)
|
|
11
11
|
*/
|
|
12
|
-
export type AutostartMethod = 'vbs' | 'registry' | 'auto';
|
|
12
|
+
export type AutostartMethod = 'vbs' | 'registry' | 'systemd' | 'auto';
|
|
13
|
+
type ResolvedMethod = 'vbs' | 'registry' | 'systemd';
|
|
14
|
+
export type ResolvedAutostartMethod = ResolvedMethod | 'unsupported';
|
|
13
15
|
/**
|
|
14
16
|
* Detect third-party antivirus by scanning running processes.
|
|
15
17
|
* Exported for testing.
|
|
@@ -17,9 +19,14 @@ export type AutostartMethod = 'vbs' | 'registry' | 'auto';
|
|
|
17
19
|
export declare function detectThirdPartyAv(): boolean;
|
|
18
20
|
/**
|
|
19
21
|
* Resolve the effective method based on user preference and environment.
|
|
22
|
+
* Explicit methods are returned as-is; unknown platforms return 'unsupported'
|
|
23
|
+
* so callers can warn instead of silently doing nothing.
|
|
20
24
|
* Exported for testing.
|
|
21
25
|
*/
|
|
22
|
-
export declare function resolveMethod(method?: AutostartMethod, avDetected?: boolean):
|
|
26
|
+
export declare function resolveMethod(method?: AutostartMethod, avDetected?: boolean): ResolvedAutostartMethod;
|
|
27
|
+
/** Build the unit file contents. Exported for testing. */
|
|
28
|
+
export declare function buildSystemdUnit(port?: number): string;
|
|
23
29
|
export declare function autostartInstall(port?: number, method?: AutostartMethod): Promise<void>;
|
|
24
30
|
export declare function autostartUninstall(method?: AutostartMethod): void;
|
|
25
31
|
export declare function autostartStatus(method?: AutostartMethod): void;
|
|
32
|
+
export {};
|
package/dist/cli/autostart.js
CHANGED
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
* autostart.ts — Register/unregister the daemon to start on user login.
|
|
3
3
|
*
|
|
4
4
|
* Methods:
|
|
5
|
-
* registry — HKCU\Software\Microsoft\Windows\CurrentVersion\Run
|
|
5
|
+
* registry — HKCU\Software\Microsoft\Windows\CurrentVersion\Run
|
|
6
6
|
* vbs — VBScript in Windows Startup folder (legacy, may trigger AV)
|
|
7
|
-
*
|
|
7
|
+
* systemd — ~/.config/systemd/user/saros-proxy.service (Linux default)
|
|
8
|
+
* auto — platform default: systemd on Linux, AV-aware vbs/registry on Windows
|
|
8
9
|
*
|
|
9
|
-
* macOS:
|
|
10
|
-
* Linux: creates a systemd --user service (TODO)
|
|
10
|
+
* macOS: not implemented (reported as unsupported, never a silent no-op)
|
|
11
11
|
*/
|
|
12
|
-
import { existsSync, writeFileSync, rmSync, readFileSync } from 'node:fs';
|
|
13
|
-
import { join } from 'node:path';
|
|
12
|
+
import { existsSync, mkdirSync, writeFileSync, rmSync, readFileSync } from 'node:fs';
|
|
13
|
+
import { isAbsolute, join } from 'node:path';
|
|
14
14
|
import { homedir } from 'node:os';
|
|
15
15
|
import { execFileSync } from 'node:child_process';
|
|
16
|
+
import { logger } from '../logger.js';
|
|
16
17
|
import * as ui from './ui.js';
|
|
17
18
|
// ---------------------------------------------------------------------------
|
|
18
19
|
// Constants
|
|
@@ -47,13 +48,17 @@ function windowsStartupDir() {
|
|
|
47
48
|
function vbsPath() {
|
|
48
49
|
return join(windowsStartupDir(), 'saros-proxy-daemon.vbs');
|
|
49
50
|
}
|
|
51
|
+
/** Path of the compiled entry point, relative to this module. */
|
|
52
|
+
function distEntryPath() {
|
|
53
|
+
return join(import.meta.dirname, '..', '..', 'dist', 'index.js');
|
|
54
|
+
}
|
|
50
55
|
/**
|
|
51
56
|
* Resolve the saros-proxy command path.
|
|
52
57
|
* On Windows with a global install this is typically %APPDATA%\npm\saros-proxy.cmd.
|
|
53
58
|
* Falls back to the bare command name which works if the npm bin directory is on PATH.
|
|
54
59
|
*/
|
|
55
60
|
function resolveCommand() {
|
|
56
|
-
const viaDist =
|
|
61
|
+
const viaDist = distEntryPath();
|
|
57
62
|
if (existsSync(viaDist)) {
|
|
58
63
|
return `"${process.execPath}" "${viaDist}"`;
|
|
59
64
|
}
|
|
@@ -102,16 +107,18 @@ export function detectThirdPartyAv() {
|
|
|
102
107
|
}
|
|
103
108
|
/**
|
|
104
109
|
* Resolve the effective method based on user preference and environment.
|
|
110
|
+
* Explicit methods are returned as-is; unknown platforms return 'unsupported'
|
|
111
|
+
* so callers can warn instead of silently doing nothing.
|
|
105
112
|
* Exported for testing.
|
|
106
113
|
*/
|
|
107
114
|
export function resolveMethod(method, avDetected) {
|
|
108
|
-
if (method === 'vbs')
|
|
109
|
-
return
|
|
110
|
-
if (
|
|
111
|
-
return '
|
|
112
|
-
// auto or undefined → detect
|
|
115
|
+
if (method === 'vbs' || method === 'registry' || method === 'systemd')
|
|
116
|
+
return method;
|
|
117
|
+
if (process.platform === 'linux')
|
|
118
|
+
return 'systemd';
|
|
113
119
|
if (process.platform !== 'win32')
|
|
114
|
-
return '
|
|
120
|
+
return 'unsupported';
|
|
121
|
+
// auto or undefined → detect
|
|
115
122
|
const hasAv = avDetected ?? detectThirdPartyAv();
|
|
116
123
|
if (hasAv)
|
|
117
124
|
return 'registry';
|
|
@@ -186,77 +193,319 @@ function vbsUninstall() {
|
|
|
186
193
|
function vbsExists() {
|
|
187
194
|
return existsSync(vbsPath());
|
|
188
195
|
}
|
|
196
|
+
function vbsStatus() {
|
|
197
|
+
const path = vbsPath();
|
|
198
|
+
if (!vbsExists()) {
|
|
199
|
+
console.log('Auto-start is not installed (VBS).');
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const content = readFileSync(path, 'utf-8').trim();
|
|
203
|
+
const match = content.match(/start\s*--port\s+(\d+)/);
|
|
204
|
+
const portInfo = match?.[1] ? ` on port ${match[1]}` : '';
|
|
205
|
+
console.log(`Auto-start is enabled (VBS)${portInfo}. File: ${path}`);
|
|
206
|
+
}
|
|
189
207
|
// ---------------------------------------------------------------------------
|
|
190
|
-
//
|
|
208
|
+
// systemd method (Linux user manager)
|
|
191
209
|
// ---------------------------------------------------------------------------
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
210
|
+
const SYSTEMD_UNIT_NAME = 'saros-proxy.service';
|
|
211
|
+
const SYSTEMCTL_TIMEOUT_MS = 10_000;
|
|
212
|
+
/**
|
|
213
|
+
* Exit statuses systemctl documents as answers: `is-enabled` returns 0
|
|
214
|
+
* (enabled) or 1 (disabled/not-found); `is-active` returns 0 (active) or 3
|
|
215
|
+
* (inactive). Anything else — missing binary, no user bus, timeout — is a
|
|
216
|
+
* failure to answer.
|
|
217
|
+
*/
|
|
218
|
+
const IS_ENABLED_ANSWER_STATUSES = [0, 1];
|
|
219
|
+
const IS_ACTIVE_ANSWER_STATUSES = [0, 3];
|
|
220
|
+
/** Set once so a relative XDG_CONFIG_HOME is reported on the first use only. */
|
|
221
|
+
let warnedRelativeXdg = false;
|
|
222
|
+
/** `$XDG_CONFIG_HOME/systemd/user`, defaulting to `~/.config/systemd/user`. */
|
|
223
|
+
function systemdUserDir() {
|
|
224
|
+
const configHome = process.env.XDG_CONFIG_HOME;
|
|
225
|
+
if (configHome && isAbsolute(configHome)) {
|
|
226
|
+
return join(configHome, 'systemd', 'user');
|
|
197
227
|
}
|
|
198
|
-
|
|
199
|
-
resolved
|
|
228
|
+
if (configHome && !warnedRelativeXdg) {
|
|
229
|
+
// The XDG spec requires relative values to be ignored, not resolved against the cwd.
|
|
230
|
+
warnedRelativeXdg = true;
|
|
231
|
+
logger.warn('Ignoring relative XDG_CONFIG_HOME=%s; using %s instead.', configHome, join(homedir(), '.config'));
|
|
200
232
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
233
|
+
return join(homedir(), '.config', 'systemd', 'user');
|
|
234
|
+
}
|
|
235
|
+
function systemdUnitPath() {
|
|
236
|
+
return join(systemdUserDir(), SYSTEMD_UNIT_NAME);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Command for `ExecStart`. systemd resolves a bare command name only in
|
|
240
|
+
* /usr/local/bin, /usr/bin, /bin and /sbin — not in the PATH of the shell that
|
|
241
|
+
* ran `install` — so an absolute path is mandatory.
|
|
242
|
+
*/
|
|
243
|
+
function resolveSystemdCommand() {
|
|
244
|
+
const viaDist = distEntryPath();
|
|
245
|
+
if (!existsSync(viaDist)) {
|
|
246
|
+
throw new Error(`cannot find ${viaDist}; run \`npm run build\` before installing the systemd unit`);
|
|
247
|
+
}
|
|
248
|
+
return `"${process.execPath}" "${viaDist}"`;
|
|
249
|
+
}
|
|
250
|
+
/** Build the unit file contents. Exported for testing. */
|
|
251
|
+
export function buildSystemdUnit(port) {
|
|
252
|
+
const portArg = port ? ` --port ${port}` : '';
|
|
253
|
+
return [
|
|
254
|
+
'[Unit]',
|
|
255
|
+
'Description=Saros proxy',
|
|
256
|
+
'After=network-online.target',
|
|
257
|
+
'Wants=network-online.target',
|
|
258
|
+
'StartLimitIntervalSec=60',
|
|
259
|
+
'StartLimitBurst=3',
|
|
260
|
+
'',
|
|
261
|
+
'[Service]',
|
|
262
|
+
'Type=simple',
|
|
263
|
+
// The journal keeps the JSON lines; pino-pretty only runs outside production.
|
|
264
|
+
'Environment=NODE_ENV=production',
|
|
265
|
+
`ExecStart=${resolveSystemdCommand()} serve${portArg}`,
|
|
266
|
+
'Restart=on-failure',
|
|
267
|
+
'RestartSec=5',
|
|
268
|
+
'',
|
|
269
|
+
'[Install]',
|
|
270
|
+
'WantedBy=default.target',
|
|
271
|
+
'',
|
|
272
|
+
].join('\n');
|
|
273
|
+
}
|
|
274
|
+
/** Run `systemctl --user …`, returning trimmed stdout. Throws on failure. */
|
|
275
|
+
function runSystemctl(args) {
|
|
276
|
+
return execFileSync('systemctl', ['--user', ...args], {
|
|
277
|
+
stdio: 'pipe',
|
|
278
|
+
timeout: SYSTEMCTL_TIMEOUT_MS,
|
|
279
|
+
}).toString().trim();
|
|
280
|
+
}
|
|
281
|
+
/** Explain why systemctl failed in a way the CLI can print verbatim. */
|
|
282
|
+
function describeSystemctlError(err) {
|
|
283
|
+
const execError = err;
|
|
284
|
+
if (execError.code === 'ENOENT') {
|
|
285
|
+
return '`systemctl` was not found on PATH';
|
|
286
|
+
}
|
|
287
|
+
const stderr = execError.stderr?.toString().trim().split('\n')[0];
|
|
288
|
+
if (stderr)
|
|
289
|
+
return stderr;
|
|
290
|
+
return execError.message ?? String(err);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Run a read-only systemctl query. Classifies by exit status only: stderr is
|
|
294
|
+
* localised (LANG=pt_BR translates "could not be found"), so it is kept for
|
|
295
|
+
* display and never inspected to decide whether systemd answered.
|
|
296
|
+
*/
|
|
297
|
+
function querySystemctl(args) {
|
|
298
|
+
try {
|
|
299
|
+
return { output: runSystemctl(args) };
|
|
300
|
+
}
|
|
301
|
+
catch (err) {
|
|
302
|
+
const execError = err;
|
|
303
|
+
const output = execError.stdout?.toString().trim() ?? '';
|
|
304
|
+
if (execError.code === 'ENOENT') {
|
|
305
|
+
return { output, reason: describeSystemctlError(err) };
|
|
215
306
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
307
|
+
const answerStatuses = args[0] === 'is-active'
|
|
308
|
+
? IS_ACTIVE_ANSWER_STATUSES
|
|
309
|
+
: IS_ENABLED_ANSWER_STATUSES;
|
|
310
|
+
if (typeof execError.status === 'number' && answerStatuses.includes(execError.status)) {
|
|
311
|
+
return { output };
|
|
219
312
|
}
|
|
313
|
+
return { output, reason: describeSystemctlError(err) };
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function systemdInstall(port) {
|
|
317
|
+
const unitPath = systemdUnitPath();
|
|
318
|
+
let unit;
|
|
319
|
+
try {
|
|
320
|
+
unit = buildSystemdUnit(port);
|
|
321
|
+
}
|
|
322
|
+
catch (err) {
|
|
323
|
+
logger.warn('Cannot install the systemd autostart unit: %s', err.message);
|
|
324
|
+
process.exitCode = 1;
|
|
325
|
+
return;
|
|
220
326
|
}
|
|
221
|
-
|
|
327
|
+
try {
|
|
328
|
+
mkdirSync(systemdUserDir(), { recursive: true });
|
|
329
|
+
writeFileSync(unitPath, unit, 'utf-8');
|
|
330
|
+
}
|
|
331
|
+
catch (err) {
|
|
332
|
+
logger.warn('Could not write the systemd unit file at %s: %s', unitPath, describeSystemctlError(err));
|
|
333
|
+
process.exitCode = 1;
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
try {
|
|
337
|
+
runSystemctl(['daemon-reload']);
|
|
338
|
+
runSystemctl(['enable', SYSTEMD_UNIT_NAME]);
|
|
339
|
+
// `enable --now` is a no-op start for an active unit, so a reinstall with a
|
|
340
|
+
// new --port would keep the old process. `restart` covers active and inactive.
|
|
341
|
+
runSystemctl(['restart', SYSTEMD_UNIT_NAME]);
|
|
342
|
+
}
|
|
343
|
+
catch (err) {
|
|
344
|
+
logger.warn('systemd autostart could not be enabled or started: %s. The unit file is at %s; check that `systemctl --user` works on this host (containers and WSL without systemd do not provide it).', describeSystemctlError(err), unitPath);
|
|
345
|
+
process.exitCode = 1;
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
ui.success(`Auto-start installed via systemd --user: ${unitPath}`);
|
|
349
|
+
}
|
|
350
|
+
function systemdUninstall() {
|
|
351
|
+
const unitPath = systemdUnitPath();
|
|
352
|
+
if (!existsSync(unitPath)) {
|
|
353
|
+
console.log('No systemd auto-start entry found.');
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
try {
|
|
357
|
+
runSystemctl(['disable', '--now', SYSTEMD_UNIT_NAME]);
|
|
358
|
+
}
|
|
359
|
+
catch (err) {
|
|
360
|
+
// Deleting the unit while the enable symlink survives leaves
|
|
361
|
+
// default.target.wants/saros-proxy.service dangling: the next login logs
|
|
362
|
+
// "Failed to load" and `is-enabled` still answers enabled. Keep it so the
|
|
363
|
+
// user can retry.
|
|
364
|
+
logger.warn('Could not disable the systemd unit: %s. The unit file was kept at %s; run `systemctl --user disable --now %s` and retry the uninstall.', describeSystemctlError(err).replace(/\.$/, ''), unitPath, SYSTEMD_UNIT_NAME);
|
|
365
|
+
process.exitCode = 1;
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
rmSync(unitPath, { force: true });
|
|
369
|
+
try {
|
|
370
|
+
runSystemctl(['daemon-reload']);
|
|
371
|
+
}
|
|
372
|
+
catch (err) {
|
|
373
|
+
logger.warn('The systemd unit file was removed, but `daemon-reload` failed: %s', describeSystemctlError(err));
|
|
374
|
+
}
|
|
375
|
+
console.log(`Auto-start removed: ${unitPath}`);
|
|
376
|
+
}
|
|
377
|
+
function systemdStatus() {
|
|
378
|
+
const enabled = querySystemctl(['is-enabled', SYSTEMD_UNIT_NAME]);
|
|
379
|
+
const active = querySystemctl(['is-active', SYSTEMD_UNIT_NAME]);
|
|
380
|
+
const reason = enabled.reason ?? active.reason;
|
|
381
|
+
if (reason) {
|
|
382
|
+
logger.warn('Cannot determine systemd autostart status: %s', reason);
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
if (enabled.output === 'enabled' || active.output === 'active') {
|
|
386
|
+
console.log(`Auto-start is enabled (systemd). Unit: ${systemdUnitPath()}`);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
console.log('Auto-start is not installed (systemd).');
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
// ---------------------------------------------------------------------------
|
|
393
|
+
// Platform dispatch
|
|
394
|
+
// ---------------------------------------------------------------------------
|
|
395
|
+
/** Platform that implements a method. */
|
|
396
|
+
function methodPlatform(method) {
|
|
397
|
+
return method === 'systemd' ? 'Linux' : 'Windows';
|
|
398
|
+
}
|
|
399
|
+
/** A method exists only on the platform that implements it. */
|
|
400
|
+
function isMethodSupported(method, platform = process.platform) {
|
|
401
|
+
if (method === 'systemd')
|
|
402
|
+
return platform === 'linux';
|
|
403
|
+
return platform === 'win32';
|
|
404
|
+
}
|
|
405
|
+
function isExplicitMethod(method) {
|
|
406
|
+
return method === 'vbs' || method === 'registry' || method === 'systemd';
|
|
407
|
+
}
|
|
408
|
+
/** Warn (never silently succeed) when this platform has no implementation. */
|
|
409
|
+
function reportUnsupported(action, method) {
|
|
410
|
+
const alternative = process.platform === 'darwin'
|
|
411
|
+
? 'On macOS, create a launchd LaunchAgent or start `saros-proxy serve` from a login item.'
|
|
412
|
+
: 'Start `saros-proxy serve` manually or use the platform login mechanism.';
|
|
413
|
+
if (method && method !== 'auto') {
|
|
414
|
+
logger.warn(`Autostart method ${JSON.stringify(method)} is ${methodPlatform(method)}-only; this host runs ${process.platform}, so ${action} does nothing. ${alternative}`);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
logger.warn('Autostart is unsupported on %s; %s does nothing. %s', process.platform, action, alternative);
|
|
418
|
+
}
|
|
419
|
+
async function resolveInstallMethod(method) {
|
|
420
|
+
if (isExplicitMethod(method)) {
|
|
421
|
+
return {
|
|
422
|
+
resolved: isMethodSupported(method) ? method : 'unsupported',
|
|
423
|
+
prompted: false,
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
if (method === 'auto' || process.platform !== 'win32') {
|
|
427
|
+
return { resolved: resolveMethod(method), prompted: false };
|
|
428
|
+
}
|
|
429
|
+
// Windows without an explicit method: let the user pick.
|
|
430
|
+
if (!process.stdin.isTTY) {
|
|
431
|
+
ui.warn('No --method specified and stdin is not a TTY. Using auto-detect. Pass --method <vbs|registry|auto> to skip this.');
|
|
432
|
+
return { resolved: resolveMethod(undefined), prompted: false };
|
|
433
|
+
}
|
|
434
|
+
ui.intro('Saros — Autostart');
|
|
435
|
+
const choice = ui.assertNotCancelled(await ui.select({
|
|
436
|
+
message: 'Choose an autostart method',
|
|
437
|
+
options: [
|
|
438
|
+
{ value: 'registry', label: 'Windows Registry', hint: 'recommended' },
|
|
439
|
+
{ value: 'vbs', label: 'VBScript in Startup folder', hint: 'lighter, may trigger AV' },
|
|
440
|
+
{ value: 'auto', label: 'Detect automatically', hint: 'picks based on AV detection' },
|
|
441
|
+
],
|
|
442
|
+
}));
|
|
443
|
+
return { resolved: resolveMethod(choice), prompted: true };
|
|
444
|
+
}
|
|
445
|
+
// ---------------------------------------------------------------------------
|
|
446
|
+
// Public API
|
|
447
|
+
// ---------------------------------------------------------------------------
|
|
448
|
+
export async function autostartInstall(port, method) {
|
|
449
|
+
const { resolved, prompted } = await resolveInstallMethod(method);
|
|
450
|
+
if (resolved === 'unsupported') {
|
|
451
|
+
reportUnsupported('install', method);
|
|
452
|
+
process.exitCode = 1;
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (resolved === 'systemd') {
|
|
456
|
+
systemdInstall(port);
|
|
457
|
+
}
|
|
458
|
+
else if (resolved === 'registry') {
|
|
222
459
|
registryInstall(port);
|
|
223
460
|
}
|
|
224
461
|
else {
|
|
225
462
|
vbsInstall(port);
|
|
226
463
|
}
|
|
227
|
-
if (
|
|
464
|
+
if (prompted) {
|
|
228
465
|
ui.outro('Autostart configured');
|
|
229
466
|
}
|
|
230
467
|
}
|
|
231
468
|
export function autostartUninstall(method) {
|
|
232
|
-
if (method
|
|
233
|
-
|
|
469
|
+
if (isExplicitMethod(method)) {
|
|
470
|
+
if (!isMethodSupported(method)) {
|
|
471
|
+
reportUnsupported('uninstall', method);
|
|
472
|
+
process.exitCode = 1;
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
if (method === 'systemd')
|
|
476
|
+
systemdUninstall();
|
|
477
|
+
else if (method === 'vbs')
|
|
478
|
+
vbsUninstall();
|
|
479
|
+
else
|
|
480
|
+
registryUninstall();
|
|
481
|
+
return;
|
|
234
482
|
}
|
|
235
|
-
|
|
236
|
-
|
|
483
|
+
if (process.platform === 'linux') {
|
|
484
|
+
systemdUninstall();
|
|
237
485
|
}
|
|
238
|
-
else {
|
|
239
|
-
// Unspecified — clean up both
|
|
486
|
+
else if (process.platform === 'win32') {
|
|
487
|
+
// Unspecified — clean up both Windows entries
|
|
240
488
|
vbsUninstall();
|
|
241
489
|
registryUninstall();
|
|
242
490
|
}
|
|
491
|
+
else {
|
|
492
|
+
reportUnsupported('uninstall');
|
|
493
|
+
process.exitCode = 1;
|
|
494
|
+
}
|
|
243
495
|
}
|
|
244
496
|
export function autostartStatus(method) {
|
|
245
|
-
if (method
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const match = content.match(/start\s*--port\s+(\d+)/);
|
|
250
|
-
const portInfo = match?.[1] ? ` on port ${match[1]}` : '';
|
|
251
|
-
console.log(`Auto-start is enabled (VBS)${portInfo}. File: ${path}`);
|
|
497
|
+
if (isExplicitMethod(method)) {
|
|
498
|
+
if (!isMethodSupported(method)) {
|
|
499
|
+
reportUnsupported('status', method);
|
|
500
|
+
return;
|
|
252
501
|
}
|
|
253
|
-
|
|
254
|
-
|
|
502
|
+
if (method === 'systemd') {
|
|
503
|
+
systemdStatus();
|
|
255
504
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (registryStatus()) {
|
|
505
|
+
else if (method === 'vbs') {
|
|
506
|
+
vbsStatus();
|
|
507
|
+
}
|
|
508
|
+
else if (registryStatus()) {
|
|
260
509
|
console.log(`Auto-start is enabled (Registry). Key: ${REG_RUN_KEY}\\${REG_VALUE_NAME}`);
|
|
261
510
|
}
|
|
262
511
|
else {
|
|
@@ -264,7 +513,15 @@ export function autostartStatus(method) {
|
|
|
264
513
|
}
|
|
265
514
|
return;
|
|
266
515
|
}
|
|
267
|
-
|
|
516
|
+
if (process.platform === 'linux') {
|
|
517
|
+
systemdStatus();
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (process.platform !== 'win32') {
|
|
521
|
+
reportUnsupported('status');
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
// Check both Windows entries
|
|
268
525
|
const vbs = vbsExists();
|
|
269
526
|
const reg = registryStatus();
|
|
270
527
|
if (vbs || reg) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autostart.js","sourceRoot":"","sources":["../../src/cli/autostart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAQ9B,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,WAAW,GAAG,yDAAyD,CAAC;AAC9E,MAAM,cAAc,GAAG,aAAa,CAAC;AAErC,2EAA2E;AAC3E,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,SAAS,EAAQ,cAAc;IAC/B,eAAe,EAAE,cAAc;IAC/B,QAAQ,EAAS,cAAc;IAC/B,UAAU,EAAO,SAAS;IAC1B,IAAI,EAAa,SAAS;IAC1B,KAAK,EAAY,YAAY;IAC7B,SAAS,EAAQ,QAAQ;IACzB,cAAc,EAAG,QAAQ;IACzB,QAAQ,EAAS,SAAS;IAC1B,OAAO,EAAU,SAAS;IAC1B,MAAM,EAAW,OAAO;IACxB,MAAM,EAAW,OAAO;IACxB,OAAO,EAAU,MAAM;IACvB,QAAQ,EAAS,MAAM;CACxB,CAAC,CAAC;AAEH,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,uFAAuF;AACvF,SAAS,iBAAiB;IACxB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,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S,EAAE,CAAC;YACzB,aAAa,EAAE,CAAC;QAClB,CAAC;aAAM,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;YAC5B,SAAS,EAAE,CAAC;QACd,CAAC;aAAM,IAAI,cAAc,EAAE,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,0CAA0C,WAAW,KAAK,cAAc,EAAE,CAAC,CAAC;QAC1F,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QACzD,CAAC;QACD,OAAO;IACT,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,aAAa,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAC5B,OAAO;IACT,CAAC;IAED,6BAA6B;IAC7B,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;IACxB,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;IAC7B,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACtC,IAAI,GAAG;YAAE,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,EAAE,CAAC,CAAC;QAC5C,IAAI,GAAG;YAAE,OAAO,CAAC,GAAG,CAAC,eAAe,WAAW,KAAK,cAAc,EAAE,CAAC,CAAC;IACxE,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC"}
|
package/dist/cli/daemon.js
CHANGED
|
@@ -27,7 +27,9 @@ import { resolve as pathResolve, join as pathJoin, relative as pathRelative, isA
|
|
|
27
27
|
import { homedir } from 'node:os';
|
|
28
28
|
import { fileURLToPath } from 'node:url';
|
|
29
29
|
import { getModelsJsonPath } from './opencode-config.js';
|
|
30
|
+
import { mergeMissingModels, parseCatalogObject, serializeCatalogObject } from '../models-catalog.js';
|
|
30
31
|
import { formatKeyBlock } from './key-state.js';
|
|
32
|
+
import { logger } from '../logger.js';
|
|
31
33
|
import { checkForUpdate } from './update-check.js';
|
|
32
34
|
import { loadConfig, getSarosDir } from '../config.js';
|
|
33
35
|
import { DAEMON_SYNC_TIMEOUT_MS } from '../constants.js';
|
|
@@ -381,21 +383,77 @@ function readLogSince(offset) {
|
|
|
381
383
|
}
|
|
382
384
|
/**
|
|
383
385
|
* Ensure models.json exists at ~/.config/saros/models.json.
|
|
384
|
-
*
|
|
386
|
+
*
|
|
387
|
+
* A missing file is seeded from the bundle. An existing file is the user's:
|
|
388
|
+
* a value they customized is never overwritten, but bundle keys they lack are
|
|
389
|
+
* added so an installation created before a catalog refresh still gets the new
|
|
390
|
+
* models. An unparseable file is backed up to models.json.corrupt and
|
|
391
|
+
* re-seeded — it used to be kept forever while the CLI silently fell back to
|
|
392
|
+
* the bundled catalog.
|
|
385
393
|
*/
|
|
386
394
|
function ensureModelsJson() {
|
|
387
395
|
const modelsPath = getModelsJsonPath();
|
|
388
396
|
if (!assertStateDir(modelsPath, 'write'))
|
|
389
397
|
return;
|
|
390
|
-
const
|
|
391
|
-
if (!existsSync(
|
|
392
|
-
|
|
398
|
+
const bundledPath = pathJoin(PACKAGE_ROOT, 'assets', 'models.json');
|
|
399
|
+
if (!existsSync(bundledPath))
|
|
400
|
+
return;
|
|
401
|
+
let bundledContent;
|
|
402
|
+
let bundled;
|
|
403
|
+
try {
|
|
404
|
+
bundledContent = readFileSync(bundledPath, 'utf-8');
|
|
405
|
+
bundled = parseCatalogObject(bundledContent);
|
|
406
|
+
}
|
|
407
|
+
catch (err) {
|
|
408
|
+
// A damaged bundle (build defect, disk error) must not become an unhandled
|
|
409
|
+
// rejection after "✓ Proxy started": that exits 1 and skips the harness
|
|
410
|
+
// sync and the update check while the detached proxy keeps running. Warn
|
|
411
|
+
// and skip the seed; the runtime already handles a missing catalog.
|
|
412
|
+
logger.warn({ err, path: bundledPath }, 'models.json: could not read or parse the bundled catalog; skipping the seed');
|
|
413
|
+
return;
|
|
393
414
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
415
|
+
if (!existsSync(modelsPath)) {
|
|
416
|
+
mkdirSync(pathDirname(modelsPath), { recursive: true });
|
|
417
|
+
writeModelsFile(modelsPath, bundledContent);
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
const raw = readModelsFile(modelsPath);
|
|
421
|
+
if (raw === null)
|
|
422
|
+
return;
|
|
423
|
+
let existing;
|
|
424
|
+
try {
|
|
425
|
+
existing = parseCatalogObject(raw);
|
|
398
426
|
}
|
|
427
|
+
catch {
|
|
428
|
+
const backupPath = `${modelsPath}.corrupt`;
|
|
429
|
+
copyFileSync(modelsPath, backupPath);
|
|
430
|
+
writeModelsFile(modelsPath, bundledContent);
|
|
431
|
+
console.warn(chalk.yellow(`⚠ models.json is not a valid catalog; backed it up to ${backupPath} and re-seeded from the bundle`));
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
const merged = mergeMissingModels(existing, bundled);
|
|
435
|
+
if (merged.added.length === 0) {
|
|
436
|
+
console.log(chalk.dim('models.json already present, keeping the user copy'));
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
writeModelsFile(modelsPath, serializeCatalogObject(merged.models));
|
|
440
|
+
console.log(chalk.dim(`models.json: added ${merged.added.length} missing models from the bundle`));
|
|
441
|
+
}
|
|
442
|
+
/** Read models.json; a read error leaves the file alone instead of replacing it. */
|
|
443
|
+
function readModelsFile(modelsPath) {
|
|
444
|
+
try {
|
|
445
|
+
return readFileSync(modelsPath, 'utf-8');
|
|
446
|
+
}
|
|
447
|
+
catch {
|
|
448
|
+
console.warn(chalk.yellow('⚠ could not read models.json; keeping it as is'));
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
/** Write a catalog atomically: temp file beside it, then rename. */
|
|
453
|
+
function writeModelsFile(modelsPath, content) {
|
|
454
|
+
const tempPath = `${modelsPath}.tmp`;
|
|
455
|
+
writeFileSync(tempPath, content, 'utf-8');
|
|
456
|
+
renameSync(tempPath, modelsPath);
|
|
399
457
|
}
|
|
400
458
|
// ---------------------------------------------------------------------------
|
|
401
459
|
// Process management
|