sideby 0.29.0 → 0.30.1
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/dist/build.json +1 -1
- package/dist/src/cli/commands.d.ts +10 -0
- package/dist/src/cli/commands.js +306 -8
- package/dist/src/cli/json-schemas.js +75 -1
- package/dist/src/cli/main.js +83 -4
- package/dist/src/core/config.d.ts +25 -0
- package/dist/src/core/config.js +34 -0
- package/dist/src/core/fs-safe.d.ts +22 -1
- package/dist/src/core/fs-safe.js +68 -1
- package/dist/src/core/handoff-run.d.ts +2 -0
- package/dist/src/core/handoff-run.js +12 -6
- package/dist/src/core/launch.d.ts +6 -1
- package/dist/src/core/messages.js +9 -31
- package/dist/src/core/network.d.ts +5 -2
- package/dist/src/core/network.js +15 -45
- package/dist/src/core/search-catalog.d.ts +1 -1
- package/dist/src/core/search-catalog.js +37 -0
- package/dist/src/core/session-hooks.d.ts +33 -0
- package/dist/src/core/session-hooks.js +92 -0
- package/dist/src/core/unattended-ended.d.ts +62 -0
- package/dist/src/core/unattended-ended.js +275 -0
- package/dist/src/core/unattended-pending.d.ts +56 -0
- package/dist/src/core/unattended-pending.js +182 -0
- package/dist/src/core/unattended-state.d.ts +129 -0
- package/dist/src/core/unattended-state.js +373 -0
- package/dist/src/core/unattended.d.ts +142 -0
- package/dist/src/core/unattended.js +349 -0
- package/dist/src/panel/background.js +8 -0
- package/dist/src/panel/handler.d.ts +37 -0
- package/dist/src/panel/handler.js +153 -1
- package/dist/src/panel/i18n.d.ts +97 -0
- package/dist/src/panel/i18n.js +194 -0
- package/dist/src/panel/page-logic.d.ts +129 -0
- package/dist/src/panel/page-logic.js +166 -0
- package/dist/src/panel/page-script.js +638 -7
- package/dist/src/panel/page-styles.js +69 -0
- package/dist/src/panel/page.js +2 -0
- package/dist/src/plugins/bus.js +1 -0
- package/dist/src/runtime.d.ts +17 -1
- package/dist/src/runtime.js +78 -15
- package/dist/src/types.d.ts +48 -0
- package/dist/src/unattended/hook.d.ts +46 -0
- package/dist/src/unattended/hook.js +288 -0
- package/package.json +1 -1
- package/schemas/config.json +76 -0
- package/schemas/unattended-defer.json +143 -0
- package/schemas/unattended-pending.json +154 -0
- package/schemas/unattended.json +291 -0
- package/skills/sideby/SKILL.md +2 -1
- package/skills/sideby/references/unattended.md +58 -0
package/dist/build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"20261029T090354-1c6bd4"}
|
|
@@ -9,6 +9,14 @@ export interface Io {
|
|
|
9
9
|
/** The terminal Auto Handoff counts down on (spec §3.17); `process.stdin` when left out. */
|
|
10
10
|
stdin?: HandoffIo['stdin'];
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Takes sideby's own `--unattended` (spec §3.37) out of the arguments `run` and `resume` pass to the Host, anywhere
|
|
14
|
+
* before `--`: no Host has an option of that name.
|
|
15
|
+
*/
|
|
16
|
+
export declare function takeUnattended(args: readonly string[]): {
|
|
17
|
+
args: string[];
|
|
18
|
+
unattended: boolean;
|
|
19
|
+
};
|
|
12
20
|
/**
|
|
13
21
|
* Takes sideby's own `--ignore-network` (spec §3.35) out of the arguments `run` and `resume` pass to the Host,
|
|
14
22
|
* anywhere before `--`: no Host has an option of that name.
|
|
@@ -155,6 +163,8 @@ export declare function cmdTheme(a: ParsedArgs, io: Io): Promise<number>;
|
|
|
155
163
|
* `network` after a preview (exit 10 without `--yes`).
|
|
156
164
|
*/
|
|
157
165
|
export declare function cmdNetwork(a: ParsedArgs, io: Io): Promise<number>;
|
|
166
|
+
/** `sideby unattended …` (spec §3.37, ADR-0058): status, on and off, the Schedule, Pending Decisions and `defer`. */
|
|
167
|
+
export declare function cmdUnattended(a: ParsedArgs, io: Io): Promise<number>;
|
|
158
168
|
/**
|
|
159
169
|
* `sideby commands <words>` (spec §3.36, ADR-0054): the Search Catalog the Panel's Command Palette searches, read-only.
|
|
160
170
|
* Titles and places are in English, as every other command prints; the words may be English or Chinese.
|
package/dist/src/cli/commands.js
CHANGED
|
@@ -22,6 +22,7 @@ import { USAGE_DAYS } from '../core/quota-levels.js';
|
|
|
22
22
|
import { groupsToUndo, remoteControlNothingToDo, remoteControlTodo, } from '../core/remote-control.js';
|
|
23
23
|
import { SEARCH_CATALOG, searchCatalog } from '../core/search-catalog.js';
|
|
24
24
|
import { SHELLS } from '../core/shell-init.js';
|
|
25
|
+
import { clockText, daysText } from '../core/unattended-state.js';
|
|
25
26
|
import { MODEL_NAME } from '../families/shared/model-args.js';
|
|
26
27
|
import { AI_TASK_KINDS, hiddenIn, inDisplayOrder, pinnedIn, suggestAlias, suggestName, withPinned, } from '../panel/page-logic.js';
|
|
27
28
|
import { createRuntime, UnknownFamilyError } from '../runtime.js';
|
|
@@ -43,6 +44,32 @@ async function whileRunning(rt, fn) {
|
|
|
43
44
|
async function runAccount(rt, ref, args, io, opts = {}) {
|
|
44
45
|
return whileRunning(rt, () => runAccountNow(rt, ref, args, io, opts));
|
|
45
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Takes sideby's own `--unattended` (spec §3.37) out of the arguments `run` and `resume` pass to the Host, anywhere
|
|
49
|
+
* before `--`: no Host has an option of that name.
|
|
50
|
+
*/
|
|
51
|
+
export function takeUnattended(args) {
|
|
52
|
+
const end = args.indexOf('--');
|
|
53
|
+
const head = end === -1 ? args : args.slice(0, end);
|
|
54
|
+
if (!head.includes('--unattended'))
|
|
55
|
+
return { args: [...args], unattended: false };
|
|
56
|
+
return {
|
|
57
|
+
args: [...head.filter((x) => x !== '--unattended'), ...(end === -1 ? [] : args.slice(end))],
|
|
58
|
+
unattended: true,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Both of sideby's own Launch options, as `run` and `resume` find them among the Host's arguments. */
|
|
62
|
+
function takeLaunchFlags(args) {
|
|
63
|
+
const net = takeIgnoreNetwork(args);
|
|
64
|
+
const un = takeUnattended(net.args);
|
|
65
|
+
return {
|
|
66
|
+
args: un.args,
|
|
67
|
+
flags: {
|
|
68
|
+
...(net.ignoreNetwork ? { ignoreNetwork: true } : {}),
|
|
69
|
+
...(un.unattended ? { unattended: true } : {}),
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
46
73
|
/**
|
|
47
74
|
* Takes sideby's own `--ignore-network` (spec §3.35) out of the arguments `run` and `resume` pass to the Host,
|
|
48
75
|
* anywhere before `--`: no Host has an option of that name.
|
|
@@ -501,12 +528,11 @@ export async function cmdRun(a, io, command) {
|
|
|
501
528
|
if (command === 'login' && (extra.length || a.rest.length))
|
|
502
529
|
throw new UsageError('login takes no extra arguments');
|
|
503
530
|
const rt = await createRuntime();
|
|
504
|
-
const { args,
|
|
505
|
-
const net = ignoreNetwork ? { ignoreNetwork } : {};
|
|
531
|
+
const { args, flags } = takeLaunchFlags([...extra, ...a.rest]);
|
|
506
532
|
if (command === 'run' && rt.pickCommandFamily(ref) !== undefined)
|
|
507
|
-
return runPick(rt, ref, args, io,
|
|
533
|
+
return runPick(rt, ref, args, io, flags);
|
|
508
534
|
if (command === 'run')
|
|
509
|
-
return runAccount(rt, ref, args, io,
|
|
535
|
+
return runAccount(rt, ref, args, io, flags);
|
|
510
536
|
return runLogin(rt, ref, io);
|
|
511
537
|
}
|
|
512
538
|
/** Who an Account is signed in as, for `runLogin`; identity fields and Same Login peers only, never a credential. */
|
|
@@ -570,8 +596,8 @@ export async function cmdResume(a, io) {
|
|
|
570
596
|
if (!family)
|
|
571
597
|
throw new UsageError('usage: sideby resume <family> [-- host args]');
|
|
572
598
|
const rt = await createRuntime();
|
|
573
|
-
const { args,
|
|
574
|
-
const route = await rt.resumeLaunch(family, args,
|
|
599
|
+
const { args, flags } = takeLaunchFlags([...extra, ...a.rest]);
|
|
600
|
+
const route = await rt.resumeLaunch(family, args, flags);
|
|
575
601
|
if (route.launch.notice)
|
|
576
602
|
io.err(c.cyan(route.launch.notice));
|
|
577
603
|
if (route.newSession)
|
|
@@ -588,7 +614,7 @@ function shellQuote(arg) {
|
|
|
588
614
|
export async function cmdNext(a, io) {
|
|
589
615
|
const [family, ...extra] = a.positionals;
|
|
590
616
|
if (!family || extra.length)
|
|
591
|
-
throw new UsageError('usage: sideby next <family> [--dry-run] [--include-api] [--ignore-network] [-- host args]');
|
|
617
|
+
throw new UsageError('usage: sideby next <family> [--dry-run] [--include-api] [--ignore-network] [--unattended] [-- host args]');
|
|
592
618
|
const includeApi = a.flags.has('include-api');
|
|
593
619
|
const rt = await createRuntime();
|
|
594
620
|
const plan = await rt.handoff(family, { includeApi });
|
|
@@ -654,7 +680,10 @@ export async function cmdNext(a, io) {
|
|
|
654
680
|
io.out(c.dim('Tip: ask your old session for a short handoff note and paste it into the new one.'));
|
|
655
681
|
if (!rt.handoffSettings().auto)
|
|
656
682
|
io.out(c.dim('Sessions can also hand over by themselves when quota runs low: see `sideby handoff status`.'));
|
|
657
|
-
return runAccount(rt, plan.pick, a.rest, io,
|
|
683
|
+
return runAccount(rt, plan.pick, a.rest, io, {
|
|
684
|
+
...(a.flags.has('ignore-network') ? { ignoreNetwork: true } : {}),
|
|
685
|
+
...(a.flags.has('unattended') ? { unattended: true } : {}),
|
|
686
|
+
});
|
|
658
687
|
}
|
|
659
688
|
export async function cmdDoctor(a, io) {
|
|
660
689
|
const rt = await createRuntime();
|
|
@@ -1571,8 +1600,15 @@ export async function cmdUi(a, io) {
|
|
|
1571
1600
|
if (srv.reused)
|
|
1572
1601
|
return 0;
|
|
1573
1602
|
io.out(c.dim('Ctrl+C to stop'));
|
|
1603
|
+
// Like the background Panel, a Panel left running notices the end of a stretch of Unattended Mode (spec §3.37).
|
|
1604
|
+
const { watchUnattendedEnded } = await import('../core/unattended-ended.js');
|
|
1605
|
+
const stopWatch = watchUnattendedEnded(paths, async (ctx) => {
|
|
1606
|
+
for (const f of await (await createRuntime()).unattendedEnded(ctx))
|
|
1607
|
+
io.err(`sideby: [${f.plugin}] unattended.ended failed: ${f.error}`);
|
|
1608
|
+
});
|
|
1574
1609
|
await new Promise((resolve) => {
|
|
1575
1610
|
const stop = () => {
|
|
1611
|
+
stopWatch();
|
|
1576
1612
|
void srv.close().then(resolve);
|
|
1577
1613
|
};
|
|
1578
1614
|
process.once('SIGINT', stop);
|
|
@@ -3932,6 +3968,268 @@ export async function cmdNetwork(a, io) {
|
|
|
3932
3968
|
io.out(c.dim('Sessions started without sideby (running `claude` or `codex` directly) are not checked.'));
|
|
3933
3969
|
return 0;
|
|
3934
3970
|
}
|
|
3971
|
+
/** The family a `defer` from inside a session comes from: its Account, else the Host's own variables. */
|
|
3972
|
+
function deferFamily(env) {
|
|
3973
|
+
const ref = env.SIDEBY_ACCOUNT;
|
|
3974
|
+
if (ref?.includes(':'))
|
|
3975
|
+
return ref.slice(0, ref.indexOf(':'));
|
|
3976
|
+
if (env.CLAUDE_CODE_SESSION_ID || env.CLAUDECODE)
|
|
3977
|
+
return 'claude';
|
|
3978
|
+
if (env.CODEX_THREAD_ID)
|
|
3979
|
+
return 'codex';
|
|
3980
|
+
return 'unknown';
|
|
3981
|
+
}
|
|
3982
|
+
/** One line for where Unattended Mode stands now. */
|
|
3983
|
+
function unattendedLine(s, now) {
|
|
3984
|
+
const at = (iso) => clock2(iso, now);
|
|
3985
|
+
const slot = s.slot ? ` · Slot "${s.slot}"` : '';
|
|
3986
|
+
if (s.reason === 'slot' || s.reason === 'manual')
|
|
3987
|
+
return `${c.green('on')}${s.reason === 'manual' ? ' · turned on by hand' : slot}${s.until ? ` · until ${at(s.until)}` : ' · no end: the Schedule covers every hour'}`;
|
|
3988
|
+
if (s.reason === 'session')
|
|
3989
|
+
return `${c.green('on')} for this session only (started with --unattended)`;
|
|
3990
|
+
if (s.reason === 'paused')
|
|
3991
|
+
return `${c.yellow('paused')}${slot}${s.until ? ` · until ${at(s.until)}, then the Schedule goes on` : ' · until you turn it on (`sideby unattended on`)'}`;
|
|
3992
|
+
return `${c.dim('off')}${s.next ? ` · next ${at(s.next.at)}${s.next.slot ? ` (${s.next.slot})` : ''}` : ''}`;
|
|
3993
|
+
}
|
|
3994
|
+
const clock2 = (iso, now) => clockText(Date.parse(iso), now.getTime());
|
|
3995
|
+
function printSchedule(io, schedule) {
|
|
3996
|
+
if (!schedule.length) {
|
|
3997
|
+
io.out(c.dim('Schedule: empty. Add weeknights 23:00-08:00 with `sideby unattended schedule preset weeknights`.'));
|
|
3998
|
+
return;
|
|
3999
|
+
}
|
|
4000
|
+
io.out('Schedule:');
|
|
4001
|
+
schedule.forEach((s, i) => {
|
|
4002
|
+
const night = s.end <= s.start ? (s.end === s.start ? ' (whole day)' : ' (next day)') : '';
|
|
4003
|
+
io.out(` ${i + 1}. ${s.name ? `${s.name} ` : ''}${daysText(s.days)} ${s.start}-${s.end}${night}`);
|
|
4004
|
+
});
|
|
4005
|
+
}
|
|
4006
|
+
function printUnattended(io, s, now, opts = {}) {
|
|
4007
|
+
io.out(`Unattended Mode: ${unattendedLine(s, now)}`);
|
|
4008
|
+
if (s.problem)
|
|
4009
|
+
io.out(c.red(s.problem));
|
|
4010
|
+
if (opts.schedule !== false)
|
|
4011
|
+
printSchedule(io, s.schedule);
|
|
4012
|
+
if (s.pending)
|
|
4013
|
+
io.out(`Pending decisions: ${c.yellow(String(s.pending))} open; see them with \`sideby unattended pending\`.`);
|
|
4014
|
+
if (!s.configured)
|
|
4015
|
+
io.out(c.cyan('Not set up yet: `sideby unattended on` or `sideby unattended schedule preset weeknights` sets it up, and Claude and Codex sessions sideby starts after that are covered.'));
|
|
4016
|
+
else
|
|
4017
|
+
io.out(c.dim('Covers Claude sessions sideby starts (questions and permission prompts), and questions in Codex sessions once you trust `unattended-hook` in /hooks; Codex approval prompts still wait. Not Grok, pi, desktop apps or sessions started without sideby.'));
|
|
4018
|
+
}
|
|
4019
|
+
/** `sideby unattended …` (spec §3.37, ADR-0058): status, on and off, the Schedule, Pending Decisions and `defer`. */
|
|
4020
|
+
export async function cmdUnattended(a, io) {
|
|
4021
|
+
const [sub, ...rest] = a.positionals;
|
|
4022
|
+
const asJson = a.flags.has('json');
|
|
4023
|
+
const allow = (...names) => {
|
|
4024
|
+
for (const k of a.flags.keys())
|
|
4025
|
+
if (k !== 'json' && !names.includes(k))
|
|
4026
|
+
throw new UsageError(`--${k} does not go with \`sideby unattended ${sub ?? ''}\`; run \`sideby unattended --help\``);
|
|
4027
|
+
if (a.rest.length)
|
|
4028
|
+
throw new UsageError('`sideby unattended` takes no arguments after `--`');
|
|
4029
|
+
};
|
|
4030
|
+
const u = await import('../core/unattended.js');
|
|
4031
|
+
const rt = await createRuntime();
|
|
4032
|
+
const families = [...rt.families.keys()];
|
|
4033
|
+
const paths = rt.paths;
|
|
4034
|
+
const now = () => rt.readContext().now;
|
|
4035
|
+
const { checkUnattendedEnded } = await import('../core/unattended-ended.js');
|
|
4036
|
+
// Turning it off or on may end a stretch: notice it now, not at the next command (spec §3.37).
|
|
4037
|
+
const noticeEnd = () => checkUnattendedEnded(paths, async (ctx) => void (await rt.unattendedEnded(ctx)));
|
|
4038
|
+
const show = (change, done) => {
|
|
4039
|
+
if (asJson) {
|
|
4040
|
+
json(io, { ...change.status, changed: change.changed, ...(change.undo ? { undo: change.undo } : {}) });
|
|
4041
|
+
return 0;
|
|
4042
|
+
}
|
|
4043
|
+
io.out(change.changed ? `${c.green('✓')} ${done}` : done);
|
|
4044
|
+
printUnattended(io, change.status, now());
|
|
4045
|
+
if (change.undo)
|
|
4046
|
+
io.out(c.dim(`Undo: ${change.undo}`));
|
|
4047
|
+
return 0;
|
|
4048
|
+
};
|
|
4049
|
+
if (sub === undefined || sub === 'status') {
|
|
4050
|
+
allow();
|
|
4051
|
+
if (rest.length)
|
|
4052
|
+
throw new UsageError('usage: sideby unattended [status] [--json]');
|
|
4053
|
+
const s = await rt.unattendedStatus();
|
|
4054
|
+
if (asJson)
|
|
4055
|
+
json(io, s);
|
|
4056
|
+
else
|
|
4057
|
+
printUnattended(io, s, now());
|
|
4058
|
+
return 0;
|
|
4059
|
+
}
|
|
4060
|
+
if (sub === 'on') {
|
|
4061
|
+
allow('for', 'until', 'slot-end');
|
|
4062
|
+
if (rest.length)
|
|
4063
|
+
throw new UsageError('usage: sideby unattended on [--for <n>h|<n>m | --until <HH:MM|date and time> | --slot-end]');
|
|
4064
|
+
const status = await rt.unattendedStatus();
|
|
4065
|
+
const value = (k) => {
|
|
4066
|
+
const v = a.flags.get(k);
|
|
4067
|
+
return typeof v === 'string' ? v : undefined;
|
|
4068
|
+
};
|
|
4069
|
+
const r = u.onUntil({
|
|
4070
|
+
...(a.flags.has('for') ? { for: value('for') ?? '' } : {}),
|
|
4071
|
+
...(a.flags.has('until') ? { until: value('until') ?? '' } : {}),
|
|
4072
|
+
...(a.flags.has('slot-end') ? { slotEnd: true } : {}),
|
|
4073
|
+
}, status.schedule, now());
|
|
4074
|
+
if ('error' in r)
|
|
4075
|
+
throw new UsageError(r.error);
|
|
4076
|
+
const change = await u.turnUnattendedOn({ paths, families, until: r.until, now: now() });
|
|
4077
|
+
await noticeEnd();
|
|
4078
|
+
return show(change, `Unattended Mode is on until ${clock2(new Date(r.until).toISOString(), now())}.`);
|
|
4079
|
+
}
|
|
4080
|
+
if (sub === 'off') {
|
|
4081
|
+
allow();
|
|
4082
|
+
if (rest.length)
|
|
4083
|
+
throw new UsageError('usage: sideby unattended off [--json]');
|
|
4084
|
+
const change = await u.turnUnattendedOff({ paths, families, now: now() });
|
|
4085
|
+
await noticeEnd();
|
|
4086
|
+
const s = change.status;
|
|
4087
|
+
return show(change, !change.changed
|
|
4088
|
+
? s.reason === 'paused'
|
|
4089
|
+
? s.until
|
|
4090
|
+
? 'Unattended Mode is already paused until this Slot ends.'
|
|
4091
|
+
: 'Unattended Mode is already paused until you turn it on.'
|
|
4092
|
+
: s.reason === 'session'
|
|
4093
|
+
? 'Unattended Mode is off for the computer; this session was started with --unattended and stays on.'
|
|
4094
|
+
: 'Unattended Mode is already off.'
|
|
4095
|
+
: s.reason === 'paused'
|
|
4096
|
+
? s.until
|
|
4097
|
+
? 'Unattended Mode is paused until this Slot ends; the next Slot turns it on as usual.'
|
|
4098
|
+
: 'Unattended Mode is paused until you turn it on: your Schedule covers every hour, so it has no end.'
|
|
4099
|
+
: 'Unattended Mode is off.');
|
|
4100
|
+
}
|
|
4101
|
+
if (sub === 'schedule') {
|
|
4102
|
+
const [action, ...args] = rest;
|
|
4103
|
+
if (action === undefined) {
|
|
4104
|
+
allow();
|
|
4105
|
+
const s = await rt.unattendedStatus();
|
|
4106
|
+
if (asJson)
|
|
4107
|
+
json(io, s);
|
|
4108
|
+
else
|
|
4109
|
+
printSchedule(io, s.schedule);
|
|
4110
|
+
return 0;
|
|
4111
|
+
}
|
|
4112
|
+
if (action === 'add') {
|
|
4113
|
+
allow('days', 'from', 'to', 'name', 'at');
|
|
4114
|
+
if (args.length)
|
|
4115
|
+
throw new UsageError('usage: sideby unattended schedule add --days <mon-fri|sat,sun|…> --from HH:MM --to HH:MM [--name <name>]');
|
|
4116
|
+
const get = (k) => {
|
|
4117
|
+
const v = a.flags.get(k);
|
|
4118
|
+
return typeof v === 'string' ? v : undefined;
|
|
4119
|
+
};
|
|
4120
|
+
const slot = u.slotFromOptions({
|
|
4121
|
+
...(get('days') !== undefined ? { days: get('days') } : {}),
|
|
4122
|
+
...(get('from') !== undefined ? { from: get('from') } : {}),
|
|
4123
|
+
...(get('to') !== undefined ? { to: get('to') } : {}),
|
|
4124
|
+
...(get('name') !== undefined ? { name: get('name') } : {}),
|
|
4125
|
+
});
|
|
4126
|
+
if ('error' in slot)
|
|
4127
|
+
throw new UsageError(slot.error);
|
|
4128
|
+
const at = get('at');
|
|
4129
|
+
if (at !== undefined && !/^[1-9]\d{0,2}$/.test(at))
|
|
4130
|
+
throw new UsageError('--at takes a position such as 1 (the first Slot); leave it out to add at the end');
|
|
4131
|
+
const change = await u.addUnattendedSlot({ paths, families, slot, ...(at ? { at: Number(at) } : {}) });
|
|
4132
|
+
await noticeEnd();
|
|
4133
|
+
return show(change, change.changed ? 'Added the Slot.' : 'That Slot is already in the Schedule.');
|
|
4134
|
+
}
|
|
4135
|
+
if (action === 'remove') {
|
|
4136
|
+
allow();
|
|
4137
|
+
const n = args[0];
|
|
4138
|
+
if (args.length !== 1 || !n || !/^[1-9]\d{0,2}$/.test(n))
|
|
4139
|
+
throw new UsageError('usage: sideby unattended schedule remove <number>, the number `sideby unattended` shows (1 is the first)');
|
|
4140
|
+
const change = await u.removeUnattendedSlot({ paths, families, n: Number(n) });
|
|
4141
|
+
await noticeEnd();
|
|
4142
|
+
return show(change, `Removed Slot ${n}.`);
|
|
4143
|
+
}
|
|
4144
|
+
if (action === 'preset') {
|
|
4145
|
+
allow();
|
|
4146
|
+
const preset = args[0] ? u.UNATTENDED_PRESETS[args[0]] : undefined;
|
|
4147
|
+
if (args.length !== 1 || !preset)
|
|
4148
|
+
throw new UsageError(`usage: sideby unattended schedule preset weeknights (Monday to Friday, 23:00 to 08:00)`);
|
|
4149
|
+
const change = await u.addUnattendedSlot({ paths, families, slot: preset });
|
|
4150
|
+
await noticeEnd();
|
|
4151
|
+
return show(change, change.changed
|
|
4152
|
+
? `Added ${preset.name}: ${daysText(preset.days)} ${preset.start}-${preset.end}.`
|
|
4153
|
+
: `${preset.name} is already in the Schedule.`);
|
|
4154
|
+
}
|
|
4155
|
+
throw new UsageError('usage: sideby unattended schedule [add --days … --from … --to … [--name …] | remove <number> | preset weeknights]');
|
|
4156
|
+
}
|
|
4157
|
+
if (sub === 'pending') {
|
|
4158
|
+
const { listPendingDecisions, markPendingDone } = await import('../core/unattended-pending.js');
|
|
4159
|
+
const [action, ...args] = rest;
|
|
4160
|
+
if (action === 'done') {
|
|
4161
|
+
allow('all');
|
|
4162
|
+
const all = a.flags.has('all');
|
|
4163
|
+
if (all === Boolean(args.length) || args.length > 1)
|
|
4164
|
+
throw new UsageError('usage: sideby unattended pending done <id> | --all (the id is in `sideby unattended pending`)');
|
|
4165
|
+
let done;
|
|
4166
|
+
try {
|
|
4167
|
+
done = await markPendingDone(paths.stateDir, all ? 'all' : args[0], now());
|
|
4168
|
+
}
|
|
4169
|
+
catch (err) {
|
|
4170
|
+
throw new UserError(err.message, { code: 'no-pending' });
|
|
4171
|
+
}
|
|
4172
|
+
const pending = await listPendingDecisions(paths.stateDir, { now: now() });
|
|
4173
|
+
if (asJson)
|
|
4174
|
+
json(io, { done: done.map((d) => d.id), pending });
|
|
4175
|
+
else
|
|
4176
|
+
io.out(`${c.green('✓')} marked ${done.length === 1 ? '1 decision' : `${done.length} decisions`} done; ${pending.length} still open.`);
|
|
4177
|
+
return 0;
|
|
4178
|
+
}
|
|
4179
|
+
allow('all');
|
|
4180
|
+
if (action !== undefined)
|
|
4181
|
+
throw new UsageError('usage: sideby unattended pending [--all] | pending done <id>|--all');
|
|
4182
|
+
const pending = await listPendingDecisions(paths.stateDir, { all: a.flags.has('all'), now: now() });
|
|
4183
|
+
if (asJson) {
|
|
4184
|
+
json(io, { pending });
|
|
4185
|
+
return 0;
|
|
4186
|
+
}
|
|
4187
|
+
if (!pending.length) {
|
|
4188
|
+
io.out('Nothing is waiting for you.');
|
|
4189
|
+
return 0;
|
|
4190
|
+
}
|
|
4191
|
+
for (const d of pending) {
|
|
4192
|
+
const where = [
|
|
4193
|
+
d.account ?? d.family,
|
|
4194
|
+
d.kind === 'question' ? 'question' : d.kind === 'permission' ? 'needed your OK' : 'left undone',
|
|
4195
|
+
d.agentType ? `subagent ${d.agentType}` : '',
|
|
4196
|
+
d.doneAt ? 'done' : '',
|
|
4197
|
+
]
|
|
4198
|
+
.filter(Boolean)
|
|
4199
|
+
.join(' · ');
|
|
4200
|
+
io.out(`${c.bold(d.id)} ${clock2(d.at, now())} ${c.dim(where)}`);
|
|
4201
|
+
for (const line of d.text.split('\n'))
|
|
4202
|
+
io.out(` ${line}`);
|
|
4203
|
+
if (d.sessionId)
|
|
4204
|
+
io.out(c.dim(` session ${d.sessionId}${d.cwd ? ` in ${tildify(d.cwd, paths.home)}` : ''}`));
|
|
4205
|
+
}
|
|
4206
|
+
io.out(c.dim('Mark one done with `sideby unattended pending done <id>`, or all with `--all`.'));
|
|
4207
|
+
return 0;
|
|
4208
|
+
}
|
|
4209
|
+
if (sub === 'defer') {
|
|
4210
|
+
allow();
|
|
4211
|
+
const text = rest.join(' ').trim();
|
|
4212
|
+
if (!text)
|
|
4213
|
+
throw new UsageError('usage: sideby unattended defer "<one sentence on what was left undone>"');
|
|
4214
|
+
const { addPendingDecision } = await import('../core/unattended-pending.js');
|
|
4215
|
+
const env = process.env;
|
|
4216
|
+
const sessionId = env.CLAUDE_CODE_SESSION_ID || env.CODEX_THREAD_ID;
|
|
4217
|
+
const decision = await addPendingDecision(paths.stateDir, {
|
|
4218
|
+
kind: 'deferred',
|
|
4219
|
+
family: deferFamily(env),
|
|
4220
|
+
...(env.SIDEBY_ACCOUNT ? { account: env.SIDEBY_ACCOUNT } : {}),
|
|
4221
|
+
...(sessionId ? { sessionId } : {}),
|
|
4222
|
+
cwd: process.cwd(),
|
|
4223
|
+
text,
|
|
4224
|
+
}, now());
|
|
4225
|
+
if (asJson)
|
|
4226
|
+
json(io, { decision });
|
|
4227
|
+
else
|
|
4228
|
+
io.out(`${c.green('✓')} kept for the user (${decision.id}); they see it with \`sideby unattended pending\`. Go on with the rest of the task.`);
|
|
4229
|
+
return 0;
|
|
4230
|
+
}
|
|
4231
|
+
throw new UsageError('usage: sideby unattended [status|on|off|schedule|pending|defer]; run `sideby unattended --help`');
|
|
4232
|
+
}
|
|
3935
4233
|
/**
|
|
3936
4234
|
* `sideby commands <words>` (spec §3.36, ADR-0054): the Search Catalog the Panel's Command Palette searches, read-only.
|
|
3937
4235
|
* Titles and places are in English, as every other command prints; the words may be English or Chinese.
|
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
// JSON Schemas for every `--json` output. Additive changes keep schemaVersion 1; removals, renames or
|
|
2
2
|
// meaning changes bump it (spec §3.9). `pnpm schemas` writes these to schemas/*.json.
|
|
3
3
|
import { Type } from 'typebox';
|
|
4
|
-
import { ConfigSchema, HandoffSettingsSchema } from '../core/config.js';
|
|
4
|
+
import { ConfigSchema, HandoffSettingsSchema, UnattendedSlotSchema } from '../core/config.js';
|
|
5
5
|
const Str = Type.String();
|
|
6
6
|
/** Why sideby cannot do something itself (spec §3.23); `reason` keeps the English text. */
|
|
7
7
|
const ReasonCode = Type.Union(['local-build', 'npx', 'volta', 'not-writable', 'project', 'source', 'skill-in-git'].map((k) => Type.Literal(k)), { description: 'Why, as a code a page can say in its own language.' });
|
|
8
8
|
const Level = Type.Union([Type.Literal('ok'), Type.Literal('warn'), Type.Literal('fail')]);
|
|
9
9
|
const Kind = Type.Union([Type.Literal('subscription'), Type.Literal('api')]);
|
|
10
10
|
const Version = Type.Literal(1);
|
|
11
|
+
/** One Pending Decision of Unattended Mode (spec §3.37). */
|
|
12
|
+
const PendingDecision = Type.Object({
|
|
13
|
+
id: Str,
|
|
14
|
+
at: Type.String({ description: 'When it was kept; ISO.' }),
|
|
15
|
+
kind: Type.Union([Type.Literal('question'), Type.Literal('permission'), Type.Literal('deferred')], {
|
|
16
|
+
description: 'question: the ask tool was refused; permission: a permission request Claude Code was about to show was refused; deferred: kept with `sideby unattended defer`.',
|
|
17
|
+
}),
|
|
18
|
+
family: Str,
|
|
19
|
+
account: Type.Optional(Type.String({ description: 'The account the session ran as.' })),
|
|
20
|
+
sessionId: Type.Optional(Str),
|
|
21
|
+
cwd: Type.Optional(Str),
|
|
22
|
+
agentId: Type.Optional(Type.String({ description: 'The subagent a permission request came from.' })),
|
|
23
|
+
agentType: Type.Optional(Type.String({ description: 'Its type, such as `general-purpose`.' })),
|
|
24
|
+
text: Type.String({
|
|
25
|
+
description: 'The question and its options, the tool and what it was to do, or the deferred text; at most 4000 characters.',
|
|
26
|
+
}),
|
|
27
|
+
doneAt: Type.Optional(Type.String({ description: 'When it was marked done; ISO.' })),
|
|
28
|
+
});
|
|
11
29
|
/** The menu bar shortcut (`sideby menubar hotkey`, spec §3.31). */
|
|
12
30
|
const hotkeyProps = {
|
|
13
31
|
keys: Type.String({
|
|
@@ -1170,6 +1188,62 @@ export const OUTPUT_SCHEMAS = {
|
|
|
1170
1188
|
before: Type.Object({ guard: Type.Boolean(), allow: Type.Array(Str) }),
|
|
1171
1189
|
after: Type.Object({ guard: Type.Boolean(), allow: Type.Array(Str) }),
|
|
1172
1190
|
}, { title: 'sideby network on|off|allow --json' }),
|
|
1191
|
+
unattended: Type.Object({
|
|
1192
|
+
schemaVersion: Version,
|
|
1193
|
+
on: Type.Boolean({ description: 'Unattended Mode is on now.' }),
|
|
1194
|
+
reason: Type.Union([
|
|
1195
|
+
Type.Literal('slot'),
|
|
1196
|
+
Type.Literal('manual'),
|
|
1197
|
+
Type.Literal('session'),
|
|
1198
|
+
Type.Literal('paused'),
|
|
1199
|
+
Type.Literal('off'),
|
|
1200
|
+
], {
|
|
1201
|
+
description: 'slot: a Slot of the Schedule turned it on; manual: the user did; session: only this session, started with --unattended; paused: off until the current Slot ends; off.',
|
|
1202
|
+
}),
|
|
1203
|
+
until: Type.Optional(Type.String({
|
|
1204
|
+
description: 'When it turns off (on), or when the pause ends (paused); ISO. Absent for a session alone, and when the Schedule covers every hour (on with no end, or paused until `on`).',
|
|
1205
|
+
})),
|
|
1206
|
+
slot: Type.Optional(Type.String({ description: 'The Slot it is in: its name, or its days and times when it has none.' })),
|
|
1207
|
+
slotNumber: Type.Optional(Type.Integer({ description: 'That Slot’s number in `schedule`, from 1.', minimum: 1 })),
|
|
1208
|
+
next: Type.Optional(Type.Object({
|
|
1209
|
+
at: Type.String({ description: 'ISO.' }),
|
|
1210
|
+
slot: Str,
|
|
1211
|
+
slotNumber: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
1212
|
+
}, { description: 'The next time a Slot turns it on by itself.' })),
|
|
1213
|
+
configured: Type.Boolean({
|
|
1214
|
+
description: 'The config has an `unattended` section, so sideby adds its hook to the Claude and Codex sessions it starts.',
|
|
1215
|
+
}),
|
|
1216
|
+
schedule: Type.Array(UnattendedSlotSchema, {
|
|
1217
|
+
description: 'Config `unattended.schedule`, numbered from 1.',
|
|
1218
|
+
}),
|
|
1219
|
+
pending: Type.Integer({ description: 'Open Pending Decisions (`sideby unattended pending`).' }),
|
|
1220
|
+
coverage: Type.Record(Str, Type.Union([Type.Literal('covered'), Type.Literal('needs-trust'), Type.Literal('not-covered')]), {
|
|
1221
|
+
description: 'Per family: covered (sessions sideby starts get the hook), needs-trust (Codex runs it once the user trusts it in /hooks), not-covered (no hook sideby can add, or the feature was never used).',
|
|
1222
|
+
}),
|
|
1223
|
+
slotEnd: Type.Optional(Type.String({
|
|
1224
|
+
description: 'When `on --slot-end` would end: the end of the current or next Slot, when that is within 72 hours; ISO.',
|
|
1225
|
+
})),
|
|
1226
|
+
manual: Type.Optional(Type.Object({
|
|
1227
|
+
mode: Type.Union([Type.Literal('on'), Type.Literal('pause')]),
|
|
1228
|
+
until: Type.Optional(Type.String({
|
|
1229
|
+
description: 'ISO. Absent only for a pause made while the Schedule covers every hour: it lasts until `on`.',
|
|
1230
|
+
})),
|
|
1231
|
+
at: Type.String({ description: 'When the user chose it; ISO.' }),
|
|
1232
|
+
}, { description: 'The manual state in effect now: on until, or paused until.' })),
|
|
1233
|
+
problem: Type.Optional(Type.String({
|
|
1234
|
+
description: 'Why sideby cannot keep its state: `<state>/unattended` is a link, someone else’s, or writable by others. Says what to do.',
|
|
1235
|
+
})),
|
|
1236
|
+
changed: Type.Optional(Type.Boolean({ description: 'Set by on, off and schedule changes: whether anything changed.' })),
|
|
1237
|
+
undo: Type.Optional(Type.String({ description: 'The command that puts back what the change replaced.' })),
|
|
1238
|
+
}, { title: 'sideby unattended [on|off|schedule …] --json' }),
|
|
1239
|
+
'unattended-pending': Type.Object({
|
|
1240
|
+
schemaVersion: Version,
|
|
1241
|
+
pending: Type.Array(PendingDecision, {
|
|
1242
|
+
description: 'Open Pending Decisions, oldest first; with --all the done ones too.',
|
|
1243
|
+
}),
|
|
1244
|
+
done: Type.Optional(Type.Array(Str, { description: '`pending done`: the ids marked done.' })),
|
|
1245
|
+
}, { title: 'sideby unattended pending [done <id>|--all] --json' }),
|
|
1246
|
+
'unattended-defer': Type.Object({ schemaVersion: Version, decision: PendingDecision }, { title: 'sideby unattended defer "<text>" --json' }),
|
|
1173
1247
|
browser: Type.Object({
|
|
1174
1248
|
schemaVersion: Version,
|
|
1175
1249
|
enabled: Type.Boolean({
|
package/dist/src/cli/main.js
CHANGED
|
@@ -44,7 +44,7 @@ Usage:
|
|
|
44
44
|
sideby login <account> sign in to an account
|
|
45
45
|
sideby resume <family> [-- args] run the host; a session resumed by id (claude --resume <id>,
|
|
46
46
|
codex resume <id>) starts in the account that holds it
|
|
47
|
-
sideby next <family> [--dry-run] [--include-api] [--ignore-network] [-- args]
|
|
47
|
+
sideby next <family> [--dry-run] [--include-api] [--ignore-network] [--unattended] [-- args]
|
|
48
48
|
recommend the account with the most quota left (claude, codex, grok)
|
|
49
49
|
and start it; --dry-run only recommends
|
|
50
50
|
sideby doctor [target] [--fix] [--force]
|
|
@@ -100,6 +100,9 @@ Usage:
|
|
|
100
100
|
config.toml) in your editor
|
|
101
101
|
sideby network [check] stop Claude and Codex when requests would leave from a country
|
|
102
102
|
you did not allow (network on|off|allow <CC>... [--yes])
|
|
103
|
+
sideby unattended [on|off] nobody is here: sessions sideby starts do not stop to ask; on takes
|
|
104
|
+
--for 4h, --until 07:30 or --slot-end (schedule add|remove|preset weeknights,
|
|
105
|
+
pending [done <id>|--all], defer "<text>"); run --unattended for one session
|
|
103
106
|
sideby browser [--enable [--yes]] which Chrome browser user signed in to each account's website
|
|
104
107
|
(read on this computer only; off until you enable it)
|
|
105
108
|
sideby browser open <account> [--profile <name>]
|
|
@@ -135,9 +138,9 @@ Usage:
|
|
|
135
138
|
Options:
|
|
136
139
|
--json machine-readable output (list, new, next, alias, doctor, quota, tune, model, remote-control, handoff,
|
|
137
140
|
families, commands, plugins, app, desktop, sessions, history, send, messages, edit, browser, update, local, ask,
|
|
138
|
-
terminal, key, try, autostart, menubar, config)
|
|
141
|
+
terminal, key, try, autostart, menubar, config, network, unattended)
|
|
139
142
|
-h, --help show this help; \`sideby <command> --help\` for new, alias, login, doctor, families, commands, desktop, edit, browser,
|
|
140
|
-
autostart, menubar, config, sessions, history, send, messages
|
|
143
|
+
autostart, menubar, config, sessions, history, send, messages, network, unattended
|
|
141
144
|
-v, --version show the version
|
|
142
145
|
|
|
143
146
|
An <account> is <family>:<name> (claude:work) or just <name> when it is unique.
|
|
@@ -465,6 +468,43 @@ Examples:
|
|
|
465
468
|
sideby network check
|
|
466
469
|
Exit: 0 shown or changed; 10 a change was shown and waits for --yes; 1 a country code that is not one, or on with
|
|
467
470
|
no country allowed; 2 malformed command line.`,
|
|
471
|
+
unattended: `sideby unattended [status] [--json]
|
|
472
|
+
sideby unattended on [--for <n>h|<n>m | --until <HH:MM|date and time> | --slot-end] [--json]
|
|
473
|
+
sideby unattended off [--json]
|
|
474
|
+
sideby unattended schedule [add --days <days> --from HH:MM --to HH:MM [--name <name>] [--at <n>]] [--json]
|
|
475
|
+
sideby unattended schedule remove <n> | preset weeknights [--json]
|
|
476
|
+
sideby unattended pending [--all] [--json]
|
|
477
|
+
sideby unattended pending done <id> | --all [--json]
|
|
478
|
+
sideby unattended defer "<text>" [--json]
|
|
479
|
+
|
|
480
|
+
Unattended Mode: nobody is at the computer, so sessions sideby starts never stop to wait for a person. While it is on,
|
|
481
|
+
a Claude or Codex session sideby started is not allowed to ask a question: the model takes the recommended option
|
|
482
|
+
where it can be undone, and skips anything hard to undo (deleting, sending, publishing, deploying, paying). Each
|
|
483
|
+
question it could not ask, and each thing it skipped (\`defer\`), is kept as a Pending Decision for when you are back.
|
|
484
|
+
In Claude sessions, a permission prompt Claude Code is about to show (a command it wants a person to confirm, also in
|
|
485
|
+
a subagent) is answered with "no" and how to do it without one, and kept as a Pending Decision too. Codex's own
|
|
486
|
+
approval prompts are not covered.
|
|
487
|
+
|
|
488
|
+
When it is on: during a Slot of the Schedule (local days and times; an end before the start is the next day), from
|
|
489
|
+
\`on\` until the time you choose (at most 72 hours; without an option, until the current or next Slot ends, else 12
|
|
490
|
+
hours), or for one session started with \`--unattended\` (\`sideby run <account> --unattended\`, also next, resume,
|
|
491
|
+
short commands and pick commands). \`off\` outside a Slot turns it off; during a Slot it pauses until that Slot ends.
|
|
492
|
+
|
|
493
|
+
It covers Claude and Codex sessions sideby starts after the first use (sideby adds its hook to them; nothing is written
|
|
494
|
+
into the account folders). Codex runs the hook once you trust \`unattended-hook\` in /hooks. Grok, pi, desktop apps and
|
|
495
|
+
sessions started without sideby are not covered. Pending Decisions stay on this computer; \`pending done\` marks them
|
|
496
|
+
done, and they are deleted 30 days later. \`defer\` keeps a line from inside a session ("deploy left for the user").
|
|
497
|
+
|
|
498
|
+
--days takes mon…sun, ranges and lists: mon-fri, sat,sun, fri-mon, weekdays, daily. Each change prints its undo.
|
|
499
|
+
|
|
500
|
+
Examples:
|
|
501
|
+
sideby unattended on --until 07:30
|
|
502
|
+
sideby unattended schedule preset weeknights
|
|
503
|
+
sideby unattended schedule add --days sat,sun --from 01:00 --to 09:00 --name "Weekend nights"
|
|
504
|
+
sideby unattended pending
|
|
505
|
+
sideby unattended defer "deleting the old branch is left for the user"
|
|
506
|
+
Exit: 0 shown or done; 1 no such Slot or Pending Decision; 2 a time or option it does not take (the message says
|
|
507
|
+
which to use).`,
|
|
468
508
|
browser: `sideby browser [--enable|--disable] [--yes] [--json]
|
|
469
509
|
sideby browser open <account> [--profile <folder|name>] [--json]
|
|
470
510
|
sideby browser set <account> <folder|name> [--json]
|
|
@@ -549,8 +589,12 @@ const COMMANDS = {
|
|
|
549
589
|
run: { flags: [] },
|
|
550
590
|
resume: { flags: [] },
|
|
551
591
|
login: { flags: [] },
|
|
552
|
-
next: { flags: ['dry-run', 'include-api', 'json', 'ignore-network'] },
|
|
592
|
+
next: { flags: ['dry-run', 'include-api', 'json', 'ignore-network', 'unattended'] },
|
|
553
593
|
network: { flags: ['json', 'yes'] },
|
|
594
|
+
unattended: {
|
|
595
|
+
flags: ['json', 'all', 'slot-end'],
|
|
596
|
+
valued: ['for', 'until', 'days', 'from', 'to', 'name', 'at'],
|
|
597
|
+
},
|
|
554
598
|
new: { flags: ['api', 'json', 'next'], valued: ['alias'] },
|
|
555
599
|
alias: { flags: ['json', 'yes'], valued: ['pick'] },
|
|
556
600
|
doctor: { flags: ['fix', 'force', 'json'] },
|
|
@@ -697,6 +741,11 @@ export async function main(argv) {
|
|
|
697
741
|
const { runNetworkHook } = await import('../network/hook.js');
|
|
698
742
|
return runNetworkHook(rest, process.env, process.stderr);
|
|
699
743
|
}
|
|
744
|
+
// Unattended Mode's hook runs before every tool call it matches (spec §3.37); same fast path.
|
|
745
|
+
if (first === 'unattended-hook') {
|
|
746
|
+
const { runUnattendedHook } = await import('../unattended/hook.js');
|
|
747
|
+
return runUnattendedHook(rest, process.env, process.stdin, { out: process.stdout, err: process.stderr });
|
|
748
|
+
}
|
|
700
749
|
if (nodeTooOld()) {
|
|
701
750
|
console.error(`sideby needs Node ${MIN_NODE.join('.')} or newer (you have ${process.versions.node}). Upgrade: https://nodejs.org, or with nvm: \`nvm install 22 && nvm alias default 22\`, then \`npm i -g sideby\` again (each Node version has its own global packages).`);
|
|
702
751
|
return 1;
|
|
@@ -719,6 +768,7 @@ export async function main(argv) {
|
|
|
719
768
|
const own = args.includes('--') ? args.slice(0, args.indexOf('--')) : args;
|
|
720
769
|
const wantsJson = Boolean(spec?.flags.includes('json')) && own.includes('--json');
|
|
721
770
|
let notice = null;
|
|
771
|
+
let ended;
|
|
722
772
|
try {
|
|
723
773
|
if (!spec)
|
|
724
774
|
throw new UsageError(`unknown command "${cmd}"; run \`sideby --help\``);
|
|
@@ -758,6 +808,12 @@ export async function main(argv) {
|
|
|
758
808
|
parsed.attach = repeatedValues(own, 'attach');
|
|
759
809
|
if (cmd === 'send')
|
|
760
810
|
parsed.images = repeatedValues(own, 'image');
|
|
811
|
+
// A stretch of Unattended Mode that ended is noticed when a command starts (spec §3.37); its plugin event runs
|
|
812
|
+
// alongside the command and is waited for before exiting.
|
|
813
|
+
if (cmd !== 'update-check' && !(cmd === 'ui' && parsed.flags.has('serve-detached'))) {
|
|
814
|
+
const { noticeUnattendedEnded } = await import('../core/unattended-ended.js');
|
|
815
|
+
ended = await noticeUnattendedEnded(process.env);
|
|
816
|
+
}
|
|
761
817
|
const cmds = await import('./commands.js');
|
|
762
818
|
if (wantsJson && noticeAllowed(cmd, parsed)) {
|
|
763
819
|
notice = await jsonNoticeFor();
|
|
@@ -782,6 +838,9 @@ export async function main(argv) {
|
|
|
782
838
|
console.error(err.stack);
|
|
783
839
|
return usage ? 2 : 1;
|
|
784
840
|
}
|
|
841
|
+
finally {
|
|
842
|
+
await ended?.emitted;
|
|
843
|
+
}
|
|
785
844
|
}
|
|
786
845
|
async function dispatch(cmd, parsed, io, cmds) {
|
|
787
846
|
switch (cmd) {
|
|
@@ -847,6 +906,8 @@ async function dispatch(cmd, parsed, io, cmds) {
|
|
|
847
906
|
return await cmds.cmdBrowser(parsed, io);
|
|
848
907
|
case 'network':
|
|
849
908
|
return await cmds.cmdNetwork(parsed, io);
|
|
909
|
+
case 'unattended':
|
|
910
|
+
return await cmds.cmdUnattended(parsed, io);
|
|
850
911
|
case 'shell-init':
|
|
851
912
|
return await cmds.cmdShellInit(parsed, io);
|
|
852
913
|
case 'plugins':
|
|
@@ -885,7 +946,25 @@ function isEntry() {
|
|
|
885
946
|
return false;
|
|
886
947
|
}
|
|
887
948
|
}
|
|
949
|
+
// Node warns once on stderr when anything loads `node:sqlite`, which it still marks experimental. Session History uses
|
|
950
|
+
// it, and a plugin may read a Host's SQLite file at load time, so the warning would follow every command.
|
|
951
|
+
// The CLI drops that one warning; every other warning still reaches stderr.
|
|
952
|
+
function hideSqliteWarning() {
|
|
953
|
+
const emit = process.emitWarning;
|
|
954
|
+
process.emitWarning = ((warning, ...rest) => {
|
|
955
|
+
const text = typeof warning === 'string' ? warning : warning.message;
|
|
956
|
+
const opt = rest[0];
|
|
957
|
+
const type = typeof opt === 'string'
|
|
958
|
+
? opt
|
|
959
|
+
: (opt?.type ??
|
|
960
|
+
(typeof warning === 'string' ? undefined : warning.name));
|
|
961
|
+
if (type === 'ExperimentalWarning' && /^SQLite is an experimental feature/.test(text))
|
|
962
|
+
return;
|
|
963
|
+
emit.call(process, warning, ...rest);
|
|
964
|
+
});
|
|
965
|
+
}
|
|
888
966
|
if (isEntry()) {
|
|
967
|
+
hideSqliteWarning();
|
|
889
968
|
main(process.argv.slice(2)).then((code) => {
|
|
890
969
|
process.exitCode = code;
|
|
891
970
|
}, (err) => {
|