sideby 0.16.1 → 0.18.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.
Files changed (128) hide show
  1. package/README.md +7 -3
  2. package/ai-tasks.json +90 -0
  3. package/dist/build.json +1 -1
  4. package/dist/src/cli/commands.d.ts +25 -1
  5. package/dist/src/cli/commands.js +802 -15
  6. package/dist/src/cli/json-schemas.js +252 -1
  7. package/dist/src/cli/main.js +143 -4
  8. package/dist/src/core/after-install.d.ts +54 -0
  9. package/dist/src/core/after-install.js +78 -0
  10. package/dist/src/core/ask.d.ts +222 -0
  11. package/dist/src/core/ask.js +465 -0
  12. package/dist/src/core/attachments.d.ts +50 -0
  13. package/dist/src/core/attachments.js +442 -0
  14. package/dist/src/core/autostart.d.ts +118 -0
  15. package/dist/src/core/autostart.js +302 -0
  16. package/dist/src/core/brand-mark.d.ts +49 -11
  17. package/dist/src/core/brand-mark.js +116 -38
  18. package/dist/src/core/config.d.ts +102 -0
  19. package/dist/src/core/config.js +289 -11
  20. package/dist/src/core/desktop-app.d.ts +1 -1
  21. package/dist/src/core/desktop-app.js +2 -2
  22. package/dist/src/core/edit-settings.d.ts +24 -0
  23. package/dist/src/core/edit-settings.js +97 -0
  24. package/dist/src/core/handoff-brief.d.ts +4 -2
  25. package/dist/src/core/handoff-brief.js +6 -1
  26. package/dist/src/core/handoff-chain.d.ts +24 -0
  27. package/dist/src/core/handoff-chain.js +2 -0
  28. package/dist/src/core/handoff-run.d.ts +4 -3
  29. package/dist/src/core/handoff-run.js +14 -9
  30. package/dist/src/core/launch.d.ts +17 -4
  31. package/dist/src/core/launch.js +32 -24
  32. package/dist/src/core/local-build.d.ts +17 -5
  33. package/dist/src/core/local-build.js +61 -23
  34. package/dist/src/core/lock.d.ts +30 -0
  35. package/dist/src/core/lock.js +143 -0
  36. package/dist/src/core/probe.d.ts +78 -0
  37. package/dist/src/core/probe.js +127 -0
  38. package/dist/src/core/quota-levels.d.ts +6 -1
  39. package/dist/src/core/quota-levels.js +16 -5
  40. package/dist/src/core/same-login.d.ts +9 -4
  41. package/dist/src/core/same-login.js +9 -4
  42. package/dist/src/core/secret-file.d.ts +26 -0
  43. package/dist/src/core/secret-file.js +126 -7
  44. package/dist/src/core/task-spec.d.ts +95 -0
  45. package/dist/src/core/task-spec.js +209 -0
  46. package/dist/src/core/terminal.d.ts +93 -0
  47. package/dist/src/core/terminal.js +376 -0
  48. package/dist/src/core/update.d.ts +34 -12
  49. package/dist/src/core/update.js +96 -84
  50. package/dist/src/desktop/icon.js +12 -15
  51. package/dist/src/families/claude/ai-task.d.ts +8 -0
  52. package/dist/src/families/claude/ai-task.js +38 -0
  53. package/dist/src/families/claude/handoff-hook.js +4 -4
  54. package/dist/src/families/claude/index.js +6 -0
  55. package/dist/src/families/claude/quota-cache.d.ts +24 -7
  56. package/dist/src/families/claude/quota-cache.js +72 -21
  57. package/dist/src/families/codex/handoff-hook.js +4 -4
  58. package/dist/src/families/codex/index.js +16 -0
  59. package/dist/src/families/codex/login-key.d.ts +8 -0
  60. package/dist/src/families/codex/login-key.js +33 -0
  61. package/dist/src/families/grok/handoff-hook.js +4 -4
  62. package/dist/src/families/grok/index.js +4 -0
  63. package/dist/src/families/login-keys.d.ts +6 -0
  64. package/dist/src/families/login-keys.js +6 -0
  65. package/dist/src/families/pi/index.js +5 -0
  66. package/dist/src/handoff/hook.js +51 -30
  67. package/dist/src/handoff/levels.d.ts +24 -0
  68. package/dist/src/handoff/levels.js +70 -0
  69. package/dist/src/handoff/messages.d.ts +6 -3
  70. package/dist/src/handoff/messages.js +20 -7
  71. package/dist/src/handoff/reader.d.ts +6 -3
  72. package/dist/src/menubar/agent.d.ts +3 -0
  73. package/dist/src/menubar/agent.js +21 -0
  74. package/dist/src/menubar/script.d.ts +8 -0
  75. package/dist/src/menubar/script.js +457 -0
  76. package/dist/src/menubar/snapshot.d.ts +115 -0
  77. package/dist/src/menubar/snapshot.js +255 -0
  78. package/dist/src/menubar/strings.d.ts +87 -0
  79. package/dist/src/menubar/strings.js +88 -0
  80. package/dist/src/panel/background.js +15 -21
  81. package/dist/src/panel/handler.d.ts +41 -2
  82. package/dist/src/panel/handler.js +394 -10
  83. package/dist/src/panel/i18n.d.ts +205 -2
  84. package/dist/src/panel/i18n.js +441 -35
  85. package/dist/src/panel/page-logic.d.ts +301 -0
  86. package/dist/src/panel/page-logic.js +532 -0
  87. package/dist/src/panel/page-script.js +1135 -185
  88. package/dist/src/panel/page-styles.js +111 -32
  89. package/dist/src/panel/page.d.ts +12 -0
  90. package/dist/src/panel/page.js +7 -0
  91. package/dist/src/panel/server.d.ts +16 -2
  92. package/dist/src/panel/server.js +41 -13
  93. package/dist/src/plugins/check.d.ts +47 -0
  94. package/dist/src/plugins/check.js +544 -0
  95. package/dist/src/plugins/scaffold.d.ts +21 -0
  96. package/dist/src/plugins/scaffold.js +123 -0
  97. package/dist/src/quota/statusline-tap.js +1 -1
  98. package/dist/src/runtime.d.ts +19 -1
  99. package/dist/src/runtime.js +53 -14
  100. package/dist/src/types.d.ts +33 -0
  101. package/package.json +4 -3
  102. package/schemas/ask-choices.json +168 -0
  103. package/schemas/ask-print.json +87 -0
  104. package/schemas/ask.json +180 -0
  105. package/schemas/autostart.json +165 -0
  106. package/schemas/config-get.json +132 -0
  107. package/schemas/config-set.json +107 -0
  108. package/schemas/config.json +90 -7
  109. package/schemas/edit.json +119 -0
  110. package/schemas/error.json +4 -0
  111. package/schemas/families.json +4 -0
  112. package/schemas/key.json +93 -0
  113. package/schemas/list.json +4 -0
  114. package/schemas/local.json +1 -1
  115. package/schemas/menubar-snapshot.json +646 -0
  116. package/schemas/menubar-start.json +112 -0
  117. package/schemas/menubar.json +165 -0
  118. package/schemas/plugins-check.json +113 -0
  119. package/schemas/plugins-new.json +87 -0
  120. package/schemas/terminal.json +152 -0
  121. package/schemas/try.json +109 -0
  122. package/schemas/update.json +4 -0
  123. package/skills/sideby/SKILL.md +16 -6
  124. package/skills/sideby/references/accounts.md +1 -1
  125. package/skills/sideby/references/ai-tasks.md +126 -0
  126. package/skills/sideby/references/handoff.md +3 -1
  127. package/skills/sideby/references/panel.md +20 -0
  128. package/skills/sideby/references/update.md +1 -1
