sideby 0.28.3 → 0.30.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 (64) hide show
  1. package/dist/build.json +1 -1
  2. package/dist/src/cli/commands.d.ts +12 -0
  3. package/dist/src/cli/commands.js +337 -13
  4. package/dist/src/cli/json-schemas.js +87 -1
  5. package/dist/src/cli/main.js +65 -4
  6. package/dist/src/core/config.d.ts +25 -0
  7. package/dist/src/core/config.js +34 -0
  8. package/dist/src/core/fs-safe.d.ts +22 -1
  9. package/dist/src/core/fs-safe.js +68 -1
  10. package/dist/src/core/handoff-run.d.ts +2 -0
  11. package/dist/src/core/handoff-run.js +12 -6
  12. package/dist/src/core/launch.d.ts +6 -1
  13. package/dist/src/core/live-sessions.d.ts +2 -0
  14. package/dist/src/core/messages.d.ts +2 -0
  15. package/dist/src/core/messages.js +12 -34
  16. package/dist/src/core/network.d.ts +5 -2
  17. package/dist/src/core/network.js +15 -45
  18. package/dist/src/core/run-link.d.ts +6 -1
  19. package/dist/src/core/run-link.js +62 -22
  20. package/dist/src/core/search-catalog.d.ts +1 -1
  21. package/dist/src/core/search-catalog.js +37 -0
  22. package/dist/src/core/session-handoffs.d.ts +22 -0
  23. package/dist/src/core/session-handoffs.js +110 -0
  24. package/dist/src/core/session-hooks.d.ts +33 -0
  25. package/dist/src/core/session-hooks.js +92 -0
  26. package/dist/src/core/session-select.d.ts +18 -3
  27. package/dist/src/core/session-select.js +82 -8
  28. package/dist/src/core/unattended-ended.d.ts +62 -0
  29. package/dist/src/core/unattended-ended.js +275 -0
  30. package/dist/src/core/unattended-pending.d.ts +56 -0
  31. package/dist/src/core/unattended-pending.js +182 -0
  32. package/dist/src/core/unattended-state.d.ts +129 -0
  33. package/dist/src/core/unattended-state.js +373 -0
  34. package/dist/src/core/unattended.d.ts +142 -0
  35. package/dist/src/core/unattended.js +349 -0
  36. package/dist/src/panel/background.js +8 -0
  37. package/dist/src/panel/handler.d.ts +37 -0
  38. package/dist/src/panel/handler.js +156 -2
  39. package/dist/src/panel/i18n.d.ts +97 -0
  40. package/dist/src/panel/i18n.js +194 -0
  41. package/dist/src/panel/page-logic.d.ts +129 -0
  42. package/dist/src/panel/page-logic.js +166 -0
  43. package/dist/src/panel/page-script.js +638 -7
  44. package/dist/src/panel/page-styles.js +69 -0
  45. package/dist/src/panel/page.js +2 -0
  46. package/dist/src/plugins/bus.js +1 -0
  47. package/dist/src/runtime.d.ts +17 -1
  48. package/dist/src/runtime.js +78 -15
  49. package/dist/src/types.d.ts +48 -0
  50. package/dist/src/unattended/hook.d.ts +46 -0
  51. package/dist/src/unattended/hook.js +288 -0
  52. package/package.json +1 -1
  53. package/schemas/config.json +76 -0
  54. package/schemas/messages.json +4 -0
  55. package/schemas/send.json +4 -0
  56. package/schemas/sessions-copy.json +4 -0
  57. package/schemas/sessions-open-run.json +4 -0
  58. package/schemas/sessions.json +7 -0
  59. package/schemas/unattended-defer.json +143 -0
  60. package/schemas/unattended-pending.json +154 -0
  61. package/schemas/unattended.json +291 -0
  62. package/skills/sideby/SKILL.md +3 -2
  63. package/skills/sideby/references/sessions.md +1 -1
  64. package/skills/sideby/references/unattended.md +58 -0
@@ -17,7 +17,7 @@ import { handoffOverview } from '../core/handoff-overview.js';
17
17
  import { apiUndecided, handoffRulesView } from '../core/handoff-rules.js';
18
18
  import { configureHandoff, handoffStatus } from '../core/handoff-status.js';
19
19
  import { acceptInbound, groupsToAccept, inboundGroups, undoInbound, waitingFiles, } from '../core/inbound.js';
20
- import { listLiveSessions, liveKey, referenceText, sessionCopyText, } from '../core/live-sessions.js';
20
+ import { accountLabels, listLiveSessions, liveKey, referenceText, resumeCommandFor, sessionCopyText, } from '../core/live-sessions.js';
21
21
  import { listMessages, sendMessage } from '../core/messages.js';
22
22
  import { accountModel, setAccountModel } from '../core/model-choice.js';
23
23
  import { GUARDED_FAMILIES, setNetwork } from '../core/network.js';
@@ -25,10 +25,15 @@ import { tildify } from '../core/paths.js';
25
25
  import { remoteControlTodo } from '../core/remote-control.js';
26
26
  import { openRunBoard, withRuns } from '../core/run-link.js';
27
27
  import { SECRET_VAR_NAME, secretVarFor, setSecret } from '../core/secret-file.js';
28
+ import { readHandoffChains, withHandoffs } from '../core/session-handoffs.js';
28
29
  import { SKILL_INSTALL } from '../core/skill-check.js';
