sideby 0.39.0 → 0.40.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/README.md +2 -2
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.js +34 -3
- package/dist/src/cli/json-schemas.js +9 -2
- package/dist/src/cli/main.js +10 -2
- package/dist/src/core/cli-commands.js +12 -0
- package/dist/src/core/config.d.ts +1 -0
- package/dist/src/core/config.js +3 -0
- package/dist/src/core/handoff-run.js +192 -175
- package/dist/src/core/progress-state.d.ts +21 -7
- package/dist/src/core/progress-state.js +32 -8
- package/dist/src/core/search-catalog.js +18 -0
- package/dist/src/core/session-hooks.d.ts +7 -0
- package/dist/src/core/session-hooks.js +27 -0
- package/dist/src/core/unattended-pending.d.ts +14 -2
- package/dist/src/core/unattended-pending.js +27 -3
- package/dist/src/core/unattended-state.d.ts +19 -1
- package/dist/src/core/unattended-state.js +31 -5
- package/dist/src/core/unattended-wait.d.ts +86 -0
- package/dist/src/core/unattended-wait.js +125 -0
- package/dist/src/core/unattended.d.ts +19 -0
- package/dist/src/core/unattended.js +37 -4
- package/dist/src/families/claude/handoff.js +3 -1
- package/dist/src/panel/handler.js +16 -1
- package/dist/src/panel/i18n.d.ts +9 -0
- package/dist/src/panel/i18n.js +26 -8
- package/dist/src/panel/page-script.js +51 -2
- package/dist/src/panel/page-styles.js +7 -0
- package/dist/src/progress/hook.d.ts +7 -0
- package/dist/src/progress/hook.js +18 -11
- package/dist/src/types.d.ts +5 -0
- package/dist/src/unattended/hook.d.ts +21 -6
- package/dist/src/unattended/hook.js +261 -19
- package/package.json +2 -2
- package/schemas/config.json +14 -0
- package/schemas/unattended-defer.json +5 -0
- package/schemas/unattended-pending.json +5 -0
- package/schemas/unattended.json +16 -2
- package/skills/sideby/SKILL.md +3 -2
- package/skills/sideby/references/progress.md +3 -3
- package/skills/sideby/references/unattended.md +16 -2
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
// most three times in a row, and keeps a Pending Decision when that did not help (Turn Retry, ADR-0067). And in Claude
|
|
16
16
|
// it runs in the background on every prompt (`UserPromptSubmit`, `async`): a prompt a person typed makes that session
|
|
17
17
|
// an Attended Session for 30 minutes, which it leaves alone as if the mode were off, telling the user once (ADR-0075).
|
|
18
|
+
// A question or a permission prompt Claude Code shows, in an Attended Session or while the mode is off, is watched in
|
|
19
|
+
// the background (Answer Wait, ADR-0077): once it has waited `unattended.answerWait` minutes with nobody answering and
|
|
20
|
+
// the mode is on, it is refused as the mode would refuse it, and so is a turn that ended on a question written as text
|
|
21
|
+
// (a second `Stop` entry, `asyncRewake`). It never answers anything with "yes".
|
|
18
22
|
// A failure before the decision is made does nothing: that is
|
|
19
23
|
// how a session behaves without the feature (unlike `network-hook`, which blocks when it cannot tell). Once the
|
|
20
24
|
// decision is to refuse, it refuses: keeping the Pending Decision and writing the reason are best effort, and their
|
|
@@ -22,9 +26,10 @@
|
|
|
22
26
|
import { resolvePaths } from '../core/paths.js';
|
|
23
27
|
import { hostMade, launchPrompt, sidebyMessage } from '../core/prompt-origin.js';
|
|
24
28
|
import { ATTENDED_MS, markAttended, markTold, ownTranscript, promptOrigin, readAttended, sessionUnattended, } from '../core/unattended-attended.js';
|
|
25
|
-
import { addPendingDecision } from '../core/unattended-pending.js';
|
|
29
|
+
import { addPendingDecision, withdrawPendingDecision, } from '../core/unattended-pending.js';
|
|
26
30
|
import { clearRetryStreak, countFailure, passingFailure, RETRY_LIMIT, readRetryStreak, retryDelay, retryGaveUpText, retryMessage, } from '../core/unattended-retry.js';
|
|
27
31
|
import { clockText, readUnattendedConfig, readUnattendedOverride, UNATTENDED_ENV, unattendedState, } from '../core/unattended-state.js';
|
|
32
|
+
import { lastLook, waitedMinutes, watchScreen } from '../core/unattended-wait.js';
|
|
28
33
|
export const UNATTENDED_HOOK_COMMAND = 'sideby unattended-hook';
|
|
29
34
|
/** The tool each Host's model asks the user with. */
|
|
30
35
|
export const ASK_TOOLS = {
|
|
@@ -107,21 +112,31 @@ export function questionText(input) {
|
|
|
107
112
|
}
|
|
108
113
|
return parts.join('\n\n') || JSON.stringify(input);
|
|
109
114
|
}
|
|
110
|
-
/**
|
|
111
|
-
|
|
115
|
+
/**
|
|
116
|
+
* What the model reads instead of an answer. `waited`: the question was on screen this many minutes with nobody
|
|
117
|
+
* answering (Answer Wait); the session shows the text too, so it opens with what happened for the person coming back.
|
|
118
|
+
*/
|
|
119
|
+
export function questionReason(state, now, zh, kept, waited) {
|
|
112
120
|
const until = state.until ? clockText(Date.parse(state.until), now.getTime(), zh) : undefined;
|
|
113
121
|
const session = state.reason === 'session';
|
|
114
122
|
if (zh) {
|
|
115
123
|
const when = session ? '(这个会话)' : until ? `(到 ${until})` : '(没有结束时间)';
|
|
116
124
|
const keep = kept ? 'sideby 已把这个问题记下,等用户回来看' : 'sideby 没能记下这个问题,请写进最终汇报';
|
|
117
|
-
|
|
125
|
+
const head = waited
|
|
126
|
+
? `${waited} 分钟没人回答:sideby 无人值守已开启${when},会话不再等回答,${keep}。`
|
|
127
|
+
: `未显示:sideby 无人值守已开启${when},现在没人能回答,${keep}。`;
|
|
128
|
+
return `${head}不要再问。能撤回的选择按推荐的选项继续,在最终汇报里写出这个问题和你的选择。删除、对外发送或发布、部署、付费等难撤回的操作不要做:跳过它,运行 \`sideby unattended defer "<一句话>"\` 记下,再继续做其余的事。`;
|
|
118
129
|
}
|
|
119
130
|
const when = session ? 'for this session' : until ? `until ${until}` : 'with no end set';
|
|
120
131
|
const keep = kept
|
|
121
132
|
? 'sideby kept this question for the user to look at later'
|
|
122
133
|
: 'sideby could not keep this question, so put it in your final report';
|
|
123
|
-
|
|
134
|
+
const head = waited
|
|
135
|
+
? `No answer after ${minutesText(waited)}: sideby's Unattended Mode is on ${when}, so the session goes on without one, and ${keep}.`
|
|
136
|
+
: `Not shown: sideby's Unattended Mode is on ${when}, so nobody is here to answer, and ${keep}.`;
|
|
137
|
+
return `${head} Do not ask again. Where the choice can be undone, go on with the recommended option, and list the question and your choice in your final report. Do not do anything hard to undo (deleting, sending or posting anything outside, publishing, deploying, paying): skip it, record it with \`sideby unattended defer "<one sentence>"\`, and go on with the rest.`;
|
|
124
138
|
}
|
|
139
|
+
const minutesText = (n) => (n === 1 ? '1 minute' : `${n} minutes`);
|
|
125
140
|
/** How much of the end of the model's last message is read to tell whether it ends on a question. */
|
|
126
141
|
export const QUESTION_TAIL = 600;
|
|
127
142
|
/**
|
|
@@ -217,20 +232,29 @@ export function endingQuestion(message) {
|
|
|
217
232
|
return question;
|
|
218
233
|
return undefined;
|
|
219
234
|
}
|
|
220
|
-
/**
|
|
221
|
-
|
|
235
|
+
/**
|
|
236
|
+
* What the model reads when it ended its turn on a question and nobody is here to answer. `waited`: the question was
|
|
237
|
+
* left this many minutes with no reply (Answer Wait); this note then wakes the session, and is not the user's reply.
|
|
238
|
+
*/
|
|
239
|
+
export function stopReason(state, now, zh, kept, waited) {
|
|
222
240
|
const until = state.until ? clockText(Date.parse(state.until), now.getTime(), zh) : undefined;
|
|
223
241
|
const session = state.reason === 'session';
|
|
224
242
|
if (zh) {
|
|
225
243
|
const when = session ? '(这个会话)' : until ? `(到 ${until})` : '(没有结束时间)';
|
|
226
244
|
const keep = kept ? 'sideby 已把你的问题记下,等用户回来看' : 'sideby 没能记下你的问题,请写进最终汇报';
|
|
227
|
-
|
|
245
|
+
const head = waited
|
|
246
|
+
? `${waited} 分钟没人回复你的问题:sideby 无人值守已开启${when},${keep}。这条不是用户的回复。`
|
|
247
|
+
: `没人能回答:sideby 无人值守已开启${when},${keep}。`;
|
|
248
|
+
return `${head}不要等回复,也不要再问。能撤回的选择按推荐的选项继续,一直做到完。删除、对外发送或发布、部署、付费等难撤回的操作不要做:跳过它,运行 \`sideby unattended defer "<一句话>"\` 记下,再做完其余的事。最后写一份最终汇报,列出你做的每个选择和记下的每件事,不提任何问题。`;
|
|
228
249
|
}
|
|
229
250
|
const when = session ? 'for this session' : until ? `until ${until}` : 'with no end set';
|
|
230
251
|
const keep = kept
|
|
231
252
|
? 'sideby kept your question for the user to look at later'
|
|
232
253
|
: 'sideby could not keep your question, so put it in your final report';
|
|
233
|
-
|
|
254
|
+
const head = waited
|
|
255
|
+
? `Nobody replied to your question for ${minutesText(waited)}: sideby's Unattended Mode is on ${when}, and ${keep}. This note is not the user's reply.`
|
|
256
|
+
: `Nobody is here to answer: sideby's Unattended Mode is on ${when}, and ${keep}.`;
|
|
257
|
+
return `${head} Do not wait for an answer and do not ask again. Where the choice can be undone, go on with the recommended option and carry on to the end. Do not do anything hard to undo (deleting, sending or posting anything outside, publishing, deploying, paying): skip it, record it with \`sideby unattended defer "<one sentence>"\`, and finish the rest. Then end with a final report that lists each choice you made and each item you recorded, without asking anything.`;
|
|
234
258
|
}
|
|
235
259
|
/** What a declined MCP form is kept as: the server's name and what it asked, never a field's value. */
|
|
236
260
|
export function elicitationText(v) {
|
|
@@ -323,12 +347,18 @@ export function permissionText(tool, input) {
|
|
|
323
347
|
}
|
|
324
348
|
return tool;
|
|
325
349
|
}
|
|
326
|
-
/**
|
|
327
|
-
|
|
350
|
+
/**
|
|
351
|
+
* What the model reads instead of the permission prompt Claude Code would have shown. `waited`: the prompt was on
|
|
352
|
+
* screen this many minutes with nobody answering (Answer Wait).
|
|
353
|
+
*/
|
|
354
|
+
export function permissionReason(state, now, kept, waited) {
|
|
328
355
|
const until = state.until ? clockText(Date.parse(state.until), now.getTime(), false) : undefined;
|
|
329
356
|
const when = state.reason === 'session' ? 'for this session' : until ? `until ${until}` : 'with no end set';
|
|
330
357
|
const keep = kept ? ' sideby kept this request for the user to look at later.' : '';
|
|
331
|
-
|
|
358
|
+
const head = waited
|
|
359
|
+
? `Not allowed: nobody confirmed this action in ${minutesText(waited)}, and sideby's Unattended Mode is on ${when}.`
|
|
360
|
+
: `Not allowed: Claude Code wanted a person to confirm this action, and nobody is here (sideby's Unattended Mode is on ${when}).`;
|
|
361
|
+
return `${head}${keep} Rewrite it so it needs no confirmation: literal paths, "\${VAR:?}" for variables in rm targets, plain bash syntax, and rm as a command of its own. Or skip it, record it with \`sideby unattended defer "<what and why>"\`, and go on with the rest.`;
|
|
332
362
|
}
|
|
333
363
|
/**
|
|
334
364
|
* What the user reads once in an Attended Session while Unattended Mode is on (ADR-0075), as a `systemMessage`: shown
|
|
@@ -340,8 +370,11 @@ export function attendedNotice(state, zh) {
|
|
|
340
370
|
return `sideby:你在,这个会话在你最后一条消息后 30 分钟内照常问你。${session ? '它是按无人值守启动的,30 分钟没人打字后恢复。' : '其他会话仍然无人值守。要全部关掉,运行 `sideby unattended off`。'}`;
|
|
341
371
|
return `sideby: you're here, so this session asks you as usual for 30 minutes after your last message. ${session ? 'It was started unattended, and goes back to that once nobody has typed for 30 minutes.' : 'Other sessions stay unattended. To turn Unattended Mode off everywhere, run `sideby unattended off`.'}`;
|
|
342
372
|
}
|
|
343
|
-
/**
|
|
344
|
-
|
|
373
|
+
/**
|
|
374
|
+
* What to do with this call: undefined allows it. Any error here allows it too (the caller catches it). A permission
|
|
375
|
+
* request (in Claude, also the ask tool's) that is not refused at once may first wait for a person (Answer Wait).
|
|
376
|
+
*/
|
|
377
|
+
async function decide(argv, env, input, now, deps) {
|
|
345
378
|
const [family = '', event = ''] = argv;
|
|
346
379
|
const askTool = ASK_TOOLS[family];
|
|
347
380
|
const permission = family === 'claude' && event === 'PermissionRequest';
|
|
@@ -359,10 +392,12 @@ async function decide(argv, env, input, now) {
|
|
|
359
392
|
if (sessionId)
|
|
360
393
|
await clearRetryStreak(paths.stateDir, sessionId).catch(() => { });
|
|
361
394
|
}
|
|
362
|
-
const { schedule } = await readUnattendedConfig(paths.configFile);
|
|
395
|
+
const { schedule, answerWait } = await readUnattendedConfig(paths.configFile);
|
|
363
396
|
const override = await readUnattendedOverride(paths.stateDir);
|
|
364
397
|
const state = unattendedState({ schedule, override, now, session: env[UNATTENDED_ENV] === '1' });
|
|
365
|
-
|
|
398
|
+
// Answer Wait: what Claude Code shows is watched while the mode is off too, since it may come on before anyone answers.
|
|
399
|
+
const watch = permission && answerWait !== null;
|
|
400
|
+
if (!state.on && !watch)
|
|
366
401
|
return undefined;
|
|
367
402
|
const raw = early ?? (await readInput(input));
|
|
368
403
|
const zh = prefersChinese(env);
|
|
@@ -429,8 +464,14 @@ async function decide(argv, env, input, now) {
|
|
|
429
464
|
const payload = parsePayload(raw);
|
|
430
465
|
if (!payload)
|
|
431
466
|
return undefined;
|
|
432
|
-
if (permission
|
|
433
|
-
|
|
467
|
+
if (permission) {
|
|
468
|
+
// Asked in front of someone (an Attended Session) or while the mode is off: shown, and watched while it waits.
|
|
469
|
+
const shown = state.on ? await attended(payload.sessionId, false) : {};
|
|
470
|
+
if (shown)
|
|
471
|
+
return watch ? answerAfterWait(payload, env, now.getTime(), deps) : undefined;
|
|
472
|
+
}
|
|
473
|
+
else if (payload.tool === askTool) {
|
|
474
|
+
const here = await attended(payload.sessionId, true);
|
|
434
475
|
if (here)
|
|
435
476
|
return here.answer;
|
|
436
477
|
}
|
|
@@ -479,6 +520,19 @@ export async function runUnattendedHook(argv, env, input, io, deps = {}) {
|
|
|
479
520
|
await notePrompt(env, input, deps).catch(() => { });
|
|
480
521
|
return 0;
|
|
481
522
|
}
|
|
523
|
+
if (argv[0] === 'claude' && argv[1] === 'StopWait') {
|
|
524
|
+
// In the background (`asyncRewake`): exit 2 wakes the idle session with the note on stderr.
|
|
525
|
+
try {
|
|
526
|
+
const wake = await wakeAfterWait(env, input, deps);
|
|
527
|
+
if (!wake)
|
|
528
|
+
return 0;
|
|
529
|
+
io.err.write(`${wake}\n`);
|
|
530
|
+
return 2;
|
|
531
|
+
}
|
|
532
|
+
catch {
|
|
533
|
+
return 0;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
482
536
|
if (argv[0] === 'claude' && argv[1] === 'StopFailure') {
|
|
483
537
|
try {
|
|
484
538
|
const wake = await retryAfterFailure(env, input, deps);
|
|
@@ -494,7 +548,7 @@ export async function runUnattendedHook(argv, env, input, io, deps = {}) {
|
|
|
494
548
|
let refusal;
|
|
495
549
|
const now = deps.now ? deps.now() : new Date();
|
|
496
550
|
try {
|
|
497
|
-
refusal = await decide(argv, env, input, now);
|
|
551
|
+
refusal = await decide(argv, env, input, now, deps);
|
|
498
552
|
}
|
|
499
553
|
catch {
|
|
500
554
|
return 0;
|
|
@@ -541,6 +595,194 @@ async function isOn(env, now, sessionId) {
|
|
|
541
595
|
now,
|
|
542
596
|
})).on;
|
|
543
597
|
}
|
|
598
|
+
/** Unattended Mode for the whole computer (or this `--unattended` session) at `at`, read fresh; an Attended Session counts as on. */
|
|
599
|
+
async function modeAt(env, at) {
|
|
600
|
+
const paths = resolvePaths(env);
|
|
601
|
+
const { schedule, answerWait } = await readUnattendedConfig(paths.configFile);
|
|
602
|
+
const override = await readUnattendedOverride(paths.stateDir);
|
|
603
|
+
return {
|
|
604
|
+
state: unattendedState({ schedule, override, now: at, session: env[UNATTENDED_ENV] === '1' }),
|
|
605
|
+
answerWait,
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
/** The clock, the wait and the Host, as Answer Wait's watches use them. */
|
|
609
|
+
function waitTools(deps) {
|
|
610
|
+
const clock = () => (deps.now ? deps.now() : new Date()).getTime();
|
|
611
|
+
const sleep = deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
612
|
+
const startPpid = process.ppid;
|
|
613
|
+
const parentGone = deps.parentGone ?? (() => process.ppid !== startPpid || process.ppid === 1);
|
|
614
|
+
return { clock, sleep, parentGone, pid: deps.hostPid ?? startPpid };
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Watches what the session shows (`watchScreen`), then keeps the Pending Decision only while it is still so: one last
|
|
618
|
+
* look just before keeping and again after, with the wait and the mode read afresh (a person may answer meanwhile, the
|
|
619
|
+
* mode go off, or the wait be made longer). When the dialog ended or the wait is now never, nothing is decided
|
|
620
|
+
* (undefined); when the longer wait has not passed or the mode is off, it goes on watching the same dialog. A decision
|
|
621
|
+
* kept before such a change is taken back. Otherwise what the hook answers with: when it went on (`at`), how long it
|
|
622
|
+
* waited, the mode then, and whether the decision was kept. What is left is the moment between the last look and the
|
|
623
|
+
* Host reading the answer: a person who answers then has their answer applied and a denial that comes after it
|
|
624
|
+
* changes nothing (ADR-0077); a wake-up is told it is not their reply.
|
|
625
|
+
*/
|
|
626
|
+
async function actAfterWait(opts) {
|
|
627
|
+
const { env, deps, sessionId } = opts;
|
|
628
|
+
const t = waitTools(deps);
|
|
629
|
+
const settings = async () => {
|
|
630
|
+
const m = await modeAt(env, new Date(t.clock()));
|
|
631
|
+
return { wait: m.answerWait, on: m.state.on };
|
|
632
|
+
};
|
|
633
|
+
const look = {
|
|
634
|
+
env,
|
|
635
|
+
pid: t.pid,
|
|
636
|
+
sessionId,
|
|
637
|
+
startedAt: opts.start,
|
|
638
|
+
clock: t.clock,
|
|
639
|
+
parentGone: t.parentGone,
|
|
640
|
+
settings,
|
|
641
|
+
...(opts.moved ? { moved: opts.moved } : {}),
|
|
642
|
+
};
|
|
643
|
+
const stateDir = resolvePaths(env).stateDir;
|
|
644
|
+
let mark;
|
|
645
|
+
for (;;) {
|
|
646
|
+
mark = await watchScreen({
|
|
647
|
+
...look,
|
|
648
|
+
expect: opts.expect,
|
|
649
|
+
sleep: t.sleep,
|
|
650
|
+
...(opts.shownBy !== undefined ? { shownBy: opts.shownBy } : {}),
|
|
651
|
+
...(mark ? { from: mark } : {}),
|
|
652
|
+
});
|
|
653
|
+
if (!mark)
|
|
654
|
+
return undefined;
|
|
655
|
+
await deps.beforeAct?.();
|
|
656
|
+
const first = await lastLook({ ...look, mark });
|
|
657
|
+
if (first === 'stop')
|
|
658
|
+
return undefined;
|
|
659
|
+
if (first === 'wait')
|
|
660
|
+
continue;
|
|
661
|
+
const at = new Date(t.clock());
|
|
662
|
+
const waited = waitedMinutes(opts.start, at.getTime());
|
|
663
|
+
const { state } = await modeAt(env, at);
|
|
664
|
+
let kept;
|
|
665
|
+
try {
|
|
666
|
+
kept = await addPendingDecision(stateDir, opts.keep(at, waited), at, { dedupe: true });
|
|
667
|
+
}
|
|
668
|
+
catch {
|
|
669
|
+
// Best effort: the reason then asks for it in the final report instead.
|
|
670
|
+
}
|
|
671
|
+
await deps.afterKeep?.();
|
|
672
|
+
const second = await lastLook({ ...look, mark });
|
|
673
|
+
if (second === 'act')
|
|
674
|
+
return { at, waited, state, kept: kept !== undefined };
|
|
675
|
+
if (kept)
|
|
676
|
+
await withdrawPendingDecision(stateDir, kept, at).catch(() => { });
|
|
677
|
+
if (second === 'stop')
|
|
678
|
+
return undefined;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Answer Wait for a question or a permission prompt Claude Code shows (spec §3.37 item 7, ADR-0077): watches the
|
|
683
|
+
* session record while the dialog stays on screen and, once it has waited `unattended.answerWait` minutes and
|
|
684
|
+
* Unattended Mode is on (counting an Attended Session as on: nobody answered), refuses it as the mode would, keeping a
|
|
685
|
+
* Pending Decision with how long it waited. Anything that says someone answered, or that it cannot tell, lets it be
|
|
686
|
+
* (undefined): the record does not show a dialog (a subagent's request, which Claude Code shows only after the hooks,
|
|
687
|
+
* or a session that shows none), the dialog ended or another took its place, the Host is gone, or the wait is now
|
|
688
|
+
* never; looked at once more just before and after keeping the Pending Decision (`actAfterWait`); a dialog put on screen
|
|
689
|
+
* after the hook began is another one (this one was answered meanwhile) and is never taken for it. It never answers
|
|
690
|
+
* "yes": the only decision it gives is a denial.
|
|
691
|
+
*/
|
|
692
|
+
async function answerAfterWait(payload, env, start, deps) {
|
|
693
|
+
// Claude Code runs a subagent's hooks before it shows the prompt: holding one would hide it from the person.
|
|
694
|
+
if (payload.agentId || !payload.sessionId)
|
|
695
|
+
return undefined;
|
|
696
|
+
const sessionId = payload.sessionId;
|
|
697
|
+
const account = text(env.SIDEBY_ACCOUNT, 256);
|
|
698
|
+
const where = {
|
|
699
|
+
family: 'claude',
|
|
700
|
+
...(account ? { account } : {}),
|
|
701
|
+
sessionId,
|
|
702
|
+
...(payload.cwd ? { cwd: payload.cwd } : {}),
|
|
703
|
+
};
|
|
704
|
+
const question = payload.tool === ASK_TOOLS.claude;
|
|
705
|
+
const done = await actAfterWait({
|
|
706
|
+
env,
|
|
707
|
+
deps,
|
|
708
|
+
sessionId,
|
|
709
|
+
expect: 'waiting',
|
|
710
|
+
start,
|
|
711
|
+
// The dialog this request put on screen was there before the hook began; one put up later is another dialog.
|
|
712
|
+
shownBy: start,
|
|
713
|
+
keep: (_at, waited) => question
|
|
714
|
+
? { kind: 'question', ...where, text: questionText(payload.input), waited }
|
|
715
|
+
: { kind: 'permission', ...where, text: permissionText(payload.tool, payload.input), waited },
|
|
716
|
+
});
|
|
717
|
+
if (!done)
|
|
718
|
+
return undefined;
|
|
719
|
+
const { at, waited, state, kept } = done;
|
|
720
|
+
const deny = (message) => ({
|
|
721
|
+
hookSpecificOutput: { hookEventName: 'PermissionRequest', decision: { behavior: 'deny', message } },
|
|
722
|
+
});
|
|
723
|
+
// Kept already (and checked after): the answer only says whether that worked.
|
|
724
|
+
return {
|
|
725
|
+
json: deny,
|
|
726
|
+
reason: () => question
|
|
727
|
+
? questionReason(state, at, prefersChinese(env), kept, waited)
|
|
728
|
+
: permissionReason(state, at, kept, waited),
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Answer Wait for a turn that ended on a question written as text (spec §3.37 item 7, ADR-0077): Claude's second `Stop`
|
|
733
|
+
* entry, in the background (`asyncRewake`). When the session is not unattended right now (the mode is off, or it is an
|
|
734
|
+
* Attended Session: otherwise the first `Stop` entry already keeps the turn going) and the last message ends on a
|
|
735
|
+
* question, it watches the session record while the session waits for a prompt. Once nobody replied for
|
|
736
|
+
* `unattended.answerWait` minutes and the mode is on, it keeps the question as a Pending Decision and returns the note
|
|
737
|
+
* that wakes the session (exit 2). A new turn (a reply, a notification), a prompt someone typed after this `Stop` (the
|
|
738
|
+
* Attended Session's record, which also catches a reply whose turn ended before this hook first read the record), the
|
|
739
|
+
* Host gone, the wait set to never, or anything it cannot tell: undefined, nothing happens.
|
|
740
|
+
*/
|
|
741
|
+
async function wakeAfterWait(env, input, deps) {
|
|
742
|
+
const t = waitTools(deps);
|
|
743
|
+
const start = t.clock();
|
|
744
|
+
const v = parseObject(await readInput(input));
|
|
745
|
+
// Only a first Stop (`stop_hook_active` false) of the main session.
|
|
746
|
+
if (v?.stop_hook_active !== false || v.agent_id !== undefined)
|
|
747
|
+
return undefined;
|
|
748
|
+
const sessionId = text(v.session_id, 256);
|
|
749
|
+
const message = typeof v.last_assistant_message === 'string' ? v.last_assistant_message : '';
|
|
750
|
+
const question = sessionId ? endingQuestion(message) : undefined;
|
|
751
|
+
if (!sessionId || !question)
|
|
752
|
+
return undefined;
|
|
753
|
+
if ((await modeAt(env, new Date(start))).answerWait === null)
|
|
754
|
+
return undefined;
|
|
755
|
+
if (await isOn(env, new Date(start), sessionId))
|
|
756
|
+
return undefined;
|
|
757
|
+
const stateDir = resolvePaths(env).stateDir;
|
|
758
|
+
// Someone typed after this Stop: the question is answered, even when that turn already ended.
|
|
759
|
+
const moved = async () => {
|
|
760
|
+
const r = await readAttended(stateDir, sessionId, new Date(t.clock()));
|
|
761
|
+
return r !== undefined && Date.parse(r.at) > start;
|
|
762
|
+
};
|
|
763
|
+
const account = text(env.SIDEBY_ACCOUNT, 256);
|
|
764
|
+
const cwd = text(v.cwd);
|
|
765
|
+
const done = await actAfterWait({
|
|
766
|
+
env,
|
|
767
|
+
deps,
|
|
768
|
+
sessionId,
|
|
769
|
+
expect: 'idle',
|
|
770
|
+
start,
|
|
771
|
+
moved,
|
|
772
|
+
keep: (_at, waited) => ({
|
|
773
|
+
kind: 'question',
|
|
774
|
+
family: 'claude',
|
|
775
|
+
...(account ? { account } : {}),
|
|
776
|
+
sessionId,
|
|
777
|
+
...(cwd ? { cwd } : {}),
|
|
778
|
+
text: question,
|
|
779
|
+
waited,
|
|
780
|
+
}),
|
|
781
|
+
});
|
|
782
|
+
if (!done)
|
|
783
|
+
return undefined;
|
|
784
|
+
return stopReason(done.state, done.at, prefersChinese(env), done.kept, done.waited);
|
|
785
|
+
}
|
|
544
786
|
/** A prompt id as Claude Code writes it; anything else is not looked for. */
|
|
545
787
|
const PROMPT_ID = /^[A-Za-z0-9_.:-]{1,128}$/;
|
|
546
788
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sideby",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.1",
|
|
4
4
|
"description": "Run work, personal and API-key accounts at the same time, without their configs drifting apart.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Adonis0123 (https://github.com/Adonis0123)",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
},
|
|
87
87
|
"packageManager": "pnpm@10.15.0",
|
|
88
88
|
"readmeFilename": "README.md",
|
|
89
|
-
"readme": "<p align=\"center\">\n <img alt=\"sideby: work, personal and API-key accounts, one terminal each, one shared config\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/banner.jpg\" width=\"880\">\n</p>\n\n<p align=\"center\">\n <b>Run work, personal and API-key accounts at the same time, without their configs drifting apart.</b><br>\n Each account is its own directory and its own terminal. Skills, hooks and settings stay linked to your main account. Claude Code, Codex, Grok Build and pi.\n</p>\n\n<p align=\"center\">\n <a href=\"https://www.npmjs.com/package/sideby\"><img alt=\"npm\" src=\"https://img.shields.io/npm/v/sideby\"></a>\n <a href=\"https://github.com/Adonis0123/sideby/actions/workflows/ci.yml\"><img alt=\"CI\" src=\"https://github.com/Adonis0123/sideby/actions/workflows/ci.yml/badge.svg\"></a>\n <img alt=\"Node 22.18+\" src=\"https://img.shields.io/badge/node-%E2%89%A522.18-339933\">\n <a href=\"LICENSE\"><img alt=\"MIT\" src=\"https://img.shields.io/badge/license-MIT-blue\"></a>\n</p>\n\n<p align=\"center\">English | <a href=\"README.zh-CN.md\">中文</a></p>\n\n## Quick start\n\nRequires Node 22.18+ and at least one Host CLI (Claude Code, Codex, Grok Build or pi) installed. AI agents: follow the setup steps in [`llms.txt`](llms.txt) (\"Set up sideby for a user\") instead.\n\n```sh\nnpm i -g sideby\nsideby new claude work # create ~/.claude-work, sharing ~/.claude's skills and hooks\nsideby login claude:work # sign in once\nsideby run work # Claude Code on the work account\nsideby quota setup claude --yes # optional: live Claude quota while a session runs; undo: sideby quota teardown claude\nsideby ui --background # every account's quota at http://127.0.0.1:17420, still there after you close the terminal\n```\n\n`sideby app install` adds a Dock icon that opens the panel, and `sideby autostart on` has it ready each time you log in. `sideby update` installs a newer sideby when there is one; sideby says so after a command and in the panel. `sideby run claude:main` keeps using `~/.claude` in another terminal at the same time. Arguments after `--` go to the Host: `sideby run work -- --resume`. To try it without installing, run `npx sideby`.\n\n## Set up with your AI agent\n\nPaste this into Claude Code, Codex or any coding agent:\n\n```text\nInstall the sideby CLI (npm package `sideby`) and its agent skill, then set up a second Claude Code account for me.\nFollow \"Set up sideby for a user\" in https://raw.githubusercontent.com/Adonis0123/sideby/main/llms.txt\n```\n\nThe agent checks Node and your Host CLIs, installs sideby and the skill, creates the account, tells you what it shares with your main one and makes its short command work. You sign in once in your browser; the agent gives you that one command. Once the skill is installed, short requests work too: \"add another Claude account, cc008\", \"what do my Codex accounts share?\", \"which account still has quota?\".\n\n## What it looks like\n\nThe 25-second story: one account buried in tasks, then accounts side by side sharing one setup, and a task moving on when one runs out.\n\nhttps://github.com/user-attachments/assets/d1d7e8dd-1df1-4881-ac88-e468c2dd4a1d\n\n<img alt=\"Two terminals: the personal account and the work account running at the same time, both linked to the main account's skills and settings, then the local quota panel, and at 95% Auto Handoff moving work's session to the next account\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/demo.gif\" width=\"1280\">\n\n<picture>\n <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/panel-dark.png\">\n <source media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/panel.png\">\n <img alt=\"sideby panel: every account's 5h and 7d quota, 7-day token usage and health in one page\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/panel.png\" width=\"1280\">\n</picture>\n\nOn macOS, the same quota sits in the menu bar (`sideby menubar on`): click or press `⌥X` to open it, and click an account to start it in the terminal.\n\n<picture>\n <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/menubar-dark.png\">\n <source media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/menubar.png\">\n <img alt=\"sideby macOS menu bar dropdown: a status card, each tool with 5-hour and weekly quota bars, reset times, and the suggested account marked\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/menubar.png\" width=\"468\">\n</picture>\n\n## Why not just an alias?\n\n`CLAUDE_CONFIG_DIR` plus a shell alias already starts a second account. It does not keep skills and settings in one place, and it does not show quota for every account. [Does this break a provider's terms?](docs/guide/faq.md#terms)\n\n| | At the same time | Skills, hooks, settings | Quota and usage | Setup |\n|---|---|---|---|---|\n| `CLAUDE_CONFIG_DIR` and an alias | Yes. Each terminal exports the variable. | Each directory is its own copy. They drift unless you symlink by hand. | That session's status line | One alias per account |\n| [cc-switch](https://github.com/farion1231/cc-switch) | Enabling a provider writes the host's live config, so open sessions share that switch. | Plugin settings are copied across providers as a separate step. | The active provider, from its quota endpoint | Install the desktop app |\n| sideby | Yes. `sideby run` selects the directory for that process and leaves your shell alone. | Linked to the main account. `sideby doctor --fix` repairs copies. Sign-in and sessions stay separate. | Every account, from local files and each tool's own CLI. | `npm i -g sideby`, then `sideby new` and sign in |\n\ncc-switch's docs describe that switch: it writes the live settings file ([README](https://github.com/farion1231/cc-switch#readme)). [#1105](https://github.com/farion1231/cc-switch/issues/1105) and [#2908](https://github.com/farion1231/cc-switch/issues/2908) ask for several sessions at once. [#1106](https://github.com/farion1231/cc-switch/issues/1106) is closed; the maintainer says Claude Code's \"open terminal\" can start one provider without changing the global config.\n\n## What else it does\n\n| You want to | Run | Guide |\n|---|---|---|\n| Find any past session of any account by what you remember, grouped by project, read it and continue it where it was | **Sessions › History** in the panel, or `sideby history \"fix login\" --project .` | [History](docs/guide/panel.md#history) |\n| See what every account is running right now and copy one session for another AI | **Sessions › Running** in the panel, or `sideby sessions` | [Sessions](docs/guide/panel.md#sessions) |\n| Send a running session a message, screenshots included | **Send to it** on a running session, or `sideby send claude:work \"run the tests\"` | [Send to a session](docs/guide/panel.md#send-to-a-session) |\n| Hand a task to your own AI from the panel: set up an account, fix a problem, support a new tool | **Let AI do it** in the panel, or `sideby ask` | [Let AI do it](docs/guide/panel.md#let-ai-do-it) |\n| See quota at a glance in the macOS menu bar | **Settings › Startup** in the panel, or `sideby menubar on` | [Quota in the menu bar](docs/guide/usage.md#quota-in-the-menu-bar) |\n| Have the panel ready in the background whenever you log in | **Settings › Startup** in the panel, or `sideby autostart on` | [Start at login](docs/guide/usage.md#start-at-login) |\n| Add an API key account (DeepSeek, a gateway, …) | `sideby new claude deepseek --api` | [API accounts](docs/guide/usage.md#api-accounts) |\n| Find and fix config drift between accounts | `sideby doctor --fix` | [Doctor](docs/guide/usage.md#doctor) |\n| See every account's quota (no setup) | `sideby quota` | [Claude quota](docs/guide/usage.md#claude-quota) |\n| Find the cheapest auto-compact size from your own sessions, and use it in one click | `sideby tune` (or the panel's Context tuning tab) | [Context tuning](docs/guide/usage.md#context-tuning) |\n| See each account's model and effort, and set them per account | `sideby model <account>` (or click the model in the panel) | [Model and effort](docs/guide/usage.md#model-and-effort) |\n| Stop Claude and Codex when your requests would leave from a country you did not allow, for example when the proxy stopped | **Settings › Network check** in the panel, or `sideby network on` | [Network check](docs/guide/usage.md#network-check) |\n| Choose whether Claude sessions connect to claude.ai by themselves (Remote Control), for every account at once | `sideby remote-control off` or `on` (or the panel's Settings) | [Remote Control](docs/guide/usage.md#remote-control) |\n| Pin the accounts you use most, put tools and accounts in your own order, and hide the ones you never use | `sideby pin claude:work`, `sideby order`, `sideby hide grok` (or the panel's Settings) | [Your own order](docs/guide/usage.md#your-own-order) |\n| Give the panel other colors: five built-in Themes, your own color, or one your AI writes | **Settings › Theme** in the panel, or `sideby theme use leaf` | [Themes](docs/guide/panel.md#themes) |\n| Move on when an account hits its limit | `sideby next claude` | [Handoff](docs/guide/usage.md#when-an-account-hits-its-limit) |\n| Let a running task move to the next account by itself when quota runs low (off by default; see the risk) | `sideby handoff enable` (or the panel) | [Auto Handoff](docs/guide/usage.md#auto-handoff) |\n| Short commands such as `ccw` | `sideby alias add ccw claude:work` | [Shell functions](docs/guide/configuration.md#shell-functions) |\n| Reopen a session from Orca and the like in the account that holds it | `\"resumeRouting\": true` in config | [Resuming from other tools](docs/guide/configuration.md#resuming-from-other-tools) |\n| Open Claude Desktop or the Codex app as one account, several side by side (macOS) | `sideby desktop claude:work` (or the panel) | [Desktop apps](docs/guide/usage.md#desktop-apps) |\n| Keep several Grok Bot windows open, each signed in to its own account (macOS) | `sideby desktop grok-bot:002` (or the panel) | [Grok Bot windows](docs/guide/usage.md#grok-bot-windows) |\n| Open the panel from the Dock or app menu | `sideby app install` | [Panel app](docs/guide/panel.md#panel-app) |\n| Show the panel inside your own local page | `createPanelHandler()` | [Embed the panel](docs/guide/panel.md#embed-the-panel) |\n| Add a Host, a pre-launch check, or your own project categories for History | a local plugin | [Plugins](docs/guide/plugins.md) |\n\n## Supported hosts\n\n| Host | Account directories | Sign-in | Quota | Usage (7 days) |\n|---|---|---|---|---|\n| Claude Code | `~/.claude`, `~/.claude-<name>` | `claude auth login` | ✓ | ✓ |\n| Codex CLI | `~/.codex`, `~/.codex-<name>` | `codex login` | ✓ | ✓ |\n| Grok Build | `~/.grok`, `~/.grok-<name>` | `grok login` | weekly, asked from the `grok` CLI | no public source |\n| pi | `~/.pi/agent`, `~/.pi-<name>/agent` | `/login` inside pi | no public source | no public source |\n| Antigravity CLI | `~/.gemini/antigravity-cli` (main account only) | sign in with Google inside `agy` | 5-hour and weekly per model group, asked from the `agy` CLI | no public source |\n\nsideby starts the official binary on your `PATH` and never patches it. Tested versions and per-Host notes are in the [guide](docs/guide/usage.md#host-notes).\n\n## Platforms\n\nmacOS and Linux. CI runs the suite on `ubuntu-latest` and `macos-latest`, Node 22 and 24. **Windows is untested.** `sideby app` only installs a launcher on macOS and Linux. Linked items are symlinks, `sideby shell-init` prints bash and zsh functions, and the Claude quota wrapper runs `/bin/sh`.\n\n## Roadmap\n\n**Gemini CLI.** Gemini can point at another config directory with `GEMINI_CONFIG_DIR`. Older docs use `GEMINI_CLI_HOME`; current builds treat that name as deprecated, and exit on startup if it is set together with an exact directory override. A sideby family still needs a tested Gemini version, a login check that does not read tokens, and a list of which files to link or copy. That is more than a small patch, so it is not in this version.\n\n## Safe by design\n\n- It never edits a Host's global config to switch accounts. It moves a task to another account only when you turn on Auto Handoff, and never proxies requests or pools logins.\n- It never reads, prints or sends a credential value. Nothing about your accounts leaves your machine: the only request sideby makes on its own is a daily check of the npm registry for its newest version (off with `NO_UPDATE_NOTIFIER=1`; see [Updates](docs/guide/configuration.md#updates)).\n- `doctor --fix` never replaces a real file and never changes where a link points.\n- The panel answers only on `127.0.0.1` and refuses web pages from other sites, but it trusts every user of this computer. On a shared Mac, do not leave it running in the background ([details](docs/guide/panel.md#who-can-reach-the-panel)).\n\nDetails and the terms-of-service question are in the [FAQ](docs/guide/faq.md).\n\nUsage questions and ideas go in [Discussions](https://github.com/Adonis0123/sideby/discussions).\n\n## Docs\n\n- [Using sideby](docs/guide/usage.md): accounts, API accounts, Doctor, quota, Handoff, Host notes\n- [Commands](docs/guide/commands.md): every command, exit codes and `--json`\n- [Configuration](docs/guide/configuration.md): `config.json`, aliases, shell functions\n- [Panel](docs/guide/panel.md): the panel, sessions and their history, panel app and embedding\n- [Plugins](docs/guide/plugins.md): write your own Family, launch hook or project categories\n- [FAQ](docs/guide/faq.md): terms of service, data locations, alternatives, uninstall\n- [Changelog](https://github.com/Adonis0123/sideby/releases)\n\n## For AI agents\n\n- [`llms.txt`](llms.txt): setup steps, commands, JSON contract and plugin API in one index. `sideby families --json` states what each Host's accounts share.\n- [`skills/sideby/SKILL.md`](skills/sideby/SKILL.md): one Agent Skill for seeing, repairing and creating accounts and for moving on when one hits its limit. Install with `npx skills add Adonis0123/sideby -g`; `sideby doctor` warns when the installed copy is for another sideby version.\n- [`AGENTS.md`](AGENTS.md): rules for agents working on this repository.\n\n## License\n\n[MIT](LICENSE)\n"
|
|
89
|
+
"readme": "<p align=\"center\">\n <img alt=\"sideby: work, personal and API-key accounts, one terminal each, one shared config\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/banner.jpg\" width=\"880\">\n</p>\n\n<p align=\"center\">\n <b>Run work, personal and API-key accounts at the same time, without their configs drifting apart.</b><br>\n Each account is its own directory and its own terminal. Skills, hooks and settings stay linked to your main account. Claude Code, Codex, Grok Build, pi and Antigravity CLI.\n</p>\n\n<p align=\"center\">\n <a href=\"https://www.npmjs.com/package/sideby\"><img alt=\"npm\" src=\"https://img.shields.io/npm/v/sideby\"></a>\n <a href=\"https://github.com/Adonis0123/sideby/actions/workflows/ci.yml\"><img alt=\"CI\" src=\"https://github.com/Adonis0123/sideby/actions/workflows/ci.yml/badge.svg\"></a>\n <img alt=\"Node 22.18+\" src=\"https://img.shields.io/badge/node-%E2%89%A522.18-339933\">\n <a href=\"LICENSE\"><img alt=\"MIT\" src=\"https://img.shields.io/badge/license-MIT-blue\"></a>\n</p>\n\n<p align=\"center\">English | <a href=\"README.zh-CN.md\">中文</a></p>\n\n## Quick start\n\nRequires Node 22.18+ and at least one Host CLI (Claude Code, Codex, Grok Build, pi or Antigravity CLI) installed. AI agents: follow the setup steps in [`llms.txt`](llms.txt) (\"Set up sideby for a user\") instead.\n\n```sh\nnpm i -g sideby\nsideby new claude work # create ~/.claude-work, sharing ~/.claude's skills and hooks\nsideby login claude:work # sign in once\nsideby run work # Claude Code on the work account\nsideby quota setup claude --yes # optional: live Claude quota while a session runs; undo: sideby quota teardown claude\nsideby ui --background # every account's quota at http://127.0.0.1:17420, still there after you close the terminal\n```\n\n`sideby app install` adds a Dock icon that opens the panel, and `sideby autostart on` has it ready each time you log in. `sideby update` installs a newer sideby when there is one; sideby says so after a command and in the panel. `sideby run claude:main` keeps using `~/.claude` in another terminal at the same time. Arguments after `--` go to the Host: `sideby run work -- --resume`. To try it without installing, run `npx sideby`.\n\n## Set up with your AI agent\n\nPaste this into Claude Code, Codex or any coding agent:\n\n```text\nInstall the sideby CLI (npm package `sideby`) and its agent skill, then set up a second Claude Code account for me.\nFollow \"Set up sideby for a user\" in https://raw.githubusercontent.com/Adonis0123/sideby/main/llms.txt\n```\n\nThe agent checks Node and your Host CLIs, installs sideby and the skill, creates the account, tells you what it shares with your main one and makes its short command work. You sign in once in your browser; the agent gives you that one command. Once the skill is installed, short requests work too: \"add another Claude account, cc008\", \"what do my Codex accounts share?\", \"which account still has quota?\".\n\n## What it looks like\n\nThe 25-second story: one account buried in tasks, then accounts side by side sharing one setup, and a task moving on when one runs out.\n\nhttps://github.com/user-attachments/assets/d1d7e8dd-1df1-4881-ac88-e468c2dd4a1d\n\n<img alt=\"Two terminals: the personal account and the work account running at the same time, both linked to the main account's skills and settings, then the local quota panel, and at 95% Auto Handoff moving work's session to the next account\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/demo.gif\" width=\"1280\">\n\n<picture>\n <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/panel-dark.png\">\n <source media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/panel.png\">\n <img alt=\"sideby panel: every account's 5h and 7d quota, 7-day token usage and health in one page\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/panel.png\" width=\"1280\">\n</picture>\n\nOn macOS, the same quota sits in the menu bar (`sideby menubar on`): click or press `⌥X` to open it, and click an account to start it in the terminal.\n\n<picture>\n <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/menubar-dark.png\">\n <source media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/menubar.png\">\n <img alt=\"sideby macOS menu bar dropdown: a status card, each tool with 5-hour and weekly quota bars, reset times, and the suggested account marked\" src=\"https://raw.githubusercontent.com/Adonis0123/sideby/main/docs/assets/menubar.png\" width=\"468\">\n</picture>\n\n## Why not just an alias?\n\n`CLAUDE_CONFIG_DIR` plus a shell alias already starts a second account. It does not keep skills and settings in one place, and it does not show quota for every account. [Does this break a provider's terms?](docs/guide/faq.md#terms)\n\n| | At the same time | Skills, hooks, settings | Quota and usage | Setup |\n|---|---|---|---|---|\n| `CLAUDE_CONFIG_DIR` and an alias | Yes. Each terminal exports the variable. | Each directory is its own copy. They drift unless you symlink by hand. | That session's status line | One alias per account |\n| [cc-switch](https://github.com/farion1231/cc-switch) | Enabling a provider writes the host's live config, so open sessions share that switch. | Plugin settings are copied across providers as a separate step. | The active provider, from its quota endpoint | Install the desktop app |\n| sideby | Yes. `sideby run` selects the directory for that process and leaves your shell alone. | Linked to the main account. `sideby doctor --fix` repairs copies. Sign-in and sessions stay separate. | Every account, from local files and each tool's own CLI. | `npm i -g sideby`, then `sideby new` and sign in |\n\ncc-switch's docs describe that switch: it writes the live settings file ([README](https://github.com/farion1231/cc-switch#readme)). [#1105](https://github.com/farion1231/cc-switch/issues/1105) and [#2908](https://github.com/farion1231/cc-switch/issues/2908) ask for several sessions at once. [#1106](https://github.com/farion1231/cc-switch/issues/1106) is closed; the maintainer says Claude Code's \"open terminal\" can start one provider without changing the global config.\n\n## What else it does\n\n| You want to | Run | Guide |\n|---|---|---|\n| Find any past session of any account by what you remember, grouped by project, read it and continue it where it was | **Sessions › History** in the panel, or `sideby history \"fix login\" --project .` | [History](docs/guide/panel.md#history) |\n| See what every account is running right now and copy one session for another AI | **Sessions › Running** in the panel, or `sideby sessions` | [Sessions](docs/guide/panel.md#sessions) |\n| Send a running session a message, screenshots included | **Send to it** on a running session, or `sideby send claude:work \"run the tests\"` | [Send to a session](docs/guide/panel.md#send-to-a-session) |\n| Hand a task to your own AI from the panel: set up an account, fix a problem, support a new tool | **Let AI do it** in the panel, or `sideby ask` | [Let AI do it](docs/guide/panel.md#let-ai-do-it) |\n| See quota at a glance in the macOS menu bar | **Settings › Startup** in the panel, or `sideby menubar on` | [Quota in the menu bar](docs/guide/usage.md#quota-in-the-menu-bar) |\n| Have the panel ready in the background whenever you log in | **Settings › Startup** in the panel, or `sideby autostart on` | [Start at login](docs/guide/usage.md#start-at-login) |\n| Add an API key account (DeepSeek, a gateway, …) | `sideby new claude deepseek --api` | [API accounts](docs/guide/usage.md#api-accounts) |\n| Find and fix config drift between accounts | `sideby doctor --fix` | [Doctor](docs/guide/usage.md#doctor) |\n| See every account's quota (no setup) | `sideby quota` | [Claude quota](docs/guide/usage.md#claude-quota) |\n| Find the cheapest auto-compact size from your own sessions, and use it in one click | `sideby tune` (or the panel's Context tuning tab) | [Context tuning](docs/guide/usage.md#context-tuning) |\n| See each account's model and effort, and set them per account | `sideby model <account>` (or click the model in the panel) | [Model and effort](docs/guide/usage.md#model-and-effort) |\n| Stop Claude and Codex when your requests would leave from a country you did not allow, for example when the proxy stopped | **Settings › Network check** in the panel, or `sideby network on` | [Network check](docs/guide/usage.md#network-check) |\n| Choose whether Claude sessions connect to claude.ai by themselves (Remote Control), for every account at once | `sideby remote-control off` or `on` (or the panel's Settings) | [Remote Control](docs/guide/usage.md#remote-control) |\n| Pin the accounts you use most, put tools and accounts in your own order, and hide the ones you never use | `sideby pin claude:work`, `sideby order`, `sideby hide grok` (or the panel's Settings) | [Your own order](docs/guide/usage.md#your-own-order) |\n| Give the panel other colors: five built-in Themes, your own color, or one your AI writes | **Settings › Theme** in the panel, or `sideby theme use leaf` | [Themes](docs/guide/panel.md#themes) |\n| Move on when an account hits its limit | `sideby next claude` | [Handoff](docs/guide/usage.md#when-an-account-hits-its-limit) |\n| Let a running task move to the next account by itself when quota runs low (off by default; see the risk) | `sideby handoff enable` (or the panel) | [Auto Handoff](docs/guide/usage.md#auto-handoff) |\n| Short commands such as `ccw` | `sideby alias add ccw claude:work` | [Shell functions](docs/guide/configuration.md#shell-functions) |\n| Reopen a session from Orca and the like in the account that holds it | `\"resumeRouting\": true` in config | [Resuming from other tools](docs/guide/configuration.md#resuming-from-other-tools) |\n| Open Claude Desktop or the Codex app as one account, several side by side (macOS) | `sideby desktop claude:work` (or the panel) | [Desktop apps](docs/guide/usage.md#desktop-apps) |\n| Keep several Grok Bot windows open, each signed in to its own account (macOS) | `sideby desktop grok-bot:002` (or the panel) | [Grok Bot windows](docs/guide/usage.md#grok-bot-windows) |\n| Open the panel from the Dock or app menu | `sideby app install` | [Panel app](docs/guide/panel.md#panel-app) |\n| Show the panel inside your own local page | `createPanelHandler()` | [Embed the panel](docs/guide/panel.md#embed-the-panel) |\n| Add a Host, a pre-launch check, or your own project categories for History | a local plugin | [Plugins](docs/guide/plugins.md) |\n\n## Supported hosts\n\n| Host | Account directories | Sign-in | Quota | Usage (7 days) |\n|---|---|---|---|---|\n| Claude Code | `~/.claude`, `~/.claude-<name>` | `claude auth login` | ✓ | ✓ |\n| Codex CLI | `~/.codex`, `~/.codex-<name>` | `codex login` | ✓ | ✓ |\n| Grok Build | `~/.grok`, `~/.grok-<name>` | `grok login` | weekly, asked from the `grok` CLI | no public source |\n| pi | `~/.pi/agent`, `~/.pi-<name>/agent` | `/login` inside pi | no public source | no public source |\n| Antigravity CLI | `~/.gemini/antigravity-cli` (main account only) | sign in with Google inside `agy` | 5-hour and weekly per model group, asked from the `agy` CLI | no public source |\n\nsideby starts the official binary on your `PATH` and never patches it. Tested versions and per-Host notes are in the [guide](docs/guide/usage.md#host-notes).\n\n## Platforms\n\nmacOS and Linux. CI runs the suite on `ubuntu-latest` and `macos-latest`, Node 22 and 24. **Windows is untested.** `sideby app` only installs a launcher on macOS and Linux. Linked items are symlinks, `sideby shell-init` prints bash and zsh functions, and the Claude quota wrapper runs `/bin/sh`.\n\n## Roadmap\n\n**Gemini CLI.** Gemini can point at another config directory with `GEMINI_CONFIG_DIR`. Older docs use `GEMINI_CLI_HOME`; current builds treat that name as deprecated, and exit on startup if it is set together with an exact directory override. A sideby family still needs a tested Gemini version, a login check that does not read tokens, and a list of which files to link or copy. That is more than a small patch, so it is not in this version.\n\n## Safe by design\n\n- It never edits a Host's global config to switch accounts. It moves a task to another account only when you turn on Auto Handoff, and never proxies requests or pools logins.\n- It never reads, prints or sends a credential value. Nothing about your accounts leaves your machine: the only request sideby makes on its own is a daily check of the npm registry for its newest version (off with `NO_UPDATE_NOTIFIER=1`; see [Updates](docs/guide/configuration.md#updates)).\n- `doctor --fix` never replaces a real file and never changes where a link points.\n- The panel answers only on `127.0.0.1` and refuses web pages from other sites, but it trusts every user of this computer. On a shared Mac, do not leave it running in the background ([details](docs/guide/panel.md#who-can-reach-the-panel)).\n\nDetails and the terms-of-service question are in the [FAQ](docs/guide/faq.md).\n\nUsage questions and ideas go in [Discussions](https://github.com/Adonis0123/sideby/discussions).\n\n## Docs\n\n- [Using sideby](docs/guide/usage.md): accounts, API accounts, Doctor, quota, Handoff, Host notes\n- [Commands](docs/guide/commands.md): every command, exit codes and `--json`\n- [Configuration](docs/guide/configuration.md): `config.json`, aliases, shell functions\n- [Panel](docs/guide/panel.md): the panel, sessions and their history, panel app and embedding\n- [Plugins](docs/guide/plugins.md): write your own Family, launch hook or project categories\n- [FAQ](docs/guide/faq.md): terms of service, data locations, alternatives, uninstall\n- [Changelog](https://github.com/Adonis0123/sideby/releases)\n\n## For AI agents\n\n- [`llms.txt`](llms.txt): setup steps, commands, JSON contract and plugin API in one index. `sideby families --json` states what each Host's accounts share.\n- [`skills/sideby/SKILL.md`](skills/sideby/SKILL.md): one Agent Skill for seeing, repairing and creating accounts and for moving on when one hits its limit. Install with `npx skills add Adonis0123/sideby -g`; `sideby doctor` warns when the installed copy is for another sideby version.\n- [`AGENTS.md`](AGENTS.md): rules for agents working on this repository.\n\n## License\n\n[MIT](LICENSE)\n"
|
|
90
90
|
}
|
package/schemas/config.json
CHANGED
|
@@ -500,6 +500,20 @@
|
|
|
500
500
|
"additionalProperties": false
|
|
501
501
|
},
|
|
502
502
|
"description": "Slots that turn Unattended Mode on and off by themselves, in this computer's time zone. Empty by default."
|
|
503
|
+
},
|
|
504
|
+
"answerWait": {
|
|
505
|
+
"anyOf": [
|
|
506
|
+
{
|
|
507
|
+
"type": "integer",
|
|
508
|
+
"minimum": 1,
|
|
509
|
+
"maximum": 120
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
"type": "boolean",
|
|
513
|
+
"const": false
|
|
514
|
+
}
|
|
515
|
+
],
|
|
516
|
+
"description": "Answer Wait (ADR-0077): how many minutes a question or a permission prompt shown in a Claude session sideby started waits for a person. Once it has waited this long with nobody answering and Unattended Mode is on, the session goes on as Unattended Mode would: the question with the recommended choice where it can be undone, the permission prompt refused (never allowed); each is kept as a Pending Decision. A turn that ended on a question written as text goes on the same way. `false`: never, questions wait for you. Not set: 10 minutes."
|
|
503
517
|
}
|
|
504
518
|
},
|
|
505
519
|
"additionalProperties": false,
|
|
@@ -70,6 +70,11 @@
|
|
|
70
70
|
"type": "string",
|
|
71
71
|
"description": "The question and its options, the tool and what it was to do, or the deferred text; at most 4000 characters."
|
|
72
72
|
},
|
|
73
|
+
"waited": {
|
|
74
|
+
"type": "integer",
|
|
75
|
+
"minimum": 1,
|
|
76
|
+
"description": "Minutes the question or permission prompt was on screen with nobody answering before the session went on without an answer (Answer Wait, ADR-0077). Absent when it was never shown."
|
|
77
|
+
},
|
|
73
78
|
"doneAt": {
|
|
74
79
|
"type": "string",
|
|
75
80
|
"description": "When it was marked done; ISO."
|
|
@@ -72,6 +72,11 @@
|
|
|
72
72
|
"type": "string",
|
|
73
73
|
"description": "The question and its options, the tool and what it was to do, or the deferred text; at most 4000 characters."
|
|
74
74
|
},
|
|
75
|
+
"waited": {
|
|
76
|
+
"type": "integer",
|
|
77
|
+
"minimum": 1,
|
|
78
|
+
"description": "Minutes the question or permission prompt was on screen with nobody answering before the session went on without an answer (Answer Wait, ADR-0077). Absent when it was never shown."
|
|
79
|
+
},
|
|
75
80
|
"doneAt": {
|
|
76
81
|
"type": "string",
|
|
77
82
|
"description": "When it was marked done; ISO."
|
package/schemas/unattended.json
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"reason",
|
|
9
9
|
"configured",
|
|
10
10
|
"schedule",
|
|
11
|
+
"answerWait",
|
|
11
12
|
"pending",
|
|
12
13
|
"attended",
|
|
13
14
|
"coverage"
|
|
@@ -153,6 +154,19 @@
|
|
|
153
154
|
},
|
|
154
155
|
"description": "Config `unattended.schedule`, numbered from 1."
|
|
155
156
|
},
|
|
157
|
+
"answerWait": {
|
|
158
|
+
"anyOf": [
|
|
159
|
+
{
|
|
160
|
+
"type": "integer",
|
|
161
|
+
"minimum": 1,
|
|
162
|
+
"maximum": 120
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"type": "null"
|
|
166
|
+
}
|
|
167
|
+
],
|
|
168
|
+
"description": "Answer Wait (ADR-0077): minutes a question or permission prompt shown in a Claude session sideby started waits for a person before, with Unattended Mode on, the session goes on without an answer. null: never. 10 when config `unattended.answerWait` is not set. Change it with `sideby unattended wait <minutes>|off`."
|
|
169
|
+
},
|
|
156
170
|
"pending": {
|
|
157
171
|
"type": "integer",
|
|
158
172
|
"description": "Open Pending Decisions (`sideby unattended pending`)."
|
|
@@ -256,7 +270,7 @@
|
|
|
256
270
|
},
|
|
257
271
|
"changed": {
|
|
258
272
|
"type": "boolean",
|
|
259
|
-
"description": "Set by on, off and
|
|
273
|
+
"description": "Set by on, off, schedule and wait changes: whether anything changed."
|
|
260
274
|
},
|
|
261
275
|
"undo": {
|
|
262
276
|
"type": "string",
|
|
@@ -325,5 +339,5 @@
|
|
|
325
339
|
"description": "Not the answer to the task: mention it briefly afterwards and offer to update."
|
|
326
340
|
}
|
|
327
341
|
},
|
|
328
|
-
"title": "sideby unattended [on|off|schedule …] --json"
|
|
342
|
+
"title": "sideby unattended [on|off|schedule …|wait …] --json"
|
|
329
343
|
}
|
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 ("找一下我上周改登录页的那个会话"), telling another running session something, in any account ("告诉 cc002 ……", "给跑构建的那个会话发消息"; Claude Code's own SendMessage reaches only sessions of the same 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.40.1"
|
|
6
6
|
requires:
|
|
7
7
|
bins: [sideby, node]
|
|
8
8
|
cliHelp: sideby --help
|
|
@@ -84,8 +84,9 @@ Account refs are `<family>:<name>`; a bare `<name>` works only when it is unique
|
|
|
84
84
|
| A Claude API account's gateway rejects requests after an Advisor change, or why sideby adds `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` to API accounts ("API 账号网关报错了", "为什么 API 账号多了这个变量") | `sideby advisor --json` (`apiBetasOff`, each group's `apiAccounts`), `sideby config get claude.apiBetasOff --json`; `sideby advisor undo` or `sideby config set claude.apiBetasOff false` after they agree | `references/panel.md` |
|
|
85
85
|
| Stop Claude and Codex when the network is wrong ("网络不对时别让 Claude 用", "代理断了就拦住", "only allow US and Japan", "开网络检查"), see where requests leave from now, or a session says it was blocked | `sideby network --json`, `sideby network check --json`, `sideby network allow <CC>... --json` and `sideby network on --json` (each exits 10 first; rerun with `--yes` after they agree) | `references/network.md` |
|
|
86
86
|
| Leave sessions running with nobody there ("挂机", "无人值守", "今晚自己跑完", "设个时间段别问我", "keep going while I sleep"), set a nightly Schedule, or see what was left for the user | `sideby unattended on [--until 08:00] --json` (run it yourself when they say they are leaving), `sideby unattended schedule preset weeknights --json`, `sideby unattended --json`, `sideby unattended pending --json`; inside a session refused a question: `sideby unattended defer "<one sentence>"` | `references/unattended.md` |
|
|
87
|
+
| How long a question waits before the session goes on without an answer ("问题没人回就自动按推荐继续", "问题等我 30 分钟", "别自动继续,一直等我", "how long does a question wait for me") | `sideby unattended wait --json` shows `answerWait`; `sideby unattended wait <1-120> --json` or `sideby unattended wait off --json` sets it. It acts only while Unattended Mode is on, and never answers "yes" | `references/unattended.md` |
|
|
87
88
|
| The user is back early and wants questions in one session ("我回来了,会话怎么还不问我", "为什么这个会话又开始问我", "I'm back, why doesn't it ask me"), or asks which sessions ask as usual | Tell them to type in that session: it asks as usual for 30 minutes after each message. `sideby unattended --json` lists them (`attended`); there is no command to set it. `sideby unattended off --json` turns it off everywhere | `references/unattended.md` |
|
|
88
|
-
| A session waits on background work and says nothing for a long time ("后台任务跑着时没动静", "等子任务时隔一阵告诉我进度", "tell me what it is waiting for every
|
|
89
|
+
| A session waits on background work and says nothing for a long time ("后台任务跑着时没动静", "等子任务时隔一阵告诉我进度", "tell me what it is waiting for every 30 minutes", "进度提醒"), or stop those updates ("别再报进度了", "turn off progress updates") | `sideby progress --json`, then `sideby progress on [--every <minutes>] --json` or `sideby progress off --json` (writes only sideby's config, no preview; relay that each update uses quota and that only Claude sessions started afterwards get it) | `references/progress.md` |
|
|
89
90
|
| See Claude quota, refresh it, or turn on live quota for Auto Handoff | `sideby quota claude --refresh --json` (no setup); `sideby quota setup claude` (exits 10) for Auto Handoff | `references/quota.md` |
|
|
90
91
|
| Update sideby or its skill ("is there a new version", "更新 sideby"), or an output has `_notice` | `sideby update --json` (exits 10 first) | `references/update.md` |
|
|
91
92
|
| See everything at once | `sideby ui` (local panel on `127.0.0.1:17420`; `--no-open` prints the address) | — |
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# Progress updates: a waiting session says what it waits for
|
|
2
2
|
|
|
3
|
-
Progress Reminders (spec §3.42, ADR-0076): while a Claude session sideby started waits on background work (subagents, background commands), the session is idle and the model cannot say anything, so the user sees silence. With progress updates on, sideby wakes such a session every
|
|
3
|
+
Progress Reminders (spec §3.42, ADR-0076): while a Claude session sideby started waits on background work (subagents, background commands), the session is idle and the model cannot say anything, so the user sees silence. With progress updates on, sideby wakes such a session every 30 minutes (or the interval the user picks), and the model tells the user in one or two sentences what it waits for, how long it has waited and whether there is new output, then ends its turn.
|
|
4
4
|
|
|
5
5
|
## Turn it on or off
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
sideby progress --json # { on, every?, defaultEvery, choices, families }
|
|
9
|
-
sideby progress on --json # every
|
|
9
|
+
sideby progress on --json # every 30 minutes (or keeps the interval it had)
|
|
10
10
|
sideby progress on --every 15 --json # 1 to 240 minutes
|
|
11
11
|
sideby progress off --json
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
It writes only sideby's config (`progress.every`), so there is no preview and no `--yes`; each change returns `undo`. Before turning it on for the user, tell them, in one line each:
|
|
15
|
-
- Each update is one model turn, which reads the whole conversation: it uses quota. That is why it is off by default.
|
|
15
|
+
- Each update is one model turn, which reads the whole conversation: it uses quota, and a longer interval uses less. That is why it is off by default.
|
|
16
16
|
- Claude sessions sideby starts from now on get it; a session already running needs a restart. Turning it off, or a new interval, reaches running sessions too.
|
|
17
17
|
- There are no updates while the session is unattended (Unattended Mode, unless the user typed there in the last 30 minutes), while a turn is running, or once the background work is done.
|
|
18
18
|
- Codex is not covered: no Codex hook can wake a waiting session. Grok, pi and sessions started without sideby are not covered either.
|