sideby 0.38.1 → 0.39.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 (42) 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 +88 -0
  4. package/dist/src/cli/json-schemas.js +35 -0
  5. package/dist/src/cli/main.js +29 -0
  6. package/dist/src/core/cli-commands.js +14 -2
  7. package/dist/src/core/config.d.ts +13 -0
  8. package/dist/src/core/config.js +18 -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 +80 -0
  12. package/dist/src/core/progress-state.js +216 -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 +25 -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.d.ts +10 -2
  21. package/dist/src/core/unattended.js +11 -2
  22. package/dist/src/handoff/hook.js +19 -4
  23. package/dist/src/network/hook.js +4 -8
  24. package/dist/src/panel/handler.d.ts +3 -0
  25. package/dist/src/panel/handler.js +15 -0
  26. package/dist/src/panel/i18n.d.ts +18 -0
  27. package/dist/src/panel/i18n.js +36 -0
  28. package/dist/src/panel/page-script.js +67 -2
  29. package/dist/src/panel/page-styles.js +14 -0
  30. package/dist/src/progress/hook.d.ts +50 -0
  31. package/dist/src/progress/hook.js +251 -0
  32. package/dist/src/runtime.d.ts +9 -0
  33. package/dist/src/runtime.js +45 -2
  34. package/dist/src/unattended/hook.d.ts +5 -0
  35. package/dist/src/unattended/hook.js +103 -9
  36. package/package.json +1 -1
  37. package/schemas/config.json +13 -0
  38. package/schemas/progress.json +137 -0
  39. package/schemas/unattended.json +38 -0
  40. package/skills/sideby/SKILL.md +3 -1
  41. package/skills/sideby/references/progress.md +25 -0
  42. package/skills/sideby/references/unattended.md +9 -1
package/dist/build.json CHANGED
@@ -1 +1 @@
1
- {"id":"20261116T040114-0f0555"}
1
+ {"id":"20261116T070722-38c598"}
@@ -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;
@@ -4732,11 +4732,99 @@ function printUnattended(io, s, now, opts = {}) {
4732
4732
  printSchedule(io, s.schedule);
4733
4733
  if (s.pending)
4734
4734
  io.out(`Pending decisions: ${c.yellow(String(s.pending))} open; see them with \`sideby unattended pending\`.`);
4735
+ // Attended Sessions (ADR-0075): shown while the mode is on, when they are what keeps a session asking.
4736
+ if (s.on && s.attended.length) {
4737
+ io.out('Asking you as usual (you typed there in the last 30 minutes):');
4738
+ for (const x of s.attended)
4739
+ io.out(` ${x.account ?? x.family}${x.cwd ? ` · ${basename(x.cwd)}` : ''} · ${x.sessionId.slice(0, 8)} · until ${clock2(x.until, now)}`);
4740
+ }
4741
+ else if (s.on && s.configured)
4742
+ io.out(c.dim('Type in a session and it asks you as usual for 30 minutes; the others stay unattended.'));
4735
4743
  if (!s.configured)
4736
4744
  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
4745
  else
4738
4746
  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
4747
  }
