sideby 0.35.2 → 0.35.4

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/dist/build.json CHANGED
@@ -1 +1 @@
1
- {"id":"20261102T095419-2a750b"}
1
+ {"id":"20261105T083628-eff5ca"}
@@ -7,6 +7,18 @@ export declare const NETWORK_ENV: {
7
7
  readonly allow: 'SIDEBY_NETWORK_ALLOW';
8
8
  readonly dir: 'SIDEBY_NETWORK_DIR';
9
9
  };
10
+ /** True in CI, where a notice is noise and a check is a request nobody reads. */
11
+ export declare const inCi: (env: Record<string, string | undefined>) => boolean;
12
+ /**
13
+ * Config `network` as the file says now, read by hand (no schema) so a running session follows the Panel and
14
+ * `sideby network on|off|allow`: `guard` is false when the switch is off or no country is allowed, and when there is no
15
+ * config file (as for every other reader, no file means the defaults, where the check is off). Undefined when the file
16
+ * exists but cannot be read or is not JSON; the caller then keeps what the session was started with.
17
+ */
18
+ export declare function readNetworkConfig(configFile: string): Promise<{
19
+ guard: boolean;
20
+ allow: string[];
21
+ } | undefined>;
10
22
  export declare const TIMEOUT_MS = 3000;
11
23
  /**
12
24
  * Inside a session a check that cannot tell is asked again after these waits, before it blocks: a prompt the Host made
@@ -27,6 +27,36 @@ export const NETWORK_ENV = {
27
27
  allow: 'SIDEBY_NETWORK_ALLOW',
28
28
  dir: 'SIDEBY_NETWORK_DIR',
29
29
  };
30
+ const set = (v) => v !== undefined && v !== '' && v !== '0' && v.toLowerCase() !== 'false';
31
+ /** True in CI, where a notice is noise and a check is a request nobody reads. */
32
+ export const inCi = (env) => set(env.CI) || set(env.CONTINUOUS_INTEGRATION) || set(env.BUILD_NUMBER);
33
+ /**
34
+ * Config `network` as the file says now, read by hand (no schema) so a running session follows the Panel and
35
+ * `sideby network on|off|allow`: `guard` is false when the switch is off or no country is allowed, and when there is no
36
+ * config file (as for every other reader, no file means the defaults, where the check is off). Undefined when the file
37
+ * exists but cannot be read or is not JSON; the caller then keeps what the session was started with.
38
+ */
39
+ export async function readNetworkConfig(configFile) {
40
+ // The config may be a link a dotfiles manager keeps; reading through it is fine. No size limit: every other config
41
+ // reader takes the whole file, and a limit would turn a large config that says "off" into the started-with list.
42
+ let config;
43
+ try {
44
+ config = JSON.parse(await readFile(configFile, 'utf8'));
45
+ }
46
+ catch (err) {
47
+ if (err.code === 'ENOENT')
48
+ return { guard: false, allow: [] };
49
+ return undefined;
50
+ }
51
+ if (!config || typeof config !== 'object')
52
+ return undefined;
53
+ const section = config.network;
54
+ const net = section && typeof section === 'object' ? section : {};
55
+ const allow = Array.isArray(net.allow)
56
+ ? net.allow.filter((c) => typeof c === 'string' && /^[A-Z]{2}$/.test(c))
57
+ : [];
58
+ return { guard: net.guard === true && allow.length > 0, allow };
59
+ }
30
60
  export const TIMEOUT_MS = 3000;
31
61
  /**
32
62
  * Inside a session a check that cannot tell is asked again after these waits, before it blocks: a prompt the Host made
@@ -373,7 +403,11 @@ export function blockMessage(v, allow, opts) {
373
403
  : opts.at === 'prompt'
374
404
  ? '检查代理是否开着、节点是否正确,然后重新发送这条消息。'
375
405
  : '检查代理是否开着、节点是否正确,然后让它继续。';
376
- return `${what}${next}临时跳过:\`${skip}\`。`;
406
+ // Inside a session `--ignore-network` only helps a new one; turning the check off reaches this one at once.
407
+ const skipZh = opts.at === 'launch'
408
+ ? `临时跳过:\`${skip}\`。`
409
+ : `不想检查了:运行 \`sideby network off --yes\`,正在运行的会话也会马上放行;只跳过一次就新开会话:\`${skip}\`。`;
410
+ return `${what}${next}${skipZh}`;
377
411
  }
378
412
  const tried = tries > 1 ? ` after ${tries} tries in about ${secs} s` : '';
379
413
  const what = v.status === 'unknown'
@@ -384,5 +418,8 @@ export function blockMessage(v, allow, opts) {
384
418
  : opts.at === 'prompt'
385
419
  ? 'Check that the proxy is on and the node is right, then send the message again.'
386
420
  : 'Check that the proxy is on and the node is right, then let it continue.';
387
- return `${what} ${next} To skip once: \`${skip}\`.`;
421
+ const skipEn = opts.at === 'launch'
422
+ ? `To skip once: \`${skip}\`.`
423
+ : `To stop checking, run \`sideby network off --yes\`; sessions already running follow it at once. To skip once, start a new session: \`${skip}\`.`;
424
+ return `${what} ${next} ${skipEn}`;
388
425
  }
@@ -1,4 +1,5 @@
1
1
  import type { Env } from '../types.ts';
2
+ import { inCi } from './egress.ts';
2
3
  import type { Paths } from './paths.ts';
3
4
  export { isZombieStat } from './lock.ts';
4
5
  export { compareVersions } from './version.ts';
@@ -122,8 +123,7 @@ export declare const isNewer: (latest: string | undefined, current: string) => l
122
123
  * only gets a notice.
123
124
  */
