sideby 0.27.0 → 0.28.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/ai-tasks.json +14 -0
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.js +14 -7
- package/dist/src/cli/json-schemas.js +4 -1
- package/dist/src/cli/main.js +7 -5
- package/dist/src/core/ask.js +2 -1
- package/dist/src/core/autostart.d.ts +22 -1
- package/dist/src/core/autostart.js +188 -17
- package/dist/src/core/egress.d.ts +5 -2
- package/dist/src/core/egress.js +7 -4
- package/dist/src/core/skill-check.d.ts +5 -0
- package/dist/src/core/skill-check.js +7 -1
- package/dist/src/core/update.d.ts +2 -3
- package/dist/src/core/update.js +39 -40
- package/dist/src/core/version.d.ts +8 -0
- package/dist/src/core/version.js +34 -0
- package/dist/src/panel/handler.d.ts +1 -0
- package/dist/src/panel/handler.js +1 -0
- package/dist/src/panel/i18n.d.ts +9 -0
- package/dist/src/panel/i18n.js +20 -2
- package/dist/src/panel/page-logic.d.ts +3 -1
- package/dist/src/panel/page-logic.js +12 -0
- package/dist/src/panel/page-script.js +19 -5
- package/package.json +1 -1
- package/schemas/autostart.json +17 -0
- package/schemas/menubar.json +17 -0
- package/skills/sideby/SKILL.md +1 -1
- package/skills/sideby/references/ai-tasks.md +1 -1
- package/skills/sideby/references/panel.md +1 -1
- package/skills/sideby/references/update.md +3 -2
package/ai-tasks.json
CHANGED
|
@@ -142,6 +142,20 @@
|
|
|
142
142
|
{ "en": "Allow only my Japan and Singapore nodes", "zh": "只允许日本和新加坡节点" },
|
|
143
143
|
{ "en": "A message was blocked; help me check the proxy", "zh": "消息被拦了,帮我查查代理" }
|
|
144
144
|
]
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"id": "update",
|
|
148
|
+
"native": true,
|
|
149
|
+
"title": { "en": "Let AI fix the update", "zh": "让 AI 帮我更新" },
|
|
150
|
+
"placeholder": {
|
|
151
|
+
"en": "Anything to add? For example: I use a proxy",
|
|
152
|
+
"zh": "想补充什么?比如:我要走代理才能上网"
|
|
153
|
+
},
|
|
154
|
+
"examples": [
|
|
155
|
+
{ "en": "I am behind a proxy", "zh": "我上网要走代理" },
|
|
156
|
+
{ "en": "Use a registry mirror in China", "zh": "在国内,帮我换成镜像源" },
|
|
157
|
+
{ "en": "It says it cannot update itself here", "zh": "提示这里不能自己更新" }
|
|
158
|
+
]
|
|
145
159
|
}
|
|
146
160
|
]
|
|
147
161
|
}
|
package/dist/build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"20261028T132743-ee8214"}
|
package/dist/src/cli/commands.js
CHANGED
|
@@ -1532,6 +1532,8 @@ export async function cmdUi(a, io) {
|
|
|
1532
1532
|
io.err(c.red(`✗ could not stop the background panel: ${r.detail}`));
|
|
1533
1533
|
return r.status === 'failed' ? 1 : 0;
|
|
1534
1534
|
}
|
|
1535
|
+
if (a.flags.has('wait') && !a.flags.has('background'))
|
|
1536
|
+
throw new UsageError('--wait goes with --background: sideby ui --background --wait');
|
|
1535
1537
|
if (a.flags.has(bg.DETACHED_FLAG))
|
|
1536
1538
|
return bg.serveDetached({
|
|
1537
1539
|
paths,
|
|
@@ -1553,6 +1555,10 @@ export async function cmdUi(a, io) {
|
|
|
1553
1555
|
: `sideby panel: ${r.url} (in the background${r.replaced ? ', replacing the one from an older sideby' : ''}; stop it with \`sideby ui --stop\`)`);
|
|
1554
1556
|
if (!a.flags.has('no-open') && !(await openBrowser(r.url)))
|
|
1555
1557
|
io.out(`open ${r.url} in your browser`);
|
|
1558
|
+
// Under WSL the Startup script's `wsl.exe` waits here, so WSL keeps the distribution (and the Panel) up (ADR-0055).
|
|
1559
|
+
if (a.flags.has('wait'))
|
|
1560
|
+
while ((await bg.backgroundPanelPort(paths)) !== null)
|
|
1561
|
+
await new Promise((r) => setTimeout(r, 30_000));
|
|
1556
1562
|
return 0;
|
|
1557
1563
|
}
|
|
1558
1564
|
const srv = await startPanelServer({
|
|
@@ -2470,7 +2476,7 @@ export async function cmdTry(a, io) {
|
|
|
2470
2476
|
}
|
|
2471
2477
|
/** `sideby autostart [on|off] [--yes]` (spec §3.29, ADR-0029): start the Panel in the background at login. */
|
|
2472
2478
|
export async function cmdAutostart(a, io) {
|
|
2473
|
-
const { applyAutostart, autostartStatus, planAutostart, refreshAutostart } = await import('../core/autostart.js');
|
|
2479
|
+
const { applyAutostart, autostartStatus, autostartWhen, planAutostart, refreshAutostart } = await import('../core/autostart.js');
|
|
2474
2480
|
const [action, extra] = a.positionals;
|
|
2475
2481
|
if (extra !== undefined || (action !== undefined && action !== 'on' && action !== 'off'))
|
|
2476
2482
|
throw new UsageError('usage: sideby autostart [on|off] [--yes] [--json]');
|
|
@@ -2502,13 +2508,13 @@ export async function cmdAutostart(a, io) {
|
|
|
2502
2508
|
else if (!s.supported)
|
|
2503
2509
|
io.out(`${s.reason}.`);
|
|
2504
2510
|
else if (s.state === 'off')
|
|
2505
|
-
io.out(
|
|
2511
|
+
io.out(`Off: sideby does not start ${autostartWhen(s.mechanism)}. Turn it on: sideby autostart on`);
|
|
2506
2512
|
else if (s.state === 'foreign')
|
|
2507
2513
|
io.out(`${tilde(s.path, home)} is not sideby's, so sideby leaves it alone; remove or rename it yourself if it is not needed.`);
|
|
2508
2514
|
else if (s.state === 'stale')
|
|
2509
2515
|
io.out(`Out of date: the login item starts ${s.missing.join(' and ')}, which no longer exists. Run \`sideby autostart on\` to point it at this sideby.`);
|
|
2510
2516
|
else {
|
|
2511
|
-
io.out(
|
|
2517
|
+
io.out(`On: the panel starts in the background ${autostartWhen(s.mechanism)}, without opening a window.`);
|
|
2512
2518
|
if (!s.current)
|
|
2513
2519
|
io.out(c.dim('It starts another sideby than this one; `sideby autostart on` points it here.'));
|
|
2514
2520
|
io.out(c.dim('Turn it off: sideby autostart off'));
|
|
@@ -2546,9 +2552,10 @@ export async function cmdAutostart(a, io) {
|
|
|
2546
2552
|
}
|
|
2547
2553
|
else
|
|
2548
2554
|
io.out(`Removes ${tilde(plan.path, home)}.`);
|
|
2549
|
-
|
|
2555
|
+
if (plan.commands.length)
|
|
2556
|
+
io.out(`Then runs: ${plan.commands.map((cmd) => cmd.join(' ')).join('; ')}`);
|
|
2550
2557
|
io.out(action === 'on'
|
|
2551
|
-
?
|
|
2558
|
+
? `Then the panel starts in the background ${autostartWhen(plan.status.mechanism)}, without opening a window. Run again with --yes to turn it on.`
|
|
2552
2559
|
: 'Run again with --yes to turn it off.');
|
|
2553
2560
|
}
|
|
2554
2561
|
return 10;
|
|
@@ -2564,8 +2571,8 @@ export async function cmdAutostart(a, io) {
|
|
|
2564
2571
|
});
|
|
2565
2572
|
else {
|
|
2566
2573
|
io.out(action === 'on'
|
|
2567
|
-
?
|
|
2568
|
-
:
|
|
2574
|
+
? `On: the panel starts in the background ${autostartWhen(plan.status.mechanism)}. Undo: sideby autostart off`
|
|
2575
|
+
: `Off: sideby no longer starts ${autostartWhen(plan.status.mechanism)}.`);
|
|
2569
2576
|
if (r.note)
|
|
2570
2577
|
io.out(c.dim(r.note));
|
|
2571
2578
|
}
|
|
@@ -22,7 +22,7 @@ const hotkeyProps = {
|
|
|
22
22
|
problem: Type.Optional(Type.Object({ code: Str, message: Str }, { description: 'A value config allows but a new choice would be refused for; it still works.' })),
|
|
23
23
|
};
|
|
24
24
|
const MenubarHotkeyView = Type.Object(hotkeyProps);
|
|
25
|
-
/** `sideby autostart` and `sideby menubar` (ADR-0029, ADR-0034):
|
|
25
|
+
/** `sideby autostart` and `sideby menubar` (ADR-0029, ADR-0034, ADR-0055): the login item sideby writes. */
|
|
26
26
|
const loginItem = (current) => Type.Object({
|
|
27
27
|
schemaVersion: Version,
|
|
28
28
|
supported: Type.Boolean({
|
|
@@ -33,6 +33,9 @@ const loginItem = (current) => Type.Object({
|
|
|
33
33
|
description: '`stale`: the Node or sideby it starts no longer exists; `foreign`: a file at that path that sideby did not write.',
|
|
34
34
|
}),
|
|
35
35
|
path: Str,
|
|
36
|
+
mechanism: Type.Optional(Type.Union(['launchd', 'xdg', 'wsl-startup'].map((k) => Type.Literal(k)), {
|
|
37
|
+
description: 'How it starts at login: a LaunchAgent (macOS), an XDG autostart entry (Linux desktop sessions), or a script in the Windows Startup folder (WSL). Absent when unsupported.',
|
|
38
|
+
})),
|
|
36
39
|
programArguments: Type.Optional(Type.Array(Str)),
|
|
37
40
|
current: Type.Boolean({ description: current }),
|
|
38
41
|
missing: Type.Optional(Type.Array(Str)),
|
package/dist/src/cli/main.js
CHANGED
|
@@ -118,8 +118,8 @@ Usage:
|
|
|
118
118
|
sideby plugins new <id> create a local Family Plugin skeleton
|
|
119
119
|
sideby plugins check <id|path> check a plugin and show fixes
|
|
120
120
|
sideby update [--yes] update sideby to the newest version (shows the command first)
|
|
121
|
-
sideby autostart [on|off] [--yes] start the panel in the background at login (macOS
|
|
122
|
-
file first)
|
|
121
|
+
sideby autostart [on|off] [--yes] start the panel in the background at login (macOS, Linux, WSL;
|
|
122
|
+
shows the file first)
|
|
123
123
|
sideby menubar [on|off] [--yes] show quota in the macOS menu bar; click an account to start it
|
|
124
124
|
sideby menubar hotkey [<keys>|off] show or change the shortcut that opens that menu (⌥X)
|
|
125
125
|
sideby theme [list] the Panel's Themes; use <name> switches, use --undo goes back, use default clears
|
|
@@ -365,8 +365,10 @@ malformed command line.`,
|
|
|
365
365
|
autostart: `sideby autostart [on|off] [--yes] [--json]
|
|
366
366
|
|
|
367
367
|
Start the panel in the background when you log in, so it already shows fresh quota when you open it. It never
|
|
368
|
-
opens a window or a browser and never starts a host.
|
|
369
|
-
~/Library/LaunchAgents/dev.sideby.panel.plist,
|
|
368
|
+
opens a window or a browser and never starts a host. It starts this Node and this sideby with ui --background:
|
|
369
|
+
on macOS from a LaunchAgent (~/Library/LaunchAgents/dev.sideby.panel.plist), on Linux from an autostart entry
|
|
370
|
+
(~/.config/autostart/dev.sideby.panel.desktop, run by desktop sessions), and under WSL from sideby-panel.vbs in
|
|
371
|
+
the Windows Startup folder, when you sign in to Windows.
|
|
370
372
|
|
|
371
373
|
Without on or off it says whether it is on, off, out of date (the Node or sideby it starts was moved) or blocked
|
|
372
374
|
by a file that is not sideby's. on and off show the file and the launchctl command first; --yes does it.
|
|
@@ -560,7 +562,7 @@ const COMMANDS = {
|
|
|
560
562
|
flags: ['json', 'yes', 'same-family', 'no-same-family', 'other-ai', 'no-other-ai', 'api', 'no-api'],
|
|
561
563
|
valued: ['brief', 'to', 'order', 'ai-order', 'prepare-at', 'threshold', 'wait-minutes', 'countdown'],
|
|
562
564
|
},
|
|
563
|
-
ui: { flags: ['no-open', 'background', 'stop', 'serve-detached'], valued: ['port'] },
|
|
565
|
+
ui: { flags: ['no-open', 'background', 'stop', 'serve-detached', 'wait'], valued: ['port'] },
|
|
564
566
|
app: { flags: ['json'], valued: ['url'] },
|
|
565
567
|
desktop: { flags: ['json', 'remove', 'yes'] },
|
|
566
568
|
sessions: { flags: ['json'], valued: ['as', 'lang'] },
|
package/dist/src/core/ask.js
CHANGED
|
@@ -266,7 +266,8 @@ export function taskContext(c, fail) {
|
|
|
266
266
|
k === 'quotaReason' ||
|
|
267
267
|
k === 'version' ||
|
|
268
268
|
k === 'terminalCustom' ||
|
|
269
|
-
k === 'theme'
|
|
269
|
+
k === 'theme' ||
|
|
270
|
+
k === 'updateError')
|
|
270
271
|
out[k] = str(v, `"context.${k}"`);
|
|
271
272
|
else if (k === 'terminals') {
|
|
272
273
|
if (!Array.isArray(v) || v.length > 50)
|
|
@@ -26,6 +26,10 @@ export interface LoginAgent {
|
|
|
26
26
|
environment?: (env: Env) => Record<string, string>;
|
|
27
27
|
}
|
|
28
28
|
export type AutostartState = 'off' | 'on' | 'stale' | 'foreign';
|
|
29
|
+
/** How the system starts the agent at login: launchd (macOS), an XDG autostart entry (Linux), the Windows Startup folder (WSL). */
|
|
30
|
+
export type AutostartMechanism = 'launchd' | 'xdg' | 'wsl-startup';
|
|
31
|
+
/** The Windows file name under WSL; its folder is the current Windows user's Startup folder. */
|
|
32
|
+
export declare const WSL_STARTUP_FILE = "sideby-panel.vbs";
|
|
29
33
|
/** Runs a program and resolves with its exit code and output; never rejects. */
|
|
30
34
|
export type AutostartExec = (file: string, args: readonly string[]) => Promise<{
|
|
31
35
|
code: number;
|
|
@@ -44,6 +48,13 @@ export interface AutostartContext {
|
|
|
44
48
|
env?: Env;
|
|
45
49
|
/** Waits between launchctl calls; tests pass one that returns at once. */
|
|
46
50
|
sleep?: (ms: number) => Promise<void>;
|
|
51
|
+
/** On WSL, the distribution and where Windows drives are mounted; null on other Linux. Found from the environment by default. */
|
|
52
|
+
wsl?: {
|
|
53
|
+
distro: string;
|
|
54
|
+
mount: string;
|
|
55
|
+
} | null;
|
|
56
|
+
/** On WSL, the Windows Startup folder as WSL sees it; asked from `cmd.exe` by default (only for the login home). */
|
|
57
|
+
startupDir?: string;
|
|
47
58
|
}
|
|
48
59
|
export interface AutostartStatus {
|
|
49
60
|
/** False on a system sideby cannot start at login yet; `reason` says so. */
|
|
@@ -51,6 +62,8 @@ export interface AutostartStatus {
|
|
|
51
62
|
reason?: string;
|
|
52
63
|
state: AutostartState;
|
|
53
64
|
path: string;
|
|
65
|
+
/** How it starts at login; absent when unsupported. */
|
|
66
|
+
mechanism?: AutostartMechanism;
|
|
54
67
|
/** What sideby's agent starts (absent when off or foreign). */
|
|
55
68
|
programArguments?: string[];
|
|
56
69
|
/** The agent starts this sideby with this Node. */
|
|
@@ -104,8 +117,16 @@ export declare const programArgumentsFor: (l: AskLauncher) => string[];
|
|
|
104
117
|
export declare function plistContent(args: readonly string[], agent?: LoginAgent, environment?: Record<string, string>): string;
|
|
105
118
|
/** The ProgramArguments of a file sideby wrote; null when it holds none. */
|
|
106
119
|
export declare function parseProgramArguments(content: string): string[] | null;
|
|
120
|
+
/** The mechanism for this system and agent; null when there is none. Only the Panel's agent runs outside macOS. */
|
|
121
|
+
export declare function autostartMechanism(ctx: AutostartContext, agent?: LoginAgent): AutostartMechanism | null;
|
|
122
|
+
/** The XDG autostart entry; the `sideby-args` line keeps the arguments for status. */
|
|
123
|
+
export declare function desktopContent(args: readonly string[], agent?: LoginAgent): string;
|
|
124
|
+
/** The Windows Startup script: runs `wsl.exe` with a hidden window and does not wait for it. */
|
|
125
|
+
export declare function vbsContent(args: readonly string[], distro: string, agent?: LoginAgent): string;
|
|
126
|
+
/** What turning it on means for the user, by mechanism; used by the CLI and the Panel. */
|
|
127
|
+
export declare function autostartWhen(mech: AutostartMechanism | undefined): string;
|
|
107
128
|
/** Whether a sideby agent (with the marker) is installed; reads only that one file. */
|
|
108
|
-
export declare function autostartInstalled(home: string, agent?: LoginAgent): Promise<boolean>;
|
|
129
|
+
export declare function autostartInstalled(home: string, agent?: LoginAgent, ctx?: Partial<AutostartContext>): Promise<boolean>;
|
|
109
130
|
export declare function autostartStatus(ctx: AutostartContext, agent?: LoginAgent): Promise<AutostartStatus>;
|
|
110
131
|
/** Why the agent cannot start this launcher, with what to do instead; null when it can. */
|
|
111
132
|
export declare function autostartLauncherProblem(l: AskLauncher, command?: string): Promise<{
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
// Start the Panel at login (spec §3.29, ADR-0029): a LaunchAgent on macOS
|
|
2
|
-
//
|
|
1
|
+
// Start the Panel at login (spec §3.29, ADR-0029, ADR-0055): a LaunchAgent on macOS, an XDG autostart entry on Linux,
|
|
2
|
+
// and a `.vbs` in the Windows Startup folder under WSL, each running this Node and this sideby's entry with
|
|
3
|
+
// `ui --background --no-open`. sideby writes, replaces or removes only a file that carries its marker; any other
|
|
3
4
|
// file at that path is reported and left alone. Every program runs through `AutostartContext.exec`, so tests never
|
|
4
5
|
// load a real agent.
|
|
5
6
|
import { execFile } from 'node:child_process';
|
|
6
7
|
import { mkdir, readFile, rm } from 'node:fs/promises';
|
|
7
8
|
import { tmpdir, userInfo } from 'node:os';
|
|
8
|
-
import { dirname, join } from 'node:path';
|
|
9
|
+
import { dirname, isAbsolute, join } from 'node:path';
|
|
9
10
|
import { UserError } from './errors.js';
|
|
10
11
|
import { fileHash, realpathOrNull, sha256, statOrNull, writeIfUnchanged } from './fs-safe.js';
|
|
11
12
|
import { askLauncher, launcherProblem } from './terminal.js';
|
|
13
|
+
import { toUnix } from './windows-dirs.js';
|
|
12
14
|
export const AUTOSTART_LABEL = 'dev.sideby.panel';
|
|
13
15
|
/** Present in every agent sideby writes; a file without it is someone else's. */
|
|
14
16
|
export const AUTOSTART_MARKER = 'Written by `sideby autostart`';
|
|
17
|
+
/** The Windows file name under WSL; its folder is the current Windows user's Startup folder. */
|
|
18
|
+
export const WSL_STARTUP_FILE = 'sideby-panel.vbs';
|
|
15
19
|
export const defaultExec = (file, args) => new Promise((resolve) => {
|
|
16
20
|
execFile(file, [...args], { timeout: 15_000 }, (err, stdout, stderr) => {
|
|
17
21
|
const code = err ? (typeof err.code === 'number' ? err.code : 1) : 0;
|
|
@@ -80,7 +84,127 @@ export function parseProgramArguments(content) {
|
|
|
80
84
|
return [...m[1].matchAll(/<string>([\s\S]*?)<\/string>/g)].map((s) => unxml(s[1]));
|
|
81
85
|
}
|
|
82
86
|
const platformOf = (ctx) => ctx.platform ?? process.platform;
|
|
83
|
-
const UNSUPPORTED = 'sideby
|
|
87
|
+
const UNSUPPORTED = 'sideby cannot start at login on this system yet; it can on macOS, Linux and WSL';
|
|
88
|
+
const UNSUPPORTED_AGENT = 'this login item is for macOS only';
|
|
89
|
+
function wslOf(ctx) {
|
|
90
|
+
if (ctx.wsl !== undefined)
|
|
91
|
+
return ctx.wsl;
|
|
92
|
+
const distro = (ctx.env ?? process.env).WSL_DISTRO_NAME;
|
|
93
|
+
return distro ? { distro, mount: '/mnt' } : null;
|
|
94
|
+
}
|
|
95
|
+
/** The mechanism for this system and agent; null when there is none. Only the Panel's agent runs outside macOS. */
|
|
96
|
+
export function autostartMechanism(ctx, agent = PANEL_AGENT) {
|
|
97
|
+
const platform = platformOf(ctx);
|
|
98
|
+
if (platform === 'darwin')
|
|
99
|
+
return 'launchd';
|
|
100
|
+
if (platform !== 'linux' || agent.label !== AUTOSTART_LABEL)
|
|
101
|
+
return null;
|
|
102
|
+
return wslOf(ctx) ? 'wsl-startup' : 'xdg';
|
|
103
|
+
}
|
|
104
|
+
const loginHomeOf = (ctx) => {
|
|
105
|
+
if (ctx.loginHome !== undefined)
|
|
106
|
+
return ctx.loginHome;
|
|
107
|
+
try {
|
|
108
|
+
return userInfo().homedir;
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return '';
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* The Windows Startup folder as WSL sees it, from one `cmd.exe` call. Another HOME than the login one (a demo or test
|
|
116
|
+
* HOME) gets a folder inside it instead, so it never writes into the real Windows profile.
|
|
117
|
+
*/
|
|
118
|
+
async function wslStartupDir(ctx, mount) {
|
|
119
|
+
if (ctx.startupDir)
|
|
120
|
+
return ctx.startupDir;
|
|
121
|
+
if (loginHomeOf(ctx) !== ctx.home)
|
|
122
|
+
return join(ctx.home, '.sideby-windows-startup');
|
|
123
|
+
const r = await (ctx.exec ?? defaultExec)(join(mount, 'c', 'Windows', 'System32', 'cmd.exe'), [
|
|
124
|
+
'/d',
|
|
125
|
+
'/c',
|
|
126
|
+
'echo %APPDATA%',
|
|
127
|
+
]).catch(() => null);
|
|
128
|
+
const appData = r?.code === 0 ? toUnix(r.output.trim().split(/\r?\n/)[0] ?? '', mount) : undefined;
|
|
129
|
+
return appData ? join(appData, 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup') : null;
|
|
130
|
+
}
|
|
131
|
+
/** Where the agent's file goes for this mechanism; null when Windows could not be asked. */
|
|
132
|
+
async function agentFile(ctx, agent, mech) {
|
|
133
|
+
if (mech === 'launchd')
|
|
134
|
+
return agentPath(ctx.home, agent);
|
|
135
|
+
if (mech === 'xdg') {
|
|
136
|
+
const xdg = (ctx.env ?? process.env).XDG_CONFIG_HOME;
|
|
137
|
+
const config = xdg && isAbsolute(xdg) ? xdg : join(ctx.home, '.config');
|
|
138
|
+
return join(config, 'autostart', `${agent.label}.desktop`);
|
|
139
|
+
}
|
|
140
|
+
const dir = await wslStartupDir(ctx, wslOf(ctx).mount);
|
|
141
|
+
return dir ? join(dir, WSL_STARTUP_FILE) : null;
|
|
142
|
+
}
|
|
143
|
+
/** The arguments the agent records: under WSL, `--wait` keeps `wsl.exe` attached so WSL keeps the distribution up. */
|
|
144
|
+
const wantedArguments = (agent, l, mech) => mech === 'wsl-startup' ? [...agent.programArguments(l), '--wait'] : agent.programArguments(l);
|
|
145
|
+
/** One argument of a desktop entry's `Exec` line (Desktop Entry Specification, "The Exec key"). */
|
|
146
|
+
function desktopArg(a) {
|
|
147
|
+
const q = /^[A-Za-z0-9_/.:=+,@-]+$/.test(a) ? a : `"${a.replace(/[\\"`$]/g, (m) => `\\${m}`)}"`;
|
|
148
|
+
return q.replace(/%/g, '%%');
|
|
149
|
+
}
|
|
150
|
+
/** The XDG autostart entry; the `sideby-args` line keeps the arguments for status. */
|
|
151
|
+
export function desktopContent(args, agent = PANEL_AGENT) {
|
|
152
|
+
return `[Desktop Entry]
|
|
153
|
+
# ${agent.marker}: ${agent.comment}. Turn it off with \`sideby ${agent.command} off\`.
|
|
154
|
+
# sideby-args: ${JSON.stringify(args)}
|
|
155
|
+
Type=Application
|
|
156
|
+
Name=sideby panel
|
|
157
|
+
Comment=${agent.comment}
|
|
158
|
+
Exec=${args.map(desktopArg).join(' ')}
|
|
159
|
+
Terminal=false
|
|
160
|
+
NoDisplay=true
|
|
161
|
+
X-GNOME-Autostart-enabled=true
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
/** The Windows Startup script: runs `wsl.exe` with a hidden window and does not wait for it. */
|
|
165
|
+
export function vbsContent(args, distro, agent = PANEL_AGENT) {
|
|
166
|
+
const q = (a) => `""${a}""`;
|
|
167
|
+
// `wsl.exe -d` does not unquote the distribution name (WSL 2.4.13 exits -1), so it goes bare; see `unsafeDistro`.
|
|
168
|
+
const line = `wsl.exe -d ${distro} --exec ${args.map(q).join(' ')}`;
|
|
169
|
+
return [
|
|
170
|
+
`' ${agent.marker}: ${agent.comment.replace(/ at login$/, '')} when you sign in to Windows. Turn it off with \`sideby ${agent.command} off\`.`,
|
|
171
|
+
`' sideby-args: ${JSON.stringify(args)}`,
|
|
172
|
+
`CreateObject("WScript.Shell").Run "${line}", 0, False`,
|
|
173
|
+
'',
|
|
174
|
+
].join('\r\n');
|
|
175
|
+
}
|
|
176
|
+
/** What a WSL Startup script cannot carry safely: a `"`, a `%`, or anything outside printable ASCII. */
|
|
177
|
+
const unsafeDistro = (s) => !/^[A-Za-z0-9._-]+$/.test(s);
|
|
178
|
+
const unsafeForVbs = (s) => !/^[\x20-\x7e]+$/.test(s) || /["%]/.test(s);
|
|
179
|
+
function contentFor(ctx, agent, mech, args) {
|
|
180
|
+
if (mech === 'xdg')
|
|
181
|
+
return desktopContent(args, agent);
|
|
182
|
+
if (mech === 'wsl-startup')
|
|
183
|
+
return vbsContent(args, wslOf(ctx).distro, agent);
|
|
184
|
+
return plistContent(args, agent, agent.environment?.(ctx.env ?? process.env));
|
|
185
|
+
}
|
|
186
|
+
function parseArgsFor(mech, content) {
|
|
187
|
+
if (mech === 'launchd')
|
|
188
|
+
return parseProgramArguments(content);
|
|
189
|
+
const m = /sideby-args: (\[.*\])/.exec(content);
|
|
190
|
+
if (!m)
|
|
191
|
+
return null;
|
|
192
|
+
try {
|
|
193
|
+
const v = JSON.parse(m[1]);
|
|
194
|
+
return Array.isArray(v) && v.every((x) => typeof x === 'string') ? v : null;
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/** What turning it on means for the user, by mechanism; used by the CLI and the Panel. */
|
|
201
|
+
export function autostartWhen(mech) {
|
|
202
|
+
if (mech === 'wsl-startup')
|
|
203
|
+
return 'when you sign in to Windows';
|
|
204
|
+
if (mech === 'xdg')
|
|
205
|
+
return 'when your desktop session starts';
|
|
206
|
+
return 'at login';
|
|
207
|
+
}
|
|
84
208
|
async function readAgent(path) {
|
|
85
209
|
try {
|
|
86
210
|
return await readFile(path, 'utf8');
|
|
@@ -92,20 +216,32 @@ async function readAgent(path) {
|
|
|
92
216
|
}
|
|
93
217
|
}
|
|
94
218
|
/** Whether a sideby agent (with the marker) is installed; reads only that one file. */
|
|
95
|
-
export async function autostartInstalled(home, agent = PANEL_AGENT) {
|
|
96
|
-
const
|
|
219
|
+
export async function autostartInstalled(home, agent = PANEL_AGENT, ctx = {}) {
|
|
220
|
+
const c = { ...ctx, home };
|
|
221
|
+
const mech = autostartMechanism(c, agent);
|
|
222
|
+
const path = mech ? await agentFile(c, agent, mech).catch(() => null) : null;
|
|
223
|
+
const content = path ? await readAgent(path).catch(() => null) : null;
|
|
97
224
|
return content?.includes(agent.marker) ?? false;
|
|
98
225
|
}
|
|
99
226
|
export async function autostartStatus(ctx, agent = PANEL_AGENT) {
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
227
|
+
const mech = autostartMechanism(ctx, agent);
|
|
228
|
+
const unsupported = (reason, path = agentPath(ctx.home, agent)) => ({
|
|
229
|
+
supported: false,
|
|
230
|
+
reason,
|
|
231
|
+
path,
|
|
232
|
+
current: false,
|
|
233
|
+
state: 'off',
|
|
234
|
+
});
|
|
235
|
+
if (!mech)
|
|
236
|
+
return unsupported(platformOf(ctx) === 'linux' || platformOf(ctx) === 'darwin' ? UNSUPPORTED_AGENT : UNSUPPORTED);
|
|
237
|
+
const path = await agentFile(ctx, agent, mech);
|
|
238
|
+
if (!path)
|
|
239
|
+
return unsupported('sideby could not ask Windows for your Startup folder (cmd.exe did not answer); check that WSL can run Windows programs, then try again', '');
|
|
240
|
+
const base = { supported: true, path, mechanism: mech, current: false };
|
|
105
241
|
const content = await readAgent(path);
|
|
106
242
|
if (content === null)
|
|
107
243
|
return { ...base, state: 'off' };
|
|
108
|
-
const args = content.includes(agent.marker) ?
|
|
244
|
+
const args = content.includes(agent.marker) ? parseArgsFor(mech, content) : null;
|
|
109
245
|
if (!args)
|
|
110
246
|
return { ...base, state: 'foreign' };
|
|
111
247
|
const missing = [];
|
|
@@ -113,9 +249,11 @@ export async function autostartStatus(ctx, agent = PANEL_AGENT) {
|
|
|
113
249
|
if (!(await statOrNull(p)))
|
|
114
250
|
missing.push(p);
|
|
115
251
|
const launcher = ctx.launcher ?? askLauncher();
|
|
116
|
-
const want = agent
|
|
252
|
+
const want = wantedArguments(agent, launcher, mech);
|
|
117
253
|
const current = args.length === want.length && args.every((a, i) => a === want[i]);
|
|
118
|
-
const loaded = agent.restartOnCrash && !launchctlNote(ctx)
|
|
254
|
+
const loaded = mech === 'launchd' && agent.restartOnCrash && !launchctlNote(ctx)
|
|
255
|
+
? await agentLoaded(ctx, agent)
|
|
256
|
+
: undefined;
|
|
119
257
|
return {
|
|
120
258
|
...base,
|
|
121
259
|
state: missing.length ? 'stale' : 'on',
|
|
@@ -188,15 +326,28 @@ export async function planAutostart(ctx, action, agent = PANEL_AGENT) {
|
|
|
188
326
|
message: `${path} was not written by sideby, so sideby leaves it alone; look at it, and remove or rename it yourself before \`sideby ${agent.command} ${action}\` if it is not needed`,
|
|
189
327
|
},
|
|
190
328
|
});
|
|
329
|
+
const mech = status.mechanism;
|
|
330
|
+
const launchd = mech === 'launchd';
|
|
191
331
|
if (action === 'off')
|
|
192
|
-
return status.state === 'off'
|
|
332
|
+
return status.state === 'off'
|
|
333
|
+
? plan({})
|
|
334
|
+
: plan({ changed: true, commands: launchd ? [bootout(ctx, agent)] : [] });
|
|
193
335
|
const launcher = ctx.launcher ?? askLauncher();
|
|
194
336
|
const blocked = await autostartLauncherProblem(launcher, agent.command);
|
|
195
337
|
if (blocked)
|
|
196
338
|
return plan({ blocked });
|
|
197
|
-
const programArguments = agent
|
|
198
|
-
|
|
339
|
+
const programArguments = wantedArguments(agent, launcher, mech);
|
|
340
|
+
if (mech === 'wsl-startup' && (programArguments.some(unsafeForVbs) || unsafeDistro(wslOf(ctx).distro)))
|
|
341
|
+
return plan({
|
|
342
|
+
blocked: {
|
|
343
|
+
code: 'unsafe-path',
|
|
344
|
+
message: `the path of sideby or Node, or the WSL distribution name, has a character the Windows Startup script cannot carry (\`"\`, \`%\` or a non-ASCII letter); install sideby with \`npm i -g sideby\` in an ordinary folder, then run \`sideby ${agent.command} on\` again`,
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
const content = contentFor(ctx, agent, mech, programArguments);
|
|
199
348
|
const same = hash !== null && hash === sha256(content);
|
|
349
|
+
if (!launchd)
|
|
350
|
+
return plan({ changed: !same, content, programArguments });
|
|
200
351
|
// The file alone does not start it: launchd may have let it go (a `launchctl bootout`, a failed start), and then
|
|
201
352
|
// only loading it again brings it back.
|
|
202
353
|
const loaded = !same || (status.loaded ?? (await agentLoaded(ctx, agent)));
|
|
@@ -264,6 +415,26 @@ export async function applyAutostart(ctx, plan, agent = PANEL_AGENT) {
|
|
|
264
415
|
throw new UserError(`${path} changed since sideby looked at it; nothing was changed. Run the command again`, {
|
|
265
416
|
code: 'changed',
|
|
266
417
|
});
|
|
418
|
+
if (plan.status.mechanism !== 'launchd') {
|
|
419
|
+
// An autostart entry or a Startup script: nothing to tell, it takes effect at the next login.
|
|
420
|
+
if (plan.action === 'off') {
|
|
421
|
+
await rm(path, { force: true });
|
|
422
|
+
return { changed: true, state: 'off', path, loaded: false };
|
|
423
|
+
}
|
|
424
|
+
await mkdir(dirname(path), { recursive: true, mode: 0o755 });
|
|
425
|
+
if (!(await writeIfUnchanged(path, plan.hash, plan.content, 0o644)))
|
|
426
|
+
throw new UserError(`${path} changed while sideby was writing it; nothing was changed. Run the command again`, {
|
|
427
|
+
code: 'changed',
|
|
428
|
+
});
|
|
429
|
+
return {
|
|
430
|
+
changed: true,
|
|
431
|
+
state: 'on',
|
|
432
|
+
path,
|
|
433
|
+
programArguments: plan.programArguments,
|
|
434
|
+
loaded: false,
|
|
435
|
+
note: agent.later,
|
|
436
|
+
};
|
|
437
|
+
}
|
|
267
438
|
const exec = ctx.exec ?? defaultExec;
|
|
268
439
|
const note = launchctlNote(ctx);
|
|
269
440
|
const run = async (cmd) => (note ? null : exec(cmd[0], cmd.slice(1)));
|
|
@@ -50,8 +50,11 @@ export declare function parseTrace(text: string): {
|
|
|
50
50
|
ip?: string;
|
|
51
51
|
loc?: string;
|
|
52
52
|
};
|
|
53
|
-
/**
|
|
54
|
-
|
|
53
|
+
/**
|
|
54
|
+
* One GET of an `https://` `url`, directly or through an `http://` proxy (CONNECT), as the Host would send it. The
|
|
55
|
+
* Update Check uses it too, since Node's own `fetch` does not follow the proxy variables.
|
|
56
|
+
*/
|
|
57
|
+
export declare const fetchTrace: (url: string, env: Env, timeoutMs: number, userAgent?: string) => Promise<string>;
|
|
55
58
|
export declare function readEntry(dir: string, key: string): Promise<EgressEntry | null>;
|
|
56
59
|
/** Whether `loc` passes `allow`; without a country the check could not tell. */
|
|
57
60
|
export declare function judge(entry: EgressEntry, allow: readonly string[]): EgressStatus;
|
package/dist/src/core/egress.js
CHANGED
|
@@ -79,8 +79,11 @@ export function parseTrace(text) {
|
|
|
79
79
|
}
|
|
80
80
|
return out;
|
|
81
81
|
}
|
|
82
|
-
/**
|
|
83
|
-
|
|
82
|
+
/**
|
|
83
|
+
* One GET of an `https://` `url`, directly or through an `http://` proxy (CONNECT), as the Host would send it. The
|
|
84
|
+
* Update Check uses it too, since Node's own `fetch` does not follow the proxy variables.
|
|
85
|
+
*/
|
|
86
|
+
export const fetchTrace = (url, env, timeoutMs, userAgent = 'sideby-network-guard') => new Promise((resolve, reject) => {
|
|
84
87
|
const target = new URL(url);
|
|
85
88
|
const proxy = proxyFor(url, env);
|
|
86
89
|
let done = false;
|
|
@@ -112,9 +115,9 @@ export const fetchTrace = (url, env, timeoutMs) => new Promise((resolve, reject)
|
|
|
112
115
|
const get = (socket) => {
|
|
113
116
|
const req = httpsRequest({
|
|
114
117
|
host: target.hostname,
|
|
115
|
-
path: target.pathname,
|
|
118
|
+
path: target.pathname + target.search,
|
|
116
119
|
method: 'GET',
|
|
117
|
-
headers: { 'user-agent': '
|
|
120
|
+
headers: { 'user-agent': userAgent, accept: 'application/json, text/plain' },
|
|
118
121
|
...(socket ? { createConnection: () => socket } : {}),
|
|
119
122
|
}, read);
|
|
120
123
|
req.on('error', (e) => finish(e));
|
|
@@ -32,6 +32,11 @@ export declare function installedSkills(home: string): Promise<{
|
|
|
32
32
|
version: string | null;
|
|
33
33
|
}[]>;
|
|
34
34
|
/** The command `sideby update` runs to update an installed sideby skill: it keeps the agents it was installed for. */
|
|
35
|
+
/**
|
|
36
|
+
* An installed skill for `installed` (null: from before skills had a version) is behind `target`. A skill for a newer
|
|
37
|
+
* sideby is not: `npx skills update` brings the newest skill, so it is the CLI that is behind (spec §3.23).
|
|
38
|
+
*/
|
|
39
|
+
export declare const skillIsBehind: (installed: string | null, target: string) => boolean;
|
|
35
40
|
export declare const SKILL_UPDATE: readonly ['npx', '-y', 'skills', 'update', 'sideby', '-g', '-y'];
|
|
36
41
|
/**
|
|
37
42
|
* Checks, for each given Family, the sideby skill its Host reads: `<main>/skills/sideby`, and for Codex also
|
|
@@ -5,6 +5,7 @@ import { readFile, realpath, stat } from 'node:fs/promises';
|
|
|
5
5
|
import { dirname, join } from 'node:path';
|
|
6
6
|
import { mainDirOf } from './accounts.js';
|
|
7
7
|
import { tildify } from './paths.js';
|
|
8
|
+
import { compareVersions } from './version.js';
|
|
8
9
|
export const SKILL_SOURCE = 'Adonis0123/sideby';
|
|
9
10
|
/** sideby's repository, linked from the Panel's header. */
|
|
10
11
|
export const REPO_URL = `https://github.com/${SKILL_SOURCE}`;
|
|
@@ -81,6 +82,11 @@ export async function installedSkills(home) {
|
|
|
81
82
|
return out;
|
|
82
83
|
}
|
|
83
84
|
/** The command `sideby update` runs to update an installed sideby skill: it keeps the agents it was installed for. */
|
|
85
|
+
/**
|
|
86
|
+
* An installed skill for `installed` (null: from before skills had a version) is behind `target`. A skill for a newer
|
|
87
|
+
* sideby is not: `npx skills update` brings the newest skill, so it is the CLI that is behind (spec §3.23).
|
|
88
|
+
*/
|
|
89
|
+
export const skillIsBehind = (installed, target) => installed !== target && compareVersions(installed ?? '', target) !== 1;
|
|
84
90
|
export const SKILL_UPDATE = ['npx', '-y', 'skills', 'update', 'sideby', '-g', '-y'];
|
|
85
91
|
/**
|
|
86
92
|
* Checks, for each given Family, the sideby skill its Host reads: `<main>/skills/sideby`, and for Codex also
|
|
@@ -109,7 +115,7 @@ export async function checkInstalledSkills(home, families, version) {
|
|
|
109
115
|
}
|
|
110
116
|
seen.add(`${family.id}\0${real}`);
|
|
111
117
|
const found = skillVersionOf(text);
|
|
112
|
-
if (found
|
|
118
|
+
if (!skillIsBehind(found, version))
|
|
113
119
|
continue;
|
|
114
120
|
const where = tildify(path, home);
|
|
115
121
|
// `sideby update` brings the skill along, except one a git repository owns (a dotfiles clone, say).
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Env } from '../types.ts';
|
|
2
2
|
import type { Paths } from './paths.ts';
|
|
3
3
|
export { isZombieStat } from './lock.ts';
|
|
4
|
+
export { compareVersions } from './version.ts';
|
|
4
5
|
export declare const DEFAULT_REGISTRY = "https://registry.npmjs.org";
|
|
5
6
|
export declare const CHECK_INTERVAL_MS: number;
|
|
6
7
|
export declare const NOTICE_INTERVAL_MS: number;
|
|
@@ -114,8 +115,6 @@ export declare const runProgram: UpdateDeps['exec'];
|
|
|
114
115
|
export declare const updateMachine: () => UpdateDeps;
|
|
115
116
|
/** The lock every install shares (`update-install.lock`), so a Local Build switch never races an Update. */
|
|
116
117
|
export declare const takeInstallLock: (paths: Paths) => Promise<(() => Promise<void>) | null>;
|
|
117
|
-
/** -1, 0 or 1 like a sort comparator; a prerelease sorts before its release. Null when either is not a version. */
|
|
118
|
-
export declare function compareVersions(a: string, b: string): number | null;
|
|
119
118
|
/** `latest` is newer than `current`. */
|
|
120
119
|
export declare const isNewer: (latest: string | undefined, current: string) => latest is string;
|
|
121
120
|
/**
|
|
@@ -280,7 +279,7 @@ export declare function shownPlan(plan: UpdatePlan): {
|
|
|
280
279
|
export interface SkillUpdatePlan {
|
|
281
280
|
/** Versions of the installed skills (`null`: one without a version). */
|
|
282
281
|
installed: (string | null)[];
|
|
283
|
-
/** Some installed skill is for
|
|
282
|
+
/** Some installed skill is for an older version than the one sideby will run (a newer one is not outdated). */
|
|
284
283
|
outdated: boolean;
|
|
285
284
|
command: string;
|
|
286
285
|
/** False when sideby must not run it; `reason` says why and the user runs `command` where it belongs. */
|
package/dist/src/core/update.js
CHANGED
|
@@ -6,11 +6,13 @@ import { access, constants, mkdir, readdir, readFile, realpath, rm } from 'node:
|
|
|
6
6
|
import { dirname, join, sep } from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import { afterInstall, runSkillUpdate } from './after-install.js';
|
|
9
|
+
import { fetchTrace, proxyFor } from './egress.js';
|
|
9
10
|
import { writeFileAtomic } from './fs-safe.js';
|
|
10
11
|
import { processAlive, takeFileLock } from './lock.js';
|
|
11
|
-
import { installedSkills, REPO_URL, SKILL_UPDATE, SKILL_UPDATE_SHOWN, skillOwnerRepo } from './skill-check.js';
|
|
12
|
-
import { localBuild, packageVersion, parseLocalBuild } from './version.js';
|
|
12
|
+
import { installedSkills, REPO_URL, SKILL_UPDATE, SKILL_UPDATE_SHOWN, skillIsBehind, skillOwnerRepo, } from './skill-check.js';
|
|
13
|
+
import { compareVersions, localBuild, packageVersion, parseLocalBuild, parseVersion } from './version.js';
|
|
13
14
|
export { isZombieStat } from './lock.js';
|
|
15
|
+
export { compareVersions } from './version.js';
|
|
14
16
|
export const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
15
17
|
export const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
16
18
|
export const NOTICE_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
@@ -51,8 +53,38 @@ async function ownPackageDir() {
|
|
|
51
53
|
}
|
|
52
54
|
return realpath(join(here, '../..'));
|
|
53
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Node's `fetch` ignores `HTTPS_PROXY` and the like, so on a network that only reaches npm through a proxy the check
|
|
58
|
+
* would time out. An `https://` registry the proxy variables cover is asked through that proxy, as npm itself would.
|
|
59
|
+
*/
|
|
60
|
+
async function registryFetch(input, init) {
|
|
61
|
+
const url = String(input instanceof Request ? input.url : input);
|
|
62
|
+
if (!url.startsWith('https://') || !proxyFor(url, process.env))
|
|
63
|
+
return fetch(input, init);
|
|
64
|
+
try {
|
|
65
|
+
const body = await fetchTrace(url, process.env, FETCH_TIMEOUT_MS, 'sideby-update-check');
|
|
66
|
+
return new Response(body, { status: 200, headers: { 'content-type': 'application/json' } });
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
const e = err;
|
|
70
|
+
const status = /^HTTP (\d{3})$/.exec(e.message ?? '');
|
|
71
|
+
if (status)
|
|
72
|
+
return new Response(null, { status: Number(status[1]) });
|
|
73
|
+
// Plain words that never carry the proxy address or its password.
|
|
74
|
+
const why = e.message === 'timeout'
|
|
75
|
+
? Object.assign(new Error('timed out'), { name: 'TimeoutError' })
|
|
76
|
+
: e.code === 'ECONNREFUSED'
|
|
77
|
+
? new Error('the proxy in HTTPS_PROXY refused the connection; is it running?')
|
|
78
|
+
: e.code === 'ENOTFOUND' || e.code === 'EAI_AGAIN'
|
|
79
|
+
? new Error('the address could not be looked up; offline?')
|
|
80
|
+
: new Error(e.message?.startsWith('the proxy') || e.message?.startsWith('a ')
|
|
81
|
+
? `${e.message} (HTTPS_PROXY)`
|
|
82
|
+
: 'the request through the proxy in HTTPS_PROXY failed');
|
|
83
|
+
throw why;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
54
86
|
const realDeps = {
|
|
55
|
-
fetch:
|
|
87
|
+
fetch: registryFetch,
|
|
56
88
|
now: () => new Date(),
|
|
57
89
|
packageDir: ownPackageDir,
|
|
58
90
|
writable: (dir) => access(dir, constants.W_OK).then(() => true, () => false),
|
|
@@ -148,40 +180,7 @@ export const runProgram = (file, args, opts) => deps().exec(file, args, opts);
|
|
|
148
180
|
export const updateMachine = () => deps();
|
|
149
181
|
/** The lock every install shares (`update-install.lock`), so a Local Build switch never races an Update. */
|
|
150
182
|
export const takeInstallLock = (paths) => takeLock(paths, 'update-install.lock').catch(() => null);
|
|
151
|
-
//
|
|
152
|
-
const VERSION = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
153
|
-
function parseVersion(v) {
|
|
154
|
-
const m = VERSION.exec(v.trim());
|
|
155
|
-
return m ? { core: [Number(m[1]), Number(m[2]), Number(m[3])], pre: m[4] ? m[4].split('.') : [] } : null;
|
|
156
|
-
}
|
|
157
|
-
/** Semver precedence of two prerelease identifiers: numbers compare as numbers and sort before words. */
|
|
158
|
-
function comparePre(a, b) {
|
|
159
|
-
const na = /^\d+$/.test(a);
|
|
160
|
-
const nb = /^\d+$/.test(b);
|
|
161
|
-
if (na && nb)
|
|
162
|
-
return Math.sign(Number(a) - Number(b));
|
|
163
|
-
if (na !== nb)
|
|
164
|
-
return na ? -1 : 1;
|
|
165
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
166
|
-
}
|
|
167
|
-
/** -1, 0 or 1 like a sort comparator; a prerelease sorts before its release. Null when either is not a version. */
|
|
168
|
-
export function compareVersions(a, b) {
|
|
169
|
-
const pa = parseVersion(a);
|
|
170
|
-
const pb = parseVersion(b);
|
|
171
|
-
if (!pa || !pb)
|
|
172
|
-
return null;
|
|
173
|
-
for (let i = 0; i < 3; i++)
|
|
174
|
-
if (pa.core[i] !== pb.core[i])
|
|
175
|
-
return pa.core[i] < pb.core[i] ? -1 : 1;
|
|
176
|
-
if (!pa.pre.length || !pb.pre.length)
|
|
177
|
-
return Math.sign(pb.pre.length - pa.pre.length);
|
|
178
|
-
for (let i = 0; i < Math.min(pa.pre.length, pb.pre.length); i++) {
|
|
179
|
-
const c = comparePre(pa.pre[i], pb.pre[i]);
|
|
180
|
-
if (c)
|
|
181
|
-
return c;
|
|
182
|
-
}
|
|
183
|
-
return Math.sign(pa.pre.length - pb.pre.length);
|
|
184
|
-
}
|
|
183
|
+
// ---- versions
|
|
185
184
|
/** `latest` is newer than `current`. */
|
|
186
185
|
export const isNewer = (latest, current) => latest !== undefined && compareVersions(latest, current) === 1;
|
|
187
186
|
/**
|
|
@@ -331,7 +330,7 @@ export async function fetchLatest(env) {
|
|
|
331
330
|
}
|
|
332
331
|
catch (err) {
|
|
333
332
|
const why = err.name === 'TimeoutError' ? 'timed out' : err.message;
|
|
334
|
-
throw new Error(`could not reach ${shown} (${why}); check the connection, or set SIDEBY_UPDATE_REGISTRY to a mirror`);
|
|
333
|
+
throw new Error(`could not reach ${shown} (${why}); check the connection (and HTTPS_PROXY if you use a proxy), or set SIDEBY_UPDATE_REGISTRY to a mirror`);
|
|
335
334
|
}
|
|
336
335
|
if (!res.ok)
|
|
337
336
|
throw new Error(`${shown} answered ${res.status} for sideby's versions; try again later, or set SIDEBY_UPDATE_REGISTRY`);
|
|
@@ -412,7 +411,7 @@ export function skillAutoLine(cache) {
|
|
|
412
411
|
}
|
|
413
412
|
/** The skill part of a `SkillUpdatePlan` toward the running version, as `afterCommandPlan` takes it. */
|
|
414
413
|
export const skillBehind = (plan, current) => plan?.outdated
|
|
415
|
-
? { installed: plan.installed.find((v) => v
|
|
414
|
+
? { installed: plan.installed.find((v) => skillIsBehind(v, current)) ?? null, canRun: plan.canRun }
|
|
416
415
|
: null;
|
|
417
416
|
/**
|
|
418
417
|
* The line about a skill behind this version the CLI may print now (spec §3.23), or null: once a day per CLI version,
|
|
@@ -680,7 +679,7 @@ export async function skillUpdatePlan(home, target) {
|
|
|
680
679
|
const installed = skills.map((s) => s.version);
|
|
681
680
|
const plan = {
|
|
682
681
|
installed,
|
|
683
|
-
outdated: installed.some((v) => v
|
|
682
|
+
outdated: installed.some((v) => skillIsBehind(v, target)),
|
|
684
683
|
command: SKILL_UPDATE.join(' '),
|
|
685
684
|
canRun: true,
|
|
686
685
|
};
|
|
@@ -18,3 +18,11 @@ export interface LocalBuild {
|
|
|
18
18
|
export declare function parseLocalBuild(data: unknown): LocalBuild | null;
|
|
19
19
|
/** The running code's Local Build, or null when it was published or runs from source. */
|
|
20
20
|
export declare function localBuild(): LocalBuild | null;
|
|
21
|
+
type Parsed = {
|
|
22
|
+
core: [number, number, number];
|
|
23
|
+
pre: string[];
|
|
24
|
+
};
|
|
25
|
+
export declare function parseVersion(v: string): Parsed | null;
|
|
26
|
+
/** -1, 0 or 1 like a sort comparator; a prerelease sorts before its release. Null when either is not a version. */
|
|
27
|
+
export declare function compareVersions(a: string, b: string): number | null;
|
|
28
|
+
export {};
|
package/dist/src/core/version.js
CHANGED
|
@@ -70,3 +70,37 @@ export function localBuild() {
|
|
|
70
70
|
}
|
|
71
71
|
return cachedLocal;
|
|
72
72
|
}
|
|
73
|
+
// Build metadata is limited to what semver allows, so a version never carries a terminal escape into the notice.
|
|
74
|
+
const VERSION = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
75
|
+
export function parseVersion(v) {
|
|
76
|
+
const m = VERSION.exec(v.trim());
|
|
77
|
+
return m ? { core: [Number(m[1]), Number(m[2]), Number(m[3])], pre: m[4] ? m[4].split('.') : [] } : null;
|
|
78
|
+
}
|
|
79
|
+
/** Semver precedence of two prerelease identifiers: numbers compare as numbers and sort before words. */
|
|
80
|
+
function comparePre(a, b) {
|
|
81
|
+
const na = /^\d+$/.test(a);
|
|
82
|
+
const nb = /^\d+$/.test(b);
|
|
83
|
+
if (na && nb)
|
|
84
|
+
return Math.sign(Number(a) - Number(b));
|
|
85
|
+
if (na !== nb)
|
|
86
|
+
return na ? -1 : 1;
|
|
87
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
88
|
+
}
|
|
89
|
+
/** -1, 0 or 1 like a sort comparator; a prerelease sorts before its release. Null when either is not a version. */
|
|
90
|
+
export function compareVersions(a, b) {
|
|
91
|
+
const pa = parseVersion(a);
|
|
92
|
+
const pb = parseVersion(b);
|
|
93
|
+
if (!pa || !pb)
|
|
94
|
+
return null;
|
|
95
|
+
for (let i = 0; i < 3; i++)
|
|
96
|
+
if (pa.core[i] !== pb.core[i])
|
|
97
|
+
return pa.core[i] < pb.core[i] ? -1 : 1;
|
|
98
|
+
if (!pa.pre.length || !pb.pre.length)
|
|
99
|
+
return Math.sign(pb.pre.length - pa.pre.length);
|
|
100
|
+
for (let i = 0; i < Math.min(pa.pre.length, pb.pre.length); i++) {
|
|
101
|
+
const c = comparePre(pa.pre[i], pb.pre[i]);
|
|
102
|
+
if (c)
|
|
103
|
+
return c;
|
|
104
|
+
}
|
|
105
|
+
return Math.sign(pa.pre.length - pb.pre.length);
|
|
106
|
+
}
|
|
@@ -274,6 +274,7 @@ export declare function autostartView(s: AutostartStatus, home: string): {
|
|
|
274
274
|
reason?: string | undefined;
|
|
275
275
|
state: import("../core/autostart.ts").AutostartState;
|
|
276
276
|
path: string;
|
|
277
|
+
mechanism?: import("../core/autostart.ts").AutostartMechanism | undefined;
|
|
277
278
|
current: boolean;
|
|
278
279
|
programArguments?: string[] | undefined;
|
|
279
280
|
missing?: string[] | undefined;
|
|
@@ -142,6 +142,7 @@ export function autostartView(s, home) {
|
|
|
142
142
|
...(s.reason ? { reason: s.reason } : {}),
|
|
143
143
|
state: s.state,
|
|
144
144
|
path: t(s.path),
|
|
145
|
+
...(s.mechanism ? { mechanism: s.mechanism } : {}),
|
|
145
146
|
current: s.current,
|
|
146
147
|
...(s.programArguments ? { programArguments: s.programArguments.map(t) } : {}),
|
|
147
148
|
...(s.missing ? { missing: s.missing.map(t) } : {}),
|
package/dist/src/panel/i18n.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ declare const en: {
|
|
|
64
64
|
'upd.unconfirmed': string;
|
|
65
65
|
'upd.reloading': string;
|
|
66
66
|
'upd.restartHint': string;
|
|
67
|
+
'upd.askAi': string;
|
|
67
68
|
'upd.skillLabel': string;
|
|
68
69
|
'upd.skillLater': string;
|
|
69
70
|
'upd.skillLabelLong': string;
|
|
@@ -665,6 +666,12 @@ declare const en: {
|
|
|
665
666
|
'th.removeSure': string;
|
|
666
667
|
'th.removed': string;
|
|
667
668
|
'ask.title.theme': string;
|
|
669
|
+
'ask.task.update': string;
|
|
670
|
+
'ask.title.update': string;
|
|
671
|
+
'ask.ph.update': string;
|
|
672
|
+
'ask.ex.update.1': string;
|
|
673
|
+
'ask.ex.update.2': string;
|
|
674
|
+
'ask.ex.update.3': string;
|
|
668
675
|
'ask.title.network': string;
|
|
669
676
|
'ask.task.network': string;
|
|
670
677
|
'ask.ph.network': string;
|
|
@@ -1350,6 +1357,8 @@ declare const en: {
|
|
|
1350
1357
|
'as.checking': string;
|
|
1351
1358
|
'as.failed': string;
|
|
1352
1359
|
'as.unsupported': string;
|
|
1360
|
+
'as.labelWsl': string;
|
|
1361
|
+
'as.hintXdg': string;
|
|
1353
1362
|
'as.foreign': string;
|
|
1354
1363
|
'as.stale': string;
|
|
1355
1364
|
'as.other': string;
|
package/dist/src/panel/i18n.js
CHANGED
|
@@ -66,6 +66,7 @@ const en = {
|
|
|
66
66
|
'upd.unconfirmed': 'Could not confirm the update to sideby {v}: this page cannot reach sideby. Reload the page to see which version runs.',
|
|
67
67
|
'upd.reloading': 'Waiting for the new version; this page reloads by itself.',
|
|
68
68
|
'upd.restartHint': 'This page still runs the old version. Restart sideby ui (or reload the page in your portal) to use the new one.',
|
|
69
|
+
'upd.askAi': 'Not sure why? Let AI fix it',
|
|
69
70
|
'upd.skillLabel': 'Update skill',
|
|
70
71
|
'upd.skillLater': 'Once the new version is installed, open this again to bring the sideby skill agents read along.',
|
|
71
72
|
'upd.skillLabelLong': 'The sideby skill agents read is for {s}; this sideby is {cur}. Click to update it.',
|
|
@@ -667,6 +668,12 @@ const en = {
|
|
|
667
668
|
'th.removeSure': 'Remove for good?',
|
|
668
669
|
'th.removed': 'Removed {name}',
|
|
669
670
|
'ask.title.theme': 'Let AI pick your colors',
|
|
671
|
+
'ask.task.update': 'AI checks why the update failed (network, proxy, how sideby is installed), shows you the fix and updates sideby after you agree.',
|
|
672
|
+
'ask.title.update': 'Let AI fix the update',
|
|
673
|
+
'ask.ph.update': 'Anything to add? For example: I use a proxy',
|
|
674
|
+
'ask.ex.update.1': 'I am behind a proxy',
|
|
675
|
+
'ask.ex.update.2': 'Use a registry mirror in China',
|
|
676
|
+
'ask.ex.update.3': 'It says it cannot update itself here',
|
|
670
677
|
'ask.title.network': 'Let AI help',
|
|
671
678
|
'ask.task.network': 'AI asks which countries your requests may leave from, shows the change, and turns the check on only after you agree.',
|
|
672
679
|
'ask.ph.network': 'Where are you, and which proxy nodes do you use? Or paste what was blocked.',
|
|
@@ -1351,7 +1358,9 @@ const en = {
|
|
|
1351
1358
|
'as.hint': 'No window opens; the panel is up to date when you open it.',
|
|
1352
1359
|
'as.checking': 'Checking…',
|
|
1353
1360
|
'as.failed': 'Could not check: {msg}',
|
|
1354
|
-
'as.unsupported': 'Not supported on this system yet; Linux and
|
|
1361
|
+
'as.unsupported': 'Not supported on this system yet; it works on macOS, Linux and WSL.',
|
|
1362
|
+
'as.labelWsl': 'Start sideby in the background when you sign in to Windows',
|
|
1363
|
+
'as.hintXdg': 'No window opens; your desktop session starts it at login.',
|
|
1355
1364
|
'as.foreign': 'A login item with the same name was not made by sideby, so sideby leaves it alone.',
|
|
1356
1365
|
'as.stale': 'It points to a sideby that is no longer there.',
|
|
1357
1366
|
'as.other': 'It starts another copy of sideby, not this one.',
|
|
@@ -1532,6 +1541,7 @@ const zh = {
|
|
|
1532
1541
|
'upd.unconfirmed': '没能确认是否已更新到 sideby {v}:这个页面连不上 sideby。刷新页面看看现在是哪个版本。',
|
|
1533
1542
|
'upd.reloading': '等待新版本启动,本页会自动刷新。',
|
|
1534
1543
|
'upd.restartHint': '本页仍在运行旧版本。重启 sideby ui(在 Portal 里就刷新页面)后使用新版本。',
|
|
1544
|
+
'upd.askAi': '不知道怎么办?让 AI 帮我修',
|
|
1535
1545
|
'upd.skillLabel': '更新 skill',
|
|
1536
1546
|
'upd.skillLater': '装好新版本后,再打开这里把 agent 用的 sideby skill 一起更新。',
|
|
1537
1547
|
'upd.skillLabelLong': 'agent 用的 sideby skill 还是 {s},当前 sideby 是 {cur}。点击更新。',
|
|
@@ -2133,6 +2143,12 @@ const zh = {
|
|
|
2133
2143
|
'th.removeSure': '确定删除?',
|
|
2134
2144
|
'th.removed': '已删除「{name}」',
|
|
2135
2145
|
'ask.title.theme': '让 AI 帮我配色',
|
|
2146
|
+
'ask.task.update': 'AI 会查更新为什么失败(网络、代理、安装方式),先给你看怎么修,你同意后再更新 sideby。',
|
|
2147
|
+
'ask.title.update': '让 AI 帮我更新',
|
|
2148
|
+
'ask.ph.update': '想补充什么?比如:我要走代理才能上网',
|
|
2149
|
+
'ask.ex.update.1': '我上网要走代理',
|
|
2150
|
+
'ask.ex.update.2': '在国内,帮我换成镜像源',
|
|
2151
|
+
'ask.ex.update.3': '提示这里不能自己更新',
|
|
2136
2152
|
'ask.title.network': '让 AI 帮我',
|
|
2137
2153
|
'ask.task.network': 'AI 会问你允许哪些地区,先给你看改动,你同意后才打开检查。',
|
|
2138
2154
|
'ask.ph.network': '你在哪里、用哪些代理节点?或者贴上被拦下的提示。',
|
|
@@ -2817,7 +2833,9 @@ const zh = {
|
|
|
2817
2833
|
'as.hint': '不打开窗口,打开面板时就是最新状态',
|
|
2818
2834
|
'as.checking': '正在检查…',
|
|
2819
2835
|
'as.failed': '没能检查:{msg}',
|
|
2820
|
-
'as.unsupported': '这个系统暂不支持,Linux 和
|
|
2836
|
+
'as.unsupported': '这个系统暂不支持,macOS、Linux 和 WSL 可以用。',
|
|
2837
|
+
'as.labelWsl': '登录 Windows 后在后台启动 sideby',
|
|
2838
|
+
'as.hintXdg': '不打开窗口,登录桌面时自动启动',
|
|
2821
2839
|
'as.foreign': '同名的登录项不是 sideby 建的,sideby 不动它。',
|
|
2822
2840
|
'as.stale': '它指向的 sideby 已经不在了。',
|
|
2823
2841
|
'as.other': '它启动的是另一份 sideby,不是现在这份。',
|
|
@@ -559,7 +559,7 @@ export declare function networkTaskFacts(n: {
|
|
|
559
559
|
}[];
|
|
560
560
|
}): string[];
|
|
561
561
|
/** The kinds of AI Task (spec §3.28); anything else is refused. */
|
|
562
|
-
export declare const AI_TASK_KINDS: readonly ['free', 'fix', 'quota', 'account', 'host', 'plugin', 'terminal', 'theme', 'handoff', 'menubar', 'hotkey', 'network'];
|
|
562
|
+
export declare const AI_TASK_KINDS: readonly ['free', 'fix', 'quota', 'account', 'host', 'plugin', 'terminal', 'theme', 'handoff', 'menubar', 'hotkey', 'network', 'update'];
|
|
563
563
|
export type AiTaskKind = (typeof AI_TASK_KINDS)[number];
|
|
564
564
|
/**
|
|
565
565
|
* The message keys of the AI dialog for `task` (spec §3.28 "每个入口的提示"): its title, the text box placeholder and
|
|
@@ -647,6 +647,8 @@ export declare function taskPrompt(input: {
|
|
|
647
647
|
handoff?: readonly string[];
|
|
648
648
|
/** Network Guard facts, one per line, as `networkTaskFacts` gives them (`network` task, spec §3.35). */
|
|
649
649
|
network?: readonly string[];
|
|
650
|
+
/** The error the last Update Check or Update showed (`update` task, spec §3.23). */
|
|
651
|
+
updateError?: string;
|
|
650
652
|
};
|
|
651
653
|
/** Files saved for the task (spec §3.28 "附件"): absolute paths and their kind. */
|
|
652
654
|
attachments?: readonly {
|
|
@@ -996,6 +996,7 @@ export const AI_TASK_KINDS = [
|
|
|
996
996
|
'menubar',
|
|
997
997
|
'hotkey',
|
|
998
998
|
'network',
|
|
999
|
+
'update',
|
|
999
1000
|
];
|
|
1000
1001
|
/**
|
|
1001
1002
|
* The message keys of the AI dialog for `task` (spec §3.28 "每个入口的提示"): its title, the text box placeholder and
|
|
@@ -1104,6 +1105,9 @@ export function taskPrompt(input, strip) {
|
|
|
1104
1105
|
cHandoff: '自动接力现在的设置(来自 `sideby handoff status --json`):',
|
|
1105
1106
|
network: '帮我设置 sideby 的网络检查:请求要从我没允许的国家或地区发出时(比如代理断了、节点切错了),拦下 Claude 和 Codex。',
|
|
1106
1107
|
cNetwork: '网络检查现在的情况(来自 `sideby network --json`):',
|
|
1108
|
+
update: '帮我把 sideby 和它的 skill 更新到最新版:面板检查更新或更新时出错了,请找出原因并修好。',
|
|
1109
|
+
cUpdate: '面板上的报错:',
|
|
1110
|
+
pUpdate: '先运行 `sideby update --json`,看它能不能连上 npm、最新版是多少、是哪种安装方式(`canRun`)。连不上时先查网络:要走代理的话,看启动 sideby 的终端里有没有 `HTTPS_PROXY`、代理开没开;在中国大陆可以用镜像 `SIDEBY_UPDATE_REGISTRY=https://registry.npmmirror.com`,要写进 shell 配置文件前先问我。能更新时,`sideby update --json` 已经给出预览(退出码 10),我同意后再跑 `sideby update --yes --json`。`canRun` 为 `false` 时(npx、项目依赖、没有写权限的全局目录),把输出里的 `command` 给我,告诉我在哪里运行。skill 比 sideby 新不是问题,更新 sideby 就好。最后再跑一次 `sideby update --json`,确认 sideby 和 skill 都已是最新。',
|
|
1107
1111
|
pNetwork: '先运行 `sideby network check --json`,告诉我现在每个地址的请求从哪里发出。问我允许哪些国家或地区;不要替我决定,也不要因为现在在哪就把它加进去(网络不对时那正是错的地区)。我说了以后,先不加 `--yes` 跑 `sideby network allow <代码>... --json` 和 `sideby network on --json` 给我看预览,我同意后再加 `--yes`。告诉我:只检查 sideby 启动的会话;Codex 要在 `/hooks` 里信任一次 `network-hook`;临时跳过一次用 `sideby run <账号> --ignore-network`。被拦过的话,先帮我查代理(开没开、哪个节点),再跑 `sideby network check --json` 确认。它只防代理出意外,不会让在不支持的地区使用变得合规;不要帮我隐藏所在地(时区、指纹之类)。',
|
|
1108
1112
|
pHandoff: '先运行 `sideby handoff status --json` 和 `sideby quota --json`,看清每个账号的额度来源和用量。只用 `sideby handoff enable …` 或 `sideby config set handoff.<键> <值>` 改设置;先不加 `--yes` 给我看预览,我同意后再加 `--yes`。没有额度数据的账号排在顺序后面,并告诉我怎么让它显示额度。',
|
|
1109
1113
|
cAccount: '账号:',
|
|
@@ -1153,6 +1157,9 @@ export function taskPrompt(input, strip) {
|
|
|
1153
1157
|
cHandoff: 'Auto Handoff now (from `sideby handoff status --json`):',
|
|
1154
1158
|
network: "Help me set up sideby's network check: stop Claude and Codex when my requests would leave from a country I did not allow (for example when the proxy stopped or a node in the wrong country is picked).",
|
|
1155
1159
|
cNetwork: 'Network check now (from `sideby network --json`):',
|
|
1160
|
+
update: 'Bring sideby and its skill up to date: the Panel showed an error while checking for or installing an update. Find out why and fix it.',
|
|
1161
|
+
cUpdate: 'The error the Panel showed: ',
|
|
1162
|
+
pUpdate: 'Run `sideby update --json` first to see whether it reaches npm, the latest version and how sideby is installed (`canRun`). When it cannot reach npm, check the network: behind a proxy, whether the terminal that starts sideby has `HTTPS_PROXY` and the proxy is on; in mainland China the mirror `SIDEBY_UPDATE_REGISTRY=https://registry.npmmirror.com` helps, but ask me before writing it into a shell config file. When it can update, `sideby update --json` already shows the change (exit 10); run `sideby update --yes --json` after I agree. When `canRun` is false (npx, a project dependency, a global folder I cannot write), give me the `command` from its output and tell me where to run it. A skill newer than sideby is fine: updating sideby is enough. Finish with `sideby update --json` again to confirm sideby and the skill are current.',
|
|
1156
1163
|
pNetwork: "Run `sideby network check --json` first and tell me where each address's requests leave from now. Ask me which countries to allow; never decide for me, and never add the current country because it is current (on a wrong network that is the wrong one). Once I say, run `sideby network allow <codes>... --json` and `sideby network on --json` without `--yes` to show me the change, and add `--yes` after I agree. Tell me: only sessions sideby starts are checked; in Codex I trust `network-hook` once in `/hooks`; `sideby run <account> --ignore-network` skips it once. If something was blocked, help me check the proxy (is it on, which node) first, then run `sideby network check --json` to confirm. It guards against proxy accidents; it does not make use from an unsupported region allowed, and never help hide where I am (time zone, fingerprints).",
|
|
1157
1164
|
pHandoff: 'Run `sideby handoff status --json` and `sideby quota --json` first to see where each account gets its quota and how much is used. Change settings only with `sideby handoff enable …` or `sideby config set handoff.<key> <value>`; show me the preview without `--yes` first, and add `--yes` only after I agree. Put accounts without quota data last in the order, and tell me how to make them show it.',
|
|
1158
1165
|
cAccount: 'Account: ',
|
|
@@ -1228,6 +1235,11 @@ export function taskPrompt(input, strip) {
|
|
|
1228
1235
|
if (lines.length)
|
|
1229
1236
|
facts.push('- ' + L.cNetwork, ...lines.map((l) => ' - ' + l));
|
|
1230
1237
|
}
|
|
1238
|
+
if (task === 'update') {
|
|
1239
|
+
const err = clean(c.updateError);
|
|
1240
|
+
if (err)
|
|
1241
|
+
facts.push('- ' + L.cUpdate + err);
|
|
1242
|
+
}
|
|
1231
1243
|
const version = clean(c.version);
|
|
1232
1244
|
if (version)
|
|
1233
1245
|
facts.push('- ' + L.cVersion + version);
|
|
@@ -6153,8 +6153,9 @@ const MAIN = String.raw `
|
|
|
6153
6153
|
const st = li[k]
|
|
6154
6154
|
const s = st.status
|
|
6155
6155
|
const n = autostartNote(s, BOOT.readOnly)
|
|
6156
|
-
const
|
|
6157
|
-
const
|
|
6156
|
+
const mech = k === 'autostart' && s ? s.mechanism : undefined
|
|
6157
|
+
const label = lt(k, mech === 'wsl-startup' ? 'labelWsl' : 'label')
|
|
6158
|
+
const hint = [st.error ? lt(k, 'failed', { msg: st.error.message }) : lt(k, n.key === 'as.hint' && mech === 'xdg' ? 'hintXdg' : n.key.slice(3))]
|
|
6158
6159
|
// The menu bar item: how to bring it back once hidden, and why a running one may not show (Rectangle, Stats).
|
|
6159
6160
|
if (k === 'menubar' && s && s.supported && !st.error && n.key === 'as.hint') {
|
|
6160
6161
|
if (!n.on) hint.push(' ', lt(k, 'hintOff'))
|
|
@@ -7608,7 +7609,14 @@ const MAIN = String.raw `
|
|
|
7608
7609
|
const skillOld = (u) => !!(u && !u.available && !isLocal(u) && u.skillUpdate && u.skillUpdate.outdated)
|
|
7609
7610
|
const skillDue = (u) => skillOld(u) && u.skillUpdate.canRun
|
|
7610
7611
|
function skillFor(u) {
|
|
7611
|
-
|
|
7612
|
+
// Only a skill for an older sideby is behind; one for a newer sideby means the CLI is the one to update.
|
|
7613
|
+
const older = (a, b) => {
|
|
7614
|
+
const p = (x) => String(x).split(/[.+-]/).slice(0, 3).map(Number)
|
|
7615
|
+
const x = p(a), y = p(b)
|
|
7616
|
+
for (let i = 0; i < 3; i++) if (x[i] !== y[i]) return x[i] < y[i]
|
|
7617
|
+
return false
|
|
7618
|
+
}
|
|
7619
|
+
const v = u.skillUpdate.installed.find((x) => x !== u.current && (x === null || older(x, u.current)))
|
|
7612
7620
|
return v ? v : t('upd.skillNoVer')
|
|
7613
7621
|
}
|
|
7614
7622
|
// Why sideby cannot do something itself, in the viewer's language; the English reason when the code is unknown.
|
|
@@ -7714,6 +7722,12 @@ const MAIN = String.raw `
|
|
|
7714
7722
|
openPopover(anchor, 'version', t('upd.title'), verPopKids)
|
|
7715
7723
|
}
|
|
7716
7724
|
function renderVerPop() { refreshPopover('version') }
|
|
7725
|
+
// Where an update fails (spec §3.28): the AI checks the network, the proxy and the install method, and fixes them.
|
|
7726
|
+
function updAskKids(err) {
|
|
7727
|
+
if (BOOT.readOnly) return []
|
|
7728
|
+
const go = () => { closeMenu(); if (dlg.el && dlg.el.open) dlg.el.close(); openAsk({ task: 'update', context: { updateError: err.message, version: BOOT.version } }) }
|
|
7729
|
+
return [h('p', { class: 'small', 'data-enter': 'upd-ai' }, h('button', { class: 'link-btn small', type: 'button', onclick: go }, icon('bot'), ' ', t('upd.askAi')))]
|
|
7730
|
+
}
|
|
7717
7731
|
// A Local Build (ADR-0024) names its commit, with + when the working tree had changes, so the viewer can tell
|
|
7718
7732
|
// which code they are looking at.
|
|
7719
7733
|
function verLabel() {
|
|
@@ -7745,7 +7759,7 @@ const MAIN = String.raw `
|
|
|
7745
7759
|
kids.push(h('div', { class: 'popover-actions' }, h('button', { class: 'btn btn-sm', type: 'button', disabled: vp.checking, 'aria-busy': vp.checking ? 'true' : null, onclick: verPopCheck },
|
|
7746
7760
|
vp.checking ? spinner() : icon('refresh'), vp.checking ? t('upd.checking') : t('upd.check'))))
|
|
7747
7761
|
}
|
|
7748
|
-
if (vp.error) kids.push(errorNote(vp.error, null))
|
|
7762
|
+
if (vp.error) kids.push(errorNote(vp.error, null), ...updAskKids(vp.error))
|
|
7749
7763
|
const sw = localSwitchKids(u)
|
|
7750
7764
|
if (sw) kids.push(sw)
|
|
7751
7765
|
if (u && !BOOT.readOnly && !isLocal(u))
|
|
@@ -7963,7 +7977,7 @@ const MAIN = String.raw `
|
|
|
7963
7977
|
h('button', { class: 'btn btn-sm btn-primary', type: 'button', disabled: up.autoBusy, onclick: updAutoSave }, t('upd.save'))))
|
|
7964
7978
|
}
|
|
7965
7979
|
if (BOOT.readOnly) body.push(h('p', { class: 'note' }, t('banner.readOnly')))
|
|
7966
|
-
if (up.error) body.push(errorNote(up.error, null))
|
|
7980
|
+
if (up.error) body.push(errorNote(up.error, null), ...updAskKids(up.error))
|
|
7967
7981
|
const foot = [h('button', { class: 'btn', type: 'button', disabled: up.busy, onclick: () => dlg.el.close() }, t('btn.close'))]
|
|
7968
7982
|
const primary = (label, run) => h('button', { class: 'btn btn-primary', type: 'button', disabled: up.busy, 'aria-busy': up.busy ? 'true' : null, onclick: run }, up.busy ? spinner() : null, up.busy ? t('upd.updating') : label)
|
|
7969
7983
|
if (up.unknown || (u.available && isLocal(u) && (vs.stuck || vs.unknown))) foot.push(h('button', { class: 'btn btn-primary', type: 'button', onclick: () => location.reload() }, icon('refresh'), t('loc.reload')))
|
package/package.json
CHANGED
package/schemas/autostart.json
CHANGED
|
@@ -45,6 +45,23 @@
|
|
|
45
45
|
"path": {
|
|
46
46
|
"type": "string"
|
|
47
47
|
},
|
|
48
|
+
"mechanism": {
|
|
49
|
+
"anyOf": [
|
|
50
|
+
{
|
|
51
|
+
"type": "string",
|
|
52
|
+
"const": "launchd"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"type": "string",
|
|
56
|
+
"const": "xdg"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"type": "string",
|
|
60
|
+
"const": "wsl-startup"
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"description": "How it starts at login: a LaunchAgent (macOS), an XDG autostart entry (Linux desktop sessions), or a script in the Windows Startup folder (WSL). Absent when unsupported."
|
|
64
|
+
},
|
|
48
65
|
"programArguments": {
|
|
49
66
|
"type": "array",
|
|
50
67
|
"items": {
|
package/schemas/menubar.json
CHANGED
|
@@ -45,6 +45,23 @@
|
|
|
45
45
|
"path": {
|
|
46
46
|
"type": "string"
|
|
47
47
|
},
|
|
48
|
+
"mechanism": {
|
|
49
|
+
"anyOf": [
|
|
50
|
+
{
|
|
51
|
+
"type": "string",
|
|
52
|
+
"const": "launchd"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"type": "string",
|
|
56
|
+
"const": "xdg"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"type": "string",
|
|
60
|
+
"const": "wsl-startup"
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"description": "How it starts at login: a LaunchAgent (macOS), an XDG autostart entry (Linux desktop sessions), or a script in the Windows Startup folder (WSL). Absent when unsupported."
|
|
64
|
+
},
|
|
48
65
|
"programArguments": {
|
|
49
66
|
"type": "array",
|
|
50
67
|
"items": {
|
package/skills/sideby/SKILL.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: sideby
|
|
3
3
|
description: Use when the user runs, or wants to run, several AI coding accounts (Claude Code, Codex, Grok Build, pi) side by side. Covers installing sideby and setting up a new account ("install sideby", "set up another Claude account", "add cc008", "配置一个 cc00x", "再加一个 Codex 账号"), explaining what accounts share and what stays separate ("what do my accounts share?", "这些账号共享了什么"), showing which account a session is ("show [cc001] in the status line", "加上账号标识"), finding a past session of any account ("找一下我上周改登录页的那个会话"), seeing accounts, quota and usage, moving on when one hits its 5-hour or weekly limit, moving the current task to another account ("用 cc008 继续", "交回 cc008"), adding a short command (alias) or a pick command that starts whichever account has the most quota ("加个 cc"), adding an API account from a vendor's docs ("加一个 DeepSeek API 账号"), supporting a new tool, and repairing drifted account directories (skills, hooks, rules or settings not shared, wrong symlinks, credential file permissions). Drives the `sideby` CLI with `--json`; the agent does every step except browser sign-in, filling in secrets and starting interactive sessions, which it hands to the user as one command (inside an Auto Handoff session, `sideby handoff ready --to` moves the task itself).
|
|
4
4
|
metadata:
|
|
5
|
-
version: "0.
|
|
5
|
+
version: "0.28.0"
|
|
6
6
|
requires:
|
|
7
7
|
bins: [sideby, node]
|
|
8
8
|
cliHelp: sideby --help
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AI Tasks
|
|
2
2
|
|
|
3
|
-
An AI Task is a session of the user's own Host that sideby started for them, with a Task Prompt as its first message. The user starts it from the Panel ("Let AI do it", a Finding, a quota cell, the new-account dialog, "Other tool…", "Let AI write a plugin", "Not sure how? Let AI set it up" in the Preferred terminal dialog, "Let AI tune it" on the Auto Handoff page) or with `sideby ask` in a terminal (`--task free|fix|quota|account|host|plugin|terminal|handoff|theme|menubar|hotkey|network`; "Let AI help" in the Panel's Network check dialog and on its wrong-network banner starts `network`, see `references/network.md`; "Let AI pick my colors" in the Panel's Theme dialog starts `theme`, see `references/themes.md`; "Let AI check it" in the Panel's Menu bar icon dialog starts `menubar`, and "Not sure which? Let AI pick one" under its shortcut starts `hotkey`). The prompt says what to do and gives facts sideby already knows (account refs, Family, Finding codes, the quota reason, the Panel language, the sideby version). How to do it is on this page.
|
|
3
|
+
An AI Task is a session of the user's own Host that sideby started for them, with a Task Prompt as its first message. The user starts it from the Panel ("Let AI do it", a Finding, a quota cell, the new-account dialog, "Other tool…", "Let AI write a plugin", "Not sure how? Let AI set it up" in the Preferred terminal dialog, "Let AI tune it" on the Auto Handoff page) or with `sideby ask` in a terminal (`--task free|fix|quota|account|host|plugin|terminal|handoff|theme|menubar|hotkey|network|update`; "Let AI help" in the Panel's Network check dialog and on its wrong-network banner starts `network`, see `references/network.md`; "Let AI pick my colors" in the Panel's Theme dialog starts `theme`, see `references/themes.md`; "Let AI check it" in the Panel's Menu bar icon dialog starts `menubar`, and "Not sure which? Let AI pick one" under its shortcut starts `hotkey`; "Not sure why? Let AI fix it" under an error in the Panel's update dialog starts `update`, see `references/update.md`). The prompt says what to do and gives facts sideby already knows (account refs, Family, Finding codes, the quota reason, the Panel language, the sideby version). How to do it is on this page.
|
|
4
4
|
|
|
5
5
|
You are inside such a session when the first message came from sideby and names a task. Work in the directory the session started in (sideby's own `ai/` folder) unless the user names another one.
|
|
6
6
|
|
|
@@ -58,7 +58,7 @@ A value the key does not take fails with code `bad-value` and changes nothing; a
|
|
|
58
58
|
|
|
59
59
|
`sideby autostart --json` returns `supported`, `state` and `path`. `state` is `off`, `on`, `stale` (the Node or sideby it starts was moved; `missing` names it) or `foreign` (a file at that path sideby did not write: leave it, and tell the user). `current` is false when it starts another sideby than this one.
|
|
60
60
|
|
|
61
|
-
To turn it on ("start sideby at login", "开机启动"), run `sideby autostart on --json`: exit 10 returns the `content` of the file, the `programArguments` and the `commands` it will run. Show that, and run `sideby autostart on --yes --json` after the user agrees; `stale` or `current: false` is fixed the same way. `sideby autostart off` turns it off the same way. At login the Panel starts in the background without opening a window. macOS only
|
|
61
|
+
To turn it on ("start sideby at login", "开机启动"), run `sideby autostart on --json`: exit 10 returns the `content` of the file, the `programArguments` and the `commands` it will run. Show that, and run `sideby autostart on --yes --json` after the user agrees; `stale` or `current: false` is fixed the same way. `sideby autostart off` turns it off the same way. At login the Panel starts in the background without opening a window. `mechanism` says how: `launchd` (macOS), `xdg` (Linux, `~/.config/autostart/dev.sideby.panel.desktop`, run by desktop sessions only) or `wsl-startup` (WSL: `sideby-panel.vbs` in the Windows Startup folder, so it starts when the user signs in to Windows; `commands` is empty there and the change takes effect at the next sign-in, `sideby ui --background` starts it now). Native Windows has `supported` false and `on` fails with code `unsupported`; under WSL a path with `"`, `%` or non-ASCII letters fails with `unsafe-path`. Running from the npx cache or a temporary folder fails with `npx-cache` or `temp-dir`: hand the user `npm i -g sideby` first. `sideby update` keeps an existing login item pointing at the new version.
|
|
62
62
|
|
|
63
63
|
## Quota in the menu bar
|
|
64
64
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Every `--json` output can carry `_notice` (it comes from sideby's daily Update Check and the installed skill, and reads no network itself):
|
|
4
4
|
|
|
5
5
|
- `_notice.update`: `{ current, latest, command: "sideby update", message }`, a newer sideby is out.
|
|
6
|
-
- `_notice.skill`: `{ installed, current, command: "sideby update", message }`, the sideby skill agents read here is for
|
|
6
|
+
- `_notice.skill`: `{ installed, current, command: "sideby update", message }`, the sideby skill agents read here is for an older version (`installed: null` when it has no version), so it may describe commands this CLI does not have.
|
|
7
7
|
|
|
8
8
|
What to do:
|
|
9
9
|
|
|
@@ -13,7 +13,8 @@ What to do:
|
|
|
13
13
|
- Run `sideby update --json`. It shows the version, the install method and the command it would run, and exits `10`. Show that to the user; after their yes, run `sideby update --yes --json`.
|
|
14
14
|
- If it exits `1` with `canRun: false` (npx, Volta, a project dependency, a source checkout, a Local Build), sideby cannot update itself: give the user the `command` it printed as one line to run.
|
|
15
15
|
- The same command updates the installed sideby skill (`skillUpdate` in the plan, `skillUpdated` in the result), so do not run a skill command yourself. With sideby already current and only the skill old (`_notice.skill`), `sideby update` updates the skill alone, after the same preview. To update only the skill and never the CLI, even when a newer sideby is out, run `sideby update --skill --json` (preview, exit `10`), then `--skill --yes --json`. When `skillUpdate.canRun` is false (the skill lives in a git repository the skills tool did not install it into), tell the user `reason` and give them `command`. Tell them that sessions already running keep the old version until they start again.
|
|
16
|
-
4.
|
|
16
|
+
4. When `sideby update --json` cannot reach the registry (the `update` AI Task, started from an error in the Panel's update dialog, brings that error): behind a proxy, check that the terminal or app that starts sideby has `HTTPS_PROXY` (sideby follows it, as npm does) and that the proxy is on; in mainland China, `SIDEBY_UPDATE_REGISTRY=https://registry.npmmirror.com` uses a mirror. Ask before writing either into a shell config file. A skill for a newer sideby than the CLI is not a problem: update the CLI.
|
|
17
|
+
5. The user can turn notices off with `SIDEBY_NO_UPDATE_NOTIFIER=1` (or config `update.check: false`); set it for one command when a script needs JSON without `_notice`. A Local Build (`pnpm local`) never has one.
|
|
17
18
|
|
|
18
19
|
## Auto Update
|
|
19
20
|
|