4748
+ /**
4749
+ * `sideby progress`: Progress Reminders (spec §3.42, ADR-0076). Without a subcommand shows whether they are on and how
4750
+ * often; `on [--every <minutes>]` and `off` change config `progress` at once (only sideby's config is written, so there
4751
+ * is no preview) and print the undo.
4752
+ */
4753
+ export async function cmdProgress(a, io) {
4754
+ const [sub, ...rest] = a.positionals;
4755
+ const asJson = a.flags.has('json');
4756
+ const usage = 'usage: sideby progress [status] | sideby progress on [--every <minutes>] | sideby progress off [--json]';
4757
+ if (rest.length || a.rest.length)
4758
+ throw new UsageError(usage);
4759
+ for (const k of a.flags.keys())
4760
+ if (k !== 'json' && !(k === 'every' && sub === 'on'))
4761
+ throw new UsageError(`--${k} does not go with \`sideby progress ${sub ?? ''}\`; ${usage}`);
4762
+ const { PROGRESS_DEFAULT, PROGRESS_MAX, PROGRESS_MIN, validEvery } = await import('../core/progress-state.js');
4763
+ const rt = await createRuntime();
4764
+ const notes = (every) => [
4765
+ every === undefined
4766
+ ? `Off. While a Claude session sideby started waits on background work (subagents, long commands), it can tell you what it waits for every few minutes: \`sideby progress on\` (every ${PROGRESS_DEFAULT} minutes; --every <minutes> for another interval).`
4767
+ : `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.`,
4768
+ 'Each reminder is one model turn, which reads the whole conversation: it uses quota.',
4769
+ '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.',
4770
+ 'Codex is not covered: it has no way for sideby to wake a waiting session.',
4771
+ ];
4772
+ if (sub === undefined || sub === 'status') {
4773
+ const v = rt.progressView();
4774
+ if (asJson)
4775
+ json(io, { action: 'status', ...v });
4776
+ else {
4777
+ const [first, ...more] = notes(v.every);
4778
+ io.out(first);
4779
+ for (const line of more)
4780
+ io.out(c.dim(line));
4781
+ }
4782
+ return 0;
4783
+ }
4784
+ if (sub !== 'on' && sub !== 'off')
4785
+ throw new UsageError(usage);
4786
+ let every;
4787
+ if (sub === 'on') {
4788
+ const raw = a.flags.get('every');
4789
+ const given = raw === undefined ? undefined : Number(raw);
4790
+ if (raw !== undefined && !validEvery(given))
4791
+ throw new UsageError(`--every takes whole minutes from ${PROGRESS_MIN} to ${PROGRESS_MAX} (for example --every 10)`);
4792
+ every = given ?? rt.progressView().every ?? PROGRESS_DEFAULT;
4793
+ }
4794
+ const r = await rt.setProgress(every);
4795
+ const undo = r.before === r.after
4796
+ ? undefined
4797
+ : r.before === undefined
4798
+ ? 'sideby progress off'
4799
+ : `sideby progress on --every ${r.before}`;
4800
+ const message = sub === 'on'
4801
+ ? r.changed
4802
+ ? r.before === undefined
4803
+ ? `Progress reminders on: every ${every} minutes. Claude sessions sideby starts from now on get them.`
4804
+ : `Progress reminders now every ${every} minutes (was ${r.before}), also in running sessions.`
4805
+ : `Progress reminders were already on, every ${every} minutes.`
4806
+ : r.changed
4807
+ ? 'Progress reminders off, also in running sessions.'
4808
+ : 'Progress reminders were already off.';
4809
+ if (asJson) {
4810
+ json(io, {
4811
+ action: sub,
4812
+ changed: r.changed,
4813
+ on: sub === 'on',
4814
+ ...(sub === 'on' ? { every } : {}),
4815
+ ...(r.before === undefined ? {} : { before: r.before }),
4816
+ ...(undo ? { undo } : {}),
4817
+ message,
4818
+ });
4819
+ return 0;
4820
+ }
4821
+ io.out(r.changed ? `${c.green('✓')} ${message}` : message);
4822
+ if (sub === 'on')
4823
+ io.out(c.dim(notes(every).slice(1).join('\n')));
4824
+ if (undo && r.changed)
4825
+ io.out(c.dim(`Undo: ${undo}`));
4826
+ return 0;
4827
+ }
4740
4828
  /** `sideby unattended …` (spec §3.37, ADR-0058): status, on and off, the Schedule, Pending Decisions and `defer`. */
4741
4829
  export async function cmdUnattended(a, io) {
4742
4830
  const [sub, ...rest] = a.positionals;
@@ -1465,6 +1465,22 @@ export const OUTPUT_SCHEMAS = {
1465
1465
  description: 'Config `unattended.schedule`, numbered from 1.',
1466
1466
  }),
1467
1467
  pending: Type.Integer({ description: 'Open Pending Decisions (`sideby unattended pending`).' }),
