sideby 0.38.1 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/build.json +1 -1
  2. package/dist/src/cli/commands.d.ts +6 -0
  3. package/dist/src/cli/commands.js +120 -1
  4. package/dist/src/cli/json-schemas.js +44 -2
  5. package/dist/src/cli/main.js +37 -0
  6. package/dist/src/core/cli-commands.js +26 -2
  7. package/dist/src/core/config.d.ts +14 -0
  8. package/dist/src/core/config.js +21 -0
  9. package/dist/src/core/launch.d.ts +5 -0
  10. package/dist/src/core/launch.js +11 -1
  11. package/dist/src/core/progress-state.d.ts +94 -0
  12. package/dist/src/core/progress-state.js +240 -0
  13. package/dist/src/core/progress.d.ts +36 -0
  14. package/dist/src/core/progress.js +77 -0
  15. package/dist/src/core/prompt-origin.d.ts +40 -0
  16. package/dist/src/core/prompt-origin.js +98 -0
  17. package/dist/src/core/search-catalog.js +43 -0
  18. package/dist/src/core/unattended-attended.d.ts +109 -0
  19. package/dist/src/core/unattended-attended.js +337 -0
  20. package/dist/src/core/unattended-pending.d.ts +14 -2
  21. package/dist/src/core/unattended-pending.js +27 -3
  22. package/dist/src/core/unattended-state.d.ts +19 -1
  23. package/dist/src/core/unattended-state.js +31 -5
  24. package/dist/src/core/unattended-wait.d.ts +86 -0
  25. package/dist/src/core/unattended-wait.js +125 -0
  26. package/dist/src/core/unattended.d.ts +29 -2
  27. package/dist/src/core/unattended.js +48 -6
  28. package/dist/src/handoff/hook.js +19 -4
  29. package/dist/src/network/hook.js +4 -8
  30. package/dist/src/panel/handler.d.ts +3 -0
  31. package/dist/src/panel/handler.js +31 -1
  32. package/dist/src/panel/i18n.d.ts +27 -0
  33. package/dist/src/panel/i18n.js +56 -2
  34. package/dist/src/panel/page-script.js +118 -4
  35. package/dist/src/panel/page-styles.js +21 -0
  36. package/dist/src/progress/hook.d.ts +57 -0
  37. package/dist/src/progress/hook.js +258 -0
  38. package/dist/src/runtime.d.ts +9 -0
  39. package/dist/src/runtime.js +45 -2
  40. package/dist/src/types.d.ts +5 -0
  41. package/dist/src/unattended/hook.d.ts +26 -6
  42. package/dist/src/unattended/hook.js +361 -25
  43. package/package.json +1 -1
  44. package/schemas/config.json +27 -0
  45. package/schemas/progress.json +137 -0
  46. package/schemas/unattended-defer.json +5 -0
  47. package/schemas/unattended-pending.json +5 -0
  48. package/schemas/unattended.json +54 -2
  49. package/skills/sideby/SKILL.md +4 -1
  50. package/skills/sideby/references/progress.md +25 -0
  51. package/skills/sideby/references/unattended.md +25 -3
package/dist/build.json CHANGED
@@ -1 +1 @@
1
- {"id":"20261116T040114-0f0555"}
1
+ {"id":"20261116T100604-6fbbc9"}
@@ -185,6 +185,12 @@ export declare function cmdTheme(a: ParsedArgs, io: Io): Promise<number>;
185
185
  * `network` after a preview (exit 10 without `--yes`).
186
186
  */
187
187
  export declare function cmdNetwork(a: ParsedArgs, io: Io): Promise<number>;
188
+ /**
189
+ * `sideby progress`: Progress Reminders (spec §3.42, ADR-0076). Without a subcommand shows whether they are on and how
190
+ * often; `on [--every <minutes>]` and `off` change config `progress` at once (only sideby's config is written, so there
191
+ * is no preview) and print the undo.
192
+ */
193
+ export declare function cmdProgress(a: ParsedArgs, io: Io): Promise<number>;
188
194
  /** `sideby unattended …` (spec §3.37, ADR-0058): status, on and off, the Schedule, Pending Decisions and `defer`. */
189
195
  export declare function cmdUnattended(a: ParsedArgs, io: Io): Promise<number>;
190
196
  export declare function cmdCommands(a: ParsedArgs, io: Io): number;
@@ -4700,6 +4700,12 @@ function deferFamily(env) {
4700
4700
  return 'codex';
4701
4701
  return 'unknown';
4702
4702
  }
4703
+ /** What happens to a question nobody answers (Answer Wait, ADR-0077), and how to change it. */
4704
+ function answerWaitLine(minutes) {
4705
+ return minutes === null
4706
+ ? `If nobody answers: questions shown in a Claude session wait for you, however long. ${c.dim('Change it with `sideby unattended wait <minutes>`.')}`
4707
+ : `If nobody answers: after ${minutes} minute${minutes === 1 ? '' : 's'} with Unattended Mode on, the session goes on (the recommended choice; a step needing your OK is skipped). ${c.dim('Change it with `sideby unattended wait <minutes>|off`.')}`;
4708
+ }
4703
4709
  /** One line for where Unattended Mode stands now. */