@@ -0,0 +1,376 @@
1
+ import { constants, realpathSync } from 'node:fs';
2
+ import { access, stat } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ /** Supported macOS terminals; custom templates have no app bundle or environment marker. */
6
+ export const TERMINALS = [
7
+ {
8
+ id: 'terminal',
9
+ name: 'Terminal',
10
+ bundleId: 'com.apple.Terminal',
11
+ app: 'Terminal.app',
12
+ termPrograms: ['Apple_Terminal'],
13
+ },
14
+ {
15
+ id: 'iterm2',
16
+ name: 'iTerm2',
17
+ bundleId: 'com.googlecode.iterm2',
18
+ app: 'iTerm.app',
19
+ termPrograms: ['iTerm.app'],
20
+ },
21
+ {
22
+ id: 'ghostty',
23
+ name: 'Ghostty',
24
+ bundleId: 'com.mitchellh.ghostty',
25
+ app: 'Ghostty.app',
26
+ termPrograms: ['ghostty'],
27
+ },
28
+ {
29
+ id: 'orca',
30
+ name: 'Orca',
31
+ bundleId: 'com.stablyai.orca',
32
+ app: 'Orca.app',
33
+ termPrograms: ['Orca'],
34
+ binary: 'orca',
35
+ },
36
+ {
37
+ id: 'wezterm',
38
+ name: 'WezTerm',
39
+ bundleId: 'com.github.wez.wezterm',
40
+ app: 'WezTerm.app',
41
+ termPrograms: ['WezTerm'],
42
+ binary: 'wezterm',
43
+ },
44
+ {
45
+ id: 'kitty',
46
+ name: 'kitty',
47
+ bundleId: 'net.kovidgoyal.kitty',
48
+ app: 'kitty.app',
49
+ termPrograms: [],
50
+ marker: 'KITTY_WINDOW_ID',
51
+ binary: 'kitty',
52
+ },
53
+ {
54
+ id: 'alacritty',
55
+ name: 'Alacritty',
56
+ bundleId: 'org.alacritty',
57
+ app: 'Alacritty.app',
58
+ termPrograms: [],
59
+ marker: 'ALACRITTY_WINDOW_ID',
60
+ },
61
+ { id: 'custom', name: 'Custom', bundleId: null, app: null, termPrograms: [] },
62
+ ];
63
+ /** Finds bundles and command line launchers without opening apps or reading user files. */
64
+ export async function installedTerminals(deps) {
65
+ if ((deps.platform ?? process.platform) !== 'darwin')
66
+ return [];
67
+ const fs = deps.fs ?? { stat, access };
68
+ const dirs = deps.appDirs ?? [
69
+ '/Applications',
70
+ join(deps.home, 'Applications'),
71
+ '/System/Applications/Utilities',
72
+ '/Applications/Utilities',
73
+ ];
74
+ const found = [];
75
+ for (const terminal of TERMINALS) {
76
+ if (!terminal.app)
77
+ continue;
78
+ let appPath;
79
+ for (const dir of dirs) {
80
+ const path = join(dir, terminal.app);
81
+ if (await fs.stat(path).then((s) => s.isDirectory(), () => false)) {
82
+ appPath = path;
83
+ break;
84
+ }
85
+ }
86
+ let executable;
87
+ if (terminal.binary) {
88
+ for (const dir of (deps.env.PATH ?? '').split(':').filter(Boolean)) {
89
+ const path = join(dir, terminal.binary);
90
+ if ((await fs.stat(path).then((s) => s.isFile(), () => false)) &&
91
+ (await fs.access(path, constants.X_OK).then(() => true, () => false))) {
92
+ executable = path;
93
+ break;
94
+ }
95
+ }
96
+ if (!executable && appPath)
97
+ executable = join(appPath, terminal.id === 'orca' ? 'Contents/Resources/bin' : 'Contents/MacOS', terminal.binary);
98
+ }
99
+ if (appPath || (terminal.id === 'orca' && executable))
100
+ found.push({ id: terminal.id, ...(appPath ? { appPath } : {}), ...(executable ? { executable } : {}) });
101
+ }
102
+ return found;
103
+ }
104
+ /** Chooses an installed preference, then the launching environment, then macOS Terminal. */
105
+ export function guessTerminal(opts) {
106
+ const has = (id) => opts.installed.some((t) => t.id === id);
107
+ if (opts.preferred && has(opts.preferred))
108
+ return { id: opts.preferred, source: 'config' };
109
+ const match = TERMINALS.find((t) => has(t.id) &&
110
+ (t.termPrograms.includes(opts.env.TERM_PROGRAM ?? '') || Boolean(t.marker && opts.env[t.marker])));
111
+ return match ? { id: match.id, source: 'env' } : { id: 'terminal', source: 'default' };
112
+ }
113
+ /** This process's Node and the real path of the CLI entry next to this module (`main.ts` from source, `main.js` from dist). */
114
+ export function askLauncher() {
115
+ const ext = import.meta.url.endsWith('.ts') ? 'ts' : 'js';
116
+ const entry = fileURLToPath(new URL(`../cli/main.${ext}`, import.meta.url));
117
+ let real = entry;
118
+ try {
119
+ real = realpathSync(entry);
120
+ }
121
+ catch {
122
+ // Keep the unresolved path; the terminal reports it if it is missing.
123
+ }
124
+ return { node: process.execPath, entry: real };
125
+ }
126
+ // A path the terminal's shell reads exactly: absolute, and no control character, newline or backslash
127
+ // (fish treats a backslash inside single quotes as an escape).
128
+ // Built from a string: a regex literal with control characters reads as a typo to linters.
129
+ const CONTROL = new RegExp(String.raw `[\x00-\x1f\x7f]`);
130
+ const safePath = (path) => path.startsWith('/') && !path.includes('\\') && !CONTROL.test(path);
131
+ /** Why the terminal cannot run this launcher, or null when it can. */
132
+ export function launcherProblem(launcher, stateDir) {
133
+ if (!safePath(launcher.node) ||
134
+ !safePath(launcher.entry) ||
135
+ (stateDir !== undefined && !safePath(stateDir)))
136
+ return {
137
+ ok: false,
138
+ reason: 'unsafe-path',
139
+ detail: 'sideby, Node or its state folder is in a folder whose name a terminal cannot run safely; install sideby with `npm i -g sideby`, or paste the task command into your terminal.',
140
+ };
141
+ if (launcher.entry.includes('/_npx/'))
142
+ return {
143
+ ok: false,
144
+ reason: 'npx-cache',
145
+ detail: 'sideby runs from the npx cache, which can disappear; install it with `npm i -g sideby` and try again, or paste the task command into your terminal now.',
146
+ };
147
+ return null;
148
+ }
149
+ /**
150
+ * Builds the only shell command accepted by the AI Task terminal launcher: the quoted Node and CLI entry, or
151
+ * `sideby` by name when `launcher` is null (a command for the user to paste where sideby is on PATH). It carries the
152
+ * state folder the task was written to, so a terminal whose environment differs from the Panel's still finds it.
153
+ */
154
+ export function askRunCommand(taskId, stateDir, launcher = askLauncher()) {
155
+ if (!/^[a-f0-9]{16}$/.test(taskId))
156
+ throw new Error('Invalid task id; create the AI task again.');
157
+ if (!launcher)
158
+ // Pasted by hand: a state folder a shell cannot take safely is left out, and `ask --run` uses the environment's.
159
+ return `sideby ask --run '${taskId}'${safePath(stateDir) ? ` --state-dir ${quote(stateDir)}` : ''}`;
160
+ if (!safePath(launcher.node) || !safePath(launcher.entry) || !safePath(stateDir))
161
+ throw new Error('Unsafe sideby path; install sideby with `npm i -g sideby` and try again.');
162
+ return `${quote(launcher.node)} ${quote(launcher.entry)} ask --run '${taskId}' --state-dir ${quote(stateDir)}`;
163
+ }
164
+ function quote(value) {
165
+ return `'${value.replaceAll("'", "'\\''")}'`;
166
+ }
167
+ // AppleScript string literals know only \\ and \" as escapes; a control character is refused, not encoded.
168
+ function appleString(value) {
169
+ if (CONTROL.test(value))
170
+ throw new Error('Invalid task command; create the AI task again.');
171
+ return `"${value.replace(/[\\"]/g, (c) => `\\${c}`)}"`;
172
+ }
173
+ // The quoted launcher and state paths, as askRunCommand writes them: single-quoted runs joined by \' (an escaped quote).
174
+ const QUOTED = String.raw `(?:'[^'\\\x00-\x1f\x7f]*'|\\')+`;
175
+ const TASK_COMMAND = new RegExp(`^${QUOTED} ${QUOTED} ask --run '[a-f0-9]{16}' --state-dir ${QUOTED}$`);
176
+ /** For `sh -c`: when the command fails, the window waits for Return instead of closing on its error. */
177
+ function holdOnFailure(command) {
178
+ return `${command} || { echo; echo "sideby: press Return to close"; read _; }`;
179
+ }
180
+ // Tokenize before substitution: paths and commands remain one argument, even with quotes or newlines.
181
+ function customArgs(template) {
182
+ const args = [];
183
+ let word = '', quoted = '', started = false;
184
+ for (let i = 0; i < template.length; i++) {
185
+ const c = template[i];
186
+ if (c === '\\' && quoted !== "'") {
187
+ if (++i === template.length)
188
+ throw new Error('Incomplete escape; fix the custom terminal template.');
189
+ word += template[i];
190
+ started = true;
191
+ }
192
+ else if (quoted) {
193
+ if (c === quoted)
194
+ quoted = '';
195
+ else
196
+ word += c;
197
+ }
198
+ else if (c === '"' || c === "'") {
199
+ quoted = c;
200
+ started = true;
201
+ }
202
+ else if (/\s/.test(c)) {
203
+ if (started) {
204
+ args.push(word);
205
+ word = '';
206
+ started = false;
207
+ }
208
+ }
209
+ else {
210
+ word += c;
211
+ started = true;
212
+ }
213
+ }
214
+ if (quoted)
215
+ throw new Error('Unclosed quote; fix the custom terminal template.');
216
+ if (started)
217
+ args.push(word);
218
+ return args;
219
+ }
220
+ /**
221
+ * Splits a custom terminal template into argv, throwing unless it names a program first and has both `{cmd}` and
222
+ * `{cwd}` in its arguments.
223
+ */
224
+ export function validateCustomTemplate(template) {
225
+ const args = customArgs(template);
226
+ const file = args[0];
227
+ const rest = args.slice(1);
228
+ if (!file ||
229
+ file.includes('{') ||
230
+ !rest.some((a) => a.includes('{cmd}')) ||
231
+ !rest.some((a) => a.includes('{cwd}')) ||
232
+ template.includes('\0'))
233
+ throw new Error("Set a custom terminal executable and both {cmd} and {cwd} placeholders, such as `sideby terminal --custom 'my-term --cwd {cwd} -e {cmd}'`.");
234
+ return [file, ...rest];
235
+ }
236
+ /** Builds argv only. The caller supplies discovered bundle/binary paths when available. */
237
+ export function launchArgs(id, opts) {
238
+ if (!TASK_COMMAND.test(opts.command))
239
+ throw new Error('Invalid task command; create the AI task again.');
240
+ if (opts.cwd.includes('\0'))
241
+ throw new Error('Invalid working directory; choose another folder.');
242
+ // `ask --run` changes to the task's directory itself, so cwd goes only where a terminal takes it as an argument.
243
+ const { cwd, command } = opts;
244
+ const held = holdOnFailure(command);
245
+ switch (id) {
246
+ case 'terminal':
247
+ return {
248
+ file: '/usr/bin/osascript',
249
+ args: [
250
+ '-e',
251
+ `tell application id "com.apple.Terminal"
252
+ if not running then launch
253
+ do script ${appleString(command)}
254
+ activate
255
+ end tell`,
256
+ ],
257
+ };
258
+ case 'iterm2':
259
+ return {
260
+ file: '/usr/bin/osascript',
261
+ args: [
262
+ '-e',
263
+ // Always a new window of its own: "current window" can be iTerm2's updater or settings window, and a
264
+ // just-started iTerm2 may open no window at all.
265
+ `tell application id "com.googlecode.iterm2"
266
+ activate
267
+ set taskWindow to (create window with default profile)
268
+ tell current session of taskWindow to write text ${appleString(command)}
269
+ end tell`,
270
+ ],
271
+ };
272
+ // Use the CLI for both running and stopped Ghostty; AppleScript new window needs newer versions.
273
+ case 'ghostty':
274
+ return {
275
+ file: '/usr/bin/open',
276
+ args: [
277
+ '-na',
278
+ opts.appPath ?? 'Ghostty',
279
+ '--args',
280
+ `--working-directory=${cwd}`,
281
+ '-e',
282
+ '/bin/sh',
283
+ '-lc',
284
+ held,
285
+ ],
286
+ };
287
+ case 'orca':
288
+ return {
289
+ file: opts.executable ?? 'orca',
290
+ args: [
291
+ 'terminal',
292
+ 'create',
293
+ '--worktree',
294
+ 'active',
295
+ '--command',
296
+ command,
297
+ '--title',
298
+ 'sideby',
299
+ '--focus',
300
+ '--json',
301
+ ],
302
+ };
303
+ case 'wezterm':
304
+ return {
305
+ file: opts.executable ?? join(opts.appPath ?? '/Applications/WezTerm.app', 'Contents/MacOS/wezterm'),
306
+ args: ['start', '--cwd', cwd, '--', '/bin/sh', '-lc', held],
307
+ };
308
+ case 'kitty':
309
+ return {
310
+ file: opts.executable ?? join(opts.appPath ?? '/Applications/kitty.app', 'Contents/MacOS/kitty'),
311
+ args: ['--single-instance', '--directory', cwd, '/bin/sh', '-lc', held],
312
+ };
313
+ case 'alacritty':
314
+ return {
315
+ file: '/usr/bin/open',
316
+ args: [
317
+ '-na',
318
+ opts.appPath ?? 'Alacritty',
319
+ '--args',
320
+ '--working-directory',
321
+ cwd,
322
+ '-e',
323
+ '/bin/sh',
324
+ '-lc',
325
+ held,
326
+ ],
327
+ };
328
+ case 'custom': {
329
+ const [file, ...args] = validateCustomTemplate(opts.custom ?? '');
330
+ return {
331
+ file,
332
+ args: args.map((a) => a.replace(/\{(cmd|cwd)\}/g, (_, key) => (key === 'cmd' ? command : cwd))),
333
+ };
334
+ }
335
+ default:
336
+ throw new Error('Unknown terminal; choose an installed terminal in Settings.');
337
+ }
338
+ }
339
+ /** Opens through the injected Desktop exec boundary, returning safe, actionable failures only. */
340
+ export async function openTerminal(id, opts, exec) {
341
+ if ((opts.platform ?? process.platform) !== 'darwin')
342
+ return { ok: false, reason: 'unsupported-platform' };
343
+ const installed = opts.installed.find((t) => t.id === id);
344
+ if (!installed && id !== 'custom')
345
+ return {
346
+ ok: false,
347
+ reason: 'not-installed',
348
+ detail: 'Install this terminal or choose another in Settings; paste the task command into your terminal.',
349
+ };
350
+ try {
351
+ const launch = launchArgs(id, { ...opts, ...installed });
352
+ const result = await exec(launch.file, launch.args);
353
+ if (result.code === 0) {
354
+ // `orca terminal create --focus` only switches tabs inside Orca; bring its window to the front too.
355
+ const bundleId = id === 'orca' ? TERMINALS.find((t) => t.id === 'orca')?.bundleId : null;
356
+ if (bundleId)
357
+ await exec('/usr/bin/open', ['-b', bundleId]).catch(() => undefined);
358
+ return { ok: true };
359
+ }
360
+ if (launch.file === '/usr/bin/osascript' &&
361
+ (result.code === -1743 || /-1743|Not authorized to send Apple events/i.test(result.stderr)))
362
+ return {
363
+ ok: false,
364
+ reason: 'automation-denied',
365
+ detail: 'Allow Automation in System Settings > Privacy & Security > Automation, then try again; or paste the task command into your terminal.',
366
+ };
367
+ }
368
+ catch {
369
+ // Never expose process output or thrown messages: they may contain private data.
370
+ }
371
+ return {
372
+ ok: false,
373
+ reason: 'failed',
374
+ detail: 'Could not open the terminal; check its settings or paste the task command into your terminal.',
375
+ };
376
+ }
@@ -1,5 +1,6 @@
1
1
  import type { Env } from '../types.ts';