29
30
  import { launchArgs, TERMINALS } from '../core/terminal.js';
30
31
  import { checkThemeData, listThemes, NO_THEME, previewColors, removeThemeFile, resolveColors, saveThemeFile, undoTheme, useTheme, } from '../core/themes.js';
31
32
  import { MIN_CALLS } from '../core/tuning.js';
33
+ import { onUntil, setUnattendedSchedule, turnUnattendedOff, turnUnattendedOn, unattendedStatus, } from '../core/unattended.js';
34
+ import { checkUnattendedEnded } from '../core/unattended-ended.js';
35
+ import { listPendingDecisions, markPendingDone, reopenPendingDecision, } from '../core/unattended-pending.js';
36
+ import { readUnattendedConfig } from '../core/unattended-state.js';
32
37
  import * as update from '../core/update.js';
33
38
  import { buildId, localBuild, packageVersion } from '../core/version.js';
34
39
  import { HOOK_FAMILIES } from '../handoff/hook.js';
@@ -591,6 +596,15 @@ async function buildState(rt, opts) {
591
596
  const { setupBlock, shellSetupStatus, userShell } = await import('../core/shell-setup.js');
592
597
  const shellSt = await shellSetupStatus(userShell(rt.env), ctx.home, rt.env, rt.config.shellInitFile);
593
598
  const browser = await browserReport(rt, accounts).catch(() => undefined);
599
+ // The Panel's own status leaves out a `--unattended` session the server itself may run in: it shows the computer.
600
+ const unattended = await unattendedStatus({
601
+ paths: rt.paths,
602
+ families: [...rt.families.keys()],
603
+ now: ctx.now,
604
+ readOnly: opts.readOnly,
605
+ })
606
+ .then((st) => withPendingIds(st, rt.paths.stateDir))
607
+ .catch(() => undefined);
594
608
  const showBrowser = browser && (browser.families.matched.length || browser.families.openOnly.length);
595
609
  return {
596
610
  schemaVersion: 1,
@@ -632,6 +646,60 @@ async function buildState(rt, opts) {
632
646
  ...(rt.quotaChecks().length ? { quotaChecks: rt.quotaChecks() } : {}),
633
647
  ...(rt.config.panel && Object.keys(rt.config.panel).length ? { panel: rt.config.panel } : {}),
634
648
  ...(network ? { network } : {}),
649
+ ...(unattended ? { unattended } : {}),
650
+ };
651
+ }
652
+ const SHELL_SAFE = /^[A-Za-z0-9_@%+=:,./-]+$/;
653
+ const shellArg = (v) => (SHELL_SAFE.test(v) ? v : `'${v.replaceAll("'", "'\\''")}'`);
654
+ /** A Session id a hook reported is text from the Host: only a plain one goes into a command. */
655
+ const SAFE_SESSION_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
656
+ /** The `undo` command a change printed, as the request the page sends for it. */
657
+ function undoRequest(undo) {
658
+ if (undo === 'sideby unattended off')
659
+ return { route: '/api/unattended/off', body: {} };
660
+ if (undo === 'sideby unattended on')
661
+ return { route: '/api/unattended/on', body: {} };
662
+ const until = undo?.startsWith('sideby unattended on --until ') ? undo.slice(29) : undefined;
663
+ return until ? { route: '/api/unattended/on', body: { until } } : undefined;
664
+ }
665
+ /** A status with the ids of the open Pending Decisions, read once more (read only: nothing is deleted here). */
666
+ async function withPendingIds(status, stateDir) {
667
+ const ids = (await listPendingDecisions(stateDir, { prune: false })).map((d) => d.id);
668
+ return { ...status, pending: ids.length, pendingIds: ids };
669
+ }
670
+ async function panelChange(c, stateDir) {
671
+ const undo = undoRequest(c.undo);
672
+ return { changed: c.changed, status: await withPendingIds(c.status, stateDir), ...(undo ? { undo } : {}) };
673
+ }
674
+ async function unattendedView(rt, readOnly, live) {
675
+ const families = [...rt.families.keys()];
676
+ const [status, decisions, accounts] = await Promise.all([
677
+ unattendedStatus({ paths: rt.paths, families, readOnly }),
678
+ listPendingDecisions(rt.paths.stateDir, { prune: !readOnly }),
679
+ rt.accounts(),
680
+ ]);
681
+ const labels = accountLabels(rt, accounts);
682
+ const running = decisions.some((d) => d.sessionId)
683
+ ? (await live(rt).catch(() => ({ sessions: [], problems: [] }))).sessions
684
+ : [];
685
+ const home = rt.paths.home;
686
+ return {
687
+ status: { ...status, pending: decisions.length, pendingIds: decisions.map((d) => d.id) },
688
+ pending: decisions.map((d) => {
689
+ const label = d.account ? labels.get(d.account) : undefined;
690
+ const session = d.sessionId ? running.find((s) => s.sessionId === d.sessionId) : undefined;
691
+ const known = d.account && accounts.some((a) => a.ref === d.account);
692
+ const resume = d.sessionId && SAFE_SESSION_ID.test(d.sessionId) && known
693
+ ? resumeCommandFor(d.family, d.account, d.sessionId)
694
+ : undefined;
695
+ return {
696
+ ...d,
697
+ ...(d.cwd ? { cwd: tildify(d.cwd, home) } : {}),
698
+ ...(label ? { accountLabel: label } : {}),
699
+ ...(session ? { live: { label: session.label, accountLabel: session.accountLabel } } : {}),
700
+ ...(resume ? { resume: d.cwd ? `cd ${shellArg(d.cwd)} && ${resume}` : resume } : {}),
701
+ };
702
+ }),
635
703
  };
636
704
  }
637
705
  /** The `display` of a /api/display-order body: null, or string lists only; anything else is refused. */
@@ -910,6 +978,12 @@ export function createPanelHandler(opts) {
910
978
  const getRuntime = typeof opts.runtime === 'function' ? opts.runtime : async () => opts.runtime;
911
979
  const sessionsSource = opts[LIVE_SESSIONS_SOURCE];
912
980
  const liveSessions = sessionsSource?.list ?? listLiveSessions;
981
+ // A change from this page can end a stretch of Unattended Mode: the plugins hear of it now, as after the CLI. The
982
+ // answer waits for that (two small reads when nothing ended), but at most 1 s; a slower plugin finishes on its own.
983
+ const noticeUnattendedEnd = (rt) => Promise.race([
984
+ checkUnattendedEnded(rt.paths, async (ctx) => void (await rt.unattendedEnded(ctx))),
985
+ new Promise((resolve) => setTimeout(resolve, 1000).unref()),
986
+ ]);
913
987
  const copyText = sessionsSource?.copyText ?? sessionCopyText;
914
988
  const orcaOf = (rt) => sessionsSource?.orca ?? systemOrca(rt.env);
915
989
  const sendTo = sessionsSource?.send ?? sendMessage;
@@ -1330,7 +1404,8 @@ export function createPanelHandler(opts) {
1330
1404
  const home = rt.paths.home;
1331
1405
  // The Run each Session works for, only where the Session Index and its board file check out (ADR-0041).
1332
1406
  const [sessions, tabs] = await Promise.all([
1333
- withRuns(rt.env, home, listed.sessions),
1407
+ // A Session an Auto Handoff chain led to stays linked to its Run under the earlier ids (ADR-0057).
1408
+ readHandoffChains(rt.paths.stateDir).then((chains) => withRuns(rt.env, home, withHandoffs(chains, listed.sessions))),
1334
1409
  orcaTabs(orcaOf(rt), listed.sessions),
1335
1410
  ]);
1336
1411
  const problems = listed.problems;
@@ -1708,6 +1783,85 @@ export function createPanelHandler(opts) {
1708
1783
  return { ...r, path: tildify(r.path, home), ...(r.target ? { target: tildify(r.target, home) } : {}) };
1709
1784
  },
1710
1785
  },
1786
+ // Unattended Mode (spec §3.37): the page's status and Pending Decisions. A read-only Panel reads them too.
1787
+ '/api/unattended': {
1788
+ writes: () => false,
1789
+ queued: false,
1790
+ async run() {
1791
+ return unattendedView(await getRuntime(), readOnly, liveSessions);
1792
+ },
1793
+ },
1794
+ // Turns it on now: `slotEnd`, `for` (4h, 12h) or `until` (07:30, the next time it is 07:30; or a date and time).
1795
+ '/api/unattended/on': {
1796
+ async run(body) {
1797
+ const choice = {
1798
+ ...(body.slotEnd === true ? { slotEnd: true } : {}),
1799
+ ...(optString(body, 'for') ? { for: optString(body, 'for') } : {}),
1800
+ ...(optString(body, 'until') ? { until: optString(body, 'until') } : {}),
1801
+ };
1802
+ const rt = await getRuntime();
1803
+ const now = new Date();
1804
+ const { schedule } = await readUnattendedConfig(rt.paths.configFile);
1805
+ const r = onUntil(choice, schedule, now);
1806
+ if ('error' in r)
1807
+ throw new HttpError(400, r.error, 'bad-time');
1808
+ const change = await turnUnattendedOn({
1809
+ paths: rt.paths,
1810
+ families: [...rt.families.keys()],
1811
+ until: r.until,
1812
+ now,
1813
+ });
1814
+ await noticeUnattendedEnd(rt);
1815
+ return panelChange(change, rt.paths.stateDir);
1816
+ },
1817
+ },
1818
+ // Off now; inside a Slot, a pause until that Slot ends.
1819
+ '/api/unattended/off': {
1820
+ async run() {
1821
+ const rt = await getRuntime();
1822
+ const change = await turnUnattendedOff({ paths: rt.paths, families: [...rt.families.keys()] });
1823
+ await noticeUnattendedEnd(rt);
1824
+ return panelChange(change, rt.paths.stateDir);
1825
+ },
1826
+ },
1827
+ // The whole Schedule at once: every edit on the page writes it, and its Undo writes `previous` back.
1828
+ '/api/unattended/schedule': {
1829
+ async run(body) {
1830
+ if (!Array.isArray(body.schedule))
1831
+ throw new HttpError(400, '"schedule" must be a list of Slots');
1832
+ const rt = await getRuntime();
1833
+ const r = await setUnattendedSchedule({
1834
+ paths: rt.paths,
1835
+ families: [...rt.families.keys()],
1836
+ schedule: body.schedule,
1837
+ });
1838
+ await noticeUnattendedEnd(rt);
1839
+ return {
1840
+ changed: r.changed,
1841
+ status: await withPendingIds(r.status, rt.paths.stateDir),
1842
+ previous: r.previous,
1843
+ };
1844
+ },
1845
+ },
1846
+ // Marks one Pending Decision done (or every open one with `all`), or with `done: false` opens one again.
1847
+ '/api/unattended/pending': {
1848
+ async run(body) {
1849
+ const id = optString(body, 'id');
1850
+ const all = body.all === true;
1851
+ if (!id && !all)
1852
+ throw new HttpError(400, '"id" or "all" is required');
1853
+ const rt = await getRuntime();
1854
+ try {
1855
+ const changed = body.done === false && id
1856
+ ? [await reopenPendingDecision(rt.paths.stateDir, id)]
1857
+ : await markPendingDone(rt.paths.stateDir, all ? 'all' : id);
1858
+ return { ids: changed.map((d) => d.id) };
1859
+ }
1860
+ catch (err) {
1861
+ throw new HttpError(400, err.message, 'no-pending');
1862
+ }
1863
+ },
1864
+ },
1711
1865
  // Network Guard (spec §3.35): asks every address now. Only sideby's own cache changes, so a read-only Panel may.
1712
1866
  '/api/network/check': {
1713
1867
  writes: () => false,
@@ -1476,6 +1476,103 @@ declare const en: {
1476
1476
  'banner.plugins.one': string;
1477
1477
  'banner.plugins.other': string;
1478
1478
  'banner.pluginsHint': string;
1479
+ 'page.unattended': string;
1480
+ 'ua.title': string;
1481
+ 'ua.intro': string;
1482
+ 'ua.ask': string;
1483
+ 'ua.on': string;
1484
+ 'ua.off': string;
1485
+ 'ua.paused': string;
1486
+ 'ua.byHand': string;
1487
+ 'ua.slotQuoted': string;
1488
+ 'ua.slotN': string;
1489
+ 'ua.untilToday': string;
1490
+ 'ua.untilDay': string;
1491
+ 'ua.backToday': string;
1492
+ 'ua.backDay': string;
1493
+ 'ua.nextToday': string;
1494
+ 'ua.nextDay': string;
1495
+ 'ua.today': string;
1496
+ 'ua.tomorrow': string;
1497
+ 'ua.noEnd': string;
1498
+ 'ua.pausedOpen': string;
1499
+ 'ua.onNote': string;
1500
+ 'ua.offNote': string;
1501
+ 'ua.pausedNote': string;
1502
+ 'ua.turnOn': string;
1503
+ 'ua.turnOff': string;
1504
+ 'ua.pauseSlot': string;
1505
+ 'ua.pause': string;
1506
+ 'ua.for': string;
1507
+ 'ua.choice.slotNow': string;
1508
+ 'ua.choice.slotNext': string;
1509
+ 'ua.choice.4h': string;
1510
+ 'ua.choice.12h': string;
1511
+ 'ua.choice.time': string;
1512
+ 'ua.pickTime': string;
1513
+ 'ua.pickHint': string;
1514
+ 'ua.turnOnGo': string;
1515
+ 'ua.toastOn': string;
1516
+ 'ua.toastOnAlways': string;
1517
+ 'ua.toastOff': string;
1518
+ 'ua.toastPaused': string;
1519
+ 'ua.toastPausedOpen': string;
1520
+ 'ua.undone': string;
1521
+ 'ua.badge': string;
1522
+ 'ua.badgeOn': string;
1523
+ 'ua.badgeTitle': string;
1524
+ 'ua.firstUse': string;
1525
+ 'ua.schedule': string;
1526
+ 'ua.scheduleNote': string;
1527
+ 'ua.scheduleEmpty': string;
1528
+ 'ua.addSlot': string;
1529
+ 'ua.preset': string;
1530
+ 'ua.presetName': string;
1531
+ 'ua.presetAdded': string;
1532
+ 'ua.slotAdded': string;
1533
+ 'ua.slotRemoved': string;
1534
+ 'ua.saved': string;
1535
+ 'ua.days': string;
1536
+ 'ua.daysOf': string;
1537
+ 'ua.keepDay': string;
1538
+ 'ua.startOf': string;
1539
+ 'ua.endOf': string;
1540
+ 'ua.overnight': string;
1541
+ 'ua.allDay': string;
1542
+ 'ua.remove': string;
1543
+ 'ua.pending': string;
1544
+ 'ua.pendingNote': string;
1545
+ 'ua.pendingEmpty': string;
1546
+ 'ua.pendingBlocked': string;
1547
+ 'ua.loading': string;
1548
+ 'ua.kind.question': string;
1549
+ 'ua.kind.deferred': string;
1550
+ 'ua.kind.permission': string;
1551
+ 'ua.agent': string;
1552
+ 'ua.done': string;
1553
+ 'ua.allDone': string;
1554
+ 'ua.doneOne': string;
1555
+ 'ua.doneMany.one': string;
1556
+ 'ua.doneMany.other': string;
1557
+ 'ua.waiting.one': string;
1558
+ 'ua.waiting.other': string;
1559
+ 'ua.back': string;
1560
+ 'ua.backLive': string;
1561
+ 'ua.liveIn': string;
1562
+ 'ua.ended': string;
1563
+ 'ua.noSession': string;
1564
+ 'ua.resumeWhat': string;
1565
+ 'ua.more': string;
1566
+ 'ua.less': string;
1567
+ 'ua.cover': string;
1568
+ 'ua.coverLine': string;
1569
+ 'ua.codexTrust': string;
1570
+ 'ua.notSupported': string;
1571
+ 'ua.listSep': string;
1572
+ 'ua.readOnly': string;
1573
+ 'ua.problem': string;
1574
+ 'ua.unreadable': string;
1575
+ 'ai.ask.unattended': string;
1479
1576
  };
1480
1577
  export type MessageKey = keyof typeof en;
1481
1578
  export declare const MESSAGES: Record<PanelLang, Record<string, string>>;
@@ -1478,6 +1478,103 @@ const en = {
1478
1478
  'banner.plugins.one': '{n} plugin problem.',
1479
1479
  'banner.plugins.other': '{n} plugin problems.',
1480
1480
  'banner.pluginsHint': 'Run sideby plugins for details.',
1481
+ 'page.unattended': 'Unattended',
1482
+ 'ua.title': 'Unattended Mode',
1483
+ 'ua.intro': 'While you are away, sessions sideby starts keep going instead of stopping to wait for you. Turn it on before you step away, or let a Schedule do it every night.',
1484
+ 'ua.ask': 'Let AI help',
1485
+ 'ua.on': 'On',
1486
+ 'ua.off': 'Off',
1487
+ 'ua.paused': 'Paused',
1488
+ 'ua.byHand': 'turned on by you',
1489
+ 'ua.slotQuoted': 'Slot “{name}”',
1490
+ 'ua.slotN': 'Slot {n}',
1491
+ 'ua.untilToday': 'until {time}',
1492
+ 'ua.untilDay': 'until {day} {time}',
1493
+ 'ua.backToday': 'back on at {time}',
1494
+ 'ua.backDay': 'back on {day} {time}',
1495
+ 'ua.nextToday': 'next: {time}',
1496
+ 'ua.nextDay': 'next: {day} {time}',
1497
+ 'ua.today': 'today',
1498
+ 'ua.tomorrow': 'tomorrow',
1499
+ 'ua.noEnd': 'stays on: your Schedule covers every hour',
1500
+ 'ua.pausedOpen': 'until you turn it on again',
1501
+ 'ua.onNote': 'Sessions sideby starts do not stop to wait for you. Questions go on with the recommended choice; a step Claude Code wants you to confirm is refused, and the session finds another way or skips it. What they skipped is listed below.',
1502
+ 'ua.offNote': 'When it is on, sessions sideby starts do not stop to wait for you: no questions, and no prompts asking you to confirm a step.',
1503
+ 'ua.pausedNote': 'Until then, sessions ask you as usual. Turn it on now to go back.',
1504
+ 'ua.turnOn': 'Turn on now',
1505
+ 'ua.turnOff': 'Turn off now',
1506
+ 'ua.pauseSlot': 'Pause until this Slot ends',
1507
+ 'ua.pause': 'Pause',
1508
+ 'ua.for': 'How long?',
1509
+ 'ua.choice.slotNow': 'Until this Slot ends',
1510
+ 'ua.choice.slotNext': 'Until the next Slot ends',
1511
+ 'ua.choice.4h': '4 hours',
1512
+ 'ua.choice.12h': '12 hours',
1513
+ 'ua.choice.time': 'Until a time',
1514
+ 'ua.pickTime': 'Time to turn it off',
1515
+ 'ua.pickHint': 'Pick a time',
1516
+ 'ua.turnOnGo': 'Turn on',
1517
+ 'ua.toastOn': 'Unattended Mode is on, {until}.',
1518
+ 'ua.toastOnAlways': 'Unattended Mode is on.',
1519
+ 'ua.toastOff': 'Unattended Mode is off.',
1520
+ 'ua.toastPaused': 'Paused, {back}.',
1521
+ 'ua.toastPausedOpen': 'Paused until you turn it on again.',
1522
+ 'ua.undone': 'Undone.',
1523
+ 'ua.badge': 'Unattended · {until}',
1524
+ 'ua.badgeOn': 'Unattended',
1525
+ 'ua.badgeTitle': 'Sessions sideby starts do not stop to ask you. Open the Unattended page.',
1526
+ 'ua.firstUse': 'Sessions you start from now on are covered. Sessions already running started without it: start them again to cover them.',
1527
+ 'ua.schedule': 'Schedule',
1528
+ 'ua.scheduleNote': 'It turns on by itself at these times, in this computer’s time zone. Changes save at once.',
1529
+ 'ua.scheduleEmpty': 'No Slot yet. Add one, and Unattended Mode turns on by itself at that time.',
1530
+ 'ua.addSlot': 'Add a Slot',
1531
+ 'ua.preset': 'Weeknights 23:00–08:00',
1532
+ 'ua.presetName': 'Weeknights',
1533
+ 'ua.presetAdded': 'Added Weeknights 23:00–08:00.',
1534
+ 'ua.slotAdded': 'Slot added.',
1535
+ 'ua.slotRemoved': 'Slot removed.',
1536
+ 'ua.saved': 'Schedule saved.',
1537
+ 'ua.days': 'Mo,Tu,We,Th,Fr,Sa,Su',
1538
+ 'ua.daysOf': 'Days of {slot}',
1539
+ 'ua.keepDay': 'A Slot needs at least one day',
1540
+ 'ua.startOf': 'Start of {slot}',
1541
+ 'ua.endOf': 'End of {slot}',
1542
+ 'ua.overnight': 'next day',
1543
+ 'ua.allDay': 'all day',
1544
+ 'ua.remove': 'Remove {slot}',
1545
+ 'ua.pending': 'Waiting for you',
1546
+ 'ua.pendingNote': 'Questions sessions did not ask you, steps that needed your OK, and steps they skipped. Nothing here was done.',
1547
+ 'ua.pendingEmpty': 'Nothing is waiting for you.',
1548
+ 'ua.pendingBlocked': 'sideby cannot read them until the folder named above is fixed.',
1549
+ 'ua.loading': 'Reading…',
1550
+ 'ua.kind.question': 'Question',
1551
+ 'ua.kind.deferred': 'Not done',
1552
+ 'ua.kind.permission': 'Needed your OK',
1553
+ 'ua.agent': 'in subagent {type}',
1554
+ 'ua.done': 'Done',
1555
+ 'ua.allDone': 'Mark all done',
1556
+ 'ua.doneOne': 'Marked done.',
1557
+ 'ua.doneMany.one': 'Marked {n} done.',
1558
+ 'ua.doneMany.other': 'Marked {n} done.',
1559
+ 'ua.waiting.one': '{n} thing waits for you',
1560
+ 'ua.waiting.other': '{n} things wait for you',
1561
+ 'ua.back': 'Back to the session',
1562
+ 'ua.backLive': 'Show it on the Sessions page',
1563
+ 'ua.liveIn': 'Still running in {account}',
1564
+ 'ua.ended': 'Ended',
1565
+ 'ua.noSession': 'Not tied to a session',
1566
+ 'ua.resumeWhat': 'the command that resumes it; paste it into a terminal',
1567
+ 'ua.more': 'Show all',
1568
+ 'ua.less': 'Show less',
1569
+ 'ua.cover': 'Where it works',
1570
+ 'ua.coverLine': 'Only in Claude Code and Codex sessions that sideby starts. Running claude or codex yourself is not covered.',
1571
+ 'ua.codexTrust': 'Codex: only its questions. Open {cmd} in Codex once and trust sideby’s hook; Codex’s own approval prompts still wait for you.',
1572
+ 'ua.notSupported': '{hosts}: not supported yet.',
1573
+ 'ua.listSep': ', ',
1574
+ 'ua.readOnly': 'Read-only view. Use sideby unattended to change it.',
1575
+ 'ua.problem': 'sideby cannot keep its state: {msg}',
1576
+ 'ua.unreadable': 'sideby could not read Unattended Mode. Refresh to try again.',
1577
+ 'ai.ask.unattended': 'Run unattended tonight, until 8 tomorrow morning.',
1481
1578
  };
1482
1579
  const zh = {
1483
1580
  'top.tagline': '所有 AI 编程账号,并排运行。',
@@ -2956,5 +3053,102 @@ const zh = {
2956
3053
  'banner.plugins.one': '{n} 个插件问题。',
2957
3054
  'banner.plugins.other': '{n} 个插件问题。',
2958
3055
  'banner.pluginsHint': '运行 sideby plugins 查看详情。',
3056
+ 'page.unattended': '无人值守',
3057
+ 'ua.title': '无人值守',
3058
+ 'ua.intro': '你不在的时候,sideby 启动的会话继续跑,不停下来等你。离开前打开,或者设个时间表每晚自动开。',
3059
+ 'ua.ask': '让 AI 帮我',
3060
+ 'ua.on': '已开启',
3061
+ 'ua.off': '未开启',
3062
+ 'ua.paused': '已暂停',
3063
+ 'ua.byHand': '手动开启',
3064
+ 'ua.slotQuoted': '时段『{name}』',
3065
+ 'ua.slotN': '时段 {n}',
3066
+ 'ua.untilToday': '到 {time}',
3067
+ 'ua.untilDay': '到{day} {time}',
3068
+ 'ua.backToday': '到 {time} 后恢复',
3069
+ 'ua.backDay': '到{day} {time} 后恢复',
3070
+ 'ua.nextToday': '下一次 {time}',
3071
+ 'ua.nextDay': '下一次 {day} {time}',
3072
+ 'ua.today': '今天',
3073
+ 'ua.tomorrow': '明天',
3074
+ 'ua.noEnd': '一直开着:时间表覆盖了每个小时',
3075
+ 'ua.pausedOpen': '等你再打开',
3076
+ 'ua.onNote': 'sideby 启动的会话不会停下来等你:提问按推荐继续;Claude Code 要你确认的操作直接拒绝,会话换个做法或跳过。跳过的记在下面。',
3077
+ 'ua.offNote': '开着时,sideby 启动的会话不停下来等你:不提问,也不弹要你确认的框。',
3078
+ 'ua.pausedNote': '在那之前,会话照常问你。现在开就恢复。',
3079
+ 'ua.turnOn': '现在开',
3080
+ 'ua.turnOff': '现在关',
3081
+ 'ua.pauseSlot': '暂停到这一段结束',
3082
+ 'ua.pause': '暂停',
3083
+ 'ua.for': '开多久?',
3084
+ 'ua.choice.slotNow': '到这一段结束',
3085
+ 'ua.choice.slotNext': '到下一个时段结束',
3086
+ 'ua.choice.4h': '4 小时',
3087
+ 'ua.choice.12h': '12 小时',
3088
+ 'ua.choice.time': '到某个时间',
3089
+ 'ua.pickTime': '关闭的时间',
3090
+ 'ua.pickHint': '选一个时间',
3091
+ 'ua.turnOnGo': '开启',
3092
+ 'ua.toastOn': '无人值守已开启,{until}。',
3093
+ 'ua.toastOnAlways': '无人值守已开启。',
3094
+ 'ua.toastOff': '无人值守已关闭。',
3095
+ 'ua.toastPaused': '已暂停,{back}。',
3096
+ 'ua.toastPausedOpen': '已暂停,等你再打开。',
3097
+ 'ua.undone': '已撤销。',
3098
+ 'ua.badge': '无人值守 · {until}',
3099
+ 'ua.badgeOn': '无人值守',
3100
+ 'ua.badgeTitle': 'sideby 启动的会话不会停下来问你。打开无人值守页。',
3101
+ 'ua.firstUse': '之后启动的会话生效。现在已经在跑的会话没有这个功能,重新启动后才生效。',
3102
+ 'ua.schedule': '时间表',
3103
+ 'ua.scheduleNote': '到这些时间自动开,按这台电脑的时区。改了立即保存。',
3104
+ 'ua.scheduleEmpty': '还没有时段。加一个,到点自动开。',
3105
+ 'ua.addSlot': '添加时段',
3106
+ 'ua.preset': '工作日夜间 23:00–08:00',
3107
+ 'ua.presetName': '工作日夜间',
3108
+ 'ua.presetAdded': '已添加 工作日夜间 23:00–08:00。',
3109
+ 'ua.slotAdded': '已添加时段。',
3110
+ 'ua.slotRemoved': '已删除时段。',
3111
+ 'ua.saved': '时间表已保存。',
3112
+ 'ua.days': '一,二,三,四,五,六,日',
3113
+ 'ua.daysOf': '{slot}的日期',
3114
+ 'ua.keepDay': '时段至少要有一天',
3115
+ 'ua.startOf': '{slot}开始时间',
3116
+ 'ua.endOf': '{slot}结束时间',
3117
+ 'ua.overnight': '次日',
3118
+ 'ua.allDay': '全天',
3119
+ 'ua.remove': '删除{slot}',
3120
+ 'ua.pending': '待你决定',
3121
+ 'ua.pendingNote': '会话没问你的问题、要你确认的操作和跳过的操作。这里的事都还没做。',
3122
+ 'ua.pendingEmpty': '没有待你决定的事',
3123
+ 'ua.pendingBlocked': '上面说的文件夹修好之前,sideby 读不到它们。',
3124
+ 'ua.loading': '正在读取…',
3125
+ 'ua.kind.question': '提问',
3126
+ 'ua.kind.deferred': '没做的操作',
3127
+ 'ua.kind.permission': '要你确认的操作',
3128
+ 'ua.agent': '子 agent {type}',
3129
+ 'ua.done': '已处理',
3130
+ 'ua.allDone': '全部标为已处理',
3131
+ 'ua.doneOne': '已标为已处理。',
3132
+ 'ua.doneMany.one': '已把 {n} 条标为已处理。',
3133
+ 'ua.doneMany.other': '已把 {n} 条标为已处理。',
3134
+ 'ua.waiting.one': '{n} 件事待你决定',
3135
+ 'ua.waiting.other': '{n} 件事待你决定',
3136
+ 'ua.back': '回到会话',
3137
+ 'ua.backLive': '在会话页找到它',
3138
+ 'ua.liveIn': '还在 {account} 里运行',
3139
+ 'ua.ended': '已结束',
3140
+ 'ua.noSession': '没有关联会话',
3141
+ 'ua.resumeWhat': '恢复会话的命令,粘贴到终端运行',
3142
+ 'ua.more': '展开',
3143
+ 'ua.less': '收起',
3144
+ 'ua.cover': '受保护范围',
3145
+ 'ua.coverLine': '只对 sideby 启动的 Claude、Codex 会话生效;直接运行 claude 或 codex 的会话不受影响。',
3146
+ 'ua.codexTrust': 'Codex:只管提问。在 Codex 里打开一次 {cmd},信任 sideby 的 hook;Codex 自己的批准提示仍会等你。',
3147
+ 'ua.notSupported': '{hosts}:暂不支持。',
3148
+ 'ua.listSep': '、',
3149
+ 'ua.readOnly': '只读视图。修改请用 sideby unattended 命令。',
3150
+ 'ua.problem': 'sideby 没法保存状态:{msg}',
3151
+ 'ua.unreadable': 'sideby 读不到无人值守的状态。刷新再试一次。',
3152
+ 'ai.ask.unattended': '今晚无人值守,到明早 8 点',
2959
3153
  };
2960
3154
  export const MESSAGES = { en, zh };
@@ -945,3 +945,132 @@ export declare function enableOutcome<P extends {
945
945
  } | {
946
946
  kind: 'done';
947
947
  };
948
+ /**
949
+ * A moment as the Unattended page says it, relative to now in this computer's time zone: today (`08:00`), tomorrow,
950
+ * a weekday within the coming week (0 = Sunday, as `Date.getDay`), else a date. The page words it in its language.
951
+ */
952
+ export declare function uaWhen(atMs: number, nowMs: number): {
953
+ hhmm: string;
954
+ day: 'today' | 'tomorrow' | 'week' | 'date';
955
+ weekday: number;
956
+ month: number;
957
+ date: number;
958
+ };
959
+ /**
960
+ * The status card's sentence (like Android's Do Not Disturb): on (by a Slot or by hand), paused, or off; with the
961
+ * Slot, when it ends or comes back, and when a Slot turns it on next. `noEnd`: the Schedule covers every hour.
962
+ */
963
+ export declare function uaStatusParts(s: {
964
+ on: boolean;
965
+ reason: string;
966
+ until?: string;
967
+ slotNumber?: number;
968
+ next?: {
969
+ at: string;
970
+ slotNumber?: number;
971
+ };
972
+ }): {
973
+ state: 'on' | 'paused' | 'off';
974
+ byHand: boolean;
975
+ slot: number | null;
976
+ until: number | null;
977
+ noEnd: boolean;
978
+ next: {
979
+ at: number;
980
+ slot: number | null;
981
+ } | null;
982
+ };
983
+ /**
984
+ * What "Turn on now" offers (spec §3.37): until the current or next Slot ends (only when there is one within 72
985
+ * hours), 4 hours, 12 hours, or a time the user picks. The first is chosen; without a Slot, 12 hours.
986
+ */
987
+ export declare function uaOnChoices(slotEnd: string | undefined, nowMs: number): {
988
+ options: {
989
+ id: 'slot' | '4h' | '12h' | 'time';
990
+ until: number | null;
991
+ }[];
992
+ chosen: 'slot' | '12h';
993
+ };
994
+ /**
995
+ * When a picked clock time (`HH:MM`) is: today when that is still ahead, else tomorrow, built from the day so a clock
996
+ * change in between does not move the hour (the server reads `until` the same way). Null for anything else.
997
+ */
998
+ export declare function uaPickTime(hhmm: string, nowMs: number): {
999
+ until: number;
1000
+ tomorrow: boolean;
1001
+ } | null;
1002
+ /** What follows a Slot's end time: `next` (it ends the next day) or `whole` (start equals end: 24 hours). */
1003
+ export declare function uaSlotNight(slot: {
1004
+ start: string;
1005
+ end: string;
1006
+ }): 'next' | 'whole' | '';
1007
+ /**
1008
+ * A Slot's days as runs of days in a row, Monday first (0 = Monday): `[[0, 4]]` for Monday to Friday, `[[4, 0]]` for
1009
+ * Friday to Monday; `all` when every day is in it.
1010
+ */
1011
+ export declare function uaDayRuns(days: readonly string[]): {
1012
+ all: boolean;
1013
+ runs: [number, number][];
1014
+ };
1015
+ /** A day chip pressed: the days with it added or taken away, in week order; null when it would leave none. */
1016
+ export declare function uaToggleDay(days: readonly string[], day: string): string[] | null;
1017
+ /** Whether two Slots cover the same days and times (names aside). */
1018
+ export declare function uaSameSlot(a: {
1019
+ days: readonly string[];
1020
+ start: string;
1021
+ end: string;
1022
+ }, b: {
1023
+ days: readonly string[];
1024
+ start: string;
1025
+ end: string;
1026
+ }): boolean;
1027
+ /**
1028
+ * Pending Decisions grouped by the Session that left them, the group with the newest one first and each group oldest
1029
+ * first; those kept outside a Session (`sideby unattended defer` in a terminal) form one group without a session.
1030
+ */
1031
+ export declare function uaGroupPending<D extends {
1032
+ id: string;
1033
+ at: string;
1034
+ sessionId?: string;
1035
+ }>(list: readonly D[]): {
1036
+ key: string;
1037
+ first: D;
1038
+ items: D[];
1039
+ }[];
1040
+ /**
1041
+ * A time typed into the Unattended page's 24-hour fields as `HH:MM`, or null when it is not one. Takes `7:30`,
1042
+ * `07:30`, `730`, `0730`, `7` (07:00), and the full-width colon a Chinese input method types; the field's `pattern`
1043
+ * accepts the same.
1044
+ */
1045
+ export declare function uaParseClock(text: string): string | null;
1046
+ /** An arrow key in a time field: the hour or the minute one up or down, wrapping like the browser's own time field. */
1047
+ export declare function uaStepClock(text: string, part: 'h' | 'm', delta: number): string | null;
1048
+ /**
1049
+ * Whether the Unattended page reads its Pending Decisions now: at once the first time; otherwise not before `nextAt`
1050
+ * (a failed read puts it a full refresh round away, so a count that changed meanwhile cannot make it try again at
1051
+ * once), then when the last read is `everyMs` old, failed, or the status counts a different number than the list.
1052
+ */
1053
+ export declare function uaShouldRead(o: {
1054
+ now: number;
1055
+ at: number;
1056
+ nextAt: number;
1057
+ everyMs: number;
1058
+ loading: boolean;
1059
+ hasData: boolean;
1060
+ failed: boolean;
1061
+ statusCount?: number;
1062
+ listCount?: number;
1063
+ }): boolean;
1064
+ /**
1065
+ * How many Pending Decisions wait, as the Unattended tab counts them: the ones the latest status lists, less those
1066
+ * being marked done right now (`inflight`, each with the status it was made on). A status that lists its ids
1067
+ * subtracts only the ids it still has, so a status read after the server took a mark does not count it twice; one
1068
+ * without ids subtracts only the marks made on that same status.
1069
+ */
1070
+ export declare function uaWaitingCount(status: {
1071
+ pending: number;
1072
+ pendingIds?: readonly string[];
1073
+ } | null | undefined, inflight: readonly {
1074
+ id: string;
1075
+ on: unknown;
1076
+ }[]): number;