4704
4710
  function unattendedLine(s, now) {
4705
4711
  const at = (iso) => clock2(iso, now);
@@ -4732,11 +4738,100 @@ function printUnattended(io, s, now, opts = {}) {
4732
4738
  printSchedule(io, s.schedule);
4733
4739
  if (s.pending)
4734
4740
  io.out(`Pending decisions: ${c.yellow(String(s.pending))} open; see them with \`sideby unattended pending\`.`);
4741
+ // Attended Sessions (ADR-0075): shown while the mode is on, when they are what keeps a session asking.
4742
+ if (s.on && s.attended.length) {
4743
+ io.out('Asking you as usual (you typed there in the last 30 minutes):');
4744
+ for (const x of s.attended)
4745
+ io.out(` ${x.account ?? x.family}${x.cwd ? ` · ${basename(x.cwd)}` : ''} · ${x.sessionId.slice(0, 8)} · until ${clock2(x.until, now)}`);
4746
+ }
4747
+ else if (s.on && s.configured)
4748
+ io.out(c.dim('Type in a session and it asks you as usual for 30 minutes; the others stay unattended.'));
4749
+ io.out(answerWaitLine(s.answerWait));
4735
4750
  if (!s.configured)
4736
4751
  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.'));
4737
4752
  else
4738
4753
  io.out(c.dim('Covers Claude sessions sideby starts (questions, permission prompts and MCP forms), and questions in Codex sessions once you trust both `unattended-hook` entries in /hooks; Codex approval prompts still wait. Not Grok, pi, desktop apps or sessions started without sideby.'));
4739
4754
  }
4755
+ /**
4756
+ * `sideby progress`: Progress Reminders (spec §3.42, ADR-0076). Without a subcommand shows whether they are on and how
4757
+ * often; `on [--every <minutes>]` and `off` change config `progress` at once (only sideby's config is written, so there
4758
+ * is no preview) and print the undo.
4759
+ */
4760
+ export async function cmdProgress(a, io) {
4761
+ const [sub, ...rest] = a.positionals;
4762
+ const asJson = a.flags.has('json');
4763
+ const usage = 'usage: sideby progress [status] | sideby progress on [--every <minutes>] | sideby progress off [--json]';
4764
+ if (rest.length || a.rest.length)
4765
+ throw new UsageError(usage);
4766
+ for (const k of a.flags.keys())
4767
+ if (k !== 'json' && !(k === 'every' && sub === 'on'))
4768
+ throw new UsageError(`--${k} does not go with \`sideby progress ${sub ?? ''}\`; ${usage}`);
4769
+ const { PROGRESS_DEFAULT, PROGRESS_MAX, PROGRESS_MIN, validEvery } = await import('../core/progress-state.js');
4770
+ const rt = await createRuntime();
4771
+ const notes = (every) => [
4772
+ every === undefined
4773
+ ? `Off. While a Claude session sideby started waits on background work (subagents, long commands), it can tell you what it waits for: \`sideby progress on\` (every ${PROGRESS_DEFAULT} minutes; --every <minutes> for another interval).`
4774
+ : `On: while a Claude session sideby started waits on background work (subagents, long commands), it tells you every ${every} minutes what it waits for, how long, and whether there is new output.`,
4775
+ 'Each reminder is one model turn, which reads the whole conversation: it uses quota, and a longer interval uses less.',
4776
+ 'Turning it on reaches Claude sessions sideby starts from now on; turning it off or changing the interval also reaches running ones. No reminders while a session is unattended.',
4777
+ 'Codex is not covered: it has no way for sideby to wake a waiting session.',
4778
+ ];
4779
+ if (sub === undefined || sub === 'status') {
4780
+ const v = rt.progressView();
4781
+ if (asJson)
4782
+ json(io, { action: 'status', ...v });
4783
+ else {
4784
+ const [first, ...more] = notes(v.every);
4785
+ io.out(first);
4786
+ for (const line of more)
4787
+ io.out(c.dim(line));
4788
+ }
4789
+ return 0;
4790
+ }
4791
+ if (sub !== 'on' && sub !== 'off')
4792
+ throw new UsageError(usage);
4793
+ let every;
4794
+ if (sub === 'on') {
4795
+ const raw = a.flags.get('every');
4796
+ const given = raw === undefined ? undefined : Number(raw);
4797
+ if (raw !== undefined && !validEvery(given))
4798
+ throw new UsageError(`--every takes whole minutes from ${PROGRESS_MIN} to ${PROGRESS_MAX} (for example --every 10)`);
4799
+ every = given ?? rt.progressView().every ?? PROGRESS_DEFAULT;
4800
+ }
4801
+ const r = await rt.setProgress(every);
4802
+ const undo = r.before === r.after
4803
+ ? undefined
4804
+ : r.before === undefined
4805
+ ? 'sideby progress off'
4806
+ : `sideby progress on --every ${r.before}`;
4807
+ const message = sub === 'on'
4808
+ ? r.changed
4809
+ ? r.before === undefined
4810
+ ? `Progress reminders on: every ${every} minutes. Claude sessions sideby starts from now on get them.`
4811
+ : `Progress reminders now every ${every} minutes (was ${r.before}), also in running sessions.`
4812
+ : `Progress reminders were already on, every ${every} minutes.`
4813
+ : r.changed
4814
+ ? 'Progress reminders off, also in running sessions.'
4815
+ : 'Progress reminders were already off.';
4816
+ if (asJson) {
4817
+ json(io, {
4818
+ action: sub,
4819
+ changed: r.changed,
4820
+ on: sub === 'on',
4821
+ ...(sub === 'on' ? { every } : {}),
4822
+ ...(r.before === undefined ? {} : { before: r.before }),
4823
+ ...(undo ? { undo } : {}),
4824
+ message,
4825
+ });
4826
+ return 0;
4827
+ }
4828
+ io.out(r.changed ? `${c.green('✓')} ${message}` : message);
4829
+ if (sub === 'on')
4830
+ io.out(c.dim(notes(every).slice(1).join('\n')));
4831
+ if (undo && r.changed)
4832
+ io.out(c.dim(`Undo: ${undo}`));
4833
+ return 0;
4834
+ }
4740
4835
  /** `sideby unattended …` (spec §3.37, ADR-0058): status, on and off, the Schedule, Pending Decisions and `defer`. */
4741
4836
  export async function cmdUnattended(a, io) {
4742
4837
  const [sub, ...rest] = a.positionals;
@@ -4875,6 +4970,29 @@ export async function cmdUnattended(a, io) {
4875
4970
  }
4876
4971
  throw new UsageError('usage: sideby unattended schedule [add --days … --from … --to … [--name …] | remove <number> | preset weeknights]');
4877
4972
  }
4973
+ if (sub === 'wait') {
4974
+ allow();
4975
+ const usage = 'usage: sideby unattended wait [<minutes>|off]: minutes from 1 to 120 (for example 10), or off to wait for you however long';
4976
+ if (rest.length > 1)
4977
+ throw new UsageError(usage);
4978
+ const raw = rest[0];
4979
+ if (raw === undefined) {
4980
+ const s = await rt.unattendedStatus();
4981
+ if (asJson)
4982
+ json(io, s);
4983
+ else
4984
+ io.out(answerWaitLine(s.answerWait));
4985
+ return 0;
4986
+ }
4987
+ const minutes = raw === 'off' || raw === 'never' ? null : /^\d{1,3}$/.test(raw) ? Number(raw) : Number.NaN;
4988
+ if (minutes !== null && !(minutes >= 1 && minutes <= 120))
4989
+ throw new UsageError(usage);
4990
+ const change = await u.setAnswerWait({ paths, families, minutes, now: now() });
4991
+ const said = minutes === null
4992
+ ? 'Questions shown in Claude sessions now wait for you, however long.'
4993
+ : `Questions shown in Claude sessions now wait ${minutes} minute${minutes === 1 ? '' : 's'}; then, with Unattended Mode on, the session goes on.`;
4994
+ return show(change, change.changed ? said : `It was already set. ${said}`);
4995
+ }
4878
4996
  if (sub === 'pending') {
4879
4997
  const { listPendingDecisions, markPendingDone } = await import('../core/unattended-pending.js');
4880
4998
  const [action, ...args] = rest;
@@ -4913,6 +5031,7 @@ export async function cmdUnattended(a, io) {
4913
5031
  const where = [
4914
5032
  d.account ?? d.family,
4915
5033
  d.kind === 'question' ? 'question' : d.kind === 'permission' ? 'needed your OK' : 'left undone',
5034
+ d.waited ? `no answer for ${d.waited} min` : '',
4916
5035
  d.agentType ? `subagent ${d.agentType}` : '',
4917
5036
  d.doneAt ? 'done' : '',
4918
5037
  ]
@@ -4949,7 +5068,7 @@ export async function cmdUnattended(a, io) {
4949
5068
  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.`);
4950
5069
  return 0;
4951
5070
  }
4952
- throw new UsageError('usage: sideby unattended [status|on|off|schedule|pending|defer]; run `sideby unattended --help`');
5071
+ throw new UsageError('usage: sideby unattended [status|on|off|schedule|wait|pending|defer]; run `sideby unattended --help`');
4953
5072
  }
4954
5073
  /**
4955
5074
  * `sideby commands <words>` (spec §3.36, ADR-0054): the Search Catalog the Panel's Command Palette searches, read-only.
@@ -24,6 +24,10 @@ const PendingDecision = Type.Object({
24
24
  text: Type.String({
25
25
  description: 'The question and its options, the tool and what it was to do, or the deferred text; at most 4000 characters.',
26
26
  }),
27
+ waited: Type.Optional(Type.Integer({
28
+ minimum: 1,
29
+ 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.',
30
+ })),
27
31
  doneAt: Type.Optional(Type.String({ description: 'When it was marked done; ISO.' })),
28
32
  });
29
33
  /** The menu bar shortcut (`sideby menubar hotkey`, spec §3.31). */
@@ -1464,7 +1468,26 @@ export const OUTPUT_SCHEMAS = {
1464
1468
  schedule: Type.Array(UnattendedSlotSchema, {
1465
1469
  description: 'Config `unattended.schedule`, numbered from 1.',
1466
1470
  }),
1471
+ answerWait: Type.Union([Type.Integer({ minimum: 1, maximum: 120 }), Type.Null()], {
1472
+ 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`.',
1473
+ }),
1467
1474
  pending: Type.Integer({ description: 'Open Pending Decisions (`sideby unattended pending`).' }),
1475
+ attended: Type.Array(Type.Object({
1476
+ sessionId: Str,
1477
+ family: Str,
1478
+ account: Type.Optional(Str),
1479
+ cwd: Type.Optional(Str),
1480
+ since: Type.String({
1481
+ format: 'date-time',
1482
+ description: 'When someone first typed into it after it last stopped counting.',
1483
+ }),
1484
+ until: Type.String({
1485
+ format: 'date-time',
1486
+ description: '30 minutes after the last prompt someone typed into it.',
1487
+ }),
1488
+ }), {
1489
+ description: 'Attended Sessions (ADR-0075): Claude sessions sideby started that someone typed into within the last 30 minutes. They ask as usual while the mode stays on for every other session. Latest `until` first. Read-only: only a prompt typed into the session sets it.',
1490
+ }),
1468
1491
  coverage: Type.Record(Str, Type.Union([Type.Literal('covered'), Type.Literal('needs-trust'), Type.Literal('not-covered')]), {
1469
1492
  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).',
1470
1493
  }),
@@ -1481,9 +1504,9 @@ export const OUTPUT_SCHEMAS = {
1481
1504
  problem: Type.Optional(Type.String({
1482
1505
  description: 'Why sideby cannot keep its state: `<state>/unattended` is a link, someone else’s, or writable by others. Says what to do.',
1483
1506
  })),
1484
- changed: Type.Optional(Type.Boolean({ description: 'Set by on, off and schedule changes: whether anything changed.' })),
1507
+ changed: Type.Optional(Type.Boolean({ description: 'Set by on, off, schedule and wait changes: whether anything changed.' })),
1485
1508
  undo: Type.Optional(Type.String({ description: 'The command that puts back what the change replaced.' })),
1486
- }, { title: 'sideby unattended [on|off|schedule …] --json' }),
1509
+ }, { title: 'sideby unattended [on|off|schedule …|wait …] --json' }),
1487
1510
  'unattended-pending': Type.Object({
1488
1511
  schemaVersion: Version,
1489
1512
  pending: Type.Array(PendingDecision, {
@@ -1492,6 +1515,25 @@ export const OUTPUT_SCHEMAS = {
1492
1515
  done: Type.Optional(Type.Array(Str, { description: '`pending done`: the ids marked done.' })),
1493
1516
  }, { title: 'sideby unattended pending [done <id>|--all] --json' }),
1494
1517
  'unattended-defer': Type.Object({ schemaVersion: Version, decision: PendingDecision }, { title: 'sideby unattended defer "<text>" --json' }),
1518
+ progress: Type.Object({
1519
+ schemaVersion: Version,
1520
+ action: Type.Union([Type.Literal('status'), Type.Literal('on'), Type.Literal('off')]),
1521
+ on: Type.Boolean({
1522
+ description: 'Progress Reminders are on: a Claude session sideby starts that waits on background work tells the user every `every` minutes what it waits for (spec §3.42).',
1523
+ }),
1524
+ every: Type.Optional(Type.Integer({
1525
+ description: 'Minutes between reminders, config `progress.every`; absent while off.',
1526
+ })),
1527
+ defaultEvery: Type.Optional(Type.Integer({ description: 'What `on` picks without --every (status only).' })),
1528
+ choices: Type.Optional(Type.Array(Type.Integer(), { description: 'The intervals the Panel offers (status only).' })),
1529
+ families: Type.Optional(Type.Array(Str, {
1530
+ description: 'Families whose sessions get reminders (status only); Codex has no hook that can wake a session.',
1531
+ })),
1532
+ changed: Type.Optional(Type.Boolean({ description: 'on and off: whether the config changed.' })),
1533
+ before: Type.Optional(Type.Integer({ description: 'on and off: the interval before, when it was on.' })),
1534
+ undo: Type.Optional(Type.String({ description: 'on and off: the command that puts back what was there.' })),
1535
+ message: Type.Optional(Type.String({ description: 'on and off: one line for the user.' })),
1536
+ }, { title: 'sideby progress [on|off] --json' }),
1495
1537
  browser: Type.Object({
1496
1538
  schemaVersion: Version,
1497
1539
  enabled: Type.Boolean({
@@ -345,6 +345,7 @@ no country allowed; 2 malformed command line.`,
345
345
  sideby unattended off [--json]
346
346
  sideby unattended schedule [add --days <days> --from HH:MM --to HH:MM [--name <name>] [--at <n>]] [--json]
347
347
  sideby unattended schedule remove <n> | preset weeknights [--json]
348
+ sideby unattended wait [<minutes>|off] [--json]
348
349
  sideby unattended pending [--all] [--json]
349
350
  sideby unattended pending done <id> | --all [--json]
350
351
  sideby unattended defer "<text>" [--json]
@@ -359,6 +360,12 @@ that failed for a passing reason (an overloaded server, a dropped connection, a
359
360
  Quota) is started again after 1, 2, then 4 minutes; after three it is kept as a Pending Decision. Codex's own
360
361
  approval prompts are not covered.
361
362
 
363
+ If nobody answers (\`wait\`): a question or permission prompt that a Claude session shows while you are there (you
364
+ typed in it within 30 minutes, or Unattended Mode is off) waits for you. Once it has waited 10 minutes (\`wait
365
+ <minutes>\`, 1 to 120) and Unattended Mode is on, the session goes on as above: the recommended choice where it can
366
+ be undone, the prompt answered "no", never "yes". A turn that ended on a question in plain text goes on the same way.
367
+ Each is kept as a Pending Decision with how long it waited. \`wait off\`: questions wait for you however long.
368
+
362
369
  When it is on: during a Slot of the Schedule (local days and times; an end before the start is the next day), from
363
370
  \`on\` until the time you choose (at most 72 hours; without an option, until the current or next Slot ends, else 12
364
371
  hours), or for one session started with \`--unattended\` (\`sideby run <account> --unattended\`, also next, resume,
@@ -375,10 +382,30 @@ Examples:
375
382
  sideby unattended on --until 07:30
376
383
  sideby unattended schedule preset weeknights
377
384
  sideby unattended schedule add --days sat,sun --from 01:00 --to 09:00 --name "Weekend nights"
385
+ sideby unattended wait 30
378
386
  sideby unattended pending
379
387
  sideby unattended defer "deleting the old branch is left for the user"
380
388
  Exit: 0 shown or done; 1 no such Slot or Pending Decision; 2 a time or option it does not take (the message says
381
389
  which to use).`,
390
+ progress: `sideby progress [status] [--json]
391
+ sideby progress on [--every <minutes>] [--json]
392
+ sideby progress off [--json]
393
+
394
+ Progress reminders: while a Claude session sideby started waits on background work (subagents, long commands),
395
+ sideby wakes it now and then so it tells you in one or two sentences what it waits for, how long, and whether
396
+ there is new output. Off by default: each reminder is one model turn, which reads the whole conversation, so it uses
397
+ quota. No reminders while the session is unattended, or while a turn is running.
398
+
399
+ \`on\` turns them on (every 30 minutes, or --every <minutes>, 1 to 240); \`off\` turns them off. Turning them on reaches
400
+ Claude sessions sideby starts from now on; turning them off or changing the interval also reaches running ones. Only
401
+ sideby's config is written, so there is no preview; each change prints its undo. Codex is not covered: it has no
402
+ way for sideby to wake a waiting session. Grok, pi and sessions started without sideby are not covered either.
403
+
404
+ Examples:
405
+ sideby progress on
406
+ sideby progress on --every 15
407
+ sideby progress off
408
+ Exit: 0 shown or done (also when nothing changed); 2 an interval or option it does not take.`,
382
409
  browser: `sideby browser [--enable|--disable] [--yes] [--json]
383
410
  sideby browser open <account> [--profile <folder|name>] [--json]
384
411
  sideby browser set <account> <folder|name> [--json]
@@ -478,6 +505,7 @@ const COMMANDS = {
478
505
  flags: ['json', 'all', 'slot-end'],
479
506
  valued: ['for', 'until', 'days', 'from', 'to', 'name', 'at'],
480
507
  },
508
+ progress: { flags: ['json'], valued: ['every'] },
481
509
  new: { flags: ['api', 'json', 'next'], valued: ['alias', 'vendor'] },
482
510
  alias: { flags: ['json', 'yes'], valued: ['pick'] },
483
511
  doctor: { flags: ['fix', 'force', 'json'] },
@@ -632,6 +660,13 @@ export async function main(argv) {
632
660
  const { runUnattendedHook } = await import('../unattended/hook.js');
633
661
  return runUnattendedHook(rest, process.env, process.stdin, { out: process.stdout, err: process.stderr });
634
662
  }
663
+ // Progress Reminders' hook runs after every turn and on every prompt in the background (spec §3.42); same fast path.
664
+ if (first === 'progress-hook') {
665
+ const { runProgressHook } = await import('../progress/hook.js');
666
+ return runProgressHook(rest, process.env, process.stdin.isTTY ? '' : process.stdin, {
667
+ err: process.stderr,
668
+ });
669
+ }
635
670
  if (nodeTooOld()) {
636
671
  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).`);
637
672
  return 1;
@@ -804,6 +839,8 @@ async function dispatch(cmd, parsed, io, cmds) {
804
839
  return await cmds.cmdNetwork(parsed, io);
805
840
  case 'unattended':
806
841
  return await cmds.cmdUnattended(parsed, io);
842
+ case 'progress':
843
+ return await cmds.cmdProgress(parsed, io);
807
844
  case 'shell-init':
808
845
  return await cmds.cmdShellInit(parsed, io);
809
846
  case 'plugins':
@@ -520,6 +520,18 @@ export const CLI_COMMANDS = [
520
520
  },
521
521
  feature: 'action.inbound',
522
522
  },
523
+ {
524
+ id: 'progress',
525
+ group: 'sessions',
526
+ usage: 'sideby progress [on|off]',
527
+ help: 'while a Claude session waits on background work, it tells you every few minutes what it waits for (on [--every <minutes>], off; each reminder uses quota)',
528
+ summary: {
529
+ en: 'While a session waits on background work, it tells you what it waits for',
530
+ zh: '会话等后台任务时,隔几分钟告诉你在等什么',
531
+ },
532
+ example: 'sideby progress on --every 10',
533
+ feature: 'setting.progress',
534
+ },
523
535
  // ---------- Health and safety ----------
524
536
  {
525
537
  id: 'doctor',
@@ -567,6 +579,18 @@ export const CLI_COMMANDS = [
567
579
  example: 'sideby unattended on --until 07:30',
568
580
  feature: 'page.unattended',
569
581
  },
582
+ {
583
+ id: 'unattended.wait',
584
+ group: 'health',
585
+ usage: 'sideby unattended wait [<minutes>|off]',
586
+ help: 'how long a question shown in a Claude session waits for you before, with Unattended Mode on, the session goes on without an answer (1 to 120 minutes, 10 by default; off: wait however long)',
587
+ summary: {
588
+ en: 'Choose how long a question waits for you before the session goes on',
589
+ zh: '设置提问等你多久,之后会话自己继续',
590
+ },
591
+ example: 'sideby unattended wait 30',
592
+ feature: 'action.unattended-wait',
593
+ },
570
594
  // ---------- Panel and app ----------
571
595
  {
572
596
  id: 'ui',
@@ -854,9 +878,9 @@ export function cliHelp(list = CLI_COMMANDS) {
854
878
  const HELP_TAIL = `Options:
855
879
  --json machine-readable output (list, new, next, alias, doctor, quota, tune, model, advisor, remote-control, handoff,
856
880
  families, commands, plugins, app, desktop, sessions, history, send, messages, edit, browser, update, local, ask,
857
- terminal, key, try, autostart, menubar, config, network, unattended)
881
+ terminal, key, try, autostart, menubar, config, network, unattended, progress)
858
882
  -h, --help show this help; \`sideby <command> --help\` for new, alias, login, doctor, families, commands, desktop, edit, browser,
859
- autostart, menubar, config, sessions, history, send, messages, network, unattended
883
+ autostart, menubar, config, sessions, history, send, messages, network, unattended, progress
860
884
  -v, --version show the version
861
885
 
862
886
  An <account> is <family>:<name> (claude:work) or just <name> when it is unique.
@@ -131,6 +131,10 @@ export declare const ConfigSchema: Type.TObject<{
131
131
  start: Type.TString;
132
132
  end: Type.TString;
133
133
  }>>>;
134
+ answerWait: Type.TOptional<Type.TUnion<[Type.TInteger, Type.TLiteral<false>]>>;
135
+ }>>;
136
+ progress: Type.TOptional<Type.TObject<{
137
+ every: Type.TOptional<Type.TInteger>;
134
138
  }>>;
135
139
  browser: Type.TOptional<Type.TObject<{
136
140
  signIns: Type.TOptional<Type.TBoolean>;
@@ -258,6 +262,16 @@ export declare function editConfigQuotaCheck(file: string, family: string, on: b
258
262
  before: QuotaConfig | undefined;
259
263
  after: QuotaConfig | undefined;
260
264
  }>;
265
+ export type ProgressConfig = NonNullable<Config['progress']>;
266
+ /**
267
+ * `sideby progress on|off` and the Panel's switch (spec §3.42): a number writes `progress.every`, undefined removes
268
+ * `progress` (off is the default) (see `editConfigKey` for how the file is written).
269
+ */
270
+ export declare function editConfigProgress(file: string, every: number | undefined): Promise<{
271
+ changed: boolean;
272
+ before: ProgressConfig | undefined;
273
+ after: ProgressConfig | undefined;
274
+ }>;
261
275
  export type AccountsConfig = NonNullable<Config['accounts']>;
262
276
  /**
263
277
  * `sideby model` (spec §3.19): changes the config `accounts` key with `edit` (see `editConfigKey` for how the file is
@@ -255,10 +255,20 @@ export const ConfigSchema = Type.Object({
255
255
  schedule: Type.Optional(Type.Array(UnattendedSlotSchema, {
256
256
  description: "Slots that turn Unattended Mode on and off by themselves, in this computer's time zone. Empty by default.",
257
257
  })),
258
+ answerWait: Type.Optional(Type.Union([Type.Integer({ minimum: 1, maximum: 120 }), Type.Literal(false)], {
259
+ 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.',
260
+ })),
258
261
  }, {
259
262
  additionalProperties: false,
260
263
  description: 'Unattended Mode (spec §3.37, ADR-0058): while it is on, sessions sideby starts never stop to wait for a person. Present once the feature is used; from then on sideby adds its hook to every Claude and Codex session it starts, so turning it on later covers sessions already running. `sideby config unset unattended` stops adding it.',
261
264
  })),
265
+ progress: Type.Optional(Type.Object({
266
+ every: Type.Optional(Type.Integer({
267
+ minimum: 1,
268
+ maximum: 240,
269
+ description: 'Progress Reminders: while a Claude session sideby started waits on background work (subagents, background commands), wake it every this many minutes so the model tells you in one or two sentences what it waits for. Each reminder is one model turn over the whole conversation, so it uses quota. Not set: off (the default). Sessions started afterwards get it; turning it off or changing the interval also reaches running sessions. Not while the session is unattended; Codex is not covered.',
270
+ })),
271
+ }, { additionalProperties: false, description: 'Progress Reminders (spec §3.42, ADR-0076).' })),
262
272
  browser: Type.Optional(Type.Object({
263
273
  signIns: Type.Optional(Type.Boolean({
264
274
  description: "Look in Google Chrome's local data for which browser user signed in to each Account's website (key names only, never cookies or passwords; nothing leaves this computer). Off by default.",
@@ -540,6 +550,17 @@ export function editConfigQuotaCheck(file, family, on) {
540
550
  return Object.keys(next).length ? next : undefined;
541
551
  });
542
552
  }
553
+ /**
554
+ * `sideby progress on|off` and the Panel's switch (spec §3.42): a number writes `progress.every`, undefined removes
555
+ * `progress` (off is the default) (see `editConfigKey` for how the file is written).
556
+ */
557
+ export function editConfigProgress(file, every) {
558
+ return editConfigKey(file, 'progress', 'change the setting', (current) => {
559
+ const { every: _old, ...rest } = current ?? {};
560
+ const next = { ...rest, ...(every === undefined ? {} : { every }) };
561
+ return Object.keys(next).length ? next : undefined;
562
+ });
563
+ }
543
564
  /**
544
565
  * `sideby model` (spec §3.19): changes the config `accounts` key with `edit` (see `editConfigKey` for how the file is
545
566
  * written). With `dryRun`, shows the change without writing.
@@ -92,6 +92,11 @@ export declare function prepareLaunch(opts: LaunchCommandOptions & {
92
92
  * default action so Ctrl-Z suspends sideby together with the Host and `fg` resumes both.
93
93
  */
94
94
  export declare function runHost(p: HostLaunch): Promise<number>;
95
+ /**
96
+ * The environment the Host starts with. A session with `unattended-hook` gets the marks of the prompts sideby put on
97
+ * its command line (ADR-0075), from the final arguments: Auto Handoff adds a relay prompt after the Launch is prepared.
98
+ */
99
+ export declare function hostEnv(p: Pick<HostLaunch, 'args' | 'env'>): Env;
95
100
  /**
96
101
  * `runHost` with the child process exposed, so the Auto Handoff (spec §3.17) can end the Host and start the next
97
102
  * Account in the same terminal. Same signal handling, exit codes and title as `runHost`.
@@ -4,6 +4,7 @@ import { constants as osConstants } from 'node:os';
4
4
  import { delimiter, join } from 'node:path';
5
5
  import { apiBetasEnv, unlockAdvisorEnv } from './advisor.js';
6
6
  import { lstatOrNull, realpathOrNull } from './fs-safe.js';
7
+ import { LAUNCH_PROMPTS_ENV, launchPromptMarks } from './prompt-origin.js';
7
8
  import { readSecretFile } from './secret-file.js';
8
9
  /**
9
10
  * Whether the title `[cc002]` should grow into the Session Label as the Host runs (spec §3.32): only with config
@@ -161,6 +162,15 @@ export async function prepareLaunch(opts) {
161
162
  export function runHost(p) {
162
163
  return spawnHost(p).exited;
163
164
  }
165
+ /**
166
+ * The environment the Host starts with. A session with `unattended-hook` gets the marks of the prompts sideby put on
167
+ * its command line (ADR-0075), from the final arguments: Auto Handoff adds a relay prompt after the Launch is prepared.
168
+ */
169
+ export function hostEnv(p) {
170
+ if (p.env[LAUNCH_PROMPTS_ENV] === undefined)
171
+ return p.env;
172
+ return { ...p.env, [LAUNCH_PROMPTS_ENV]: launchPromptMarks(p.args) };
173
+ }
164
174
  /**
165
175
  * `runHost` with the child process exposed, so the Auto Handoff (spec §3.17) can end the Host and start the next
166
176
  * Account in the same terminal. Same signal handling, exit codes and title as `runHost`.
@@ -198,7 +208,7 @@ export function spawnHost(p) {
198
208
  for (const [s, h] of handlers)
199
209
  process.on(s, h);
200
210
  try {
201
- child = spawn(p.bin, p.args, { stdio: 'inherit', env: p.env });
211
+ child = spawn(p.bin, p.args, { stdio: 'inherit', env: hostEnv(p) });
202
212
  }
203
213
  catch (err) {
204
214
  cleanup();
@@ -0,0 +1,94 @@
1
+ /** Set in a session's environment: the interval at launch, used only when the config cannot be read. */
2
+ export declare const PROGRESS_ENV = "SIDEBY_PROGRESS_EVERY";
3
+ /** The interval in whole minutes: at least this, at most `PROGRESS_MAX` (under the hook's five-hour timeout). */
4
+ export declare const PROGRESS_MIN = 1;
5
+ export declare const PROGRESS_MAX = 240;
6
+ /** What turning it on picks when no interval is given. */
7
+ export declare const PROGRESS_DEFAULT = 30;
8
+ /** The intervals the Panel offers. */
9
+ export declare const PROGRESS_CHOICES: readonly number[];
10
+ /** The `timeout` of the `Stop` entry, in seconds (the same as Auto Handoff's IdleWatch). */
11
+ export declare const PROGRESS_STOP_TIMEOUT_S = 18000;
12
+ /** The `timeout` of the `UserPromptSubmit` entry, in seconds. */
13
+ export declare const PROGRESS_PROMPT_TIMEOUT_S = 10;
14
+ /** Whether `v` is an interval sideby takes. */
15
+ export declare const validEvery: (v: unknown) => v is number;
16
+ /**
17
+ * Config `progress.every`, read by hand (no schema) on every check: undefined means off. No config file means the
18
+ * defaults (off), as for every other config reader; only a file that exists but cannot be read or is not JSON falls
19
+ * back to the interval the session started with.
20
+ */
21
+ export declare function readProgressEvery(configFile: string, env: Record<string, string | undefined>): Promise<number | undefined>;
22
+ /** The first 32 hex digits of a SHA-256: how a session id and a prompt id are kept. */
23
+ export declare const hashOf: (s: string) => string;
24
+ /** The watch a `Stop` started: a later `Stop` replaces it, and the earlier watch then ends. */
25
+ export interface WatchRecord {
26
+ id: string;
27
+ /** When the session began waiting: kept across reminder turns. */
28
+ since: string;
29
+ /** When the hook of the `Stop` that started this watch began, before reading its input: the order of the Stops. */
30
+ at: string;
31
+ /** When this watch woke the session. */
32
+ wokeAt?: string;
33
+ }
34
+ /** The latest prompt of the session. */
35
+ export interface PromptRecord {
36
+ at: string;
37
+ /** `hashOf(prompt_id)`. */
38
+ prompt: string;
39
+ /** The prompt was a Progress Reminder's wake-up and nothing else. */
40
+ reminder: boolean;
41
+ }
42
+ /** How long a write waits for the session's lock, for tests; by default `LOCK_WAIT`. */
43
+ export interface LockWait {
44
+ lockWait?: {
45
+ timeoutMs: number;
46
+ pollMs: number;
47
+ };
48
+ }
49
+ export declare function readWatch(stateDir: string, sessionId: string): Promise<WatchRecord | undefined>;
50
+ /**
51
+ * Replaces the session's watch (file 600, atomically) under the session's lock, so it never lands between another
52
+ * watch's last check and its `wokeAt`, unless the record holds the watch of a later `Stop` (its `at` is later): a
53
+ * `Stop` whose hook got its input or the lock late never ends the watch of the turn after it. False when the lock
54
+ * stays held or a later watch is kept: then nothing is written and the caller must not act as the session's watch.
55
+ * Throws when the folder is not safe to use.
56
+ */
57
+ export declare function writeWatch(stateDir: string, sessionId: string, record: WatchRecord, opts?: LockWait): Promise<boolean>;
58
+ /**
59
+ * Whether the session's latest prompt is not the one the watching `Stop` ended, so a turn began after it: compared by
60
+ * the prompt's id (`own`, hashed), never by time, because the next prompt's record can be written before the watch
61
+ * starts. Only a `Stop` without an id falls back to whether the record came after it (`stopAt`).
62
+ */
63
+ export declare function newerPrompt(p: PromptRecord | undefined, own: string | undefined, stopAt: number): boolean;
64
+ /**
65
+ * Marks the watch `id` woken at `at`, only while the session's record is still that watch and, with `turn`, no
66
+ * prompt came after the turn the watch's `Stop` ended (`newerPrompt`): a reminder sent then would only queue behind
67
+ * that turn and cost a model call of its own. The checks and the write hold the session's lock, so a later `Stop`
68
+ * replaces the record, or a prompt is noted, before or after, never in between. False when the record is another
69
+ * watch's, is missing, a newer prompt is noted, or the lock stays held (`beforeWrite` runs inside the lock, for tests).
70
+ */
71
+ export declare function markWatchWoken(stateDir: string, sessionId: string, id: string, at: Date, deps?: {
72
+ beforeWrite?: () => Promise<void>;
73
+ turn?: {
74
+ prompt?: string;
75
+ stopAt: number;
76
+ };
77
+ }): Promise<boolean>;
78
+ export declare function readPromptRecord(stateDir: string, sessionId: string): Promise<PromptRecord | undefined>;
79
+ /**
80
+ * Notes the session's latest prompt under the session's lock, unless the record already holds a later one: two
81
+ * background hooks may finish out of order, and an older prompt never replaces a newer one (`at` is when the hook
82
+ * started, so it follows the order the prompts came in). The same prompt noted again at the same time or later
83
+ * replaces it. Then removes records nobody changed for a day. False when the lock stays held or a later prompt is kept.
84
+ * `beforeRemove` runs with the file's name before each removal takes its lock (for tests).
85
+ */
86
+ export declare function writePromptRecord(stateDir: string, sessionId: string, record: PromptRecord, now: Date, opts?: LockWait & {
87
+ beforeRemove?: (name: string) => Promise<void>;
88
+ }): Promise<boolean>;
89
+ /**
90
+ * Whether the `Stop` that carries `promptId` ends the turn a Progress Reminder started: the session's latest prompt
91
+ * has that id and was a reminder. A record that is missing, late or for another prompt says no, so a caller that
92
+ * cannot tell treats the turn as an ordinary one.
93
+ */
94
+ export declare function progressReminderTurn(stateDir: string, sessionId: string | undefined, promptId: string | undefined): Promise<boolean>;