sideby 0.42.2 → 0.43.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 (58) hide show
  1. package/ai-tasks.json +10 -0
  2. package/dist/build.json +1 -1
  3. package/dist/src/cli/commands.js +54 -13
  4. package/dist/src/cli/json-schemas.js +58 -1
  5. package/dist/src/cli/main.js +11 -4
  6. package/dist/src/core/ask.d.ts +8 -14
  7. package/dist/src/core/ask.js +66 -30
  8. package/dist/src/core/egress.d.ts +5 -0
  9. package/dist/src/core/egress.js +32 -2
  10. package/dist/src/core/handoff-run.js +41 -8
  11. package/dist/src/core/handoff-select.d.ts +5 -0
  12. package/dist/src/core/handoff-select.js +1 -1
  13. package/dist/src/core/handoff.d.ts +69 -1
  14. package/dist/src/core/handoff.js +90 -9
  15. package/dist/src/core/history-index.d.ts +4 -0
  16. package/dist/src/core/history-index.js +1 -1
  17. package/dist/src/core/live-sessions.d.ts +5 -0
  18. package/dist/src/core/live-sessions.js +12 -1
  19. package/dist/src/core/network.d.ts +37 -0
  20. package/dist/src/core/network.js +65 -1
  21. package/dist/src/core/pick-commands.d.ts +7 -1
  22. package/dist/src/core/pick-commands.js +15 -3
  23. package/dist/src/core/pick-records.d.ts +26 -0
  24. package/dist/src/core/pick-records.js +81 -0
  25. package/dist/src/families/agy/history.d.ts +2 -0
  26. package/dist/src/families/agy/history.js +118 -0
  27. package/dist/src/families/agy/index.js +5 -0
  28. package/dist/src/families/agy/quota.d.ts +5 -1
  29. package/dist/src/families/agy/quota.js +111 -10
  30. package/dist/src/families/history.js +2 -1
  31. package/dist/src/network/hook.js +4 -4
  32. package/dist/src/network/page-script.d.ts +40 -0
  33. package/dist/src/network/page-script.js +270 -0
  34. package/dist/src/network/page.d.ts +11 -0
  35. package/dist/src/network/page.js +189 -0
  36. package/dist/src/network/panel.d.ts +5 -0
  37. package/dist/src/network/panel.js +7 -0
  38. package/dist/src/panel/handler.d.ts +21 -1
  39. package/dist/src/panel/handler.js +174 -37
  40. package/dist/src/panel/i18n.d.ts +26 -0
  41. package/dist/src/panel/i18n.js +54 -2
  42. package/dist/src/panel/page-logic.d.ts +26 -3
  43. package/dist/src/panel/page-logic.js +95 -12
  44. package/dist/src/panel/page-script.js +86 -17
  45. package/dist/src/panel/page-styles.js +1 -0
  46. package/dist/src/runtime.d.ts +44 -5
  47. package/dist/src/runtime.js +102 -12
  48. package/dist/src/types.d.ts +3 -2
  49. package/package.json +1 -1
  50. package/schemas/network-diagnose.json +196 -0
  51. package/schemas/next.json +42 -2
  52. package/skills/sideby/SKILL.md +2 -1
  53. package/skills/sideby/references/accounts.md +1 -1
  54. package/skills/sideby/references/ai-tasks.md +1 -1
  55. package/skills/sideby/references/handoff.md +4 -2
  56. package/skills/sideby/references/network.md +6 -1
  57. package/skills/sideby/references/quota.md +1 -1
  58. package/skills/sideby/references/sessions.md +1 -1
@@ -9,7 +9,7 @@ import { bindDesktopDeps, checkAppData } from './core/desktop-app.js';
9
9
  import { applyFixes, runDoctor } from './core/doctor.js';
10
10
  import { hostSettingsFile } from './core/edit-settings.js';
11
11
  import { UserError } from './core/errors.js';
12
- import { planHandoff } from './core/handoff.js';
12
+ import { activePicks, loginLoad, planHandoff, } from './core/handoff.js';
13
13
  import { handoffFindings, tapState } from './core/handoff-doctor.js';
14
14
  import { selectNext, } from './core/handoff-select.js';
15
15
  import { identityOf } from './core/identity.js';
