sideby 0.37.0 → 0.38.1
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 +1 -1
- package/dist/src/cli/commands.js +4 -2
- package/dist/src/cli/json-schemas.js +3 -0
- package/dist/src/cli/main.js +3 -1
- package/dist/src/core/live-sessions.d.ts +7 -0
- package/dist/src/core/live-sessions.js +10 -0
- package/dist/src/core/network.d.ts +11 -1
- package/dist/src/core/network.js +21 -1
- package/dist/src/families/claude/live-sessions.d.ts +7 -0
- package/dist/src/families/claude/live-sessions.js +18 -0
- package/dist/src/families/live-sessions.d.ts +2 -0
- package/dist/src/menubar/script.js +9 -3
- package/dist/src/network/hook.d.ts +9 -0
- package/dist/src/network/hook.js +190 -4
- package/dist/src/panel/i18n.d.ts +4 -0
- package/dist/src/panel/i18n.js +8 -0
- package/dist/src/panel/page-logic.d.ts +12 -0
- package/dist/src/panel/page-logic.js +20 -0
- package/dist/src/panel/page-script.js +10 -1
- package/dist/src/panel/page-styles.js +1 -1
- package/package.json +1 -1
- package/schemas/sessions.json +4 -0
- package/skills/sideby/SKILL.md +2 -2
- package/skills/sideby/references/network.md +1 -1
- package/skills/sideby/references/sessions.md +2 -1
package/dist/build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"20261116T040114-0f0555"}
|
package/dist/src/cli/commands.js
CHANGED
|
@@ -3728,7 +3728,7 @@ export async function cmdSessions(a, io, runtime) {
|
|
|
3728
3728
|
if (more.length || a.rest.length)
|
|
3729
3729
|
throw new UsageError('usage: sideby sessions [<account>|<family>] | sideby sessions copy <account|session-id> | sideby sessions open-run <account|session-id>');
|
|
3730
3730
|
const rt = runtime ?? (await createRuntime());
|
|
3731
|
-
const { listLiveSessions, sessionLabel } = await import('../core/live-sessions.js');
|
|
3731
|
+
const { listLiveSessions, sessionLabel, startedFromName } = await import('../core/live-sessions.js');
|
|
3732
3732
|
const { withRuns } = await import('../core/run-link.js');
|
|
3733
3733
|
const { readHandoffChains, withHandoffs } = await import('../core/session-handoffs.js');
|
|
3734
3734
|
const r = await listLiveSessions(rt, first ? { only: first } : {});
|
|
@@ -3752,8 +3752,10 @@ export async function cmdSessions(a, io, runtime) {
|
|
|
3752
3752
|
// A long title (often in Chinese, two columns a character) is cut so the table stays readable.
|
|
3753
3753
|
// The RUN column shows only when an orchestrator's Session Index ties a Session to a Run (spec §3.32 step 2b).
|
|
3754
3754
|
const anyRun = sessions.some((s) => s.run);
|
|
3755
|
+
// Where a Session was started from, when not a plain terminal (Started From, spec §3.32): `· Orca`.
|
|
3755
3756
|
const rows = sessions.map((s) => [
|
|
3756
|
-
c.bold(sessionLabel(s.accountLabel, truncate(s.title, 40), s.sessionId))
|
|
3757
|
+
c.bold(sessionLabel(s.accountLabel, truncate(s.title, 40), s.sessionId)) +
|
|
3758
|
+
(s.startedFrom ? c.dim(` · ${startedFromName(s.startedFrom)}`) : ''),
|
|
3757
3759
|
sessionStatusText(s),
|
|
3758
3760
|
s.cwd ? tildify(s.cwd, home) : '',
|
|
3759
3761
|
s.startedAt ? clock(s.startedAt, now) : '',
|
|
@@ -1189,6 +1189,9 @@ export const OUTPUT_SCHEMAS = {
|
|
|
1189
1189
|
description: "True when sideby could not tie a running program to the session and took the account's newest one (Codex, pi).",
|
|
1190
1190
|
}),
|
|
1191
1191
|
transcript: Type.Optional(Type.String({ description: "Path of the session's record." })),
|
|
1192
|
+
startedFrom: Type.Optional(Type.String({
|
|
1193
|
+
description: "Started From: the app the session was started from, as the host's own record says (Claude Code's `entrypoint`). `orca`, `claude-desktop`, `script` (`claude -p`, scripts, the Agent SDK) or the host's value with only letters, digits and `._-`, at most 24 characters. Left out for a plain terminal and for hosts that do not say (Codex, Grok, pi).",
|
|
1194
|
+
})),
|
|
1192
1195
|
reference: Type.String({
|
|
1193
1196
|
description: 'The Session Reference in English: one sentence that points another AI at the session and its record.',
|
|
1194
1197
|
}),
|
package/dist/src/cli/main.js
CHANGED
|
@@ -623,7 +623,9 @@ export async function main(argv) {
|
|
|
623
623
|
// Network Guard's hook runs before every prompt and tool call it guards (spec §3.35); same fast path.
|
|
624
624
|
if (first === 'network-hook') {
|
|
625
625
|
const { runNetworkHook } = await import('../network/hook.js');
|
|
626
|
-
return runNetworkHook(rest, process.env, process.stderr
|
|
626
|
+
return runNetworkHook(rest, process.env, process.stderr, {
|
|
627
|
+
input: process.stdin.isTTY ? '' : process.stdin,
|
|
628
|
+
});
|
|
627
629
|
}
|
|
628
630
|
// Unattended Mode's hook runs before every tool call it matches and at every turn end (spec §3.37); same fast path.
|
|
629
631
|
if (first === 'unattended-hook') {
|
|
@@ -28,6 +28,11 @@ export interface LiveSession {
|
|
|
28
28
|
guessed: boolean;
|
|
29
29
|
/** Path of the Session's record (transcript), when known. */
|
|
30
30
|
transcript?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The app the Session was started from (Started From, spec §3.32), as a stable id: `orca`, `claude-desktop`,
|
|
33
|
+
* `script`, or the Host's own value cleaned. Left out for a plain terminal. Claude Code only for now.
|
|
34
|
+
*/
|
|
35
|
+
startedFrom?: string;
|
|
31
36
|
/** The command that resumes the Session in the Account that holds it. */
|
|
32
37
|
resumeCommand: string;
|
|
33
38
|
/** The Session Reference in English, as `sessionCopyText(s, 'reference', 'en')` gives it. */
|
|
@@ -46,6 +51,8 @@ export type SessionCopyAs = 'reference' | 'id' | 'resume';
|
|
|
46
51
|
export declare const shortId: (id: string) => string;
|
|
47
52
|
/** `<accountLabel> · <title> · <first 8 of id>`; a Session without a title leaves its part out. */
|
|
48
53
|
export declare const sessionLabel: (accountLabel: string, title: string, id: string) => string;
|
|
54
|
+
/** The name a Started From id is shown by in English text output. */
|
|
55
|
+
export declare const startedFromName: (id: string) => string;
|
|
49
56
|
/** The key that names a Session across Accounts: the same id in two Accounts is two Sessions. */
|
|
50
57
|
export declare const liveKey: (account: string, sessionId: string) => string;
|
|
51
58
|
/** The Host arguments that resume Session `id` of a Family. */
|
|
@@ -9,6 +9,15 @@ import { MESSAGES_LOOKED_AT, readAttention, withStatus, } from './session-status
|
|
|
9
9
|
export const shortId = (id) => id.slice(0, 8);
|
|
10
10
|
/** `<accountLabel> · <title> · <first 8 of id>`; a Session without a title leaves its part out. */
|
|
11
11
|
export const sessionLabel = (accountLabel, title, id) => [accountLabel, title, shortId(id)].filter(Boolean).join(' · ');
|
|
12
|
+
/** Display names of the Started From ids sideby knows; any other id is shown as it is. */
|
|
13
|
+
const STARTED_FROM_NAMES = {
|
|
14
|
+
orca: 'Orca',
|
|
15
|
+
'claude-desktop': 'Claude Desktop',
|
|
16
|
+
'claude-vscode': 'VS Code',
|
|
17
|
+
script: 'Script',
|
|
18
|
+
};
|
|
19
|
+
/** The name a Started From id is shown by in English text output. */
|
|
20
|
+
export const startedFromName = (id) => Object.hasOwn(STARTED_FROM_NAMES, id) ? STARTED_FROM_NAMES[id] : id;
|
|
12
21
|
/** The key that names a Session across Accounts: the same id in two Accounts is two Sessions. */
|
|
13
22
|
export const liveKey = (account, sessionId) => `${account}\0${sessionId}`;
|
|
14
23
|
/** The Host arguments that resume Session `id` of a Family. */
|
|
@@ -55,6 +64,7 @@ export function toLiveSession(account, accountLabel, raw) {
|
|
|
55
64
|
...(raw.updatedAt ? { updatedAt: raw.updatedAt } : {}),
|
|
56
65
|
guessed: raw.guessed,
|
|
57
66
|
...(raw.transcript ? { transcript: raw.transcript } : {}),
|
|
67
|
+
...(raw.startedFrom ? { startedFrom: raw.startedFrom } : {}),
|
|
58
68
|
resumeCommand: resumeCommandFor(account.family, account.ref, raw.sessionId),
|
|
59
69
|
};
|
|
60
70
|
return { ...s, reference: referenceText(s, 'en') };
|
|
@@ -51,7 +51,17 @@ export declare function ipChangedLine(v: Verdict, env: Env): string | undefined;
|
|
|
51
51
|
* Codex's default (600 seconds) is already long enough.
|
|
52
52
|
*/
|
|
53
53
|
export declare const CLAUDE_NETWORK_HOOK_TIMEOUT_S = 60;
|
|
54
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Seconds the background `Held` entry may wait for the exit to be allowed again (5 hours, as Auto Handoff's
|
|
56
|
+
* `IdleWatch`, ADR-0056). `network-hook` ends by itself a little earlier (`HELD_BUDGET_MS`).
|
|
57
|
+
*/
|
|
58
|
+
export declare const CLAUDE_NETWORK_HELD_TIMEOUT_S = 18000;
|
|
59
|
+
/**
|
|
60
|
+
* Claude Code `hooks` entries for Network Guard, to put in a `--settings` file (alone or with Auto Handoff's). Next
|
|
61
|
+
* to the check before a prompt runs `Held` in the background (`asyncRewake`): a prompt Claude Code made itself (a
|
|
62
|
+
* background task's notification) is not sent again once blocked, so `Held` keeps it and wakes the session with it
|
|
63
|
+
* when the exit is allowed again (spec §3.35). Codex has no such hook, and gets none.
|
|
64
|
+
*/
|
|
55
65
|
export declare function claudeNetworkHooks(): Record<string, unknown[]>;
|
|
56
66
|
/** The file holding Network Guard's Claude hooks alone. */
|
|
57
67
|
export declare const claudeNetworkSettings: (stateDir: string) => string;
|
package/dist/src/core/network.js
CHANGED
|
@@ -98,7 +98,17 @@ const HOOK_EVENTS = ['UserPromptSubmit', 'PreToolUse'];
|
|
|
98
98
|
* Codex's default (600 seconds) is already long enough.
|
|
99
99
|
*/
|
|
100
100
|
export const CLAUDE_NETWORK_HOOK_TIMEOUT_S = 60;
|
|
101
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Seconds the background `Held` entry may wait for the exit to be allowed again (5 hours, as Auto Handoff's
|
|
103
|
+
* `IdleWatch`, ADR-0056). `network-hook` ends by itself a little earlier (`HELD_BUDGET_MS`).
|
|
104
|
+
*/
|
|
105
|
+
export const CLAUDE_NETWORK_HELD_TIMEOUT_S = 18_000;
|
|
106
|
+
/**
|
|
107
|
+
* Claude Code `hooks` entries for Network Guard, to put in a `--settings` file (alone or with Auto Handoff's). Next
|
|
108
|
+
* to the check before a prompt runs `Held` in the background (`asyncRewake`): a prompt Claude Code made itself (a
|
|
109
|
+
* background task's notification) is not sent again once blocked, so `Held` keeps it and wakes the session with it
|
|
110
|
+
* when the exit is allowed again (spec §3.35). Codex has no such hook, and gets none.
|
|
111
|
+
*/
|
|
102
112
|
export function claudeNetworkHooks() {
|
|
103
113
|
const out = {};
|
|
104
114
|
for (const e of HOOK_EVENTS)
|
|
@@ -106,6 +116,16 @@ export function claudeNetworkHooks() {
|
|
|
106
116
|
{
|
|
107
117
|
hooks: [
|
|
108
118
|
{ type: 'command', command: hookCommand('claude', e), timeout: CLAUDE_NETWORK_HOOK_TIMEOUT_S },
|
|
119
|
+
...(e === 'UserPromptSubmit'
|
|
120
|
+
? [
|
|
121
|
+
{
|
|
122
|
+
type: 'command',
|
|
123
|
+
command: hookCommand('claude', 'Held'),
|
|
124
|
+
asyncRewake: true,
|
|
125
|
+
timeout: CLAUDE_NETWORK_HELD_TIMEOUT_S,
|
|
126
|
+
},
|
|
127
|
+
]
|
|
128
|
+
: []),
|
|
109
129
|
],
|
|
110
130
|
},
|
|
111
131
|
];
|
|
@@ -2,6 +2,13 @@ import type { LiveSessionStatus } from '../../core/live-sessions.ts';
|
|
|
2
2
|
import type { LiveSessionReader } from '../live-sessions.ts';
|
|
3
3
|
/** Claude Code's `status`: `busy` and `shell` run, `idle` waits for a prompt, a blocked one waits for the user. */
|
|
4
4
|
export declare function claudeStatus(s: unknown): LiveSessionStatus;
|
|
5
|
+
/**
|
|
6
|
+
* Where Claude Code says a session was started from (Started From, spec §3.32): its record's `entrypoint`, which the
|
|
7
|
+
* launcher sets through `CLAUDE_CODE_ENTRYPOINT`, so it is any text (seen with Claude Code 2.1.325 on 2026-11-15:
|
|
8
|
+
* `cli`, `orca`, `claude-desktop`, `sdk-cli`). A plain terminal (`cli`, or none) gives undefined; every `sdk-*` is a
|
|
9
|
+
* script; anything else keeps only letters, digits and `._-`, at most 24 characters.
|
|
10
|
+
*/
|
|
11
|
+
export declare function claudeStartedFrom(v: unknown): string | undefined;
|
|
5
12
|
/** The transcript Claude Code writes for a session: `projects/<cwd with every other character as ->/<id>.jsonl`. */
|
|
6
13
|
export declare const claudeTranscript: (dir: string, cwd: string, id: string) => string;
|
|
7
14
|
/**
|
|
@@ -19,6 +19,22 @@ export function claudeStatus(s) {
|
|
|
19
19
|
return 'needs-you';
|
|
20
20
|
return 'unknown';
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Where Claude Code says a session was started from (Started From, spec §3.32): its record's `entrypoint`, which the
|
|
24
|
+
* launcher sets through `CLAUDE_CODE_ENTRYPOINT`, so it is any text (seen with Claude Code 2.1.325 on 2026-11-15:
|
|
25
|
+
* `cli`, `orca`, `claude-desktop`, `sdk-cli`). A plain terminal (`cli`, or none) gives undefined; every `sdk-*` is a
|
|
26
|
+
* script; anything else keeps only letters, digits and `._-`, at most 24 characters.
|
|
27
|
+
*/
|
|
28
|
+
export function claudeStartedFrom(v) {
|
|
29
|
+
if (typeof v !== 'string')
|
|
30
|
+
return undefined;
|
|
31
|
+
const raw = v.trim();
|
|
32
|
+
if (!raw || raw === 'cli')
|
|
33
|
+
return undefined;
|
|
34
|
+
if (raw.startsWith('sdk-'))
|
|
35
|
+
return 'script';
|
|
36
|
+
return raw.replace(/[^A-Za-z0-9._-]/g, '').slice(0, 24) || undefined;
|
|
37
|
+
}
|
|
22
38
|
const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : undefined);
|
|
23
39
|
const str = (v) => (typeof v === 'string' && v ? v : undefined);
|
|
24
40
|
/** The transcript Claude Code writes for a session: `projects/<cwd with every other character as ->/<id>.jsonl`. */
|
|
@@ -98,6 +114,7 @@ export const claudeLiveSessions = {
|
|
|
98
114
|
const named = rec.nameSource !== 'derived' ? str(rec.name) : undefined;
|
|
99
115
|
const aiTitle = named || !transcript ? undefined : await claudeAiTitle(transcript).catch(() => undefined);
|
|
100
116
|
const title = named ?? aiTitle ?? str(rec.name) ?? (cwd ? basename(cwd) : undefined);
|
|
117
|
+
const startedFrom = claudeStartedFrom(rec.entrypoint);
|
|
101
118
|
out.push({
|
|
102
119
|
sessionId,
|
|
103
120
|
...(title ? { title } : {}),
|
|
@@ -110,6 +127,7 @@ export const claudeLiveSessions = {
|
|
|
110
127
|
: {}),
|
|
111
128
|
guessed: false,
|
|
112
129
|
...(transcript ? { transcript } : {}),
|
|
130
|
+
...(startedFrom ? { startedFrom } : {}),
|
|
113
131
|
});
|
|
114
132
|
}
|
|
115
133
|
return out;
|
|
@@ -13,6 +13,8 @@ export interface RawLiveSession {
|
|
|
13
13
|
updatedAt?: string;
|
|
14
14
|
guessed: boolean;
|
|
15
15
|
transcript?: string;
|
|
16
|
+
/** The app the Session was started from (Started From), as the Host's own record says; Claude only. */
|
|
17
|
+
startedFrom?: string;
|
|
16
18
|
}
|
|
17
19
|
export interface LiveSessionReader {
|
|
18
20
|
family: string;
|
|
@@ -212,13 +212,19 @@ function run(argv) {
|
|
|
212
212
|
if (seen && seen === iconSeen) iconStable = seen;
|
|
213
213
|
iconSeen = seen;
|
|
214
214
|
}
|
|
215
|
-
// Drops the menu from the icon when it shows
|
|
216
|
-
//
|
|
215
|
+
// Drops the menu from the icon when it shows. When the icon is hidden, such as by a full menu bar or under the
|
|
216
|
+
// notch, clicking it would drop the menu in the screen's top left corner, so the menu drops below the right end of
|
|
217
|
+
// the menu bar instead, where the icon would be, on the screen the user is typing in.
|
|
217
218
|
function openMenu() {
|
|
218
219
|
var w = item.button.window;
|
|
219
220
|
if (w && !w.isNil() && (w.occlusionState & $.NSWindowOcclusionStateVisible)) { item.button.performClick(null); return; }
|
|
221
|
+
var screen = $.NSScreen.mainScreen;
|
|
222
|
+
if (!screen || screen.isNil()) screen = $.NSScreen.screens.firstObject;
|
|
223
|
+
var v = screen.visibleFrame;
|
|
224
|
+
var at = $.NSMakePoint(Math.max(v.origin.x, v.origin.x + v.size.width - Number(item.menu.size.width) - 8), v.origin.y + v.size.height);
|
|
220
225
|
app.activateIgnoringOtherApps(true);
|
|
221
|
-
|
|
226
|
+
// nil, not null: the bridge turns null into NSNull, which AppKit asks for its window and throws.
|
|
227
|
+
item.menu.popUpMenuPositioningItemAtLocationInView($(), at, $());
|
|
222
228
|
app.deactivate;
|
|
223
229
|
}
|
|
224
230
|
function registerHotkey() {
|
|
@@ -9,7 +9,16 @@ export interface NetworkHookDeps {
|
|
|
9
9
|
sleep?: Sleep;
|
|
10
10
|
/** Starts the detached refresh; tests replace it. */
|
|
11
11
|
background?: (family: string, env: Env) => void;
|
|
12
|
+
/** What the Host hands the hook on stdin; without it the hook decides as if it were given nothing. */
|
|
13
|
+
input?: AsyncIterable<string | Uint8Array> | string;
|
|
14
|
+
/** Whether the Host that started the hook is gone (`ppid` 1 by default): nothing is left to wake. */
|
|
15
|
+
parentGone?: () => boolean;
|
|
12
16
|
}
|
|
17
|
+
/** `Held` asks again after these waits, then every `HELD_EVERY_MS`: one request each time. */
|
|
18
|
+
export declare const HELD_DELAYS_MS: readonly [15000, 30000];
|
|
19
|
+
export declare const HELD_EVERY_MS = 60000;
|
|
20
|
+
/** `Held` ends by itself after this long, two minutes before the 5 hours Claude Code gives it (core/network.ts). */
|
|
21
|
+
export declare const HELD_BUDGET_MS: number;
|
|
13
22
|
/** Returns the exit code: 0 lets the Host go on, 2 blocks (the reason is written to `err`). */
|
|
14
23
|
export declare function runNetworkHook(argv: readonly string[], env: Env, err: {
|
|
15
24
|
write(s: string): unknown;
|
package/dist/src/network/hook.js
CHANGED
|
@@ -2,13 +2,146 @@
|
|
|
2
2
|
// call in a session sideby started with Network Guard on, so it imports only Node built-ins and leaf modules: never
|
|
3
3
|
// the Runtime, a Family index or core/accounts.ts. Unlike `handoff-hook` it exists to stop the Host: exit 2 with the
|
|
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
|
-
// about 30 seconds
|
|
5
|
+
// about 30 seconds. A prompt the Host made itself (a background task's notification) is not sent again once blocked,
|
|
6
|
+
// so Claude Code also runs the `Held` entry in the background: it keeps such a prompt in memory while the exit is not
|
|
7
|
+
// allowed, and wakes the session with it (exit 2) once a new check passes.
|
|
6
8
|
import { spawn } from 'node:child_process';
|
|
7
|
-
import {
|
|
9
|
+
import { lstat, readdir, unlink } from 'node:fs/promises';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
12
|
+
import { blockMessage, inCi, judge, NETWORK_ENV, prefersChinese, readNetworkConfig, refresh, verdict, } from '../core/egress.js';
|
|
13
|
+
import { ownedFolder, readSmallFile, sha256, writeFileAtomic } from '../core/fs-safe.js';
|
|
8
14
|
import { resolvePaths } from '../core/paths.js';
|
|
9
15
|
export const NETWORK_HOOK_COMMAND = 'sideby network-hook';
|
|
10
16
|
/** The Host events this entry answers, and when each happens; `Refresh` is its own detached refresh. */
|
|
11
17
|
const MOMENTS = { UserPromptSubmit: 'prompt', PreToolUse: 'tool' };
|
|
18
|
+
/** A prompt larger than this is not read: the hook then decides as if it were given nothing. */
|
|
19
|
+
const STDIN_MAX = 1024 * 1024;
|
|
20
|
+
/** Input that has not ended after this long is not waited for: the hook then decides as if it were given nothing. */
|
|
21
|
+
const STDIN_WAIT_MS = 5000;
|
|
22
|
+
/** A wake-up Claude Code makes from a background hook's exit 2 starts like this; only such a prompt carries a held message. */
|
|
23
|
+
const WAKE_UP = /^<task-notification>\s*<summary>Stop hook feedback<\/summary>/;
|
|
24
|
+
/** A prompt Claude Code made itself starts with this (a background task's notification, a hook's wake-up). */
|
|
25
|
+
const HOST_MADE = '<task-notification>';
|
|
26
|
+
/** `Held` asks again after these waits, then every `HELD_EVERY_MS`: one request each time. */
|
|
27
|
+
export const HELD_DELAYS_MS = [15_000, 30_000];
|
|
28
|
+
export const HELD_EVERY_MS = 60_000;
|
|
29
|
+
/** `Held` ends by itself after this long, two minutes before the 5 hours Claude Code gives it (core/network.ts). */
|
|
30
|
+
export const HELD_BUDGET_MS = 5 * 3600_000 - 120_000;
|
|
31
|
+
/**
|
|
32
|
+
* How long `Held` waits for the decision of the hook that checks the same prompt: the 60 seconds Claude Code gives
|
|
33
|
+
* that hook (`CLAUDE_NETWORK_HOOK_TIMEOUT_S`, core/network.ts) and a little more.
|
|
34
|
+
*/
|
|
35
|
+
const DECISION_WAIT_MS = 65_000;
|
|
36
|
+
const DECISION_POLL_MS = 200;
|
|
37
|
+
/** A decision nobody read (a session started before `Held` existed) is removed after this long. */
|
|
38
|
+
const DECISION_KEPT_MS = 3600_000;
|
|
39
|
+
/** The most of a held message that is handed over. */
|
|
40
|
+
const HELD_MAX_CHARS = 8000;
|
|
41
|
+
const HELD_OPEN = '<sideby-held-message>';
|
|
42
|
+
const HELD_CLOSE = '</sideby-held-message>';
|
|
43
|
+
async function readInput(input) {
|
|
44
|
+
if (input === undefined)
|
|
45
|
+
return '';
|
|
46
|
+
if (typeof input === 'string')
|
|
47
|
+
return input;
|
|
48
|
+
const read = (async () => {
|
|
49
|
+
const chunks = [];
|
|
50
|
+
let size = 0;
|
|
51
|
+
for await (const chunk of input) {
|
|
52
|
+
const b = Buffer.from(chunk);
|
|
53
|
+
size += b.length;
|
|
54
|
+
if (size > STDIN_MAX)
|
|
55
|
+
return '';
|
|
56
|
+
chunks.push(b);
|
|
57
|
+
}
|
|
58
|
+
return Buffer.concat(chunks).toString('utf8');
|
|
59
|
+
})();
|
|
60
|
+
read.catch(() => { });
|
|
61
|
+
// A Host that never ends the input must not keep the check from starting.
|
|
62
|
+
let timer;
|
|
63
|
+
const late = new Promise((resolve) => {
|
|
64
|
+
timer = setTimeout(() => {
|
|
65
|
+
// Let go of the stream too: an open stdin would keep the process alive after the hook has decided.
|
|
66
|
+
;
|
|
67
|
+
input.destroy?.();
|
|
68
|
+
resolve('');
|
|
69
|
+
}, STDIN_WAIT_MS);
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
return await Promise.race([read, late]);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
clearTimeout(timer);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** The prompt and its id when the Host made the prompt itself; undefined for a typed prompt or unreadable input. */
|
|
79
|
+
async function hostMadePrompt(input) {
|
|
80
|
+
try {
|
|
81
|
+
const v = JSON.parse(await readInput(input));
|
|
82
|
+
if (!v || typeof v.prompt !== 'string' || typeof v.prompt_id !== 'string' || !v.prompt_id)
|
|
83
|
+
return undefined;
|
|
84
|
+
return v.prompt.trimStart().startsWith(HOST_MADE) ? { id: v.prompt_id, prompt: v.prompt } : undefined;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** The file that tells `Held` what the checking hook decided for one prompt: named by a hash of the prompt's id. */
|
|
91
|
+
const decisionName = (id) => sha256(id).slice(0, 32);
|
|
92
|
+
/**
|
|
93
|
+
* Keeps the decision for a prompt the Host made (`ok` or `blocked`, nothing of the prompt) where `Held` finds it, and
|
|
94
|
+
* removes decisions nobody read. A failure changes nothing: `Held` then hands nothing over, as before it existed.
|
|
95
|
+
*/
|
|
96
|
+
async function keepDecision(dir, id, decision, now) {
|
|
97
|
+
try {
|
|
98
|
+
const folder = (await ownedFolder(dir, ['held'], { create: true, private: true }));
|
|
99
|
+
for (const name of await readdir(folder)) {
|
|
100
|
+
const st = await lstat(join(folder, name)).catch(() => null);
|
|
101
|
+
if (st && now - st.mtimeMs > DECISION_KEPT_MS)
|
|
102
|
+
await unlink(join(folder, name)).catch(() => { });
|
|
103
|
+
}
|
|
104
|
+
await writeFileAtomic(join(folder, decisionName(id)), decision, 0o600);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// no decision kept
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** Reads the decision for a prompt and removes it; undefined while there is none. */
|
|
111
|
+
async function takeDecision(dir, id) {
|
|
112
|
+
try {
|
|
113
|
+
const folder = await ownedFolder(dir, ['held'], { create: false });
|
|
114
|
+
if (!folder)
|
|
115
|
+
return undefined;
|
|
116
|
+
const file = join(folder, decisionName(id));
|
|
117
|
+
const text = await readSmallFile(file, 16);
|
|
118
|
+
if (text === undefined)
|
|
119
|
+
return undefined;
|
|
120
|
+
await unlink(file).catch(() => { });
|
|
121
|
+
return text === 'ok' ? 'ok' : 'blocked';
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/** What the session is woken with: why the message is late, and the message between the two tags. */
|
|
128
|
+
function heldMessage(prompt, zh) {
|
|
129
|
+
// A wake-up that was blocked again carries the first message inside the tags: hand over that one alone.
|
|
130
|
+
const from = prompt.indexOf(HELD_OPEN);
|
|
131
|
+
const to = prompt.lastIndexOf(HELD_CLOSE);
|
|
132
|
+
const inner = WAKE_UP.test(prompt.trimStart()) && from !== -1 && to > from;
|
|
133
|
+
const whole = (inner ? prompt.slice(from + HELD_OPEN.length, to) : prompt).trim();
|
|
134
|
+
const text = whole.slice(0, HELD_MAX_CHARS);
|
|
135
|
+
const cut = whole.length > HELD_MAX_CHARS
|
|
136
|
+
? zh
|
|
137
|
+
? `\n(原文在 ${HELD_MAX_CHARS} 个字符处截断。)`
|
|
138
|
+
: `\n(The message was cut at ${HELD_MAX_CHARS} characters.)`
|
|
139
|
+
: '';
|
|
140
|
+
const why = zh
|
|
141
|
+
? 'sideby 的网络检查在网络出口不被允许或查不出期间,扣住了一条 Claude Code 自己生成的消息(例如后台任务的结果)。现在可以送达了,原文如下:'
|
|
142
|
+
: "sideby's Network Guard held back a message Claude Code made itself (such as a background task's result) while this network's exit was not allowed or could not be told. It can go through now. The message as it was:";
|
|
143
|
+
return `${why}\n${HELD_OPEN}\n${text}\n${HELD_CLOSE}${cut}\n`;
|
|
144
|
+
}
|
|
12
145
|
function startRefresh(family, env) {
|
|
13
146
|
try {
|
|
14
147
|
const entry = process.argv[1];
|
|
@@ -40,7 +173,9 @@ export async function runNetworkHook(argv, env, err, deps = {}) {
|
|
|
40
173
|
// The switch and the list as config says now, so turning the check off or allowing a country in the Panel or with
|
|
41
174
|
// `sideby network` reaches sessions already running. When config cannot be read, the list the session started with.
|
|
42
175
|
const current = await readNetworkConfig(resolvePaths(env).configFile);
|
|
43
|
-
|
|
176
|
+
// `Held` goes on when the check is off: a prompt blocked a moment before the switch still has to be handed over.
|
|
177
|
+
const off = Boolean(current && !current.guard);
|
|
178
|
+
if (off && event !== 'Held')
|
|
44
179
|
return 0;
|
|
45
180
|
const allow = current?.allow ?? (env[NETWORK_ENV.allow] ?? '').split(',').filter(Boolean);
|
|
46
181
|
const common = {
|
|
@@ -55,9 +190,56 @@ export async function runNetworkHook(argv, env, err, deps = {}) {
|
|
|
55
190
|
await refresh(common);
|
|
56
191
|
return 0;
|
|
57
192
|
}
|
|
193
|
+
const clock = () => (deps.now?.() ?? new Date()).getTime();
|
|
194
|
+
if (event === 'Held') {
|
|
195
|
+
const made = await hostMadePrompt(deps.input);
|
|
196
|
+
if (!made)
|
|
197
|
+
return 0;
|
|
198
|
+
const sleep = deps.sleep ?? delay;
|
|
199
|
+
// The hook that checks this prompt says what it decided; no answer in time means it let the prompt through.
|
|
200
|
+
const asked = clock();
|
|
201
|
+
let decision;
|
|
202
|
+
while (true) {
|
|
203
|
+
decision = await takeDecision(dir, made.id);
|
|
204
|
+
if (decision || clock() - asked >= DECISION_WAIT_MS)
|
|
205
|
+
break;
|
|
206
|
+
await sleep(DECISION_POLL_MS);
|
|
207
|
+
}
|
|
208
|
+
if (decision !== 'blocked')
|
|
209
|
+
return 0;
|
|
210
|
+
const deliver = () => {
|
|
211
|
+
err.write(heldMessage(made.prompt, prefersChinese(env)));
|
|
212
|
+
return 2;
|
|
213
|
+
};
|
|
214
|
+
if (off)
|
|
215
|
+
return deliver();
|
|
216
|
+
const parentGone = deps.parentGone ?? (() => process.ppid === 1);
|
|
217
|
+
for (let i = 0;; i++) {
|
|
218
|
+
const wait = HELD_DELAYS_MS[i] ?? HELD_EVERY_MS;
|
|
219
|
+
if (clock() - asked + wait > HELD_BUDGET_MS)
|
|
220
|
+
return 0;
|
|
221
|
+
await sleep(wait);
|
|
222
|
+
if (parentGone())
|
|
223
|
+
return 0;
|
|
224
|
+
// As for every check: config as it is now, and the session's own list when config cannot be read.
|
|
225
|
+
const now = await readNetworkConfig(resolvePaths(env).configFile);
|
|
226
|
+
if (now && !now.guard)
|
|
227
|
+
return deliver();
|
|
228
|
+
const list = now?.allow ?? allow;
|
|
229
|
+
// Only a new answer that passes hands the message over; `refresh` never throws.
|
|
230
|
+
if (judge((await refresh(common)).entry, list) === 'ok')
|
|
231
|
+
return deliver();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
58
234
|
const moment = MOMENTS[event];
|
|
59
235
|
if (!moment)
|
|
60
236
|
return 0;
|
|
237
|
+
// A prompt the Host made itself is not sent again once blocked: tell `Held` what is decided for it.
|
|
238
|
+
const made = event === 'UserPromptSubmit' ? await hostMadePrompt(deps.input) : undefined;
|
|
239
|
+
const decided = async (d) => {
|
|
240
|
+
if (made)
|
|
241
|
+
await keepDecision(dir, made.id, d, clock());
|
|
242
|
+
};
|
|
61
243
|
try {
|
|
62
244
|
const v = await verdict({
|
|
63
245
|
...common,
|
|
@@ -66,12 +248,16 @@ export async function runNetworkHook(argv, env, err, deps = {}) {
|
|
|
66
248
|
...(deps.sleep ? { sleep: deps.sleep } : {}),
|
|
67
249
|
background: () => (deps.background ?? startRefresh)(family, env),
|
|
68
250
|
});
|
|
69
|
-
if (v.status === 'ok')
|
|
251
|
+
if (v.status === 'ok') {
|
|
252
|
+
await decided('ok');
|
|
70
253
|
return 0;
|
|
254
|
+
}
|
|
255
|
+
await decided('blocked');
|
|
71
256
|
err.write(`${blockMessage(v, allow, { ref: env.SIDEBY_LABEL || env.SIDEBY_ACCOUNT, at: moment, zh: prefersChinese(env) })}\n`);
|
|
72
257
|
return 2;
|
|
73
258
|
}
|
|
74
259
|
catch {
|
|
260
|
+
await decided('blocked');
|
|
75
261
|
err.write(`${prefersChinese(env)
|
|
76
262
|
? '已拦截:sideby 的网络检查出错,没能确认网络出口。重新发送试试;一直出错就运行 `sideby network check`。'
|
|
77
263
|
: "Blocked: sideby's network check failed and could not tell this network's exit. Try again; if it keeps failing, run `sideby network check`."}\n`);
|
package/dist/src/panel/i18n.d.ts
CHANGED
|
@@ -1035,6 +1035,10 @@ declare const en: {
|
|
|
1035
1035
|
'spage.decisionTip': string;
|
|
1036
1036
|
'spage.guessed': string;
|
|
1037
1037
|
'spage.guessedTip': string;
|
|
1038
|
+
'spage.from': string;
|
|
1039
|
+
'spage.fromScript': string;
|
|
1040
|
+
'spage.fromTip': string;
|
|
1041
|
+
'spage.fromOrcaTip': string;
|
|
1038
1042
|
'spage.run': string;
|
|
1039
1043
|
'spage.runTip': string;
|
|
1040
1044
|
'spage.runTipLane': string;
|
package/dist/src/panel/i18n.js
CHANGED
|
@@ -1037,6 +1037,10 @@ const en = {
|
|
|
1037
1037
|
'spage.decisionTip': 'Open Unattended to see what it asked and mark it done.',
|
|
1038
1038
|
'spage.guessed': 'newest session (guessed)',
|
|
1039
1039
|
'spage.guessedTip': 'sideby could not tell which session this account is running, so it shows the newest one.',
|
|
1040
|
+
'spage.from': 'Started from {app}',
|
|
1041
|
+
'spage.fromScript': 'Started from a script',
|
|
1042
|
+
'spage.fromTip': 'Where this session was started, as Claude Code records it.',
|
|
1043
|
+
'spage.fromOrcaTip': "Orca picks the account for its Chat panes itself. To use a certain account, open a terminal pane in Orca and run that account's short command.",
|
|
1040
1044
|
'spage.run': 'Task: {title}',
|
|
1041
1045
|
'spage.runTip': 'Open the task board of this session.',
|
|
1042
1046
|
'spage.runTipLane': 'Open the task board of this session. Its part: {lane}.',
|
|
@@ -2782,6 +2786,10 @@ const zh = {
|
|
|
2782
2786
|
'spage.decisionTip': '打开「无人值守」页,看它问了什么,处理完标为已完成。',
|
|
2783
2787
|
'spage.guessed': '最新会话(推测)',
|
|
2784
2788
|
'spage.guessedTip': 'sideby 没法确定这个账号正在跑哪个会话,先显示它最新的一个。',
|
|
2789
|
+
'spage.from': '启动自 {app}',
|
|
2790
|
+
'spage.fromScript': '启动自脚本',
|
|
2791
|
+
'spage.fromTip': 'Claude Code 记下的这个会话是从哪里启动的。',
|
|
2792
|
+
'spage.fromOrcaTip': 'Orca 的 Chat 面板由 Orca 自己选账号。要用某个账号,在 Orca 里打开终端面板,运行这个账号的短命令。',
|
|
2785
2793
|
'spage.run': '任务:{title}',
|
|
2786
2794
|
'spage.runTip': '打开这个会话的任务看板。',
|
|
2787
2795
|
'spage.runTipLane': '打开这个会话的任务看板。它负责:{lane}。',
|
|
@@ -454,10 +454,22 @@ export declare function sessionRowShape(s: LogicSession & {
|
|
|
454
454
|
copy?: unknown;
|
|
455
455
|
orca?: unknown;
|
|
456
456
|
run?: unknown;
|
|
457
|
+
startedFrom?: string;
|
|
457
458
|
}, msg?: {
|
|
458
459
|
status: string;
|
|
459
460
|
needsApproval?: boolean;
|
|
460
461
|
}): unknown[];
|
|
462
|
+
/**
|
|
463
|
+
* How a Session's Started From id is shown (spec §3.32): the message key of the whole chip text for a name the page
|
|
464
|
+
* translates, else the name.
|
|
465
|
+
* The reader already cleans the id; it is cleaned again here, so the page never shows more than 24 letters, digits
|
|
466
|
+
* and `._-`, and the caller puts it in as text only. Null when there is nothing to show.
|
|
467
|
+
*/
|
|
468
|
+
export declare function startedFromView(id: unknown): {
|
|
469
|
+
key?: string;
|
|
470
|
+
name: string;
|
|
471
|
+
orca: boolean;
|
|
472
|
+
} | null;
|
|
461
473
|
/** How long ago a Session was last active, as a message key and count; null when it has no time at all. */
|
|
462
474
|
export declare function sessionAge(s: LogicSession, now: number): {
|
|
463
475
|
key: string;
|
|
@@ -880,9 +880,29 @@ export function sessionRowShape(s, msg) {
|
|
|
880
880
|
s.copy,
|
|
881
881
|
Boolean(s.orca),
|
|
882
882
|
s.run || null,
|
|
883
|
+
s.startedFrom || '',
|
|
883
884
|
msg ? msg.status + (msg.needsApproval ? '+approve' : '') : '',
|
|
884
885
|
];
|
|
885
886
|
}
|
|
887
|
+
/**
|
|
888
|
+
* How a Session's Started From id is shown (spec §3.32): the message key of the whole chip text for a name the page
|
|
889
|
+
* translates, else the name.
|
|
890
|
+
* The reader already cleans the id; it is cleaned again here, so the page never shows more than 24 letters, digits
|
|
891
|
+
* and `._-`, and the caller puts it in as text only. Null when there is nothing to show.
|
|
892
|
+
*/
|
|
893
|
+
export function startedFromView(id) {
|
|
894
|
+
if (typeof id !== 'string')
|
|
895
|
+
return null;
|
|
896
|
+
if (id === 'script')
|
|
897
|
+
return { key: 'spage.fromScript', name: id, orca: false };
|
|
898
|
+
const names = {
|
|
899
|
+
orca: 'Orca',
|
|
900
|
+
'claude-desktop': 'Claude Desktop',
|
|
901
|
+
'claude-vscode': 'VS Code',
|
|
902
|
+
};
|
|
903
|
+
const name = Object.hasOwn(names, id) ? names[id] : id.replace(/[^A-Za-z0-9._-]/g, '').slice(0, 24);
|
|
904
|
+
return name ? { name, orca: id === 'orca' } : null;
|
|
905
|
+
}
|
|
886
906
|
/** How long ago a Session was last active, as a message key and count; null when it has no time at all. */
|
|
887
907
|
export function sessionAge(s, now) {
|
|
888
908
|
const ts = Date.parse(s.updatedAt || s.startedAt || '');
|
|
@@ -6,7 +6,7 @@ import { groupsToAccept } from '../core/inbound.js';
|
|
|
6
6
|
import { limitResetOffer, quotaAge, quotaIsStale, windowAge } from '../core/quota-levels.js';
|
|
7
7
|
import { remoteControlTodo } from '../core/remote-control.js';
|
|
8
8
|
import { catalogMatchLevel, catalogNorm, searchCatalog } from '../core/search-catalog.js';
|
|
9
|
-
import { accountTitle, advisorPick, advisorSummary, aiTaskAccounts, aliasArgsOf, aliasIssue, aliasPrefix, askBridge, askBridged, askCopy, askPermissionNote, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dotsKeepKeyboard, enableOutcome, expiredLogins, fileSize, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyWhen, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, messageToCheck, networkTaskFacts, newAccountDir, nextReset, openBridge, openBridged, orderedAliases, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, portalRefresh, quotaAskable, quotaHighLevel, quotaPressure, radioStep, reloadForBuild, remoteControlSummary, reorder, resetWhen, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, sessionRowShape, shortCwd, shortSessionLabel, sortAccounts, sortMenu, sortSessions, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, uaDayRuns, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, vendorAlias, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
|
|
9
|
+
import { accountTitle, advisorPick, advisorSummary, aiTaskAccounts, aliasArgsOf, aliasIssue, aliasPrefix, askBridge, askBridged, askCopy, askPermissionNote, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dotsKeepKeyboard, enableOutcome, expiredLogins, fileSize, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyWhen, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, messageToCheck, networkTaskFacts, newAccountDir, nextReset, openBridge, openBridged, orderedAliases, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, portalRefresh, quotaAskable, quotaHighLevel, quotaPressure, radioStep, reloadForBuild, remoteControlSummary, reorder, resetWhen, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, sessionRowShape, shortCwd, shortSessionLabel, sortAccounts, sortMenu, sortSessions, startedFromView, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, uaDayRuns, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, vendorAlias, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
|
|
10
10
|
// The component library's dropdown menu, copied by the brand repo's add script (--html into ui/); do not edit it.
|
|
11
11
|
import { CHECK, menuItem, menuScript } from './ui/dropdown-menu/dropdown-menu.html.js';
|
|
12
12
|
import { cn, esc } from './ui/lib/cn.js';
|
|
@@ -106,6 +106,7 @@ const LOGIC = [
|
|
|
106
106
|
shortCwd,
|
|
107
107
|
shortSessionLabel,
|
|
108
108
|
sortAccounts,
|
|
109
|
+
startedFromView,
|
|
109
110
|
sortSessions,
|
|
110
111
|
steadyOrder,
|
|
111
112
|
histFilters,
|
|
@@ -4070,6 +4071,13 @@ const MAIN = String.raw `
|
|
|
4070
4071
|
h('span', { class: 'sess-run-title' }, t('spage.run', { title: run.title })),
|
|
4071
4072
|
others.length ? h('span', { class: 'sess-run-more' }, '+' + others.length) : null)
|
|
4072
4073
|
}
|
|
4074
|
+
// Where the Session was started from (Started From, spec §3.32), as text only. An Orca Session says why it may run
|
|
4075
|
+
// in an Account the user did not pick: Orca chooses it for its Chat panes.
|
|
4076
|
+
function startedFromChip(s) {
|
|
4077
|
+
const v = startedFromView(s.startedFrom)
|
|
4078
|
+
if (!v) return null
|
|
4079
|
+
return h('span', { class: 'chip sess-from', tabindex: '0', 'data-tip': v.orca ? t('spage.fromOrcaTip') : t('spage.fromTip') }, v.key ? t(v.key) : t('spage.from', { app: v.name }))
|
|
4080
|
+
}
|
|
4073
4081
|
function sessionRow(s) {
|
|
4074
4082
|
const p = sessionLabelParts(s)
|
|
4075
4083
|
const copied = (sp.copied[s.sessionId] || 0) > Date.now()
|
|
@@ -4104,6 +4112,7 @@ const MAIN = String.raw `
|
|
|
4104
4112
|
s.reason === 'pending-decision' && status === 'needs-you' ? h('button', { class: 'chip chip-sm chip-warn chip-btn sess-decision', type: 'button', 'data-key': 'sess-decision-' + s.sessionId, 'data-tip': t('spage.decisionTip'), onclick: () => setPage('unattended') }, t('spage.decision'), icon('chevron')) : null,
|
|
4105
4113
|
chip ? msgChip(chip, msg, s) : null,
|
|
4106
4114
|
s.guessed ? h('span', { class: 'chip sess-guessed', tabindex: '0', 'data-tip': t('spage.guessedTip') }, t('spage.guessed')) : null,
|
|
4115
|
+
startedFromChip(s),
|
|
4107
4116
|
runChip(s),
|
|
4108
4117
|
h('span', { class: 'sess-cwd' + (cwd ? ' mono' : ''), title: s.cwd && cwd !== s.cwd ? s.cwd : null }, cwd || t('spage.noCwd')),
|
|
4109
4118
|
h('span', { class: 'sess-age', 'data-age': s.sessionId }, sessAgeText(s)))),
|
|
@@ -693,7 +693,7 @@ a.btn:hover { text-decoration: none; }
|
|
|
693
693
|
.sess-busy .sess-dot { background: var(--ok-bar); animation: pulse 1.4s ease-in-out infinite; }
|
|
694
694
|
.sess-unknown .sess-dot { background: transparent; border: 1px solid var(--faint); }
|
|
695
695
|
.sess-cwd { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
696
|
-
.sess-guessed { cursor: help; }
|
|
696
|
+
.sess-guessed, .sess-from { cursor: help; }
|
|
697
697
|
.sess-run { flex: 0 1 auto; min-width: 0; max-width: 24em; }
|
|
698
698
|
.sess-run-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
699
699
|
.sess-run-more { flex: none; font-weight: 600; }
|
package/package.json
CHANGED
package/schemas/sessions.json
CHANGED
|
@@ -123,6 +123,10 @@
|
|
|
123
123
|
"type": "string",
|
|
124
124
|
"description": "Path of the session's record."
|
|
125
125
|
},
|
|
126
|
+
"startedFrom": {
|
|
127
|
+
"type": "string",
|
|
128
|
+
"description": "Started From: the app the session was started from, as the host's own record says (Claude Code's `entrypoint`). `orca`, `claude-desktop`, `script` (`claude -p`, scripts, the Agent SDK) or the host's value with only letters, digits and `._-`, at most 24 characters. Left out for a plain terminal and for hosts that do not say (Codex, Grok, pi)."
|
|
129
|
+
},
|
|
126
130
|
"reference": {
|
|
127
131
|
"type": "string",
|
|
128
132
|
"description": "The Session Reference in English: one sentence that points another AI at the session and its record."
|
package/skills/sideby/SKILL.md
CHANGED
|
@@ -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.
|
|
5
|
+
version: "0.38.1"
|
|
6
6
|
requires:
|
|
7
7
|
bins: [sideby, node]
|
|
8
8
|
cliHelp: sideby --help
|
|
@@ -40,7 +40,7 @@ Account refs are `<family>:<name>`; a bare `<name>` works only when it is unique
|
|
|
40
40
|
|---|---|---|
|
|
41
41
|
| Install sideby, or set up a new account ("add cc008") | `sideby --version`, `sideby list --json`, `sideby new <family> --next --json` | `references/setup.md` |
|
|
42
42
|
| Show which account a session is (`[cc001]` in the status line or tab title) | `sideby list --json` for the labels | `references/badge.md` |
|
|
43
|
-
| Find which session an account is running now ("cc002 现在在干嘛", "which session is cc002 running", "哪个会话在等我"), or copy one for another AI ("复制 cc002 的会话 id", "copy cc002's session for another AI", "把这个会话交给另一个 AI"); which Run (dispatched task) a session works for ("cc002 在哪个任务里", "which run is cc002 working on", "打开它的任务看板") | `sideby sessions [<account>\|<family>] --json`, `sideby sessions copy <account\|id> [--as reference\|id\|resume] --json`, `sideby sessions open-run <account\|id> --json` | `references/sessions.md` |
|
|
43
|
+
| Find which session an account is running now ("cc002 现在在干嘛", "which session is cc002 running", "哪个会话在等我"), or copy one for another AI ("复制 cc002 的会话 id", "copy cc002's session for another AI", "把这个会话交给另一个 AI"); which Run (dispatched task) a session works for ("cc002 在哪个任务里", "which run is cc002 working on", "打开它的任务看板"); which account an Orca chat or another app's session runs in ("这个 Orca 对话用的是哪个账号", "which account is this Orca chat using") | `sideby sessions [<account>\|<family>] --json`, `sideby sessions copy <account\|id> [--as reference\|id\|resume] --json`, `sideby sessions open-run <account\|id> --json` | `references/sessions.md` |
|
|
44
44
|
| Find where a setting, page or feature of sideby lives ("语言在哪改", "where is the dark mode setting", "远程控制在哪关") — not sessions: for those use `sideby history` | `sideby commands <words> --json` (English or Chinese words), then do it with the `cliCommand` it returns or tell the user the `panel` place | `references/panel.md` |
|
|
45
45
|
| See which commands sideby has ("有哪些命令", "which commands exist", "sideby 有哪些和额度有关的命令", "what can I type in a terminal") | `sideby commands --json` (no words): every command by task with `usage`, `description` and a runnable `example`, the `common` ones first | `references/panel.md` |
|
|
46
46
|
| Find a session from before, in any account ("find a session I had before", "找一下我上周改登录页的那个会话", "sideby 项目最近的会话", "按日期分组看看"), read it, or continue it where it was | `sideby history [<words>...] [--project <name>] [--since today\|7d\|30d] [--group project\|day\|category] --json`, `sideby history show <id> --json`, `sideby history projects --json`; `--tools` also searches tool output | `references/sessions.md` |
|
|
@@ -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. 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.
|
|
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.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sessions: which session each account runs, finding one from before, handing one to another AI, and telling it something
|
|
2
2
|
|
|
3
|
-
For "which session is cc002 running", "cc002 现在在干嘛", "cc002 在哪个任务里", "哪个会话在等我", "copy cc002's session id for another AI", "复制 cc002 的会话给另一个 AI", "告诉 cc002 ……", "把这张截图发给 cc003", "send this to the codex session"; for past sessions, "find a session I had before", "找一下我上周改登录页的那个会话", "sideby 项目最近的会话".
|
|
3
|
+
For "which session is cc002 running", "cc002 现在在干嘛", "cc002 在哪个任务里", "这个 Orca 对话用的是哪个账号", "哪个会话在等我", "copy cc002's session id for another AI", "复制 cc002 的会话给另一个 AI", "告诉 cc002 ……", "把这张截图发给 cc003", "send this to the codex session"; for past sessions, "find a session I had before", "找一下我上周改登录页的那个会话", "sideby 项目最近的会话".
|
|
4
4
|
|
|
5
5
|
## See them
|
|
6
6
|
|
|
@@ -9,6 +9,7 @@ Run `sideby sessions --json` (or `sideby sessions <account|family> --json` for o
|
|
|
9
9
|
- `label` is the Session Label, `<account> · <the host's own title> · <first 8 of the id>`, as in `cc002 · knip cleanup · 61230c3d`. Use it when you name a session to the user; sideby never invents the title.
|
|
10
10
|
- `status`: `needs-you` (the user has to act on it: tell the user first), `busy`, `idle`, or `unknown` where the host does not say. Sessions that need the user come first. With `needs-you`, `reason` says why, so tell the user what to do: `host-waits` (it waits in its terminal for a permission or an answer), `pending-decision` (it asked something while Unattended Mode was on: show it with `sideby unattended pending --json`, see `unattended.md`), `message-to-approve` (a Message to it waits for the user to approve it in its terminal) or `message-to-paste` (a Message to it waits to be pasted: `sideby messages --to <session-id> --json` gives the line, see "Tell a session something" below).
|
|
11
11
|
- `cwd`, `startedAt`, `updatedAt`, `transcript` (the path of its record), `resumeCommand`.
|
|
12
|
+
- `startedFrom` (Claude sessions only): the app the session was started from, as Claude Code records it: `orca`, `claude-desktop`, `script` (`claude -p`, a script or the Agent SDK), or another app's own name such as `claude-vscode` (VS Code). No `startedFrom` means a plain terminal, or a host that does not say. For "which account is this Orca chat using" / "这个 Orca 对话用的是哪个账号", find the session with `startedFrom: "orca"` (match its `cwd` or title with what the user sees) and answer with its `accountLabel`. If it is not the account they want, explain that Orca picks the account for its Chat panes itself, not through sideby; to use a certain account, they open a terminal pane in Orca and run that account's short command (for example `ccw`).
|
|
12
13
|
- `guessed: true` means sideby could not tie a running Codex or pi program to a session and shows that account's newest session instead. Say "probably" when you report it.
|
|
13
14
|
|
|
14
15
|
- `run` (only some sessions): the Run a local orchestrator such as the `agent-dispatch` skill gave this session, `{ title, laneTitle, role, board, url, others }`. For "cc002 在哪个任务里" / "which run is cc002 working on", answer with `title` (and `laneTitle`, the part it does; `others` lists further Runs it also works for) and give `board`, the Run Board's file on this computer; to open it for the user ("打开它的任务看板", "open cc002's run report"), run `sideby sessions open-run <account|session-id> --json` yourself: it opens the board with the default program, as the chip on the Panel's Sessions page does, and returns `{ opened, board, sessionId, label }`. It exits 1 with code `no-run` when the session is in no Run (or its board file is gone: ask the coordinating AI to show the board again), `board-changed` when the file changed while sideby checked it, and `several-sessions` like `copy` below. No `run` means no orchestrator claims the session, not an error.
|