124
125
  export declare function sameLine(from: string, to: string): boolean;
125
- /** True in CI, where a notice is noise and a check is a request nobody reads. */
126
- export declare const inCi: (env: Env) => boolean;
126
+ export { inCi };
127
127
  type UpdateSettings = {
128
128
  update?: {
129
129
  check?: boolean;
@@ -6,7 +6,7 @@ import { access, constants, mkdir, readdir, readFile, realpath, rm } from 'node:
6
6
  import { dirname, join, sep } from 'node:path';
7
7
  import { fileURLToPath } from 'node:url';
8
8
  import { afterInstall, runSkillUpdate } from './after-install.js';
9
- import { fetchTrace, proxyFor } from './egress.js';
9
+ import { fetchTrace, inCi, proxyFor } from './egress.js';
10
10
  import { writeFileAtomic } from './fs-safe.js';
11
11
  import { processAlive, takeFileLock } from './lock.js';
12
12
  import { installedSkills, REPO_URL, SKILL_UPDATE, SKILL_UPDATE_SHOWN, skillIsBehind, skillOwnerRepo, } from './skill-check.js';
@@ -194,8 +194,8 @@ export function sameLine(from, to) {
194
194
  }
195
195
  // ---- switches
196
196
  const set = (v) => v !== undefined && v !== '' && v !== '0' && v.toLowerCase() !== 'false';
197
- /** True in CI, where a notice is noise and a check is a request nobody reads. */
198
- export const inCi = (env) => set(env.CI) || set(env.CONTINUOUS_INTEGRATION) || set(env.BUILD_NUMBER);
197
+ // `inCi` lives in core/egress.ts, a leaf module `network-hook` may import.
198
+ export { inCi };
199
199
  /** Why Update Checks are off, with a code for the Panel, or null when they are on (spec §3.23). */
200
200
  export function checksOffWhy(env, config, local = localBuild() !== null) {
201
201
  // A Local Build (ADR-0024) follows the checkout: a notice or an Auto Update would only replace it with npm's.
@@ -4,7 +4,8 @@
4
4
  // reason on stderr blocks the prompt or the tool call; anything it cannot tell blocks too, after asking again for up to
5
5
  // about 30 seconds (a prompt the Host made itself is not sent again once blocked).
6
6
  import { spawn } from 'node:child_process';
7
- import { blockMessage, NETWORK_ENV, prefersChinese, refresh, verdict, } from '../core/egress.js';
7
+ import { blockMessage, inCi, NETWORK_ENV, prefersChinese, readNetworkConfig, refresh, verdict, } from '../core/egress.js';
8
+ import { resolvePaths } from '../core/paths.js';
8
9
  export const NETWORK_HOOK_COMMAND = 'sideby network-hook';
9
10
  /** The Host events this entry answers, and when each happens; `Refresh` is its own detached refresh. */
10
11
  const MOMENTS = { UserPromptSubmit: 'prompt', PreToolUse: 'tool' };
@@ -30,10 +31,18 @@ export async function runNetworkHook(argv, env, err, deps = {}) {
30
31
  const [family = '', event = ''] = argv;
31
32
  const url = env[NETWORK_ENV.url];
32
33
  const dir = env[NETWORK_ENV.dir];
33
- const allow = (env[NETWORK_ENV.allow] ?? '').split(',').filter(Boolean);
34
34
  // Not a session sideby started with Network Guard (the hook was copied somewhere): nothing to guard.
35
35
  if (!url || !dir)
36
36
  return 0;
37
+ // In CI Network Guard makes no request (AGENTS.md, spec §3.35), also when a session's variables reach it there.
38
+ if (inCi(env))
39
+ return 0;
40
+ // The switch and the list as config says now, so turning the check off or allowing a country in the Panel or with
41
+ // `sideby network` reaches sessions already running. When config cannot be read, the list the session started with.
42
+ const current = await readNetworkConfig(resolvePaths(env).configFile);
43
+ if (current && !current.guard)
44
+ return 0;
45
+ const allow = current?.allow ?? (env[NETWORK_ENV.allow] ?? '').split(',').filter(Boolean);
37
46
  const common = {
38
47
  url,
39
48
  env,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sideby",
3
- "version": "0.35.2",
3
+ "version": "0.35.4",
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)",
@@ -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.35.2"
5
+ version: "0.35.4"
6
6
  requires:
7
7
  bins: [sideby, node]
8
8
  cliHelp: sideby --help
@@ -34,4 +34,4 @@ The Panel's **Let AI help** (in the Network check dialog and on the wrong-networ
34
34
 
35
35
  ## When something was blocked
36
36
 
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. 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.
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. 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.