sideby 0.43.0 → 0.45.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 (52) hide show
  1. package/dist/build.json +1 -1
  2. package/dist/src/cli/commands.d.ts +4 -0
  3. package/dist/src/cli/commands.js +9 -8
  4. package/dist/src/cli/json-schemas.js +58 -0
  5. package/dist/src/core/cli-commands.js +0 -10
  6. package/dist/src/core/egress.d.ts +1 -7
  7. package/dist/src/core/egress.js +7 -36
  8. package/dist/src/core/file-memo.d.ts +2 -0
  9. package/dist/src/core/file-memo.js +20 -0
  10. package/dist/src/core/handoff.d.ts +9 -0
  11. package/dist/src/core/handoff.js +10 -0
  12. package/dist/src/core/history.d.ts +1 -1
  13. package/dist/src/core/history.js +2 -2
  14. package/dist/src/core/memo-store.js +32 -8
  15. package/dist/src/core/network.d.ts +5 -35
  16. package/dist/src/core/network.js +18 -54
  17. package/dist/src/core/themes.js +0 -7
  18. package/dist/src/core/update.d.ts +1 -1
  19. package/dist/src/core/update.js +4 -12
  20. package/dist/src/families/claude/quota-fetch.js +2 -2
  21. package/dist/src/families/claude/tuning.d.ts +0 -1
  22. package/dist/src/families/claude/tuning.js +1 -1
  23. package/dist/src/families/quota-watch.d.ts +12 -0
  24. package/dist/src/families/quota-watch.js +24 -0
  25. package/dist/src/network/hook.js +1 -1
  26. package/dist/src/network/page.d.ts +1 -1
  27. package/dist/src/network/page.js +15 -181
  28. package/dist/src/panel/changes.d.ts +57 -0
  29. package/dist/src/panel/changes.js +178 -0
  30. package/dist/src/panel/handler.d.ts +38 -0
  31. package/dist/src/panel/handler.js +263 -93
  32. package/dist/src/panel/i18n.d.ts +23 -0
  33. package/dist/src/panel/i18n.js +46 -0
  34. package/dist/src/panel/page-logic.d.ts +22 -29
  35. package/dist/src/panel/page-logic.js +22 -33
  36. package/dist/src/panel/page-script.js +114 -45
  37. package/dist/src/panel/page-styles.js +26 -26
  38. package/dist/src/panel/page.js +3 -1
  39. package/dist/src/quota/claude-statusline.js +1 -1
  40. package/dist/src/runtime.d.ts +13 -1
  41. package/dist/src/runtime.js +14 -8
  42. package/dist/src/types.d.ts +2 -2
  43. package/dist/src/unattended/hook.js +0 -1
  44. package/dist/testing/index.js +1 -1
  45. package/package.json +2 -1
  46. package/schemas/network-diagnose.json +239 -0
  47. package/schemas/next.json +25 -0
  48. package/skills/sideby/SKILL.md +2 -2
  49. package/skills/sideby/references/handoff.md +2 -0
  50. package/skills/sideby/references/network.md +5 -3
  51. package/dist/src/network/page-script.d.ts +0 -40
  52. package/dist/src/network/page-script.js +0 -270