2
2
  import type { Paths } from './paths.ts';
3
+ export { isZombieStat } from './lock.ts';
3
4
  export declare const DEFAULT_REGISTRY = "https://registry.npmjs.org";
4
5
  export declare const CHECK_INTERVAL_MS: number;
5
6
  export declare const NOTICE_INTERVAL_MS: number;
@@ -66,9 +67,12 @@ export interface InstallMethod {
66
67
  /** npm only: the prefix whose `lib/node_modules` holds sideby. */
67
68
  prefix?: string;
68
69
  }
69
- /** Whether a Linux `/proc/<pid>/stat` line is of a zombie: the state after the parenthesised command name is `Z`. */
70
- export declare function isZombieStat(stat: string): boolean;
71
70
  /** Swapped in tests through `bindUpdateDeps`; the real machine otherwise. */
71
+ /**
72
+ * Whether `sideby autostart --refresh --json` rewrote the login item: it exits 0 also when nothing changed or the
73
+ * rewrite was refused, so only its `changed: true` counts.
74
+ */
75
+ export declare function autostartRefreshed(code: number | null, stdout: string): boolean;
72
76
  export interface UpdateDeps {
73
77
  fetch: typeof fetch;
74
78
  now: () => Date;
@@ -92,15 +96,22 @@ export interface UpdateDeps {
92
96
  appInstalled: (home: string, env: Env) => Promise<boolean>;
93
97
  /** Runs `sideby app install --json` from the newly installed code and waits; false when it failed. */
94
98
  refreshApp: (env: Env) => Promise<boolean>;
99
+ /**
100
+ * Whether `sideby autostart on` (or `sideby menubar on`, ADR-0034) put its login item in this home (its file carries
101
+ * the sideby marker).
102
+ */
103
+ autostartInstalled: (home: string, command?: LoginItemCommand) => Promise<boolean>;
104
+ /** Runs `sideby <command> --refresh --json` from the newly installed code and waits; false when it failed. */
105
+ refreshAutostart: (env: Env, command?: LoginItemCommand) => Promise<boolean>;
95
106
  }
107
+ /** The commands whose login item records the sideby it starts. */
108
+ export type LoginItemCommand = 'autostart' | 'menubar';
96
109
  /** Internal, for tests: replaces parts of the machine. Not part of the plugin or Portal contract. */
97
110
  export declare function bindUpdateDeps(deps: Partial<UpdateDeps>): () => void;
98
111
  /** Runs a program through the swappable machine (tests bind `exec`); a Local Build switch installs with it. */
99
112
  export declare const runProgram: UpdateDeps['exec'];
100
- /** Starts the background Panel again from the code `sideby` now names; see `UpdateDeps.restartPanel`. */
101
- export declare const restartPanelByName: (env: Env, port: number) => Promise<boolean>;
102
- /** Starts a program detached through the swappable machine; see `UpdateDeps.startDetached`. */
103
- export declare const startDetached: (file: string, args: readonly string[], env: Env) => Promise<boolean>;
113
+ /** The machine in use: the real one, or the parts tests bound. Internal, for after-install.ts and local-build.ts. */
114
+ export declare const updateMachine: () => UpdateDeps;
104
115
  /** The lock every install shares (`update-install.lock`), so a Local Build switch never races an Update. */
105
116
  export declare const takeInstallLock: (paths: Paths) => Promise<(() => Promise<void>) | null>;
106
117
  /** -1, 0 or 1 like a sort comparator; a prerelease sorts before its release. Null when either is not a version. */
@@ -283,6 +294,11 @@ export interface SkillUpdatePlan {
283
294
  export declare function skillUpdatePlan(home: string, target: string): Promise<SkillUpdatePlan | null>;
284
295
  /** Asks the registry now (whatever the switches say: the user asked) and returns what an Update would do. */
285
296
  export declare function planUpdate(paths: Paths, env: Env): Promise<UpdatePlan>;
297
+ /**
298
+ * The plan of `sideby update --skill`: the installed skill toward this version, never the CLI. Asks no registry: what
299
+ * it says of a newer CLI comes from the last Update Check.
300
+ */
301
+ export declare function planSkillUpdate(paths: Paths, env: Env): Promise<UpdatePlan>;
286
302
  /** Updates the installed sideby skill when the plan says it is outdated and sideby may; null when it did nothing. */
287
303
  export declare function applySkillUpdate(plan: SkillUpdatePlan | undefined, env: Env, onOutput?: (text: string) => void): Promise<{
288
304
  ok: boolean;
@@ -307,22 +323,29 @@ export interface UpdateResult {
307
323
  restartedPanel: boolean;
308
324
  /** The desktop app was installed and `sideby app install` ran again from the new code. */
309
325
  refreshedApp: boolean;
326
+ /** A login item was installed (spec §3.29) and `sideby autostart --refresh` ran from the new code; absent without one. */
327
+ refreshedAutostart?: boolean;
310
328
  /** Another Update held the lock; nothing ran. */
311
329
  busy?: boolean;
312
330
  /** The installed sideby skill was updated too (true), or that failed (false); absent when it was not tried. */
313
331
  skillUpdated?: boolean;
314
332
  skillMessage?: string;
333
+ /** With `skillSync: 'background'`: the `sideby update --skill --yes` that updates the skill started on its own. */
334
+ skillSyncStarted?: boolean;
315
335
  }
316
336
  /**
317
- * Runs the Update the plan names, then starts a running background Panel again from the new code and, when the
318
- * desktop app is installed, runs `sideby app install` again from the new code. The caller has
319
- * shown the plan and got a confirmation (or this is an Auto Update). One Update runs at a time on this machine (the
320
- * CLI, a Panel and an Auto Update share the lock). `panelPort` gives the port of the background Panel to restart, or
321
- * null when none runs. A successful Update is recorded as said, so no notice for it follows.
337
+ * Runs the Update the plan names, then what follows an install (after-install.ts): the desktop app and the login item
338
+ * are written again from the new code where installed, the skill follows, and a running background Panel starts again
339
+ * from the new code, last. The caller has shown the plan and got a confirmation (or this is an Auto Update). One
340
+ * Update runs at a time on this machine (the CLI, a Panel and an Auto Update share the lock). `panelPort` gives the
341
+ * port of the background Panel to restart, or null when none runs. A successful Update is recorded as said, so no
342
+ * notice for it follows.
322
343
  */
323
344
  export declare function applyUpdate(paths: Paths, plan: UpdatePlan, env: Env, opts?: {
324
345
  onOutput?: (text: string) => void;
325
346
  panelPort?: () => Promise<number | null>;
347
+ /** `background` (the Panel): the new code updates the skill on its own; see `AfterInstallOptions.skillSync`. */
348
+ skillSync?: 'wait' | 'background';
326
349
  }): Promise<UpdateResult>;
327
350
  /** What keeps an Auto Update from installing `plan` until the user acts (an install it cannot update, a major version). */
328
351
  export declare function lastingBlocker(plan: UpdatePlan): string | null;
@@ -336,4 +359,3 @@ export declare function autoUpdateBlocker(paths: Paths, plan: UpdatePlan): Promi
336
359
  * `update.auto` is on and nothing blocks it. Only one runs at a time; it never throws.
337
360
  */
338
361
  export declare function backgroundCheck(paths: Paths, env: Env, config: UpdateSettings, panelPort: () => Promise<number | null>): Promise<void>;
339
- export {};