@@ -19,7 +19,7 @@ import { accountEnv, beforeDashes, brokenOnPath, launchCommand, prepareLaunch, w
19
19
  import { confirmedSpends, isOutcome, LimitResetError, limitResetFile, loginUnchanged, newLimitResetRecord, outcomeMessage, planExpired, pruneLimitResetRecords, readLimitResetRecord, sameAccounts, scanLimitResetRecords, spent, takeLimitResetLock, unreadableRecordsMessage, unresolvedFor, writeLimitResetRecord, } from './core/limit-reset.js';
20
20
  import { loginMarkFile, readLoginMark, writeLoginMark } from './core/login-mark.js';
21
21
  import { memoStore } from './core/memo-store.js';
22
- import { codexNetworkTrustLine, guardLaunch, guardOn, ipChangedLine, networkHookPart, networkOverview, networkSettingsLine, } from './core/network.js';
22
+ import { codexNetworkTrustLine, guardLaunch, guardOn, ipChangedLine, networkDiagnose, networkHookPart, networkOverview, networkSettingsLine, } from './core/network.js';
23
23
  import { resolvePaths } from './core/paths.js';
24
24
  import { choosePick, suggestPickName } from './core/pick-commands.js';
25
25
  import { PROGRESS_FAMILIES, progressHookPart, progressSettingsLine, progressView, setProgress, } from './core/progress.js';
@@ -607,7 +607,9 @@ export async function createRuntime(opts = {}) {
607
607
  const f = families.get(a.family);
608
608
  if (!f?.readLoginEvents || a.kind === 'api')
609
609
  return undefined;
610
- if ((login ?? (await loginOf(a))) !== 'logged-in')
610
+ // `unknown` too: a Host whose sign-in sideby cannot see (agy, ADR-0082) still says when it needs a new one.
611
+ const state = login ?? (await loginOf(a));
612
+ if (state !== 'logged-in' && state !== 'unknown')
611
613
  return undefined;
612
614
  const ctx = readContext();
613
615
  await memos.ready();
@@ -718,6 +720,22 @@ export async function createRuntime(opts = {}) {
718
720
  ...(files.length ? { shellInitFiles: files } : {}),
719
721
  };
720
722
  };
723
+ // The Live Sessions of each Account, for spreading picks (ADR-0083). A listing that fails counts none: the pick
724
+ // still happens, ranked as before.
725
+ const liveSessionCounts = async () => {
726
+ if (opts.picks?.liveSessions)
727
+ return opts.picks.liveSessions();
728
+ try {
729
+ const { listLiveSessions } = await import('./core/live-sessions.js');
730
+ const n = new Map();
731
+ for (const s of (await listLiveSessions(rt, { deadlineMs: 3_000 })).sessions)
732
+ n.set(s.account, (n.get(s.account) ?? 0) + 1);
733
+ return n;
734
+ }
735
+ catch {
736
+ return new Map();
737
+ }
738
+ };
721
739
  const rt = {
722
740
  paths,
723
741
  config,
@@ -1038,7 +1056,7 @@ export async function createRuntime(opts = {}) {
1038
1056
  ? config.pickCommands[name]
1039
1057
  : undefined;
1040
1058
  },
1041
- async pickChoice(name) {
1059
+ async pickChoice(name, po = {}) {
1042
1060
  const family = rt.pickCommandFamily(name);
1043
1061
  if (family === undefined)
1044
1062
  throw new UserError(`no pick command "${name}"; add one with \`sideby alias add ${name} --pick <family>\``);
@@ -1048,9 +1066,31 @@ export async function createRuntime(opts = {}) {
1048
1066
  if (!subs.length)
1049
1067
  throw new UserError(`no ${f.title} subscription accounts yet; create one with \`sideby new ${f.id} --next\``, { code: 'no-accounts' });
1050
1068
  const main = subs.find((a) => a.isMain)?.ref ?? null;
1051
- if (!f.readQuota && !f.fetchQuota)
1052
- return { name, family, choice: { ref: main ?? subs[0].ref, reason: 'no-quota-data' } };
1053
- return { name, family, choice: choosePick(await rt.handoff(f.id), main) };
1069
+ if (!f.readQuota && !f.fetchQuota) {
1070
+ const ref = main ?? subs[0].ref;
1071
+ // Nothing to rank, but a start still counts for the next pick (ADR-0083).
1072
+ if (po.record) {
1073
+ const groups = await groupsOf(subs);
1074
+ await rt.pickLoad(true, () => ({
1075
+ result: ref,
1076
+ candidates: subs.map((a) => ({
1077
+ ref: a.ref,
1078
+ name: a.name,
1079
+ isMain: a.isMain,
1080
+ kind: a.kind,
1081
+ login: 'unknown',
1082
+ quota: { status: 'unavailable', reason: 'no-source' },
1083
+ ...(groups.get(a.ref) ? { sameLogin: groups.get(a.ref) } : {}),
1084
+ })),
1085
+ }), (r) => r, po.recorded);
1086
+ }
1087
+ return { name, family, choice: { ref, reason: 'no-quota-data' } };
1088
+ }
1089
+ const plan = await rt.handoff(f.id, {
1090
+ picks: po.record ? (p) => choosePick(p, main).ref : 'read',
1091
+ ...(po.recorded ? { recorded: po.recorded } : {}),
1092
+ });
1093
+ return { name, family, choice: choosePick(plan, main) };
1054
1094
  },
1055
1095
  async pickSuggestion(familyId, given) {
1056
1096
  const f = families.get(familyId);
@@ -1173,6 +1213,17 @@ export async function createRuntime(opts = {}) {
1173
1213
  now,
1174
1214
  });
1175
1215
  },
1216
+ async networkDiagnose() {
1217
+ return networkDiagnose({
1218
+ accounts: await accounts(),
1219
+ config,
1220
+ stateDir: paths.stateDir,
1221
+ env,
1222
+ envFor: async (a) => accountEnv(familyOf(a.family), a, env),
1223
+ ...(opts.network?.probe ? { probe: opts.network.probe } : {}),
1224
+ now,
1225
+ });
1226
+ },
1176
1227
  async launchCommand(ref, userArgs, command) {
1177
1228
  const inputs = launchInputs(ref, await accounts(), userArgs, command);
1178
1229
  return { account: inputs.account, family: inputs.family, ...launchCommand(inputs) };
@@ -1781,12 +1832,44 @@ export async function createRuntime(opts = {}) {
1781
1832
  // The Takeover Limits follow the user's Handoff Threshold, so `sideby next` and Auto Handoff agree on "full".
1782
1833
  // A start the user asks for may still go past them (a Last Resort, spec §3.13); Auto Handoff never does.
1783
1834
  const limits = takeoverLimits(handoffSettings(config).threshold);
1784
- return planHandoff(f.id, candidates, readContext().now, {
1785
- ...o,
1835
+ const { picks: mode, recorded, ...rest } = o;
1836
+ const plan = (list, picks) => planHandoff(f.id, list, readContext().now, {
1837
+ ...rest,
1786
1838
  limits,
1787
1839
  lastResort: true,
1788
1840
  ...(from ? { from } : {}),
1841
+ ...(picks ? { picks } : {}),
1789
1842
  });
1843
+ if (!mode)
1844
+ return plan(candidates);
1845
+ return rt.pickLoad(typeof mode === 'function', (live, picks) => {
1846
+ const counted = candidates.map((c) => ({ ...c, liveSessions: live.get(c.ref) ?? 0 }));
1847
+ return { result: plan(counted, picks), candidates: counted };
1848
+ }, (p) => (typeof mode === 'function' ? mode(p) : null), recorded);
1849
+ },
1850
+ async pickLoad(record, rank, started, recorded) {
1851
+ const { withPickRecords } = await import('./core/pick-records.js');
1852
+ let seen;
1853
+ return withPickRecords(paths.stateDir, now, record, async (picks) => {
1854
+ const live = await liveSessionCounts();
1855
+ const r = rank(live, picks);
1856
+ seen = { live, candidates: r.candidates };
1857
+ return r.result;
1858
+ }, (result, picks, at) => {
1859
+ const ref = started(result);
1860
+ if (!ref || !seen)
1861
+ return null;
1862
+ // Its login's load at the pick, Pick Records included; records that arrived or expired are dropped.
1863
+ return {
1864
+ ref,
1865
+ liveAtPick: loginLoad(seen.candidates, picks, at, seen.live).get(ref) ?? seen.live.get(ref) ?? 0,
1866
+ keep: activePicks(picks, seen.candidates, at, seen.live),
1867
+ };
1868
+ }, recorded);
1869
+ },
1870
+ async cancelPick(rec) {
1871
+ const { dropPickRecord } = await import('./core/pick-records.js');
1872
+ await dropPickRecord(paths.stateDir, rec).catch(() => { });
1790
1873
  },
1791
1874
  handoffSettings: () => handoffSettings(config),
1792
1875
  async handoffDecision(origin, used, opts = {}) {
@@ -1846,9 +1929,9 @@ export async function createRuntime(opts = {}) {
1846
1929
  catch {
1847
1930
  // cannot tell: do not wait
1848
1931
  }
1849
- return selectNext({
1850
- origin: self,
1851
- candidates,
1932
+ const decide = (list, picks) => selectNext({
1933
+ origin: list.find((c) => c.ref === origin.ref),
1934
+ candidates: list,
1852
1935
  settings: handoffSettings(config),
1853
1936
  aliases: aliasRefs(config.aliases),
1854
1937
  used,
@@ -1856,7 +1939,14 @@ export async function createRuntime(opts = {}) {
1856
1939
  ...(opts.ahead ? { ahead: true } : {}),
1857
1940
  ...(opts.to !== undefined ? { to: opts.to } : {}),
1858
1941
  ...(opts.manual ? { manual: true } : {}),
1942
+ ...(picks ? { picks } : {}),
1859
1943
  });
1944
+ if (!opts.picks)
1945
+ return decide(candidates);
1946
+ return rt.pickLoad(opts.picks === 'record', (live, picks) => {
1947
+ const counted = candidates.map((c) => ({ ...c, liveSessions: live.get(c.ref) ?? 0 }));
1948
+ return { result: decide(counted, picks), candidates: counted };
1949
+ }, (d) => (d.kind === 'pick' ? d.ref : null), opts.recorded);
1860
1950
  },
1861
1951
  readContext,
1862
1952
  };
@@ -271,8 +271,9 @@ export interface FamilyDef {
271
271
  /**
272
272
  * When the Host last said this Account's login expired, and when it last showed it working, from the Host's own
273
273
  * records only (ADR-0071): never a token, the Keychain or an expiry field of a credential file. Called only for a
274
- * signed-in Subscription Account; an error counts as nothing known. Without it the Family's logins never show as
275
- * expired.
274
+ * Subscription Account whose login state is `logged-in` or `unknown`; an error counts as nothing known. Without it
275
+ * the Family's logins never show as expired; a Family with no such records returns `{}`, and then only its
276
+ * `fetchQuota` answers (`loginExpired`) tell.
276
277
  */
277
278
  readLoginEvents?(account: Account, ctx: ReadContext): Promise<LoginEvents>;
278
279
  model?(account: Account): Promise<string | undefined>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sideby",
3
- "version": "0.42.2",
3
+ "version": "0.43.0",
4
4
  "description": "Run work, personal and API-key accounts at the same time, without their configs drifting apart.",
5
5
  "license": "MIT",
6
6
  "author": "Adonis0123 (https://github.com/Adonis0123)",
@@ -0,0 +1,196 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "sideby/network-diagnose.json",
4
+ "type": "object",
5
+ "required": [
6
+ "schemaVersion",
7
+ "checkedAt",
8
+ "targets"
9
+ ],
10
+ "properties": {
11
+ "schemaVersion": {
12
+ "type": "number",
13
+ "const": 1
14
+ },
15
+ "checkedAt": {
16
+ "type": "string",
17
+ "description": "When this offline diagnosis ran (ISO), not the Guard cache time."
18
+ },
19
+ "targets": {
20
+ "type": "array",
21
+ "items": {
22
+ "type": "object",
23
+ "required": [
24
+ "url",
25
+ "proxy",
26
+ "guardSupport",
27
+ "listener",
28
+ "guard"
29
+ ],
30
+ "properties": {
31
+ "url": {
32
+ "type": "string",
33
+ "description": "The Guard trace address whose cached result is shown; it is not requested."
34
+ },
35
+ "proxy": {
36
+ "type": "string",
37
+ "description": "Selected proxy reduced to scheme, hostname and port, or direct/invalid."
38
+ },
39
+ "guardSupport": {
40
+ "anyOf": [
41
+ {
42
+ "type": "string",
43
+ "const": "direct"
44
+ },
45
+ {
46
+ "type": "string",
47
+ "const": "http-connect"
48
+ },
49
+ {
50
+ "type": "string",
51
+ "const": "unsupported"
52
+ },
53
+ {
54
+ "type": "string",
55
+ "const": "invalid"
56
+ }
57
+ ],
58
+ "description": "Guard supports direct and HTTP CONNECT; SOCKS/HTTPS proxies are unsupported."
59
+ },
60
+ "listener": {
61
+ "anyOf": [
62
+ {
63
+ "type": "null"
64
+ },
65
+ {
66
+ "type": "object",
67
+ "required": [
68
+ "host",
69
+ "port",
70
+ "reachable"
71
+ ],
72
+ "properties": {
73
+ "host": {
74
+ "type": "string"
75
+ },
76
+ "port": {
77
+ "type": "integer"
78
+ },
79
+ "reachable": {
80
+ "type": "boolean",
81
+ "description": "TCP connect only; not proof that the proxy protocol works."
82
+ },
83
+ "error": {
84
+ "type": "string"
85
+ }
86
+ }
87
+ }
88
+ ],
89
+ "description": "Local loopback TCP listener only; null for direct, remote or invalid proxies, and non-HTTP proxies without an explicit port."
90
+ },
91
+ "guard": {
92
+ "type": "object",
93
+ "required": [
94
+ "status"
95
+ ],
96
+ "properties": {
97
+ "status": {
98
+ "anyOf": [
99
+ {
100
+ "type": "string",
101
+ "const": "ok"
102
+ },
103
+ {
104
+ "type": "string",
105
+ "const": "blocked"
106
+ },
107
+ {
108
+ "type": "string",
109
+ "const": "unknown"
110
+ },
111
+ {
112
+ "type": "string",
113
+ "const": "not-checked"
114
+ }
115
+ ]
116
+ },
117
+ "loc": {
118
+ "type": "string"
119
+ },
120
+ "checkedAt": {
121
+ "type": "string",
122
+ "description": "When the cached Guard check ran (ISO)."
123
+ },
124
+ "error": {
125
+ "type": "string"
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+ },
132
+ "_notice": {
133
+ "type": "object",
134
+ "properties": {
135
+ "update": {
136
+ "type": "object",
137
+ "required": [
138
+ "current",
139
+ "latest",
140
+ "command",
141
+ "message"
142
+ ],
143
+ "properties": {
144
+ "current": {
145
+ "type": "string"
146
+ },
147
+ "latest": {
148
+ "type": "string"
149
+ },
150
+ "command": {
151
+ "type": "string",
152
+ "description": "Run it after the user agrees: it shows the plan and exits 10; then --yes."
153
+ },
154
+ "message": {
155
+ "type": "string"
156
+ }
157
+ }
158
+ },
159
+ "skill": {
160
+ "type": "object",
161
+ "required": [
162
+ "installed",
163
+ "current",
164
+ "command",
165
+ "message"
166
+ ],
167
+ "properties": {
168
+ "installed": {
169
+ "anyOf": [
170
+ {
171
+ "type": "string"
172
+ },
173
+ {
174
+ "type": "null"
175
+ }
176
+ ],
177
+ "description": "The skill's version; null when it has none."
178
+ },
179
+ "current": {
180
+ "type": "string"
181
+ },
182
+ "command": {
183
+ "type": "string",
184
+ "description": "`sideby update`, which updates the skill with sideby: run it after the user agrees; it shows the plan and exits 10, then --yes."
185
+ },
186
+ "message": {
187
+ "type": "string"
188
+ }
189
+ }
190
+ }
191
+ },
192
+ "description": "Not the answer to the task: mention it briefly afterwards and offer to update."
193
+ }
194
+ },
195
+ "title": "sideby network diagnose --json"
196
+ }
package/schemas/next.json CHANGED
@@ -41,7 +41,8 @@
41
41
  "kind",
42
42
  "state",
43
43
  "pressure",
44
- "limitUse"
44
+ "limitUse",
45
+ "liveSessions"
45
46
  ],
46
47
  "properties": {
47
48
  "ref": {
@@ -104,7 +105,33 @@
104
105
  "type": "null"
105
106
  }
106
107
  ],
107
- "description": "Limit Use: the percent of its own Takeover Limit that the closest window has used (a weekly 87% under 95 is 91.6); null without quota. Ready accounts rank by it, lowest first."
108
+ "description": "Limit Use: the percent of its own Takeover Limit that the closest window has used (a weekly 87% under 95 is 91.6); null without quota. Ready accounts rank by the room it leaves per running session, (100 - limitUse) / (liveSessions + 1), highest first; a Last Resort by it, lowest first."
109
+ },
110
+ "liveSessions": {
111
+ "type": "number",
112
+ "description": "The Live Sessions of the account's Same Login group, plus Pick Records: starts sideby made in the last 2 minutes that have not shown up as a Live Session yet (ADR-0083)."
113
+ },
114
+ "expiring": {
115
+ "type": "object",
116
+ "required": [
117
+ "label",
118
+ "usedPercent",
119
+ "resetsAt"
120
+ ],
121
+ "properties": {
122
+ "label": {
123
+ "type": "string",
124
+ "description": "Such as `7d`."
125
+ },
126
+ "usedPercent": {
127
+ "type": "number",
128
+ "description": "Rounded."
129
+ },
130
+ "resetsAt": {
131
+ "type": "string"
132
+ }
133
+ },
134
+ "description": "For ready: its counted weekly (or longer) window that resets within 24 hours; such an account ranks before every other ready one, since that room is lost at the reset (ADR-0083)."
108
135
  },
109
136
  "window": {
110
137
  "type": "object",
@@ -205,6 +232,19 @@
205
232
  },
206
233
  "description": "Set when nothing can be picked and some accounts are full (every one has a window used up): the first to come back."
207
234
  },
235
+ "reason": {
236
+ "anyOf": [
237
+ {
238
+ "type": "string",
239
+ "const": "expiring"
240
+ },
241
+ {
242
+ "type": "string",
243
+ "const": "room"
244
+ }
245
+ ],
246
+ "description": "Why a ready pick goes first (ADR-0083): expiring, its weekly room resets within 24 hours; room, it has the most room per running session."
247
+ },
208
248
  "_notice": {
209
249
  "type": "object",
210
250
  "properties": {
@@ -2,7 +2,7 @@
2
2
  name: sideby
3
3
  description: Use when the user runs, or wants to run, several AI coding accounts (Claude Code, Codex, Grok Build, pi) side by side. Covers installing sideby and setting up a new account ("install sideby", "set up another Claude account", "add cc008", "配置一个 cc00x", "再加一个 Codex 账号"), explaining what accounts share and what stays separate ("what do my accounts share?", "这些账号共享了什么"), showing which account a session is ("show [cc001] in the status line", "加上账号标识"), finding a past session of any account ("找一下我上周改登录页的那个会话"), telling another running session something, in any account ("告诉 cc002 ……", "给跑构建的那个会话发消息"; Claude Code's own SendMessage reaches only sessions of the same account), seeing accounts, quota and usage, moving on when one hits its 5-hour or weekly limit, moving the current task to another account ("用 cc008 继续", "交回 cc008"), adding a short command (alias) or a pick command that starts whichever account has the most quota ("加个 cc"), adding an API account from a vendor's docs ("加一个 DeepSeek API 账号"), supporting a new tool, and repairing drifted account directories (skills, hooks, rules or settings not shared, wrong symlinks, credential file permissions). Drives the `sideby` CLI with `--json`; the agent does every step except browser sign-in, filling in secrets and starting interactive sessions, which it hands to the user as one command (inside an Auto Handoff session, `sideby handoff ready --to` moves the task itself).
4
4
  metadata:
5
- version: "0.42.2"
5
+ version: "0.43.0"
6
6
  requires:
7
7
  bins: [sideby, node]
8
8
  cliHelp: sideby --help
@@ -85,6 +85,7 @@ Account refs are `<family>:<name>`; a bare `<name>` works only when it is unique
85
85
  | A Claude API account's gateway rejects requests after an Advisor change, or why sideby adds `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` to API accounts ("API 账号网关报错了", "为什么 API 账号多了这个变量") | `sideby advisor --json` (`apiBetasOff`, each group's `apiAccounts`), `sideby config get claude.apiBetasOff --json`; `sideby advisor undo` or `sideby config set claude.apiBetasOff false` after they agree | `references/panel.md` |
86
86
  | Claude asks "Is this a project you created or one you trust?" (Quick safety check, Accessing workspace) in one account although another of the user's Claude accounts already trusts the folder, or a handoff ended at that question ("别的账号已经信任过了还问", "每个账号都要点一次信任", "stop asking me to trust this folder in every account", "接力时卡在信任文件夹") | `sideby trust --json` (setting, and while on, `--dir <folder>` shows each account's trust as booleans), then `sideby trust on --json` (exits 10 with the change; rerun with `--yes` after they agree); `sideby trust undo` (exits 10 first) takes the copies back; `sideby trust off` keeps them | `references/trust.md` |
87
87
  | Stop Claude and Codex when the network is wrong ("网络不对时别让 Claude 用", "代理断了就拦住", "only allow US and Japan", "开网络检查"), see where requests leave from now, or a session says it was blocked | `sideby network --json`, `sideby network check --json`, `sideby network allow <CC>... --json` and `sideby network on --json` (each exits 10 first; rerun with `--yes` after they agree) | `references/network.md` |
88
+ | Diagnose Clash, v2rayN, direct, HTTP or SOCKS proxy connectivity without changing anything ("退出 Clash 就不能用", "v2ray 也看看", "诊断网络") | `sideby network diagnose --json` (offline, read-only; redacted route, TCP listener and cached Guard state), or the fixed read-only `network-diagnose` AI Task | `references/network.md` |
88
89
  | Leave sessions running with nobody there ("挂机", "无人值守", "今晚自己跑完", "设个时间段别问我", "keep going while I sleep"), set a nightly Schedule, or see what was left for the user | `sideby unattended on [--until 08:00] --json` (run it yourself when they say they are leaving), `sideby unattended schedule preset weeknights --json`, `sideby unattended --json`, `sideby unattended pending --json`; inside a session refused a question: `sideby unattended defer "<one sentence>"` | `references/unattended.md` |
89
90
  | What sessions left for the user, by project, and which of it they already dealt with ("哪些待我决定的处理过了", "真正没处理的是哪些", "按项目看待我决定的", "标错了恢复", "which pending decisions did I already answer") | `sideby unattended pending --json` (`state`: `open` nobody touched it since, `replied` the user wrote in that session afterwards, which does not tell whether it was finished; `projects` has each project's counts), `--project <name>` for one project; list each one to the user first, then `sideby unattended pending done <id>` or `done --ids <a>,<b> --json` for the ones they agree to; `sideby unattended pending reopen <id> --json` puts back a wrong mark | `references/unattended.md` |
90
91
  | How long a question waits before the session goes on without an answer ("问题没人回就自动按推荐继续", "问题等我 30 分钟", "别自动继续,一直等我", "how long does a question wait for me") | `sideby unattended wait --json` shows `answerWait`; `sideby unattended wait <1-120> --json` or `sideby unattended wait off --json` sets it. It acts only while Unattended Mode is on, and never answers "yes" | `references/unattended.md` |
@@ -65,7 +65,7 @@ To start one account with fixed Host arguments, such as another model, put them
65
65
 
66
66
  ## Pick commands (start the account with the most room)
67
67
 
68
- A pick command is a short command bound to a tool (Family), not to one account: each run starts the account of that tool `sideby next` would pick, the one furthest from its limits, and prints which (`cc → claude:work (5h 12% used, the most room)`). When no account of the tool has quota data yet it starts the main account and says so. When every account is past its Takeover Limit (by default 85% of a 5-hour window, 95% of a weekly one) it still starts the one with the most left under 100% and says so (`cc → claude:008 (every claude account is past its limit, 85% of a 5-hour window or 95% of a weekly one; this one has the most left, 5h 88% used)`); only when every account has a window used up or is signed out does it start nothing and say which comes back first. API accounts are never picked. Given a session to resume by id (`cc --resume <id>`), it skips the quota and starts the account that holds the session (`sideby: session <id> is in claude:work; starting it there`), or a new session where a never-saved one started.
68
+ A pick command is a short command bound to a tool (Family), not to one account: each run starts the account of that tool `sideby next` would pick, the one with the most room per running session (a weekly quota that resets within 24 hours goes first), and prints which (`cc → claude:work (5h 12% used, the most room)`, or `… 2 running, the most room per session` when sessions already run on it). When no account of the tool has quota data yet it starts the main account and says so. When every account is past its Takeover Limit (by default 85% of a 5-hour window, 95% of a weekly one) it still starts the one with the most left under 100% and says so (`cc → claude:008 (every claude account is past its limit, 85% of a 5-hour window or 95% of a weekly one; this one has the most left, 5h 88% used)`); only when every account has a window used up or is signed out does it start nothing and say which comes back first. API accounts are never picked. Given a session to resume by id (`cc --resume <id>`), it skips the quota and starts the account that holds the session (`sideby: session <id> is in claude:work; starting it there`), or a new session where a never-saved one started.
69
69
 
70
70
  - Add: `sideby alias add <short> --pick <family> --json` exits 10 with `status: "confirm"` and writes nothing; tell the user what it adds, then run it again with `--yes`. Then make sure new terminals load it: `sideby shell-init setup --json` (see `setup.md` step 7). Offer `cc` for Claude, `cx` for Codex, `gk` for Grok, or the letters the user's numbered short commands share (`cc001`, `cc008` → `cc`); pi gets none, since `pi` is the tool itself. `sideby new` offers one (`pickCommandOffer`) when a tool gets its second subscription account.
71
71
  - With `shadows` in that answer, the name hides a command on PATH (for example `/usr/bin/cc`, the C compiler on macOS). Tell the user that typing the name would start the tool instead, and run again with `--yes` only after they agree to that, or pick another name.
@@ -1,6 +1,6 @@
1
1
  # AI Tasks
2
2
 
3
- An AI Task is a session of the user's own Host that sideby started for them, with a Task Prompt as its first message. The user starts it from the Panel ("Let AI do it", a Finding, a quota cell, the new-account dialog, "Other tool…", "Let AI write a plugin", "Not sure how? Let AI set it up" in the Preferred terminal dialog, "Let AI tune it" on the Auto Handoff page) or with `sideby ask` in a terminal (`--task free|fix|quota|account|host|plugin|terminal|handoff|theme|menubar|hotkey|network|update`; "Let AI help" in the Panel's Network check dialog and on its wrong-network banner starts `network`, see `references/network.md`; "Let AI pick my colors" in the Panel's Theme dialog starts `theme`, see `references/themes.md`; "Let AI check it" in the Panel's Menu bar icon dialog starts `menubar`, and "Not sure which? Let AI pick one" under its shortcut starts `hotkey`; "Not sure why? Let AI fix it" under an error in the Panel's update dialog starts `update`, see `references/update.md`). The prompt says what to do and gives facts sideby already knows (account refs, Family, Finding codes, the quota reason, the Panel language, the sideby version). How to do it is on this page.
3
+ An AI Task is a session of the user's own Host that sideby started for them, with a Task Prompt as its first message. The user starts it from the Panel ("Let AI do it", a Finding, a quota cell, the new-account dialog, "Other tool…", "Let AI write a plugin", "Not sure how? Let AI set it up" in the Preferred terminal dialog, "Let AI tune it" on the Auto Handoff page) or with `sideby ask` in a terminal (`--task free|fix|quota|account|host|plugin|terminal|handoff|theme|menubar|hotkey|network|network-diagnose|update`; "Let AI help" in the Panel's Network check dialog and on its wrong-network banner starts `network`, see `references/network.md`; "Let AI pick my colors" in the Panel's Theme dialog starts `theme`, see `references/themes.md`; "Let AI check it" in the Panel's Menu bar icon dialog starts `menubar`, and "Not sure which? Let AI pick one" under its shortcut starts `hotkey`; "Not sure why? Let AI fix it" under an error in the Panel's update dialog starts `update`, see `references/update.md`). The prompt says what to do and gives facts sideby already knows (account refs, Family, Finding codes, the quota reason, the Panel language, the sideby version). How to do it is on this page.
4
4
 
5
5
  You are inside such a session when the first message came from sideby and names a task. Work in the directory the session started in (sideby's own `ai/` folder) unless the user names another one.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Handoff: keep working on another account
2
2
 
3
- Use this when the user says an account hit its 5-hour or weekly limit ("usage limit reached", "rate limited", "resets at …") and wants to keep working, or asks which account has room. sideby recommends the account of the same family that is furthest from its limits (lowest `limitUse`), and the user starts it. Only Auto Handoff, which the user turns on in the config, moves a running task by itself (see below).
3
+ Use this when the user says an account hit its 5-hour or weekly limit ("usage limit reached", "rate limited", "resets at …") and wants to keep working, or asks which account has room. sideby recommends the account of the same family with the most room per running session, and the user starts it. Only Auto Handoff, which the user turns on in the config, moves a running task by itself (see below).
4
4
 
5
5
  ## Steps
6
6
 
@@ -9,12 +9,14 @@ Use this when the user says an account hit its 5-hour or weekly limit ("usage li
9
9
 
10
10
  | `state` | Meaning | Can be picked |
11
11
  |---|---|---|
12
- | `ready` | Subscription account with every live window under its own limit. `pressure` is its fullest live window in percent; `limitUse` is the percent of its own limit that its closest window has used, and `window` names that window (`label`, `usedPercent`, `limit`) | Yes, lowest `limitUse` first |
12
+ | `ready` | Subscription account with every live window under its own limit. `pressure` is its fullest live window in percent; `limitUse` is the percent of its own limit that its closest window has used, and `window` names that window (`label`, `usedPercent`, `limit`) | Yes: an `expiring` one first, then the most room per running session, `(100 − limitUse) / (liveSessions + 1)` |
13
13
  | `unknown` | No quota data yet (not asked yet, quota checks are off, or the ask failed) | Yes, after `ready` |
14
14
  | `api` | API account, pay per use | Only with `--include-api` |
15
15
  | `full` | A live window is at or past its own Takeover Limit: a 5-hour window at the Auto Handoff threshold − 10 (85% by default), a weekly or longer window at the threshold (95% by default); `resetsAt` is when it is usable again | Only as a last resort, see below |
16
16
  | `logged-out` | Needs `sideby login <ref>` | No |
17
17
 
18
+ `liveSessions` counts the sessions running on the account's login (any app started them) plus picks sideby made in the last two minutes that have not shown up yet, so tasks started together spread over the accounts. `expiring` on a `ready` entry is a weekly (or longer) window that resets within 24 hours while every window is still at least 10 points under its limit: that room is lost at the reset, so the account goes first. `reason` on the plan says why the pick won: `expiring` ("claude:006's weekly quota resets tomorrow with 23% left, so it goes first") or `room` ("claude:002 has the most room per running session").
19
+
18
20
  When no subscription account is `ready` or `unknown`, the pick is the `full` one with no window used up (`pressure` under 100%) and the lowest `limitUse`, ahead of API accounts, and the plan has `tight: { limit, longLimit }` (the 5-hour and the weekly limit). Tell the user every account is past its limit and the pick has the most left (for example "every claude account is past its limit; claude:008 has the most left, its 5-hour window at 88%"), so they know it may run out soon. Auto Handoff never does this.
19
21
 
20
22
  The two limits differ because one full 5-hour window costs only about a fifth of a week: a week at 87% is still `ready` and yellow, not red. When the user asks why such an account was picked, say that.
@@ -7,10 +7,13 @@ Network Guard (spec §3.35, ADR-0053) checks the country a Host's requests leave
7
7
  ```sh
8
8
  sideby network --json # the setting and the newest result per address, from the cache (no request)
9
9
  sideby network check --json # ask every address now
10
+ sideby network diagnose --json # offline route/listener/cache diagnosis (no trace)
10
11
  ```
11
12
 
12
13
  Each `targets[]` row is one address sideby asks (`api.anthropic.com` for Claude, `chatgpt.com` for Codex) with `status` (`ok`, `blocked`, `unknown`, `not-checked`), `loc` (the country) and the `accounts` checked there. `accounts[].skip` says why an account is not checked: `api` (API accounts are never checked) or `third-party` (an endpoint set to a third party).
13
14
 
15
+ `network diagnose` is read-only and sends no `/cdn-cgi/trace`. It reports the current process's selected proxy reduced to scheme, hostname and port (`direct` when none), a loopback TCP listener result, and the cached Guard state with its own `checkedAt`. It never resolves or connects to a remote proxy, and does not invent a port for a non-HTTP proxy that omitted one. Credentials, paths, queries and fragments are never returned or cached; the command also skips generic update and Unattended-ended notification side effects. This covers direct, HTTP and SOCKS settings from Clash, v2rayN or another proxy app without identifying or controlling the app. A reachable TCP listener does not prove HTTP CONNECT, SOCKS or upstream connectivity. `guardSupport: "unsupported"` means the current Guard cannot use that scheme: it supports HTTP CONNECT only. Tell the user to configure an HTTP proxy (v2rayN commonly exposes one separately from SOCKS) or direct connection; do not add a proxy protocol stack or switch the exit. Run `network check` only when the user wants a fresh online country result.
16
+
14
17
  ## Turn it on
15
18
 
16
19
  Ask the user which countries their requests may leave from. Never choose for them, and never add the current country because it is current: on a wrong network that would allow the wrong country. Then:
@@ -32,6 +35,8 @@ Tell the user, once:
32
35
 
33
36
  The Panel's **Let AI help** (in the Network check dialog and on the wrong-network banner) starts the `network` AI Task (`sideby ask --task network`). Its prompt carries the switch, the allowed countries and the newest result per address (countries only, never an address). Follow it: run `sideby network check --json`, ask which countries, preview, then `--yes` after they agree.
34
37
 
38
+ **Diagnose connection** in the same dialog is manual and offline. **Let AI diagnose** starts the separate fixed `network-diagnose` task with only current errors, the redacted route, listener results and Guard check times; `sideby ask --task network-diagnose` gathers the same facts itself. That task excludes generic account, health, quota, version and attachment context, removes URL userinfo before preview or task-file writing, and is read-only: explain the facts and next step, never install a skill, change network settings, configuration, code or files, switch the exit, or automatically run an online check. Do not mix it with the `network` settings task.
39
+
35
40
  ## When something was blocked
36
41
 
37
- A blocked Launch exits 1 with `code` `network-blocked` (wrong country) or `network-unknown` (could not tell). Inside a session the prompt or tool call is stopped with the same reason. In a Claude session, a message Claude Code made itself (a background task's result) that was stopped is kept and handed to the session once the network is right again, between `<sideby-held-message>` tags; a typed message is not, the user sends it again. Help the user check their proxy (is it running, which node), then run `sideby network check --json` to confirm. To go on once anyway, the user runs `sideby run <account> --ignore-network` (or `sideby next <family> --ignore-network`); never add it yourself without their say-so. When the user wants the check gone, show `sideby network off --json` (exit 10, a preview), then run it with `--yes` once they agree; sessions already running follow config at once, so no restart is needed.
42
+ A blocked Launch exits 1 with `code` `network-blocked` (wrong country) or `network-unknown` (could not tell). The block names the selected redacted proxy or `direct`; connection-refused wording is kept. Inside a session the prompt or tool call is stopped with the same reason, and the message says an older session may need restarting to inherit a changed proxy environment. In a Claude session, a message Claude Code made itself (a background task's result) that was stopped is kept and handed to the session once the network is right again, between `<sideby-held-message>` tags; a typed message is not, the user sends it again. Help the user check their proxy (is it running, which node), then run `sideby network check --json` to confirm. To go on once anyway, the user runs `sideby run <account> --ignore-network` (or `sideby next <family> --ignore-network`); never add it yourself without their say-so. When the user wants the check gone, show `sideby network off --json` (exit 10, a preview), then run it with `--yes` once they agree; sessions already running follow config at once, so no restart is needed.
@@ -48,7 +48,7 @@ Two accounts of one tool signed in as the same login (Claude: same email and org
48
48
 
49
49
  Grok quota needs no setup: sideby asks the `grok` CLI of each signed-in account (`grok agent --no-leader stdio`, the Host makes the request with its own login; sideby never reads `auth.json`) at most every 15 minutes, and also reads the quota Grok logs after each turn. `sideby quota grok --refresh` asks again now. `quota.status: "unavailable"` with `reason: "fetch-failed"` carries the cause and next step in `detail` (update Grok, `sideby login grok:<name>`); `"not-enabled"` means the user turned it off (config `quota.check.grok: false`, or the Panel's Settings) or it runs in CI. A reading with `fetchError` is the last good one; say it may be old.
50
50
 
51
- Antigravity CLI (`agy`, main account only) quota also needs no setup: sideby runs `agy -p /usage --output-format json` (agy answers with its own Google sign-in and starts no model turn) at most every 15 minutes; `sideby quota agy --refresh` asks again now, and config `quota.check.agy: false` turns it off. Each window carries a model group `name` (5-hour and 7-day windows per group, some groups weekly only); tell the user which group each number belongs to. Named windows never count toward picking an account. A `detail` saying agy is not signed in means the user runs `sideby login agy:main` (it starts `agy`; they sign in with Google in the browser).
51
+ Antigravity CLI (`agy`, main account only) quota also needs no setup: sideby runs `agy -p /usage --output-format json` (agy answers with its own Google sign-in and starts no model turn) at most every 15 minutes; `sideby quota agy --refresh` asks again now, and config `quota.check.agy: false` turns it off. Each window carries a model group `name` (5-hour and 7-day windows per group, some groups weekly only); tell the user which group each number belongs to. Named windows never count toward picking an account. A `detail` saying agy is not signed in means the user runs `sideby login agy:main` (it starts `agy`; they sign in with Google in the browser). The check never opens a browser itself: when agy asks for a new sign-in, sideby stops it; `sideby quota agy --refresh --json` then shows a `detail` saying agy needs a new sign-in (or, when an older reading is kept, that reading with `fetchError`), and `sideby list --json` shows the account's `loginProblem.kind` as `"expired"`. The fix is the same.
52
52
 
53
53
  A window with a `name` (a plugin's Cursor "Other models") covers only some models: show it, but it does not make the account full.
54
54
 
@@ -62,7 +62,7 @@ For a session that is not running any more, in any account of any host, run `sid
62
62
 
63
63
  Each entry of `sessions` has `title` (the Session Title: the user's own name, else the host's, else the first prompt), `projectName`, `branch`, `updatedAt`, `accountLabel`, `snippet` (where the words matched), `children` (subagent sessions folded into it), `live` (running now) and `cwdGone` (its folder was removed). Name a session to the user by its title, account and when it was last active; when several fit, show the top few and ask.
64
64
 
65
- - To read it: `sideby history show <id> --json` (the id or its first 8 characters or more; add `--account <acct>` when the error says two accounts have that id) gives the newest 200 `messages`, oldest first; tool calls are one line each with the tool's name only. `before` in the result, passed as `--before <n>`, gives the ones before.
65
+ - To read it: `sideby history show <id> --json` (the id or its first 8 characters or more; add `--account <acct>` when the error says two accounts have that id) gives the newest 200 `messages`, oldest first; tool calls are one line each with the tool's name only. `before` in the result, passed as `--before <n>`, gives the ones before. Antigravity CLI (`agy`) sessions are listed by title and project only: sideby does not read what was said in them, so `messages` is empty and words match the title and project, not the conversation; the result still gives the command that continues it (`agy --conversation <id>`).
66
66
  - To continue it where it was, hand the user its `continueCommand` as one line: it runs `cd <its folder>` and resumes the session in the account that holds it (`resumeCommand` alone when the folder is gone). Do not start it yourself.
67
67
  - To give it to another AI, use its `reference`, the Session Reference (as in `sessions copy` above).
68
68