@@ -8,6 +8,8 @@ const en = {
8
8
  'top.loading': 'Loading…',
9
9
  'top.refreshing': 'Refreshing…',
10
10
  'top.updated': 'Read {ago} · refreshes every {s} s',
11
+ 'top.updatedLive': 'Read {ago} · updates as quota changes',
12
+ 'top.updatedTitleLive': 'Quota, usage and health of each account, last read at {at}. The page reads them again as soon as a quota file changes, and every {s} s.',
11
13
  'top.updatedTitle': 'Quota, usage and health of every account, last read at {at}. They are read again every {s} s while this page is open.',
12
14
  'top.stale': 'Not refreshed: the panel cannot be reached or the last read failed.',
13
15
  'foot.text': 'runs on this machine; nothing leaves it.',
@@ -155,6 +157,27 @@ const en = {
155
157
  'stat.sessions.other': '{n} sessions',
156
158
  'stat.nextReset': 'Next quota reset',
157
159
  'stat.noQuota': 'No quota data',
160
+ 'stat.pickNow': 'Best to use now',
161
+ 'stat.pickNowIn': 'Best to use now · {title}',
162
+ 'stat.pickLeft': '{w} {n}% left',
163
+ 'stat.pickReset': '{w} reset',
164
+ 'stat.pickTight': 'all past their limit',
165
+ 'stat.pickNoData': 'no quota data for it yet',
166
+ 'stat.pickStart': 'Start',
167
+ 'stat.pickStartTip': 'Click to start it in a terminal.',
168
+ 'stat.pickCopy': 'Copy',
169
+ 'stat.pickCopyTip': 'Click to copy the command that starts it: sideby next {family}',
170
+ 'stat.pickOnly': 'Your only {title} account, and it has quota left.',
171
+ 'stat.pickOthers': 'Other tools:{list}',
172
+ 'stat.pickUsedUp': 'All used up',
173
+ 'stat.pickBack': '{ref} is back {when}',
174
+ 'stat.pickWait': 'wait for the next reset',
175
+ 'stat.pickNoQuota': 'No quota data yet',
176
+ 'stat.pickNoQuotaTip': 'A pick shows here once one of these accounts has quota data: start a session in one, or press Refresh.',
177
+ 'stat.pickSignIn': 'Sign in to an account first',
178
+ 'stat.pickNoSource': 'No subscription account here shows its quota',
179
+ 'stat.pickNoSourceOne': 'No subscription account of this tool shows its quota',
180
+ 'stat.pickReading': 'Reading quota…',
158
181
  'need.error.one': '{n} unreadable',
159
182
  'need.error.other': '{n} unreadable',
160
183
  'need.health-fail.one': '{n} with issues',
@@ -1881,6 +1904,8 @@ const zh = {
1881
1904
  'top.loading': '加载中…',
1882
1905
  'top.refreshing': '刷新中…',
1883
1906
  'top.updated': '{ago}读取 · 每 {s} 秒自动刷新',
1907
+ 'top.updatedLive': '{ago}读取 · 额度一变就更新',
1908
+ 'top.updatedTitleLive': '各账号的额度、用量和健康状态,上次读取于 {at}。额度文件一变就立即重新读取,另外每 {s} 秒读取一次。',
1884
1909
  'top.updatedTitle': '各账号的额度、用量和健康状态,上次读取于 {at}。页面打开时每 {s} 秒重新读取一次。',
1885
1910
  'top.stale': '没有刷新:连不上面板,或上次读取失败。',
1886
1911
  'foot.text': '只在本机运行,数据不会离开这台电脑。',
@@ -2028,6 +2053,27 @@ const zh = {
2028
2053
  'stat.sessions.other': '{n} 个会话',
2029
2054
  'stat.nextReset': '下一次额度重置',
2030
2055
  'stat.noQuota': '暂无额度数据',
2056
+ 'stat.pickNow': '现在最该用',
2057
+ 'stat.pickNowIn': '现在最该用 · {title}',
2058
+ 'stat.pickLeft': '{w}剩 {n}%',
2059
+ 'stat.pickReset': '{w}已重置',
2060
+ 'stat.pickTight': '都过了提醒线',
2061
+ 'stat.pickNoData': '还没有它的额度数据',
2062
+ 'stat.pickStart': '启动',
2063
+ 'stat.pickStartTip': '点一下在终端里启动它。',
2064
+ 'stat.pickCopy': '复制',
2065
+ 'stat.pickCopyTip': '点一下复制启动它的命令:sideby next {family}',
2066
+ 'stat.pickOnly': '这是你唯一的 {title} 账号,还有额度。',
2067
+ 'stat.pickOthers': '其他工具:{list}',
2068
+ 'stat.pickUsedUp': '都用完了',
2069
+ 'stat.pickBack': '{ref} {when}恢复',
2070
+ 'stat.pickWait': '等下一次重置',
2071
+ 'stat.pickNoQuota': '还没有额度数据',
2072
+ 'stat.pickNoQuotaTip': '这些账号有了额度数据,这里就会推荐一个:在其中一个账号开个会话,或点「刷新」。',
2073
+ 'stat.pickSignIn': '先登录一个账号',
2074
+ 'stat.pickNoSource': '没有能看到额度的订阅账号',
2075
+ 'stat.pickNoSourceOne': '这个工具没有能看到额度的订阅账号',
2076
+ 'stat.pickReading': '正在读取额度…',
2031
2077
  'need.error.one': '{n} 个读取失败',
2032
2078
  'need.error.other': '{n} 个读取失败',
2033
2079
  'need.health-fail.one': '{n} 个有问题',
@@ -1,4 +1,6 @@
1
+ import { networkDiagnoseTaskFacts } from 'network-portal';
1
2
  import type { HandoffSettings } from '../core/config.ts';
3
+ export { networkDiagnoseTaskFacts };
2
4
  /** The parts of a PanelAccount the helpers read. */
3
5
  export interface LogicAccount {
4
6
  family: string;
@@ -259,6 +261,17 @@ export declare function nextReset(accounts: LogicAccount[], now: number): {
259
261
  name: string;
260
262
  family: string;
261
263
  } | null;
264
+ /**
265
+ * Which tool the "Best to use now" card shows (spec §3.45): the one the family filter names, else the first in the
266
+ * page's group `order` with a pick, else the first with an entry, so the card says why nothing can be picked. Quota
267
+ * is never compared across tools. `others`: every other tool with an entry, in `order`, for the hover text.
268
+ */
269
+ export declare function pickNowChoice(pickNow: Record<string, {
270
+ pick: string | null;
271
+ }> | undefined, order: string[], filter: string): {
272
+ family: string;
273
+ others: string[];
274
+ } | null;
262
275
  /**
263
276
  * A name to offer for a new Account of a Family, given its existing Account names (`main` included or not).
264
277
  * Numbered names (`001` … `007`) continue after the highest number with the same width (`008`); otherwise
@@ -271,10 +284,6 @@ export declare function suggestName(names: string[]): string;
271
284
  * that are not fixable, and `--fix --force`, keep the command: Fix all would not do them.
272
285
  */
273
286
  export declare function panelHint(hint: string, fixable: boolean, action: string): string;
274
- /**
275
- * Whether the Panel fixes Finding `f` with a button of its own: a sideby skill behind this version while the
276
- * Update plan says sideby may update it (`skillUpdatable`). Such Findings stay out of the prompt for an AI agent.
277
- */
278
287
  /**
279
288
  * A Local Build the Panel can leave for npm itself (ADR-0024): the global `sideby` still runs it and the Panel may
280
289
  * write. Then switching to the release is the update, offered as a button instead of the `pnpm local --off` command.
@@ -354,6 +363,10 @@ export declare function findingSentence(f: {
354
363
  item?: string;
355
364
  params?: Record<string, string | number>;
356
365
  }, table: Record<string, string>, en: Record<string, string>, prefix?: string): string;
366
+ /**
367
+ * Whether the Panel fixes Finding `f` with a button of its own: a sideby skill behind this version while the
368
+ * Update plan says sideby may update it (`skillUpdatable`). Such Findings stay out of the prompt for an AI agent.
369
+ */
357
370
  export declare function panelFixes(f: {
358
371
  code?: string;
359
372
  }, skillUpdatable: boolean): boolean;
@@ -712,26 +725,6 @@ export declare function networkTaskFacts(n: {
712
725
  skip?: string;
713
726
  }[];
714
727
  }): string[];
715
- export declare function networkDiagnoseTaskFacts(d: {
716
- checkedAt: string;
717
- targets: readonly {
718
- url: string;
719
- proxy: string;
720
- guardSupport: string;
721
- listener: null | {
722
- host: string;
723
- port: number;
724
- reachable: boolean;
725
- error?: string;
726
- };
727
- guard: {
728
- status: string;
729
- loc?: string;
730
- checkedAt?: string;
731
- error?: string;
732
- };
733
- }[];
734
- }): string[];
735
728
  /** The kinds of AI Task (spec §3.28); anything else is refused. */
736
729
  export declare const AI_TASK_KINDS: readonly ['free', 'fix', 'quota', 'account', 'host', 'plugin', 'terminal', 'theme', 'handoff', 'menubar', 'hotkey', 'network', 'network-diagnose', 'update'];
737
730
  export type AiTaskKind = (typeof AI_TASK_KINDS)[number];
@@ -953,10 +946,6 @@ export declare function panelMigration(config: {
953
946
  theme?: string;
954
947
  language?: string;
955
948
  } | null;
956
- /**
957
- * The line under the start-at-login switch (spec §3.29) as a message key, whether it is on, whether the switch can
958
- * be moved, and the action beside it: `fix` turns it on again so it starts this sideby. Read-only: no switch, no action.
959
- */
960
949
  /**
961
950
  * A key press in the Panel's shortcut recorder as config `menubar.hotkey` writes it (`ctrl+opt+s`), or null while only
962
951
  * modifiers are held or the key is not a letter or digit. Reads `code`, not `key`: on a Mac ⌥S types "ß".
@@ -974,6 +963,10 @@ export declare function hotkeyFromKey(e: {
974
963
  * so at once instead of looking stuck. A letter or digit is neither (see `hotkeyFromKey`).
975
964
  */
976
965
  export declare function hotkeyPressKind(code: string): 'key' | 'wait' | 'unsupported';
966
+ /**
967
+ * The line under the start-at-login switch (spec §3.29) as a message key, whether it is on, whether the switch can
968
+ * be moved, and the action beside it: `fix` turns it on again so it starts this sideby. Read-only: no switch, no action.
969
+ */
977
970
  export declare function autostartNote(s: {
978
971
  supported: boolean;
979
972
  state: string;
@@ -1032,12 +1025,12 @@ export declare function widthFollower<T>(shown: T, tierOf: (width: number) => T,
1032
1025
  set: (fn: () => void, ms: number) => unknown;
1033
1026
  clear: (id: unknown) => void;
1034
1027
  }): (width: number) => void;
1035
- /** When a History row was last active: "x min ago" within a week, then its date (key `time.on`). */
1036
1028
  /**
1037
1029
  * Whether the end of a list is close enough to load its next page: within `margin` px of the bottom of what can be
1038
1030
  * seen, which is the viewport where the list's box grows with its rows (the page scrolls, not the box).
1039
1031
  */
1040
1032
  export declare function tailInView(tailTop: number, boxBottom: number, viewHeight: number, margin?: number): boolean;
1033
+ /** When a History row was last active: "x min ago" within a week, then its date (key `time.on`). */
1041
1034
  export declare function historyWhen(iso: string | undefined, now: number): {
1042
1035
  key: string;
1043
1036
  n?: number;
@@ -2,6 +2,8 @@
2
2
  // browser runs exactly the code these tests cover. Each function must be self-contained: no imports, no
3
3
  // references to module scope or to each other except through parameters, and only type annotations as
4
4
  // TypeScript (they are stripped by Node and by the build, leaving plain JavaScript).
5
+ import { networkDiagnoseTaskFacts } from 'network-portal';
6
+ export { networkDiagnoseTaskFacts };
5
7
  /** A short countdown such as `2h 05m`, `3d 4h` or `12m` (`2小时05分` in Chinese); fixed shape so it does not jump. */
6
8
  export function formatDuration(ms, lang) {
7
9
  const zh = lang === 'zh';
@@ -558,6 +560,17 @@ export function nextReset(accounts, now) {
558
560
  }
559
561
  return best;
560
562
  }
563
+ /**
564
+ * Which tool the "Best to use now" card shows (spec §3.45): the one the family filter names, else the first in the
565
+ * page's group `order` with a pick, else the first with an entry, so the card says why nothing can be picked. Quota
566
+ * is never compared across tools. `others`: every other tool with an entry, in `order`, for the hover text.
567
+ */
568
+ export function pickNowChoice(pickNow, order, filter) {
569
+ const has = (f) => Boolean(pickNow && Object.hasOwn(pickNow, f));
570
+ const picks = order.filter((f) => has(f) && pickNow[f].pick);
571
+ const family = filter ? (has(filter) ? filter : null) : (picks[0] ?? order.find(has) ?? null);
572
+ return family ? { family, others: order.filter((f) => f !== family && has(f)) } : null;
573
+ }
561
574
  /**
562
575
  * A name to offer for a new Account of a Family, given its existing Account names (`main` included or not).
563
576
  * Numbered names (`001` … `007`) continue after the highest number with the same width (`008`); otherwise
@@ -600,10 +613,6 @@ export function panelHint(hint, fixable, action) {
600
613
  return hint;
601
614
  return hint.replace(/run `sideby doctor --fix`/g, (_m, at) => at === 0 ? action.charAt(0).toUpperCase() + action.slice(1) : action);
602
615
  }
603
- /**
604
- * Whether the Panel fixes Finding `f` with a button of its own: a sideby skill behind this version while the
605
- * Update plan says sideby may update it (`skillUpdatable`). Such Findings stay out of the prompt for an AI agent.
606
- */
607
616
  /**
608
617
  * A Local Build the Panel can leave for npm itself (ADR-0024): the global `sideby` still runs it and the Panel may
609
618
  * write. Then switching to the release is the update, offered as a button instead of the `pnpm local --off` command.
@@ -722,6 +731,10 @@ export function findingSentence(f, table, en, prefix = 'finding.') {
722
731
  });
723
732
  return missing ? '' : out;
724
733
  }
734
+ /**
735
+ * Whether the Panel fixes Finding `f` with a button of its own: a sideby skill behind this version while the
736
+ * Update plan says sideby may update it (`skillUpdatable`). Such Findings stay out of the prompt for an AI agent.
737
+ */
725
738
  export function panelFixes(f, skillUpdatable) {
726
739
  return skillUpdatable && f.code === 'skill.outdated';
727
740
  }
@@ -1308,30 +1321,6 @@ export function networkTaskFacts(n) {
1308
1321
  out.push(`${a.ref}: not checked here (${a.skip})`);
1309
1322
  return out;
1310
1323
  }
1311
- export function networkDiagnoseTaskFacts(d) {
1312
- const out = [`diagnosed: ${d.checkedAt} (offline; no trace sent)`];
1313
- for (const t of d.targets) {
1314
- let host = t.url;
1315
- try {
1316
- host = new URL(t.url).hostname;
1317
- }
1318
- catch {
1319
- /* keep the URL */
1320
- }
1321
- const listener = t.listener
1322
- ? `TCP ${t.listener.host}:${t.listener.port} ${t.listener.reachable ? 'reachable' : 'not reachable'}${t.listener.error ? ` (${t.listener.error})` : ''}; this does not prove the proxy protocol works`
1323
- : t.guardSupport === 'direct'
1324
- ? 'direct; no proxy TCP listener to test'
1325
- : 'no local TCP listener probe (remote proxy, invalid address, or no explicit port)';
1326
- const support = t.guardSupport === 'unsupported'
1327
- ? '; Guard does not support this proxy scheme; configure HTTP CONNECT or direct before an online check'
1328
- : t.guardSupport === 'invalid'
1329
- ? '; proxy address invalid; correct it and start a new session'
1330
- : '';
1331
- out.push(`${host}: proxy ${t.proxy}; ${listener}${support}; Guard ${t.guard.status}${t.guard.loc ? `, country ${t.guard.loc}` : ''}${t.guard.checkedAt ? `, checked ${t.guard.checkedAt}` : ', not checked yet'}${t.guard.error ? `, ${t.guard.error}` : ''}`);
1332
- }
1333
- return out;
1334
- }
1335
1324
  /** The kinds of AI Task (spec §3.28); anything else is refused. */
1336
1325
  export const AI_TASK_KINDS = [
1337
1326
  'free',
@@ -1751,10 +1740,6 @@ export function panelMigration(config, local) {
1751
1740
  patch.language = local.lang;
1752
1741
  return patch.theme || patch.language ? patch : null;
1753
1742
  }
1754
- /**
1755
- * The line under the start-at-login switch (spec §3.29) as a message key, whether it is on, whether the switch can
1756
- * be moved, and the action beside it: `fix` turns it on again so it starts this sideby. Read-only: no switch, no action.
1757
- */
1758
1743
  /**
1759
1744
  * A key press in the Panel's shortcut recorder as config `menubar.hotkey` writes it (`ctrl+opt+s`), or null while only
1760
1745
  * modifiers are held or the key is not a letter or digit. Reads `code`, not `key`: on a Mac ⌥S types "ß".
@@ -1780,6 +1765,10 @@ export function hotkeyPressKind(code) {
1780
1765
  return 'wait';
1781
1766
  return 'unsupported';
1782
1767
  }
1768
+ /**
1769
+ * The line under the start-at-login switch (spec §3.29) as a message key, whether it is on, whether the switch can
1770
+ * be moved, and the action beside it: `fix` turns it on again so it starts this sideby. Read-only: no switch, no action.
1771
+ */
1783
1772
  export function autostartNote(s, readOnly) {
1784
1773
  if (!s)
1785
1774
  return { key: 'as.checking', on: false, toggle: false, action: null };
@@ -1887,7 +1876,6 @@ export function widthFollower(shown, tierOf, apply, settleMs, timers) {
1887
1876
  };
1888
1877
  }
1889
1878
  // ---------- Session History (spec §3.33) ----------
1890
- /** When a History row was last active: "x min ago" within a week, then its date (key `time.on`). */
1891
1879
  /**
1892
1880
  * Whether the end of a list is close enough to load its next page: within `margin` px of the bottom of what can be
1893
1881
  * seen, which is the viewport where the list's box grows with its rows (the page scrolls, not the box).
@@ -1895,6 +1883,7 @@ export function widthFollower(shown, tierOf, apply, settleMs, timers) {
1895
1883
  export function tailInView(tailTop, boxBottom, viewHeight, margin = 200) {
1896
1884
  return tailTop < Math.min(boxBottom, viewHeight) + margin;
1897
1885
  }
1886
+ /** When a History row was last active: "x min ago" within a week, then its date (key `time.on`). */
1898
1887
  export function historyWhen(iso, now) {
1899
1888
  const ts = Date.parse(iso || '');
1900
1889
  if (!Number.isFinite(ts))