sideby 0.21.0 → 0.22.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.
- package/README.md +1 -0
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.js +115 -10
- package/dist/src/cli/format.js +3 -2
- package/dist/src/cli/json-schemas.js +81 -46
- package/dist/src/cli/main.js +6 -3
- package/dist/src/core/accounts.d.ts +6 -1
- package/dist/src/core/accounts.js +16 -3
- package/dist/src/core/ask.d.ts +2 -1
- package/dist/src/core/ask.js +6 -3
- package/dist/src/core/claude-settings-file.d.ts +57 -0
- package/dist/src/core/claude-settings-file.js +104 -2
- package/dist/src/core/config.d.ts +29 -15
- package/dist/src/core/config.js +40 -2
- package/dist/src/core/create.js +4 -1
- package/dist/src/core/desktop-app.js +5 -1
- package/dist/src/core/handoff-overview.d.ts +4 -1
- package/dist/src/core/handoff-overview.js +3 -2
- package/dist/src/core/handoff-rules.d.ts +34 -0
- package/dist/src/core/handoff-rules.js +115 -0
- package/dist/src/core/handoff-select.js +45 -28
- package/dist/src/core/handoff-status.d.ts +37 -7
- package/dist/src/core/handoff-status.js +95 -19
- package/dist/src/core/handoff.d.ts +4 -1
- package/dist/src/core/handoff.js +8 -5
- package/dist/src/core/inbound.d.ts +11 -3
- package/dist/src/core/inbound.js +26 -74
- package/dist/src/core/launch.js +6 -4
- package/dist/src/core/quota-levels.d.ts +6 -0
- package/dist/src/core/quota-levels.js +8 -0
- package/dist/src/core/remote-control.d.ts +10 -12
- package/dist/src/core/remote-control.js +29 -86
- package/dist/src/core/tuning-apply.js +12 -20
- package/dist/src/families/agy/index.d.ts +8 -0
- package/dist/src/families/agy/index.js +53 -0
- package/dist/src/families/agy/quota.d.ts +9 -0
- package/dist/src/families/agy/quota.js +110 -0
- package/dist/src/families/index.js +7 -0
- package/dist/src/families/logos.d.ts +10 -0
- package/dist/src/families/logos.js +12 -1
- package/dist/src/menubar/script.js +26 -3
- package/dist/src/menubar/snapshot.d.ts +23 -6
- package/dist/src/menubar/snapshot.js +126 -39
- package/dist/src/menubar/strings.d.ts +12 -2
- package/dist/src/menubar/strings.js +12 -2
- package/dist/src/panel/handler.d.ts +2 -1
- package/dist/src/panel/handler.js +81 -45
- package/dist/src/panel/i18n.d.ts +57 -7
- package/dist/src/panel/i18n.js +156 -56
- package/dist/src/panel/page-logic.d.ts +47 -19
- package/dist/src/panel/page-logic.js +33 -7
- package/dist/src/panel/page-script.js +263 -94
- package/dist/src/panel/page-styles.js +105 -8
- package/dist/src/panel/page.js +3 -3
- package/dist/src/plugins/check.js +27 -13
- package/dist/src/plugins/loader.d.ts +11 -0
- package/dist/src/plugins/loader.js +47 -1
- package/dist/src/runtime.d.ts +5 -2
- package/dist/src/runtime.js +12 -5
- package/dist/src/types.d.ts +35 -5
- package/package.json +2 -2
- package/schemas/config.json +16 -1
- package/schemas/families.json +8 -5
- package/schemas/handoff-disable.json +22 -0
- package/schemas/handoff-enable.json +22 -0
- package/schemas/handoff-rules.json +302 -0
- package/schemas/handoff-status.json +26 -0
- package/schemas/list.json +5 -0
- package/schemas/menubar-snapshot.json +309 -2
- package/skills/sideby/SKILL.md +3 -2
- package/skills/sideby/references/accounts.md +1 -0
- package/skills/sideby/references/handoff.md +7 -3
- package/skills/sideby/references/quota.md +2 -0
package/README.md
CHANGED
|
@@ -111,6 +111,7 @@ cc-switch's docs describe that switch: it writes the live settings file ([README
|
|
|
111
111
|
| Codex CLI | `~/.codex`, `~/.codex-<name>` | `codex login` | ✓ | ✓ |
|
|
112
112
|
| Grok Build | `~/.grok`, `~/.grok-<name>` | `grok login` | weekly, asked from the `grok` CLI | no public source |
|
|
113
113
|
| pi | `~/.pi/agent`, `~/.pi-<name>/agent` | `/login` inside pi | no public source | no public source |
|
|
114
|
+
| Antigravity CLI | `~/.gemini/antigravity-cli` (main account only) | sign in with Google inside `agy` | 5-hour and weekly per model group, asked from the `agy` CLI | no public source |
|
|
114
115
|
|
|
115
116
|
sideby starts the official binary on your `PATH` and never patches it. Tested versions and per-Host notes are in the [guide](docs/guide/usage.md#host-notes).
|
|
116
117
|
|
package/dist/build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"20261021T094830-069f4a"}
|
package/dist/src/cli/commands.js
CHANGED
|
@@ -9,14 +9,15 @@ import { editSettings } from '../core/edit-settings.js';
|
|
|
9
9
|
import { UserError } from '../core/errors.js';
|
|
10
10
|
import { requestHandoff } from '../core/handoff-chain.js';
|
|
11
11
|
import { handoffOverview } from '../core/handoff-overview.js';
|
|
12
|
+
import { handoffRulesView } from '../core/handoff-rules.js';
|
|
12
13
|
import { explain, readyDecision, runWithHandoff } from '../core/handoff-run.js';
|
|
13
|
-
import { configureHandoff, handoffHint, handoffStatus } from '../core/handoff-status.js';
|
|
14
|
+
import { checkHandoffRefs, configureHandoff, handoffHint, handoffRefs, handoffStatus, } from '../core/handoff-status.js';
|
|
14
15
|
import { installHint, runHost } from '../core/launch.js';
|
|
15
16
|
import { loginAfterLine, loginBeforeLine } from '../core/login-check.js';
|
|
16
17
|
import { accountModel, setAccountModel } from '../core/model-choice.js';
|
|
17
18
|
import { resolvePaths, tildify } from '../core/paths.js';
|
|
18
19
|
import { USAGE_DAYS } from '../core/quota-levels.js';
|
|
19
|
-
import {
|
|
20
|
+
import { groupsToUndo, remoteControlNothingToDo, remoteControlTodo, } from '../core/remote-control.js';
|
|
20
21
|
import { SHELLS } from '../core/shell-init.js';
|
|
21
22
|
import { MODEL_NAME } from '../families/shared/model-args.js';
|
|
22
23
|
import { AI_TASK_KINDS, inDisplayOrder, pinnedIn, suggestAlias, suggestName, withPinned, } from '../panel/page-logic.js';
|
|
@@ -741,15 +742,15 @@ export async function cmdRemoteControl(a, io, runtime) {
|
|
|
741
742
|
for (const g of groups)
|
|
742
743
|
io.out(rcGroupLine(g, home));
|
|
743
744
|
io.out(c.dim(' on: every session connects; default: Claude Code or your organization decides; off: only when you run /remote-control'));
|
|
744
|
-
if (
|
|
745
|
+
if (remoteControlTodo(groups, 'off').length)
|
|
745
746
|
io.out(c.cyan('\nRun `sideby remote-control off` so no session connects by itself (it shows the change first).'));
|
|
746
747
|
return 0;
|
|
747
748
|
}
|
|
748
749
|
const apply = () => action === 'off' ? rt.remoteControlOff() : action === 'on' ? rt.remoteControlOn() : rt.remoteControlUndo();
|
|
749
750
|
const todo = action === 'off'
|
|
750
|
-
?
|
|
751
|
+
? remoteControlTodo(groups, 'off')
|
|
751
752
|
: action === 'on'
|
|
752
|
-
?
|
|
753
|
+
? remoteControlTodo(groups, 'on')
|
|
753
754
|
: groupsToUndo(groups);
|
|
754
755
|
const verb = action === 'off' ? 'turn it off' : action === 'on' ? 'turn it on' : 'undo';
|
|
755
756
|
if (todo.length === 0) {
|
|
@@ -1017,12 +1018,16 @@ async function cmdHandoffStatus(a, io) {
|
|
|
1017
1018
|
const rt = await createRuntime();
|
|
1018
1019
|
const st = await handoffStatus(rt);
|
|
1019
1020
|
if (a.flags.has('json')) {
|
|
1020
|
-
|
|
1021
|
+
const overview = await handoffOverview(rt);
|
|
1022
|
+
json(io, { ...st, apiUndecided: (await handoffRulesView(rt, overview)).apiUndecided, overview });
|
|
1021
1023
|
return 0;
|
|
1022
1024
|
}
|
|
1023
1025
|
io.out(`Auto Handoff: ${st.auto ? c.green('on') : c.yellow('off')} (same family ${st.sameFamily ? 'on' : 'off'}; brief at ${st.prepareAt}%, hand over at ${st.threshold}%)`);
|
|
1024
1026
|
if (st.sideby.problem)
|
|
1025
1027
|
io.out(c.red(`sideby on PATH: ${st.sideby.problem}`));
|
|
1028
|
+
if ((await handoffRulesView(rt)).apiUndecided)
|
|
1029
|
+
io.out(c.yellow(API_UNDECIDED));
|
|
1030
|
+
io.out(c.dim('Every rule in plain words: `sideby handoff rules`.'));
|
|
1026
1031
|
if (st.families.length)
|
|
1027
1032
|
io.out(`\n${table(st.families.map((f) => [
|
|
1028
1033
|
c.bold(f.family),
|
|
@@ -1043,6 +1048,66 @@ async function cmdHandoffStatus(a, io) {
|
|
|
1043
1048
|
}
|
|
1044
1049
|
return 0;
|
|
1045
1050
|
}
|
|
1051
|
+
/** `sideby handoff rules` (spec §3.17 "接力规则"): every rule in effect, in plain words, and how to change each. */
|
|
1052
|
+
async function cmdHandoffRules(a, io) {
|
|
1053
|
+
const rt = await createRuntime();
|
|
1054
|
+
const view = await handoffRulesView(rt);
|
|
1055
|
+
if (a.flags.has('json')) {
|
|
1056
|
+
json(io, view);
|
|
1057
|
+
return 0;
|
|
1058
|
+
}
|
|
1059
|
+
io.out(`Auto Handoff: ${view.auto ? c.green('on') : c.yellow('off')}${view.auto ? '' : c.dim(' (these rules apply once it is on)')}`);
|
|
1060
|
+
if (view.apiUndecided)
|
|
1061
|
+
io.out(c.yellow(`\n${API_UNDECIDED}`));
|
|
1062
|
+
io.out('');
|
|
1063
|
+
for (const [i, r] of view.rules.entries()) {
|
|
1064
|
+
io.out(`${String(i + 1).padStart(2)}. ${r.text}`);
|
|
1065
|
+
const change = ruleCommand(r);
|
|
1066
|
+
if (change)
|
|
1067
|
+
io.out(c.dim(` change: ${change}`));
|
|
1068
|
+
}
|
|
1069
|
+
if (view.takeover.length) {
|
|
1070
|
+
io.out('\nIf a handoff started now:');
|
|
1071
|
+
for (const t of view.takeover)
|
|
1072
|
+
io.out(` ${t.ref} → ${decisionText(t.decision)}`);
|
|
1073
|
+
}
|
|
1074
|
+
return 0;
|
|
1075
|
+
}
|
|
1076
|
+
const API_UNDECIDED = 'API accounts no longer take over by default: they are billed per use. Keep them as the last resort with `sideby config set handoff.api true --yes`, or say no with `sideby config set handoff.api false --yes`.';
|
|
1077
|
+
/** The command that changes a rule, or null for a fixed one. */
|
|
1078
|
+
function ruleCommand(r) {
|
|
1079
|
+
const set = (key, v) => `sideby config set handoff.${key} ${v} --yes`;
|
|
1080
|
+
switch (r.id) {
|
|
1081
|
+
case 'when':
|
|
1082
|
+
return `${set('threshold', '<percent>')}; ${set('prepareAt', '<percent>')}; ${set('adaptive', String(!r.params.adaptive))}`;
|
|
1083
|
+
case 'takeover':
|
|
1084
|
+
return `follows the threshold: ${set('threshold', '<percent>')}`;
|
|
1085
|
+
case 'wait':
|
|
1086
|
+
return set('waitIfResetWithinMinutes', '<minutes>');
|
|
1087
|
+
case 'sameFamily':
|
|
1088
|
+
case 'otherFamilies':
|
|
1089
|
+
case 'api':
|
|
1090
|
+
return (set(r.id, String(!r.params.on)) +
|
|
1091
|
+
(r.id === 'otherFamilies' ? `; ${set('familyOrder', '\'["codex","grok"]\'')}` : ''));
|
|
1092
|
+
case 'organization':
|
|
1093
|
+
return set('crossOrganization', '\'["<account>"]\'');
|
|
1094
|
+
case 'order':
|
|
1095
|
+
return `sideby handoff enable --order ${r.params.family}=<account,account>`;
|
|
1096
|
+
case 'countdown':
|
|
1097
|
+
return set('countdownSeconds', '<seconds>');
|
|
1098
|
+
default:
|
|
1099
|
+
return null;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
function decisionText(d) {
|
|
1103
|
+
if (d.kind === 'pick')
|
|
1104
|
+
return d.ref;
|
|
1105
|
+
if (d.kind === 'wait')
|
|
1106
|
+
return `waits for the reset at ${new Date(d.until).toLocaleTimeString()}`;
|
|
1107
|
+
return d.earliestReset
|
|
1108
|
+
? `none now (${d.reason}); ${d.earliestReset.ref} is back at ${new Date(d.earliestReset.at).toLocaleTimeString()}`
|
|
1109
|
+
: `none (${d.reason})`;
|
|
1110
|
+
}
|
|
1046
1111
|
function intFlag(a, name) {
|
|
1047
1112
|
const v = a.flags.get(name);
|
|
1048
1113
|
if (v === undefined)
|
|
@@ -1059,6 +1124,16 @@ function switchCommand(sub, change) {
|
|
|
1059
1124
|
parts.push('--same-family');
|
|
1060
1125
|
if (change.sameFamily === false)
|
|
1061
1126
|
parts.push('--no-same-family');
|
|
1127
|
+
if (change.otherFamilies === true)
|
|
1128
|
+
parts.push('--other-ai');
|
|
1129
|
+
if (change.otherFamilies === false)
|
|
1130
|
+
parts.push('--no-other-ai');
|
|
1131
|
+
if (change.familyOrder)
|
|
1132
|
+
parts.push(`--ai-order ${change.familyOrder.join(',')}`);
|
|
1133
|
+
if (change.api === true)
|
|
1134
|
+
parts.push('--api');
|
|
1135
|
+
if (change.api === false)
|
|
1136
|
+
parts.push('--no-api');
|
|
1062
1137
|
for (const o of change.orders ?? [])
|
|
1063
1138
|
parts.push(`--order ${o.family}=${o.order.join(',')}`);
|
|
1064
1139
|
if (change.prepareAt !== undefined)
|
|
@@ -1079,6 +1154,22 @@ async function cmdHandoffSwitch(a, io, sub) {
|
|
|
1079
1154
|
change.sameFamily = true;
|
|
1080
1155
|
if (a.flags.has('no-same-family'))
|
|
1081
1156
|
change.sameFamily = false;
|
|
1157
|
+
if (a.flags.has('other-ai'))
|
|
1158
|
+
change.otherFamilies = true;
|
|
1159
|
+
if (a.flags.has('no-other-ai'))
|
|
1160
|
+
change.otherFamilies = false;
|
|
1161
|
+
if (a.flags.has('api'))
|
|
1162
|
+
change.api = true;
|
|
1163
|
+
if (a.flags.has('no-api'))
|
|
1164
|
+
change.api = false;
|
|
1165
|
+
const aiOrder = a.flags.get('ai-order');
|
|
1166
|
+
if (aiOrder === true)
|
|
1167
|
+
throw new UsageError('--ai-order takes families, for example --ai-order codex,grok');
|
|
1168
|
+
if (typeof aiOrder === 'string')
|
|
1169
|
+
change.familyOrder = aiOrder
|
|
1170
|
+
.split(',')
|
|
1171
|
+
.map((x) => x.trim())
|
|
1172
|
+
.filter(Boolean);
|
|
1082
1173
|
const order = a.flags.get('order');
|
|
1083
1174
|
if (typeof order === 'string') {
|
|
1084
1175
|
const eq = order.indexOf('=');
|
|
@@ -1117,6 +1208,8 @@ async function cmdHandoffSwitch(a, io, sub) {
|
|
|
1117
1208
|
io.out(`Auto Handoff is already ${sub === 'enable' ? 'set that way' : 'off'}; nothing to change.`);
|
|
1118
1209
|
else if (!r.applied) {
|
|
1119
1210
|
io.out(`Change to ${tildify(r.file, rt.paths.home)}:\n\n${r.diff}`);
|
|
1211
|
+
if (sub === 'enable' && r.settings.api)
|
|
1212
|
+
io.out(c.yellow('API accounts are billed per use and sideby does not cap spending; set a limit in the provider’s console.'));
|
|
1120
1213
|
if (sub === 'enable' && r.settings.sameFamily)
|
|
1121
1214
|
io.out(c.yellow('Same-family hand-over moves work between subscriptions of one vendor; vendors may act on that.'));
|
|
1122
1215
|
io.out(c.cyan(`\nApply it with \`${switchCommand(sub, change)} --yes\`.`));
|
|
@@ -1144,10 +1237,12 @@ export async function cmdHandoff(a, io) {
|
|
|
1144
1237
|
}
|
|
1145
1238
|
if (sub === 'status')
|
|
1146
1239
|
return cmdHandoffStatus(a, io);
|
|
1240
|
+
if (sub === 'rules')
|
|
1241
|
+
return cmdHandoffRules(a, io);
|
|
1147
1242
|
if (sub === 'enable' || sub === 'disable')
|
|
1148
1243
|
return cmdHandoffSwitch(a, io, sub);
|
|
1149
1244
|
if (sub !== 'ready')
|
|
1150
|
-
throw new UsageError('usage: sideby handoff status | enable [--same-family] [--order <family>=<acct,…>] [--threshold n] [--prepare-at n] [--yes] | disable [--yes] | ready [--to <account>] [--brief <file>] | setup|teardown <family> [--yes]');
|
|
1245
|
+
throw new UsageError('usage: sideby handoff status | rules | enable [--same-family] [--other-ai] [--ai-order <family,…>] [--api] [--order <family>=<acct,…>] [--threshold n] [--prepare-at n] [--yes] | disable [--yes] | ready [--to <account>] [--brief <file>] | setup|teardown <family> [--yes]');
|
|
1151
1246
|
const flag = a.flags.get('brief');
|
|
1152
1247
|
const brief = typeof flag === 'string' ? flag : undefined;
|
|
1153
1248
|
const toFlag = a.flags.get('to');
|
|
@@ -1962,10 +2057,16 @@ export async function cmdFamilies(a, io) {
|
|
|
1962
2057
|
if (i)
|
|
1963
2058
|
io.out('');
|
|
1964
2059
|
io.out(`${c.bold(f.title)} (${f.id}) ${f.installed ? c.green('installed') : c.yellow(f.brokenBin ? `install broken (${tildify(f.brokenBin, rt.paths.home)} cannot run); reinstall: ${installHint(f)}` : `not installed: ${installHint(f)}`)}`);
|
|
1965
|
-
io.out(
|
|
1966
|
-
|
|
2060
|
+
io.out(f.mainOnly
|
|
2061
|
+
? ` Accounts ~/${f.layout.main} (main only: ${f.title} keeps one sign-in per computer)`
|
|
2062
|
+
: ` Accounts ~/${f.layout.main} (main), ~/${f.layout.account}; selected with ${f.selectVar}`);
|
|
2063
|
+
io.out(` Sign in sideby login ${f.id}:${f.mainOnly ? 'main' : '<name>'} ${c.dim(f.login.args ? `(runs ${[f.bin, ...f.login.args].join(' ')})` : `(${f.login.hint})`)}`);
|
|
1967
2064
|
const yes = (b) => (b ? c.green('yes') : c.dim('no public source'));
|
|
1968
2065
|
io.out(` Quota ${yes(f.quota)}${f.quotaSetup ? c.dim(`, after \`sideby quota setup ${f.id}\``) : ''} Usage ${yes(f.usage)}`);
|
|
2066
|
+
if (!f.shared.length) {
|
|
2067
|
+
io.out(c.dim(' No shared items: everything in the account directory is its own.'));
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
1969
2070
|
io.out(' Shared items, and how each account holds them:');
|
|
1970
2071
|
const rows = f.shared.map((s) => [
|
|
1971
2072
|
` ${s.path}${s.key ? `#${s.key}` : ''}`,
|
|
@@ -2691,10 +2792,14 @@ export async function cmdConfig(a, io) {
|
|
|
2691
2792
|
? 'usage: sideby config set <key> <value> [--yes] [--json] (quote a value with spaces)'
|
|
2692
2793
|
: 'usage: sideby config unset <key> [--yes] [--json]');
|
|
2693
2794
|
const next = sub === 'set' ? cfg.parseConfigValue(value) : undefined;
|
|
2694
|
-
const
|
|
2795
|
+
const top = key.split('.')[0];
|
|
2796
|
+
const rt = top === 'accounts' || top === 'handoff' ? await createRuntime() : undefined;
|
|
2797
|
+
const argsProblem = rt && top === 'accounts' ? modelArgsProblem(rt) : undefined;
|
|
2798
|
+
const refs = rt && top === 'handoff' ? await handoffRefs(rt) : undefined;
|
|
2695
2799
|
const r = await cfg.editConfigPath(file, key, next, {
|
|
2696
2800
|
dryRun: !yes,
|
|
2697
2801
|
...(argsProblem ? { argsProblem } : {}),
|
|
2802
|
+
...(refs ? { checkHandoff: (before, after) => checkHandoffRefs(refs, before, after) } : {}),
|
|
2698
2803
|
});
|
|
2699
2804
|
const out = {
|
|
2700
2805
|
action: sub,
|
package/dist/src/cli/format.js
CHANGED
|
@@ -82,8 +82,9 @@ export function clock(iso, now) {
|
|
|
82
82
|
return sameDay ? hm : `${d.toLocaleDateString(undefined, { month: 'short', day: 'numeric' })} ${hm}`;
|
|
83
83
|
}
|
|
84
84
|
function windowText(w, now) {
|
|
85
|
-
// A window that covers only some models goes by their name (spec §3.26)
|
|
86
|
-
|
|
85
|
+
// A window that covers only some models goes by their name (spec §3.26), with its length, since one group may have
|
|
86
|
+
// a 5-hour and a weekly limit (Antigravity CLI).
|
|
87
|
+
const label = w.name ? `${w.name} ${w.label}` : w.label;
|
|
87
88
|
if (Date.parse(w.resetsAt) <= now.getTime())
|
|
88
89
|
return `${label} reset`;
|
|
89
90
|
const pct = Math.round(w.usedPercent);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// JSON Schemas for every `--json` output. Additive changes keep schemaVersion 1; removals, renames or
|
|
2
2
|
// meaning changes bump it (spec §3.9). `pnpm schemas` writes these to schemas/*.json.
|
|
3
3
|
import { Type } from 'typebox';
|
|
4
|
-
import { ConfigSchema } from '../core/config.js';
|
|
4
|
+
import { ConfigSchema, HandoffSettingsSchema } from '../core/config.js';
|
|
5
5
|
const Str = Type.String();
|
|
6
6
|
/** Why sideby cannot do something itself (spec §3.23); `reason` keeps the English text. */
|
|
7
7
|
const ReasonCode = Type.Union(['local-build', 'npx', 'volta', 'not-writable', 'project', 'source', 'skill-in-git'].map((k) => Type.Literal(k)), { description: 'Why, as a code a page can say in its own language.' });
|
|
@@ -107,15 +107,20 @@ const FamilyInfo = Type.Object({
|
|
|
107
107
|
settingsFile: Type.Optional(Type.String({
|
|
108
108
|
description: "The Host's settings file `sideby edit` opens, relative to the account directory.",
|
|
109
109
|
})),
|
|
110
|
+
mainOnly: Type.Optional(Type.Literal(true, {
|
|
111
|
+
description: 'The Host keeps one sign-in per computer, so sideby knows only its Main Account and refuses to create others (ADR-0047).',
|
|
112
|
+
})),
|
|
110
113
|
});
|
|
111
114
|
const ShareModeSchema = Type.Union(['link', 'copy', 'link-or-copy', 'link-or-local', 'local', 'local-if-api', 'info', 'json-key'].map((m) => Type.Literal(m)));
|
|
112
115
|
const FamilyDetail = Type.Intersect([
|
|
113
116
|
FamilyInfo,
|
|
114
117
|
Type.Object({
|
|
115
|
-
layout: Type.Object({ main: Str, account: Str }, {
|
|
116
|
-
|
|
117
|
-
description: 'Environment variable that selects a non-main Account directory.',
|
|
118
|
+
layout: Type.Object({ main: Str, account: Type.Optional(Str) }, {
|
|
119
|
+
description: 'Relative to HOME, for example `.claude` and `.claude-<name>`. A Main-only Family has no `account`.',
|
|
118
120
|
}),
|
|
121
|
+
selectVar: Type.Optional(Type.String({
|
|
122
|
+
description: 'Environment variable that selects a non-main Account directory. Left out for a Main-only Family.',
|
|
123
|
+
})),
|
|
119
124
|
login: Type.Object({
|
|
120
125
|
args: Type.Union([Type.Array(Str), Type.Null()], {
|
|
121
126
|
description: "Arguments of the Host's sign-in command; null when sign-in happens inside the Host.",
|
|
@@ -315,35 +320,25 @@ const PinResult = Type.Object({
|
|
|
315
320
|
display: Display,
|
|
316
321
|
});
|
|
317
322
|
const Skipped = Type.Optional(Type.Array(Type.Object({ ref: Str, reason: Str })));
|
|
323
|
+
const HandoffSettingsOut = HandoffSettingsSchema;
|
|
324
|
+
const Takeover = Type.Array(Type.Object({
|
|
325
|
+
ref: Str,
|
|
326
|
+
family: Str,
|
|
327
|
+
starts: Type.Array(Type.Union([Type.Literal('quota'), Type.Literal('limit')])),
|
|
328
|
+
decision: Type.Union([
|
|
329
|
+
Type.Object({ kind: Type.Literal('pick'), ref: Str, skipped: Skipped }),
|
|
330
|
+
Type.Object({ kind: Type.Literal('wait'), until: Str }),
|
|
331
|
+
Type.Object({
|
|
332
|
+
kind: Type.Literal('none'),
|
|
333
|
+
reason: Str,
|
|
334
|
+
earliestReset: Type.Optional(Type.Object({ ref: Str, at: Str })),
|
|
335
|
+
skipped: Skipped,
|
|
336
|
+
}),
|
|
337
|
+
]),
|
|
338
|
+
}));
|
|
318
339
|
const Overview = Type.Object({
|
|
319
|
-
settings:
|
|
320
|
-
|
|
321
|
-
sameFamily: Type.Boolean(),
|
|
322
|
-
prepareAt: Type.Number(),
|
|
323
|
-
threshold: Type.Number(),
|
|
324
|
-
waitIfResetWithinMinutes: Type.Number(),
|
|
325
|
-
countdownSeconds: Type.Number(),
|
|
326
|
-
crossOrganization: Type.Array(Str),
|
|
327
|
-
families: Type.Record(Str, Type.Object({
|
|
328
|
-
policy: Type.Union([Type.Literal('pressure'), Type.Literal('order')]),
|
|
329
|
-
order: Type.Array(Str),
|
|
330
|
-
})),
|
|
331
|
-
}),
|
|
332
|
-
takeover: Type.Array(Type.Object({
|
|
333
|
-
ref: Str,
|
|
334
|
-
family: Str,
|
|
335
|
-
starts: Type.Array(Type.Union([Type.Literal('quota'), Type.Literal('limit')])),
|
|
336
|
-
decision: Type.Union([
|
|
337
|
-
Type.Object({ kind: Type.Literal('pick'), ref: Str, skipped: Skipped }),
|
|
338
|
-
Type.Object({ kind: Type.Literal('wait'), until: Str }),
|
|
339
|
-
Type.Object({
|
|
340
|
-
kind: Type.Literal('none'),
|
|
341
|
-
reason: Str,
|
|
342
|
-
earliestReset: Type.Optional(Type.Object({ ref: Str, at: Str })),
|
|
343
|
-
skipped: Skipped,
|
|
344
|
-
}),
|
|
345
|
-
]),
|
|
346
|
-
})),
|
|
340
|
+
settings: HandoffSettingsOut,
|
|
341
|
+
takeover: Takeover,
|
|
347
342
|
recent: Type.Array(Type.Object({
|
|
348
343
|
from: Str,
|
|
349
344
|
to: Str,
|
|
@@ -375,10 +370,23 @@ const MenubarRow = Type.Object({
|
|
|
375
370
|
recommended: Type.Boolean({ description: 'The account `sideby next` would pick in this Family.' }),
|
|
376
371
|
observedAt: Type.Union([Str, Type.Null()], { description: 'When the quota was observed, not checked.' }),
|
|
377
372
|
stale: Type.Boolean({ description: 'The quota is old, undated, or its last query failed.' }),
|
|
378
|
-
tip: Type.String({
|
|
373
|
+
tip: Type.String({
|
|
374
|
+
description: "Hover text: when the numbers were read, each window's use and reset, and what a click does.",
|
|
375
|
+
}),
|
|
379
376
|
bars: Type.Union([Type.Tuple([MenubarBar, MenubarBar]), Type.Null()], {
|
|
380
377
|
description: 'The shorter window, then the longer one; a single window fills the second. Null without quota.',
|
|
381
378
|
}),
|
|
379
|
+
groups: Type.Union([
|
|
380
|
+
Type.Array(Type.Object({
|
|
381
|
+
label: Str,
|
|
382
|
+
bars: Type.Union([Type.Tuple([MenubarBar, MenubarBar]), Type.Null()]),
|
|
383
|
+
reset: Str,
|
|
384
|
+
tip: Str,
|
|
385
|
+
})),
|
|
386
|
+
Type.Null(),
|
|
387
|
+
], {
|
|
388
|
+
description: "A Host whose every limit covers one model group: a line per group under the account, each with its own bars; the account's `bars` are then null.",
|
|
389
|
+
}),
|
|
382
390
|
reset: Type.String({
|
|
383
391
|
description: 'Until the fullest window resets, such as `4d 17h`; empty when nothing is used.',
|
|
384
392
|
}),
|
|
@@ -661,6 +669,9 @@ export const OUTPUT_SCHEMAS = {
|
|
|
661
669
|
'handoff-status': Type.Object({
|
|
662
670
|
schemaVersion: Version,
|
|
663
671
|
overview: Type.Optional(Overview),
|
|
672
|
+
apiUndecided: Type.Optional(Type.Boolean({
|
|
673
|
+
description: 'Auto Handoff was on with API accounts before they became opt-in (ADR-0046): ask the user once whether they may take over, then set handoff.api.',
|
|
674
|
+
})),
|
|
664
675
|
auto: Type.Boolean(),
|
|
665
676
|
sameFamily: Type.Boolean(),
|
|
666
677
|
prepareAt: Type.Number(),
|
|
@@ -687,22 +698,39 @@ export const OUTPUT_SCHEMAS = {
|
|
|
687
698
|
applied: Type.Boolean(),
|
|
688
699
|
file: Str,
|
|
689
700
|
diff: Str,
|
|
690
|
-
settings:
|
|
691
|
-
auto: Type.Boolean(),
|
|
692
|
-
sameFamily: Type.Boolean(),
|
|
693
|
-
prepareAt: Type.Number(),
|
|
694
|
-
threshold: Type.Number(),
|
|
695
|
-
waitIfResetWithinMinutes: Type.Number(),
|
|
696
|
-
countdownSeconds: Type.Number(),
|
|
697
|
-
crossOrganization: Type.Array(Str),
|
|
698
|
-
families: Type.Record(Str, Type.Object({
|
|
699
|
-
policy: Type.Union([Type.Literal('pressure'), Type.Literal('order')]),
|
|
700
|
-
order: Type.Array(Str),
|
|
701
|
-
})),
|
|
702
|
-
}),
|
|
701
|
+
settings: HandoffSettingsOut,
|
|
703
702
|
nextSteps: Type.Array(Str),
|
|
704
703
|
}, { title: `sideby handoff ${sub} --json` }),
|
|
705
704
|
])),
|
|
705
|
+
'handoff-rules': Type.Object({
|
|
706
|
+
schemaVersion: Version,
|
|
707
|
+
auto: Type.Boolean(),
|
|
708
|
+
rules: Type.Array(Type.Object({
|
|
709
|
+
id: Type.Union([
|
|
710
|
+
'when',
|
|
711
|
+
'windows',
|
|
712
|
+
'takeover',
|
|
713
|
+
'wait',
|
|
714
|
+
'sameFamily',
|
|
715
|
+
'otherFamilies',
|
|
716
|
+
'api',
|
|
717
|
+
'organization',
|
|
718
|
+
'order',
|
|
719
|
+
'countdown',
|
|
720
|
+
].map((id) => Type.Literal(id))),
|
|
721
|
+
params: Type.Record(Str, Type.Unknown(), {
|
|
722
|
+
description: 'What the sentence needs, such as numbers.',
|
|
723
|
+
}),
|
|
724
|
+
settings: Type.Array(Str, {
|
|
725
|
+
description: 'The `handoff` config keys that change it; empty when fixed.',
|
|
726
|
+
}),
|
|
727
|
+
text: Type.String({ description: 'The rule in plain English.' }),
|
|
728
|
+
})),
|
|
729
|
+
apiUndecided: Type.Boolean({
|
|
730
|
+
description: 'Auto Handoff was on with API accounts before they became opt-in (ADR-0046): ask the user once, then set handoff.api.',
|
|
731
|
+
}),
|
|
732
|
+
takeover: Takeover,
|
|
733
|
+
}, { title: 'sideby handoff rules --json' }),
|
|
706
734
|
'handoff-ready': Type.Object({
|
|
707
735
|
schemaVersion: Version,
|
|
708
736
|
requested: Type.Literal(true),
|
|
@@ -1287,6 +1315,13 @@ export const OUTPUT_SCHEMAS = {
|
|
|
1287
1315
|
path: Str,
|
|
1288
1316
|
fillRule: Type.Optional(Type.String({ enum: ['nonzero', 'evenodd'] })),
|
|
1289
1317
|
color: Type.Optional(Type.String({ description: 'Brand colour; without one the mark follows the text colour.' })),
|
|
1318
|
+
gradients: Type.Optional(Type.Array(Type.Object({
|
|
1319
|
+
from: Type.Tuple([Type.Number(), Type.Number()]),
|
|
1320
|
+
to: Type.Tuple([Type.Number(), Type.Number()]),
|
|
1321
|
+
color: Str,
|
|
1322
|
+
}), {
|
|
1323
|
+
description: 'Colour washes over a multicoloured mark: each fades from `color` at `from` to clear at `to`.',
|
|
1324
|
+
})),
|
|
1290
1325
|
}),
|
|
1291
1326
|
Type.Null(),
|
|
1292
1327
|
]),
|
package/dist/src/cli/main.js
CHANGED
|
@@ -56,8 +56,11 @@ Usage:
|
|
|
56
56
|
whether Claude sessions connect to claude.ai by themselves;
|
|
57
57
|
off stops that for every account (shows the change first)
|
|
58
58
|
sideby handoff status what Auto Handoff still needs on this machine
|
|
59
|
+
sideby handoff rules every rule that decides when it hands over and to whom,
|
|
60
|
+
and where each account's work would go now
|
|
59
61
|
sideby handoff enable [--yes] turn it on (shows the config change first); --same-family,
|
|
60
|
-
--order claude=codex001,cc002, --threshold n, --prepare-at n
|
|
62
|
+
--order claude=codex001,cc002, --threshold n, --prepare-at n,
|
|
63
|
+
--other-ai [--ai-order codex,grok], --api (billed per use)
|
|
61
64
|
sideby handoff disable [--yes] turn it off, keeping the other settings
|
|
62
65
|
sideby handoff ready [--brief <f>] inside a session sideby started with Auto Handoff: hand over to
|
|
63
66
|
the next account when this turn ends (config \`handoff\`);
|
|
@@ -489,8 +492,8 @@ const COMMANDS = {
|
|
|
489
492
|
model: { flags: ['json', 'yes'], valued: ['effort'] },
|
|
490
493
|
'remote-control': { flags: ['json', 'yes'] },
|
|
491
494
|
handoff: {
|
|
492
|
-
flags: ['json', 'yes', 'same-family', 'no-same-family'],
|
|
493
|
-
valued: ['brief', 'to', 'order', 'prepare-at', 'threshold', 'wait-minutes', 'countdown'],
|
|
495
|
+
flags: ['json', 'yes', 'same-family', 'no-same-family', 'other-ai', 'no-other-ai', 'api', 'no-api'],
|
|
496
|
+
valued: ['brief', 'to', 'order', 'ai-order', 'prepare-at', 'threshold', 'wait-minutes', 'countdown'],
|
|
494
497
|
},
|
|
495
498
|
ui: { flags: ['no-open', 'background', 'stop', 'serve-detached'], valued: ['port'] },
|
|
496
499
|
app: { flags: ['json'], valued: ['url'] },
|
|
@@ -6,12 +6,17 @@ export { ACCOUNT_NAME };
|
|
|
6
6
|
export declare function looksLikeBackup(name: string): boolean;
|
|
7
7
|
export declare function mainDirOf(family: FamilyDef, home: string): string;
|
|
8
8
|
export declare function accountDirOf(family: FamilyDef, home: string, name: string): string;
|
|
9
|
+
/** Why a Main-only Family (ADR-0047) has no other Account, and what the user can do instead. */
|
|
10
|
+
export declare function mainOnlyMessage(family: FamilyDef): string;
|
|
9
11
|
/**
|
|
10
12
|
* The Account for this Family and name, read from its directory: the one place an Account is built.
|
|
11
13
|
* Whether it is an API Account follows the Secret File on disk (and the Family's secretFileMeansApi).
|
|
12
14
|
*/
|
|
13
15
|
export declare function accountAt(family: FamilyDef, home: string, name: string): Promise<Account>;
|
|
14
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Discovers the Main Account (if its directory exists) and every `<prefix><name><suffix>` directory in HOME. A
|
|
18
|
+
* Main-only Family (ADR-0047) has only its Main Account: HOME is not scanned for it.
|
|
19
|
+
*/
|
|
15
20
|
export declare function discoverAccounts(family: FamilyDef, home: string, ignore?: ReadonlySet<string>): Promise<Account[]>;
|
|
16
21
|
export declare class AccountRefError extends UserError {
|
|
17
22
|
}
|
|
@@ -13,10 +13,18 @@ export function mainDirOf(family, home) {
|
|
|
13
13
|
return join(home, family.layout.main);
|
|
14
14
|
}
|
|
15
15
|
export function accountDirOf(family, home, name) {
|
|
16
|
-
|
|
16
|
+
if (name === 'main')
|
|
17
|
+
return mainDirOf(family, home);
|
|
18
|
+
if (!family.layout.account)
|
|
19
|
+
throw new UserError(mainOnlyMessage(family), { code: 'family-main-only' });
|
|
20
|
+
return join(home, family.layout.account.replace('<name>', name));
|
|
21
|
+
}
|
|
22
|
+
/** Why a Main-only Family (ADR-0047) has no other Account, and what the user can do instead. */
|
|
23
|
+
export function mainOnlyMessage(family) {
|
|
24
|
+
return `${family.title} keeps one sign-in per computer, so sideby supports only its main account for now; run \`sideby run ${family.id}:main\` to use it`;
|
|
17
25
|
}
|
|
18
26
|
function splitLayout(family) {
|
|
19
|
-
const [first, ...rest] = family.layout.account.split('/');
|
|
27
|
+
const [first, ...rest] = (family.layout.account ?? '').split('/');
|
|
20
28
|
const at = first.indexOf('<name>');
|
|
21
29
|
if (at === -1)
|
|
22
30
|
throw new Error(`family ${family.id}: layout.account must contain <name> in its first segment`);
|
|
@@ -56,12 +64,17 @@ async function looksLikeAccount(family, dir) {
|
|
|
56
64
|
return false;
|
|
57
65
|
}
|
|
58
66
|
}
|
|
59
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Discovers the Main Account (if its directory exists) and every `<prefix><name><suffix>` directory in HOME. A
|
|
69
|
+
* Main-only Family (ADR-0047) has only its Main Account: HOME is not scanned for it.
|
|
70
|
+
*/
|
|
60
71
|
export async function discoverAccounts(family, home, ignore = new Set()) {
|
|
61
72
|
const out = [];
|
|
62
73
|
const main = mainDirOf(family, home);
|
|
63
74
|
if ((await statOrNull(main))?.isDirectory())
|
|
64
75
|
out.push(await accountAt(family, home, 'main'));
|
|
76
|
+
if (!family.layout.account)
|
|
77
|
+
return out;
|
|
65
78
|
const { prefix, suffix, rest } = splitLayout(family);
|
|
66
79
|
let entries = [];
|
|
67
80
|
try {
|
package/dist/src/core/ask.d.ts
CHANGED
|
@@ -58,7 +58,8 @@ export declare function taskStateDir(dir: string): Promise<string>;
|
|
|
58
58
|
* The Host arguments `ask --run` adds for a prompt task: `<imageArg>=<path>` per attached image for a Family that
|
|
59
59
|
* declares `imageArg` (spec §3.28 "附件"), then the prompt, always last. The `=` form keeps one value per option, so a
|
|
60
60
|
* Host option that takes several values cannot swallow the prompt. An image that is gone, or whose path holds a comma
|
|
61
|
-
* (a Host taking lists may split it), is left to the path in the prompt.
|
|
61
|
+
* (a Host taking lists may split it), is left to the path in the prompt. A Family with `promptArg` gets the prompt as
|
|
62
|
+
* `<promptArg>=<prompt>` instead, since its Host refuses a positional prompt.
|
|
62
63
|
*/
|
|
63
64
|
export declare function taskHostArgs(rt: Runtime, task: TaskFile): Promise<string[]>;
|
|
64
65
|
/** `env` with the HOME and XDG folders the task was written under, so the Runtime sees what the Panel saw. */
|
package/dist/src/core/ask.js
CHANGED
|
@@ -132,10 +132,12 @@ function validAttachments(list) {
|
|
|
132
132
|
* The Host arguments `ask --run` adds for a prompt task: `<imageArg>=<path>` per attached image for a Family that
|
|
133
133
|
* declares `imageArg` (spec §3.28 "附件"), then the prompt, always last. The `=` form keeps one value per option, so a
|
|
134
134
|
* Host option that takes several values cannot swallow the prompt. An image that is gone, or whose path holds a comma
|
|
135
|
-
* (a Host taking lists may split it), is left to the path in the prompt.
|
|
135
|
+
* (a Host taking lists may split it), is left to the path in the prompt. A Family with `promptArg` gets the prompt as
|
|
136
|
+
* `<promptArg>=<prompt>` instead, since its Host refuses a positional prompt.
|
|
136
137
|
*/
|
|
137
138
|
export async function taskHostArgs(rt, task) {
|
|
138
|
-
const
|
|
139
|
+
const family = rt.families.get((await rt.resolve(task.account)).family);
|
|
140
|
+
const flag = family?.imageArg;
|
|
139
141
|
const images = [];
|
|
140
142
|
if (flag)
|
|
141
143
|
for (const a of task.attachments ?? []) {
|
|
@@ -144,7 +146,8 @@ export async function taskHostArgs(rt, task) {
|
|
|
144
146
|
if (await lstat(a.path).then((s) => s.isFile(), () => false))
|
|
145
147
|
images.push(`${flag}=${a.path}`);
|
|
146
148
|
}
|
|
147
|
-
|
|
149
|
+
const prompt = task.prompt ?? '';
|
|
150
|
+
return [...images, family?.promptArg ? `${family.promptArg}=${prompt}` : prompt];
|
|
148
151
|
}
|
|
149
152
|
/** `env` with the HOME and XDG folders the task was written under, so the Runtime sees what the Panel saw. */
|
|
150
153
|
export function taskEnv(task, env) {
|
|
@@ -33,3 +33,60 @@ export declare const keyRecordPath: (stateDir: string, dir: string, file: string
|
|
|
33
33
|
export declare function writeKeyRecord(stateDir: string, dir: string, file: string, record: object): Promise<void>;
|
|
34
34
|
/** The parsed undo record of `file`, or null when there is none or it does not name `file`. */
|
|
35
35
|
export declare function readKeyRecord(stateDir: string, dir: string, file: string): Promise<Json | null>;
|
|
36
|
+
/** What sideby keeps to undo one key it wrote: whether the key was there, its exact value then, and what it wrote. */
|
|
37
|
+
export interface KeyUndo {
|
|
38
|
+
file: string;
|
|
39
|
+
hadKey: boolean;
|
|
40
|
+
previous?: unknown;
|
|
41
|
+
wrote: unknown;
|
|
42
|
+
at: string;
|
|
43
|
+
}
|
|
44
|
+
/** One line per settings file a change was meant for. */
|
|
45
|
+
export interface KeyResult {
|
|
46
|
+
file: string;
|
|
47
|
+
accounts: string[];
|
|
48
|
+
ok: boolean;
|
|
49
|
+
message: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* One top-level key of Claude's settings files that sideby writes for the user and can undo (Remote Control,
|
|
53
|
+
* ADR-0017; Cross-session inbound, ADR-0040). Each write goes through `writeSettingsKey` and leaves an undo record in
|
|
54
|
+
* `<state>/<records>/`; undo puts the old value back (or removes the key) only while it still holds what sideby
|
|
55
|
+
* wrote. `legacyWrote` reads a record from before `wrote` was kept as one that wrote that value.
|
|
56
|
+
*/
|
|
57
|
+
export declare function settingsKey(key: string, records: string, opts?: {
|
|
58
|
+
legacyWrote?: unknown;
|
|
59
|
+
}): {
|
|
60
|
+
key: string;
|
|
61
|
+
/** Whether sideby wrote `obj`'s key in `file` and it still holds that, so undo can put it back. */
|
|
62
|
+
undoable(stateDir: string, file: string, obj: Json): Promise<boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* Sets the key to `to` in each group, remembering the old value. `expect` gets the value in the file right before
|
|
65
|
+
* the write and refuses with a message when the change no longer fits it.
|
|
66
|
+
*/
|
|
67
|
+
set(stateDir: string, groups: readonly {
|
|
68
|
+
file: string;
|
|
69
|
+
accounts: string[];
|
|
70
|
+
}[], to: unknown, expect: (current: unknown) => string | null, done: string): Promise<KeyResult[]>;
|
|
71
|
+
/** Puts back what each group had before `set`, only while the key still holds what sideby wrote. */
|
|
72
|
+
undo(stateDir: string, groups: readonly {
|
|
73
|
+
file: string;
|
|
74
|
+
accounts: string[];
|
|
75
|
+
}[]): Promise<KeyResult[]>;
|
|
76
|
+
};
|
|
77
|
+
/** Why a settings file cannot be read for a change: none there, a link to nothing, or not a safe JSON object. */
|
|
78
|
+
export type SettingsProblem = 'no-settings' | 'broken-link' | 'unsafe';
|
|
79
|
+
/**
|
|
80
|
+
* Every Claude Account's settings file, grouped as `settingsFileGroups` does, with the parsed object, or the problem
|
|
81
|
+
* and a reason that says what to do (the Panel words it from `why`).
|
|
82
|
+
*/
|
|
83
|
+
export declare function readSettingsGroups(accounts: readonly Account[]): Promise<({
|
|
84
|
+
file: string;
|
|
85
|
+
accounts: string[];
|
|
86
|
+
obj: Json;
|
|
87
|
+
} | {
|
|
88
|
+
file: string;
|
|
89
|
+
accounts: string[];
|
|
90
|
+
why: SettingsProblem;
|
|
91
|
+
reason: string;
|
|
92
|
+
})[]>;
|