1468
+ attended: Type.Array(Type.Object({
1469
+ sessionId: Str,
1470
+ family: Str,
1471
+ account: Type.Optional(Str),
1472
+ cwd: Type.Optional(Str),
1473
+ since: Type.String({
1474
+ format: 'date-time',
1475
+ description: 'When someone first typed into it after it last stopped counting.',
1476
+ }),
1477
+ until: Type.String({
1478
+ format: 'date-time',
1479
+ description: '30 minutes after the last prompt someone typed into it.',
1480
+ }),
1481
+ }), {
1482
+ 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.',
1483
+ }),
1468
1484
  coverage: Type.Record(Str, Type.Union([Type.Literal('covered'), Type.Literal('needs-trust'), Type.Literal('not-covered')]), {
1469
1485
  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
1486
  }),
@@ -1492,6 +1508,25 @@ export const OUTPUT_SCHEMAS = {
1492
1508
  done: Type.Optional(Type.Array(Str, { description: '`pending done`: the ids marked done.' })),
1493
1509
  }, { title: 'sideby unattended pending [done <id>|--all] --json' }),
1494
1510
  'unattended-defer': Type.Object({ schemaVersion: Version, decision: PendingDecision }, { title: 'sideby unattended defer "<text>" --json' }),
1511
+ progress: Type.Object({
1512
+ schemaVersion: Version,
1513
+ action: Type.Union([Type.Literal('status'), Type.Literal('on'), Type.Literal('off')]),
1514
+ on: Type.Boolean({
1515
+ 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).',
1516
+ }),
1517
+ every: Type.Optional(Type.Integer({
1518
+ description: 'Minutes between reminders, config `progress.every`; absent while off.',
1519
+ })),
1520
+ defaultEvery: Type.Optional(Type.Integer({ description: 'What `on` picks without --every (status only).' })),
1521
+ choices: Type.Optional(Type.Array(Type.Integer(), { description: 'The intervals the Panel offers (status only).' })),
1522
+ families: Type.Optional(Type.Array(Str, {
1523
+ description: 'Families whose sessions get reminders (status only); Codex has no hook that can wake a session.',
1524
+ })),
1525
+ changed: Type.Optional(Type.Boolean({ description: 'on and off: whether the config changed.' })),
1526
+ before: Type.Optional(Type.Integer({ description: 'on and off: the interval before, when it was on.' })),
1527
+ undo: Type.Optional(Type.String({ description: 'on and off: the command that puts back what was there.' })),
1528
+ message: Type.Optional(Type.String({ description: 'on and off: one line for the user.' })),
1529
+ }, { title: 'sideby progress [on|off] --json' }),
1495
1530
  browser: Type.Object({
1496
1531
  schemaVersion: Version,
1497
1532
  enabled: Type.Boolean({
@@ -379,6 +379,25 @@ Examples:
379
379
  sideby unattended defer "deleting the old branch is left for the user"
380
380
  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
381
  which to use).`,
382
+ progress: `sideby progress [status] [--json]
383
+ sideby progress on [--every <minutes>] [--json]
384
+ sideby progress off [--json]
385
+
386
+ Progress reminders: while a Claude session sideby started waits on background work (subagents, long commands),
387
+ sideby wakes it every few minutes so it tells you in one or two sentences what it waits for, how long, and whether
388
+ there is new output. Off by default: each reminder is one model turn, which reads the whole conversation, so it uses
389
+ quota. No reminders while the session is unattended, or while a turn is running.
390
+
391
+ \`on\` turns them on (every 10 minutes, or --every <minutes>, 1 to 240); \`off\` turns them off. Turning them on reaches
392
+ Claude sessions sideby starts from now on; turning them off or changing the interval also reaches running ones. Only
393
+ sideby's config is written, so there is no preview; each change prints its undo. Codex is not covered: it has no
394
+ way for sideby to wake a waiting session. Grok, pi and sessions started without sideby are not covered either.
395
+
396
+ Examples:
397
+ sideby progress on
398
+ sideby progress on --every 15
399
+ sideby progress off
400
+ Exit: 0 shown or done (also when nothing changed); 2 an interval or option it does not take.`,
382
401
  browser: `sideby browser [--enable|--disable] [--yes] [--json]
383
402
  sideby browser open <account> [--profile <folder|name>] [--json]
384
403
  sideby browser set <account> <folder|name> [--json]
@@ -478,6 +497,7 @@ const COMMANDS = {
478
497
  flags: ['json', 'all', 'slot-end'],
479
498
  valued: ['for', 'until', 'days', 'from', 'to', 'name', 'at'],
480
499
  },
500
+ progress: { flags: ['json'], valued: ['every'] },
481
501
  new: { flags: ['api', 'json', 'next'], valued: ['alias', 'vendor'] },
482
502
  alias: { flags: ['json', 'yes'], valued: ['pick'] },
483
503
  doctor: { flags: ['fix', 'force', 'json'] },
@@ -632,6 +652,13 @@ export async function main(argv) {
632
652
  const { runUnattendedHook } = await import('../unattended/hook.js');
633
653
  return runUnattendedHook(rest, process.env, process.stdin, { out: process.stdout, err: process.stderr });
634
654
  }
655
+ // Progress Reminders' hook runs after every turn and on every prompt in the background (spec §3.42); same fast path.
656
+ if (first === 'progress-hook') {
657
+ const { runProgressHook } = await import('../progress/hook.js');
658
+ return runProgressHook(rest, process.env, process.stdin.isTTY ? '' : process.stdin, {
659
+ err: process.stderr,
660
+ });
661
+ }
635
662
  if (nodeTooOld()) {
636
663
  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
664
  return 1;
@@ -804,6 +831,8 @@ async function dispatch(cmd, parsed, io, cmds) {
804
831
  return await cmds.cmdNetwork(parsed, io);
805
832
  case 'unattended':
806
833
  return await cmds.cmdUnattended(parsed, io);
834
+ case 'progress':
835
+ return await cmds.cmdProgress(parsed, io);
807
836
  case 'shell-init':
808
837
  return await cmds.cmdShellInit(parsed, io);
809
838
  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',
@@ -854,9 +866,9 @@ export function cliHelp(list = CLI_COMMANDS) {
854
866
  const HELP_TAIL = `Options:
855
867
  --json machine-readable output (list, new, next, alias, doctor, quota, tune, model, advisor, remote-control, handoff,
856
868
  families, commands, plugins, app, desktop, sessions, history, send, messages, edit, browser, update, local, ask,
857
- terminal, key, try, autostart, menubar, config, network, unattended)
869
+ terminal, key, try, autostart, menubar, config, network, unattended, progress)
858
870
  -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
871
+ autostart, menubar, config, sessions, history, send, messages, network, unattended, progress
860
872
  -v, --version show the version
861
873
 
862
874
  An <account> is <family>:<name> (claude:work) or just <name> when it is unique.
@@ -132,6 +132,9 @@ export declare const ConfigSchema: Type.TObject<{
132
132
  end: Type.TString;
133
133
  }>>>;
134
134
  }>>;
135
+ progress: Type.TOptional<Type.TObject<{
136
+ every: Type.TOptional<Type.TInteger>;
137
+ }>>;
135
138
  browser: Type.TOptional<Type.TObject<{
136
139
  signIns: Type.TOptional<Type.TBoolean>;
137
140
  choices: Type.TOptional<Type.TRecord<"^.*$", Type.TString>>;
@@ -258,6 +261,16 @@ export declare function editConfigQuotaCheck(file: string, family: string, on: b
258
261
  before: QuotaConfig | undefined;
259
262
  after: QuotaConfig | undefined;
260
263
  }>;
264
+ export type ProgressConfig = NonNullable<Config['progress']>;
265
+ /**
266
+ * `sideby progress on|off` and the Panel's switch (spec §3.42): a number writes `progress.every`, undefined removes
267
+ * `progress` (off is the default) (see `editConfigKey` for how the file is written).
268
+ */
269
+ export declare function editConfigProgress(file: string, every: number | undefined): Promise<{
270
+ changed: boolean;
271
+ before: ProgressConfig | undefined;
272
+ after: ProgressConfig | undefined;
273
+ }>;
261
274
  export type AccountsConfig = NonNullable<Config['accounts']>;
262
275
  /**
263
276
  * `sideby model` (spec §3.19): changes the config `accounts` key with `edit` (see `editConfigKey` for how the file is
@@ -259,6 +259,13 @@ export const ConfigSchema = Type.Object({
259
259
  additionalProperties: false,
260
260
  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
261
  })),
262
+ progress: Type.Optional(Type.Object({
263
+ every: Type.Optional(Type.Integer({
264
+ minimum: 1,
265
+ maximum: 240,
266
+ 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.',
267
+ })),
268
+ }, { additionalProperties: false, description: 'Progress Reminders (spec §3.42, ADR-0076).' })),
262
269
  browser: Type.Optional(Type.Object({
263
270
  signIns: Type.Optional(Type.Boolean({
264
271
  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 +547,17 @@ export function editConfigQuotaCheck(file, family, on) {
540
547
  return Object.keys(next).length ? next : undefined;
541
548
  });
542
549
  }
550
+ /**
551
+ * `sideby progress on|off` and the Panel's switch (spec §3.42): a number writes `progress.every`, undefined removes
552
+ * `progress` (off is the default) (see `editConfigKey` for how the file is written).
553
+ */
554
+ export function editConfigProgress(file, every) {
555
+ return editConfigKey(file, 'progress', 'change the setting', (current) => {
556
+ const { every: _old, ...rest } = current ?? {};
557
+ const next = { ...rest, ...(every === undefined ? {} : { every }) };
558
+ return Object.keys(next).length ? next : undefined;
559
+ });
560
+ }
543
561
  /**
544
562
  * `sideby model` (spec §3.19): changes the config `accounts` key with `edit` (see `editConfigKey` for how the file is
545
563
  * 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,80 @@
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 = 10;
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 `Stop` that started this watch came. */
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`. False when the lock stays held: then nothing is written and the caller must not
53
+ * act as the session's watch. Throws when the folder is not safe to use.
54
+ */
55
+ export declare function writeWatch(stateDir: string, sessionId: string, record: WatchRecord, opts?: LockWait): Promise<boolean>;
56
+ /**
57
+ * Marks the watch `id` woken at `at`, only while the session's record is still that watch: the check and the write
58
+ * hold the session's lock, so a later `Stop` replaces the record before or after, never in between. False when the
59
+ * record is another watch's, is missing, or the lock stays held (`beforeWrite` runs inside the lock, for tests).
60
+ */
61
+ export declare function markWatchWoken(stateDir: string, sessionId: string, id: string, at: Date, deps?: {
62
+ beforeWrite?: () => Promise<void>;
63
+ }): Promise<boolean>;
64
+ export declare function readPromptRecord(stateDir: string, sessionId: string): Promise<PromptRecord | undefined>;
65
+ /**
66
+ * Notes the session's latest prompt under the session's lock, unless the record already holds a later one: two
67
+ * background hooks may finish out of order, and an older prompt never replaces a newer one (`at` is when the hook
68
+ * started, so it follows the order the prompts came in). The same prompt noted again at the same time or later
69
+ * replaces it. Then removes records nobody changed for a day. False when the lock stays held or a later prompt is kept.
70
+ * `beforeRemove` runs with the file's name before each removal takes its lock (for tests).
71
+ */
72
+ export declare function writePromptRecord(stateDir: string, sessionId: string, record: PromptRecord, now: Date, opts?: LockWait & {
73
+ beforeRemove?: (name: string) => Promise<void>;
74
+ }): Promise<boolean>;
75
+ /**
76
+ * Whether the `Stop` that carries `promptId` ends the turn a Progress Reminder started: the session's latest prompt
77
+ * has that id and was a reminder. A record that is missing, late or for another prompt says no, so a caller that
78
+ * cannot tell treats the turn as an ordinary one.
79
+ */
80
+ export declare function progressReminderTurn(stateDir: string, sessionId: string | undefined, promptId: string | undefined): Promise<boolean>;