sideby 0.19.0 → 0.20.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 +7 -4
- package/ai-tasks.json +28 -0
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.d.ts +22 -1
- package/dist/src/cli/commands.js +815 -21
- package/dist/src/cli/format.d.ts +4 -0
- package/dist/src/cli/format.js +42 -4
- package/dist/src/cli/json-schemas.js +334 -4
- package/dist/src/cli/main.js +159 -13
- package/dist/src/core/accounts.d.ts +6 -0
- package/dist/src/core/accounts.js +12 -0
- package/dist/src/core/autostart.d.ts +11 -0
- package/dist/src/core/autostart.js +32 -5
- package/dist/src/core/browser-profiles.d.ts +23 -2
- package/dist/src/core/browser-profiles.js +148 -37
- package/dist/src/core/claude-settings-file.d.ts +18 -0
- package/dist/src/core/claude-settings-file.js +52 -3
- package/dist/src/core/config.d.ts +5 -0
- package/dist/src/core/config.js +12 -1
- package/dist/src/core/edit-settings.d.ts +7 -0
- package/dist/src/core/edit-settings.js +10 -5
- package/dist/src/core/file-memo.js +26 -4
- package/dist/src/core/history-group.d.ts +28 -0
- package/dist/src/core/history-group.js +47 -0
- package/dist/src/core/history-index.d.ts +145 -0
- package/dist/src/core/history-index.js +447 -0
- package/dist/src/core/history-project.d.ts +13 -0
- package/dist/src/core/history-project.js +87 -0
- package/dist/src/core/history.d.ts +210 -0
- package/dist/src/core/history.js +952 -0
- package/dist/src/core/inbound.d.ts +62 -0
- package/dist/src/core/inbound.js +215 -0
- package/dist/src/core/launch.d.ts +9 -1
- package/dist/src/core/launch.js +58 -24
- package/dist/src/core/live-sessions-copy.d.ts +5 -0
- package/dist/src/core/live-sessions-copy.js +46 -0
- package/dist/src/core/live-sessions-procs.d.ts +89 -0
- package/dist/src/core/live-sessions-procs.js +296 -0
- package/dist/src/core/live-sessions-title.d.ts +28 -0
- package/dist/src/core/live-sessions-title.js +80 -0
- package/dist/src/core/live-sessions.d.ts +68 -0
- package/dist/src/core/live-sessions.js +163 -0
- package/dist/src/core/login-check.d.ts +15 -0
- package/dist/src/core/login-check.js +32 -0
- package/dist/src/core/messages.d.ts +83 -0
- package/dist/src/core/messages.js +433 -0
- package/dist/src/core/project-categories.d.ts +14 -0
- package/dist/src/core/project-categories.js +48 -0
- package/dist/src/core/quota-fetch.d.ts +3 -3
- package/dist/src/core/quota-fetch.js +5 -5
- package/dist/src/core/quota-levels.d.ts +5 -0
- package/dist/src/core/quota-levels.js +5 -0
- package/dist/src/core/remote-control.d.ts +2 -0
- package/dist/src/core/remote-control.js +34 -59
- package/dist/src/core/run-link.d.ts +76 -0
- package/dist/src/core/run-link.js +245 -0
- package/dist/src/core/same-login.d.ts +4 -3
- package/dist/src/core/same-login.js +10 -7
- package/dist/src/core/session-select.d.ts +31 -0
- package/dist/src/core/session-select.js +44 -0
- package/dist/src/families/browser.d.ts +7 -18
- package/dist/src/families/browser.js +19 -8
- package/dist/src/families/claude/deliver.d.ts +2 -0
- package/dist/src/families/claude/deliver.js +43 -0
- package/dist/src/families/claude/history.d.ts +2 -0
- package/dist/src/families/claude/history.js +192 -0
- package/dist/src/families/claude/live-sessions.d.ts +13 -0
- package/dist/src/families/claude/live-sessions.js +117 -0
- package/dist/src/families/claude/messaging.d.ts +69 -0
- package/dist/src/families/claude/messaging.js +165 -0
- package/dist/src/families/claude/mod.d.ts +26 -0
- package/dist/src/families/claude/mod.js +105 -0
- package/dist/src/families/claude/session-files.d.ts +21 -0
- package/dist/src/families/claude/session-files.js +54 -0
- package/dist/src/families/codex/deliver.d.ts +5 -0
- package/dist/src/families/codex/deliver.js +76 -0
- package/dist/src/families/codex/history.d.ts +7 -0
- package/dist/src/families/codex/history.js +174 -0
- package/dist/src/families/codex/index.js +2 -0
- package/dist/src/families/codex/live-sessions.d.ts +12 -0
- package/dist/src/families/codex/live-sessions.js +193 -0
- package/dist/src/families/codex/quota.d.ts +3 -0
- package/dist/src/families/codex/quota.js +123 -0
- package/dist/src/families/codex/rate-limits.js +2 -0
- package/dist/src/families/codex/rollout.js +1 -1
- package/dist/src/families/grok/browser.d.ts +3 -0
- package/dist/src/families/grok/browser.js +5 -0
- package/dist/src/families/grok/history.d.ts +2 -0
- package/dist/src/families/grok/history.js +157 -0
- package/dist/src/families/grok/live-sessions.d.ts +4 -0
- package/dist/src/families/grok/live-sessions.js +80 -0
- package/dist/src/families/grok/login-key.d.ts +14 -0
- package/dist/src/families/grok/login-key.js +37 -0
- package/dist/src/families/history.d.ts +20 -0
- package/dist/src/families/history.js +81 -0
- package/dist/src/families/live-sessions.d.ts +26 -0
- package/dist/src/families/live-sessions.js +9 -0
- package/dist/src/families/login-keys.js +5 -1
- package/dist/src/families/messaging.d.ts +27 -0
- package/dist/src/families/messaging.js +6 -0
- package/dist/src/families/pi/history.d.ts +2 -0
- package/dist/src/families/pi/history.js +124 -0
- package/dist/src/families/pi/live-sessions.d.ts +2 -0
- package/dist/src/families/pi/live-sessions.js +70 -0
- package/dist/src/families/shared/history-text.d.ts +65 -0
- package/dist/src/families/shared/history-text.js +261 -0
- package/dist/src/menubar/hotkey.d.ts +86 -0
- package/dist/src/menubar/hotkey.js +159 -0
- package/dist/src/menubar/script.d.ts +2 -0
- package/dist/src/menubar/script.js +118 -22
- package/dist/src/menubar/snapshot.d.ts +8 -4
- package/dist/src/menubar/snapshot.js +45 -13
- package/dist/src/menubar/strings.d.ts +24 -6
- package/dist/src/menubar/strings.js +24 -6
- package/dist/src/panel/handler.d.ts +69 -0
- package/dist/src/panel/handler.js +686 -15
- package/dist/src/panel/i18n.d.ts +304 -3
- package/dist/src/panel/i18n.js +669 -67
- package/dist/src/panel/orca.d.ts +48 -0
- package/dist/src/panel/orca.js +153 -0
- package/dist/src/panel/page-logic.d.ts +255 -13
- package/dist/src/panel/page-logic.js +483 -1
- package/dist/src/panel/page-script.js +2265 -207
- package/dist/src/panel/page-styles.js +404 -32
- package/dist/src/panel/page.js +1 -0
- package/dist/src/plugins/account-script.js +61 -27
- package/dist/src/plugins/check.js +16 -4
- package/dist/src/plugins/loader.d.ts +8 -1
- package/dist/src/plugins/loader.js +72 -7
- package/dist/src/runtime.d.ts +5 -0
- package/dist/src/runtime.js +27 -5
- package/dist/src/types.d.ts +116 -1
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.js +5 -0
- package/mods/claude/.claude-plugin/plugin.json +7 -0
- package/mods/claude/hooks/hooks.json +1 -0
- package/mods/claude/hooks/register.js +261 -0
- package/package.json +5 -2
- package/schemas/autostart.json +74 -1
- package/schemas/browser-set.json +110 -0
- package/schemas/browser.json +22 -2
- package/schemas/config.json +26 -1
- package/schemas/history-index.json +209 -0
- package/schemas/history-projects.json +133 -0
- package/schemas/history-show.json +275 -0
- package/schemas/history.json +410 -0
- package/schemas/menubar-hotkey.json +139 -0
- package/schemas/menubar-snapshot.json +36 -2
- package/schemas/menubar.json +74 -1
- package/schemas/messages-inbound.json +258 -0
- package/schemas/messages.json +164 -0
- package/schemas/send.json +165 -0
- package/schemas/sessions-copy.json +113 -0
- package/schemas/sessions-open-run.json +97 -0
- package/schemas/sessions.json +237 -0
- package/skills/sideby/SKILL.md +10 -5
- package/skills/sideby/references/accounts.md +11 -0
- package/skills/sideby/references/ai-tasks.md +17 -1
- package/skills/sideby/references/panel.md +6 -4
- package/skills/sideby/references/quota.md +2 -2
- package/skills/sideby/references/sessions.md +79 -0
package/dist/src/panel/page.js
CHANGED
|
@@ -97,6 +97,7 @@ export function renderPage(opts) {
|
|
|
97
97
|
<section id="summary" class="summary" aria-busy="true">${SKELETON_STAT.repeat(4)}</section>
|
|
98
98
|
<section id="handoff-page" class="block" aria-labelledby="h-handoff" hidden></section>
|
|
99
99
|
<section id="tuning-page" class="block" aria-labelledby="h-tuning" hidden></section>
|
|
100
|
+
<section id="sessions-page" class="block" aria-labelledby="h-sessions" hidden></section>
|
|
100
101
|
<section id="accounts-page" class="block" aria-labelledby="h-accounts">
|
|
101
102
|
<div class="section-head acct-head"><h2 id="h-accounts"><span data-i18n="acct.title">Accounts</span><span id="acct-count" class="muted small"></span></h2><span id="updated" class="muted small" role="status">Loading…</span></div>
|
|
102
103
|
<div id="toolbar" class="toolbar" hidden></div>
|
|
@@ -2,16 +2,32 @@
|
|
|
2
2
|
// a common hand-rolled convention (for example, start a local gateway an API Account needs).
|
|
3
3
|
// It is local code with the user's permissions, so it gets the same ownership checks as Plugins.
|
|
4
4
|
import { spawn } from 'node:child_process';
|
|
5
|
-
import { access, constants } from 'node:fs/promises';
|
|
5
|
+
import { access, constants, mkdtemp, open, rm } from 'node:fs/promises';
|
|
6
|
+
import { tmpdir } from 'node:os';
|
|
6
7
|
import { join } from 'node:path';
|
|
7
8
|
import { lstatOrNull } from '../core/fs-safe.js';
|
|
8
9
|
import { checkTrusted } from './loader.js';
|
|
9
10
|
export const SCRIPT_NAME = 'sideby-before-launch';
|
|
10
11
|
export const SCRIPT_TIMEOUT_MS = 25_000;
|
|
11
12
|
const TAIL_LINES = 20;
|
|
13
|
+
/** How much of the end of stderr is read back for the error. */
|
|
14
|
+
const STDERR_TAIL_BYTES = 16_384;
|
|
12
15
|
function tail(text) {
|
|
13
16
|
return text.trimEnd().split('\n').slice(-TAIL_LINES).join('\n');
|
|
14
17
|
}
|
|
18
|
+
async function readTail(file) {
|
|
19
|
+
const fh = await open(file, 'r');
|
|
20
|
+
try {
|
|
21
|
+
const { size } = await fh.stat();
|
|
22
|
+
const length = Math.min(size, STDERR_TAIL_BYTES);
|
|
23
|
+
const buf = Buffer.alloc(length);
|
|
24
|
+
await fh.read(buf, 0, length, size - length);
|
|
25
|
+
return buf.toString();
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
await fh.close();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
15
31
|
export const accountScript = {
|
|
16
32
|
name: 'account-script',
|
|
17
33
|
register(api) {
|
|
@@ -31,32 +47,50 @@ export const accountScript = {
|
|
|
31
47
|
catch {
|
|
32
48
|
throw api.abort(`${script} is not executable; run \`chmod u+x "${script}"\``);
|
|
33
49
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
// stderr goes to a private temp file rather than a pipe: once the script has exited, everything it wrote is
|
|
51
|
+
// in the file, so its last lines are read back without racing the event loop, and a background process the
|
|
52
|
+
// script started (a gateway, say) that inherits stderr cannot hold the launch open.
|
|
53
|
+
// Do not go back to a pipe plus a drain timer: on a loaded runner the timer can fire before the pipe is read and
|
|
54
|
+
// drop the tail. The file is the contract; the saturated-event-loop test guards it.
|
|
55
|
+
const tmp = await mkdtemp(join(tmpdir(), 'sideby-before-launch-'));
|
|
56
|
+
let code;
|
|
57
|
+
let timedOut;
|
|
58
|
+
let stderr = '';
|
|
59
|
+
try {
|
|
60
|
+
const file = join(tmp, 'stderr');
|
|
61
|
+
const out = await open(file, 'w', 0o600);
|
|
62
|
+
try {
|
|
63
|
+
;
|
|
64
|
+
({ code, timedOut } = await new Promise((resolve) => {
|
|
65
|
+
const child = spawn(script, [], {
|
|
66
|
+
cwd: ctx.account.dir,
|
|
67
|
+
env: ctx.env,
|
|
68
|
+
stdio: ['ignore', 'ignore', out.fd],
|
|
69
|
+
});
|
|
70
|
+
const timer = setTimeout(() => {
|
|
71
|
+
child.kill('SIGKILL');
|
|
72
|
+
resolve({ code: null, timedOut: true });
|
|
73
|
+
}, SCRIPT_TIMEOUT_MS);
|
|
74
|
+
child.on('error', (e) => {
|
|
75
|
+
clearTimeout(timer);
|
|
76
|
+
stderr = e.message;
|
|
77
|
+
resolve({ code: 1, timedOut: false });
|
|
78
|
+
});
|
|
79
|
+
child.on('exit', (c) => {
|
|
80
|
+
clearTimeout(timer);
|
|
81
|
+
resolve({ code: c, timedOut: false });
|
|
82
|
+
});
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
await out.close();
|
|
87
|
+
}
|
|
88
|
+
if (!stderr)
|
|
89
|
+
stderr = await readTail(file);
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
await rm(tmp, { recursive: true, force: true });
|
|
93
|
+
}
|
|
60
94
|
if (timedOut)
|
|
61
95
|
throw api.abort(`${SCRIPT_NAME} did not finish within ${SCRIPT_TIMEOUT_MS / 1000}s`);
|
|
62
96
|
if (code !== 0)
|
|
@@ -19,7 +19,7 @@ import { fakeHost, withFakeHome } from '../../testing/index.js';
|
|
|
19
19
|
import { SHARE_MODES } from '../core/share-mode-names.js';
|
|
20
20
|
import { BUILTIN_PLUGINS } from '../families/index.js';
|
|
21
21
|
import { createRuntime } from '../runtime.js';
|
|
22
|
-
import { checkTrustedTree, logoProblem } from './loader.js';
|
|
22
|
+
import { checkTrustedTree, logoProblem, websiteProblem, } from './loader.js';
|
|
23
23
|
import { FAMILY_ID_RE, TODO_MARK } from './scaffold.js';
|
|
24
24
|
/** Name of the Account the check creates next to the Main Account in its throwaway HOME. */
|
|
25
25
|
const CHECK_ACCOUNT = 'check';
|
|
@@ -235,9 +235,10 @@ export async function checkBuiltinPlugin(opts) {
|
|
|
235
235
|
async function loadedFamilies(h, builtins, source, said, problems) {
|
|
236
236
|
const rt = await createRuntime({ env: h.env, builtins });
|
|
237
237
|
const mine = rt.plugins.find((p) => p.source === source);
|
|
238
|
-
// A dropped logo is reported by defProblems as `logo.invalid`, with its own fix.
|
|
238
|
+
// A dropped logo or website is reported by defProblems as `logo.invalid` or `website.invalid`, with its own fix.
|
|
239
239
|
const errors = rt.pluginErrors.filter((e) => (e.where === source || e.where === mine?.name || !mine) &&
|
|
240
|
-
!e.message.endsWith('showing its initials instead')
|
|
240
|
+
!e.message.endsWith('showing its initials instead') &&
|
|
241
|
+
!e.message.endsWith('"Open in browser" until this is fixed'));
|
|
241
242
|
for (const e of errors)
|
|
242
243
|
problems.push({
|
|
243
244
|
code: 'load.failed',
|
|
@@ -253,7 +254,8 @@ async function loadedFamilies(h, builtins, source, said, problems) {
|
|
|
253
254
|
});
|
|
254
255
|
return null;
|
|
255
256
|
}
|
|
256
|
-
|
|
257
|
+
// A Plugin may sort Projects into categories without adding a Family.
|
|
258
|
+
if (mine.families.length === 0 && rt.projectCategoriesFrom !== mine.name)
|
|
257
259
|
problems.push({
|
|
258
260
|
code: 'family.none',
|
|
259
261
|
message: `plugin ${mine.name} registers no Family`,
|
|
@@ -266,6 +268,7 @@ async function checkDefs(plugin, problems) {
|
|
|
266
268
|
const defs = [];
|
|
267
269
|
const api = {
|
|
268
270
|
family: (def) => void defs.push(def),
|
|
271
|
+
projectCategories: () => { },
|
|
269
272
|
on: () => { },
|
|
270
273
|
abort: (message) => new Error(message),
|
|
271
274
|
fs: { writeFileAtomic: async () => { } },
|
|
@@ -366,6 +369,15 @@ export function defProblems(raw) {
|
|
|
366
369
|
fix: 'Use one 24x24 SVG path from an icon set whose license allows it, or leave `logo` out.',
|
|
367
370
|
});
|
|
368
371
|
}
|
|
372
|
+
if (def.website !== undefined) {
|
|
373
|
+
const problem = websiteProblem(def.website);
|
|
374
|
+
if (problem)
|
|
375
|
+
out.push({
|
|
376
|
+
code: 'website.invalid',
|
|
377
|
+
message: `${at}: ${problem}`,
|
|
378
|
+
fix: "Set `website.url` to the vendor's https address, and `match` to { origin, signInId } or leave it out.",
|
|
379
|
+
});
|
|
380
|
+
}
|
|
369
381
|
return out;
|
|
370
382
|
}
|
|
371
383
|
/** A discover / launch env / doctor round for one Family in the fake HOME: a Main Account and one other Account. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Config } from '../core/config.ts';
|
|
2
|
-
import type { FamilyDef, Plugin } from '../types.ts';
|
|
2
|
+
import type { FamilyDef, Plugin, ProjectCategoriesDef } from '../types.ts';
|
|
3
3
|
import { type HookBus } from './bus.ts';
|
|
4
4
|
export interface PluginManifest {
|
|
5
5
|
name: string;
|
|
@@ -38,6 +38,11 @@ export interface LoadResult {
|
|
|
38
38
|
errors: PluginLoadError[];
|
|
39
39
|
families: Map<string, FamilyDef>;
|
|
40
40
|
familyOwner: Map<string, string>;
|
|
41
|
+
/** The first Plugin's Project Categories, and who registered it. */
|
|
42
|
+
categories?: {
|
|
43
|
+
def: ProjectCategoriesDef;
|
|
44
|
+
owner: string;
|
|
45
|
+
};
|
|
41
46
|
}
|
|
42
47
|
/** Rejects plugin files other users could have written: plugins run with the user's full permissions. */
|
|
43
48
|
export declare function checkTrusted(path: string): Promise<string | null>;
|
|
@@ -49,6 +54,8 @@ export declare function checkTrustedTree(root: string, seen?: Set<string>): Prom
|
|
|
49
54
|
export declare const MAX_LOGO_PATH = 20000;
|
|
50
55
|
/** Why a Family logo is unusable, or null when it is fine. The Panel draws it with DOM APIs, never as markup. */
|
|
51
56
|
export declare function logoProblem(logo: unknown): string | null;
|
|
57
|
+
/** Why a Family website is unusable, or null when it is fine. */
|
|
58
|
+
export declare function websiteProblem(website: unknown): string | null;
|
|
52
59
|
export declare function loadPlugins(opts: {
|
|
53
60
|
builtins: BuiltinPlugin[];
|
|
54
61
|
config: Config;
|
|
@@ -73,6 +73,34 @@ export function logoProblem(logo) {
|
|
|
73
73
|
return 'logo.fillRule must be "nonzero" or "evenodd"';
|
|
74
74
|
return null;
|
|
75
75
|
}
|
|
76
|
+
// The url reaches `open` and, on WSL, `cmd.exe /c start`, so it holds no character a shell gives meaning to.
|
|
77
|
+
const WEBSITE_URL_RE = /^https:\/\/[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+(?:\/[A-Za-z0-9._~/-]*)?$/;
|
|
78
|
+
const WEBSITE_ORIGIN_RE = /^https:\/\/[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$/;
|
|
79
|
+
/** Why a Family website is unusable, or null when it is fine. */
|
|
80
|
+
export function websiteProblem(website) {
|
|
81
|
+
if (typeof website !== 'object' || website === null || Array.isArray(website))
|
|
82
|
+
return 'website must be an object';
|
|
83
|
+
const { url, match } = website;
|
|
84
|
+
if (typeof url !== 'string' || url.length > 200 || !WEBSITE_URL_RE.test(url))
|
|
85
|
+
return 'website.url must be an https address such as https://example.com, with no query or fragment';
|
|
86
|
+
if (match === undefined)
|
|
87
|
+
return null;
|
|
88
|
+
if (typeof match !== 'object' || match === null || Array.isArray(match))
|
|
89
|
+
return 'website.match must be { origin, signInId }';
|
|
90
|
+
const { origin, signInId } = match;
|
|
91
|
+
if (typeof origin !== 'string' || !WEBSITE_ORIGIN_RE.test(origin))
|
|
92
|
+
return 'website.match.origin must be an https origin such as https://example.com, with no path';
|
|
93
|
+
if (typeof signInId !== 'function')
|
|
94
|
+
return 'website.match.signInId must be a function';
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
/** Only the known website fields. */
|
|
98
|
+
function cleanWebsite(website) {
|
|
99
|
+
return {
|
|
100
|
+
url: website.url,
|
|
101
|
+
...(website.match ? { match: { origin: website.match.origin, signInId: website.match.signInId } } : {}),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
76
104
|
/** Only the known logo fields, so nothing else a Plugin put on the object reaches the Panel. */
|
|
77
105
|
function cleanLogo(logo) {
|
|
78
106
|
return {
|
|
@@ -97,7 +125,22 @@ async function register(plugin, bus, result, source, settings) {
|
|
|
97
125
|
const stagedFamilies = [];
|
|
98
126
|
const stagedHooks = [];
|
|
99
127
|
const stagedErrors = [];
|
|
128
|
+
let stagedCategories;
|
|
100
129
|
const api = {
|
|
130
|
+
projectCategories(def) {
|
|
131
|
+
if (!def || typeof def.categoriesOf !== 'function')
|
|
132
|
+
throw new Error('projectCategories needs a categoriesOf(projects) function');
|
|
133
|
+
if (result.categories || stagedCategories) {
|
|
134
|
+
stagedErrors.push(`project categories already come from ${result.categories?.owner ?? plugin.name}; this one is not used`);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
stagedCategories = {
|
|
138
|
+
categoriesOf: def.categoriesOf,
|
|
139
|
+
...(typeof def.label === 'string' && def.label.trim()
|
|
140
|
+
? { label: def.label.trim().slice(0, 40) }
|
|
141
|
+
: {}),
|
|
142
|
+
};
|
|
143
|
+
},
|
|
101
144
|
family(def) {
|
|
102
145
|
// The id becomes part of account refs and shell function names.
|
|
103
146
|
if (!/^[a-z][a-z0-9-]{0,31}$/.test(def.id))
|
|
@@ -107,19 +150,39 @@ async function register(plugin, bus, result, source, settings) {
|
|
|
107
150
|
throw new Error(`family ${def.id} is already provided by ${owner}`);
|
|
108
151
|
if (stagedFamilies.some((f) => f.id === def.id))
|
|
109
152
|
throw new Error(`family ${def.id} is registered twice`);
|
|
110
|
-
// A bad logo costs only
|
|
153
|
+
// A bad logo or website costs only that field: the Family still loads.
|
|
154
|
+
let clean = def;
|
|
111
155
|
if (def.logo !== undefined) {
|
|
112
156
|
const problem = logoProblem(def.logo);
|
|
113
157
|
if (problem) {
|
|
114
158
|
stagedErrors.push(`family ${def.id}: ${problem}; showing its initials instead`);
|
|
115
|
-
const { logo: _dropped, ...rest } =
|
|
116
|
-
|
|
117
|
-
|
|
159
|
+
const { logo: _dropped, ...rest } = clean;
|
|
160
|
+
clean = rest;
|
|
161
|
+
}
|
|
162
|
+
else
|
|
163
|
+
clean = { ...clean, logo: cleanLogo(def.logo) };
|
|
164
|
+
}
|
|
165
|
+
if (def.website !== undefined) {
|
|
166
|
+
const problem = websiteProblem(def.website);
|
|
167
|
+
if (problem) {
|
|
168
|
+
stagedErrors.push(`family ${def.id}: ${problem}; it has no "Open in browser" until this is fixed`);
|
|
169
|
+
const { website: _dropped, ...rest } = clean;
|
|
170
|
+
clean = rest;
|
|
171
|
+
}
|
|
172
|
+
else
|
|
173
|
+
clean = { ...clean, website: cleanWebsite(def.website) };
|
|
174
|
+
}
|
|
175
|
+
if (def.history !== undefined) {
|
|
176
|
+
const h = def.history;
|
|
177
|
+
const need = ['list', 'parse', 'messages', 'resumeArgs'].filter((k) => typeof h?.[k] !== 'function');
|
|
178
|
+
const opt = ['toolText', 'titles'].filter((k) => h?.[k] !== undefined && typeof h[k] !== 'function');
|
|
179
|
+
if (need.length || opt.length) {
|
|
180
|
+
stagedErrors.push(`family ${def.id}: history needs ${[...need, ...opt].join(', ')} as functions; it has no Session History until this is fixed`);
|
|
181
|
+
const { history: _dropped, ...rest } = clean;
|
|
182
|
+
clean = rest;
|
|
118
183
|
}
|
|
119
|
-
stagedFamilies.push({ ...def, logo: cleanLogo(def.logo) });
|
|
120
|
-
return;
|
|
121
184
|
}
|
|
122
|
-
stagedFamilies.push(
|
|
185
|
+
stagedFamilies.push(clean);
|
|
123
186
|
},
|
|
124
187
|
on(event, a, b) {
|
|
125
188
|
const [filter, handler] = typeof a === 'function' ? [{}, a] : [a, b];
|
|
@@ -143,6 +206,8 @@ async function register(plugin, bus, result, source, settings) {
|
|
|
143
206
|
}
|
|
144
207
|
for (const add of stagedHooks)
|
|
145
208
|
add();
|
|
209
|
+
if (stagedCategories)
|
|
210
|
+
result.categories = { def: stagedCategories, owner: plugin.name };
|
|
146
211
|
for (const message of stagedErrors)
|
|
147
212
|
result.errors.push({ where: plugin.name, message });
|
|
148
213
|
return stagedFamilies.map((f) => f.id);
|
package/dist/src/runtime.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { type DoctorHistory } from './core/last-doctor.ts';
|
|
|
10
10
|
import { type HostLaunch, type PreparedLaunch } from './core/launch.ts';
|
|
11
11
|
import { type Paths } from './core/paths.ts';
|
|
12
12
|
import { type PickChoice } from './core/pick-commands.ts';
|
|
13
|
+
import { type ProjectCategories } from './core/project-categories.ts';
|
|
13
14
|
import { type QuotaFetchMode } from './core/quota-fetch.ts';
|
|
14
15
|
import { type RemoteControlChange, type RemoteControlGroup } from './core/remote-control.ts';
|
|
15
16
|
import { type Shell, type ShellInitWrite } from './core/shell-init.ts';
|
|
@@ -163,6 +164,10 @@ export interface Runtime {
|
|
|
163
164
|
families: ReadonlyMap<string, FamilyDef>;
|
|
164
165
|
plugins: readonly LoadedPlugin[];
|
|
165
166
|
pluginErrors: readonly PluginLoadError[];
|
|
167
|
+
/** The Project Categories a Plugin gives these Projects (spec §3.33), or undefined when no Plugin sorts them. */
|
|
168
|
+
projectCategories(projects: string[]): Promise<ProjectCategories | undefined>;
|
|
169
|
+
/** The Plugin whose Project Categories are used, if any. */
|
|
170
|
+
projectCategoriesFrom?: string;
|
|
166
171
|
familyInfo(): Promise<FamilyInfo[]>;
|
|
167
172
|
/** Every loaded Family with its layout, sign-in, quota support and Shared Items (config extras included). */
|
|
168
173
|
familyDetails(): Promise<FamilyDetail[]>;
|
package/dist/src/runtime.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// The one service layer the CLI and the Panel share. Frozen contract for v0.1 (plan: 审核修订).
|
|
2
|
-
import { aliasesByAccount, discoverAccounts, resolveRef } from './core/accounts.js';
|
|
2
|
+
import { aliasesByAccount, discoverAccounts, resolveRef, startArgsOf, } from './core/accounts.js';
|
|
3
3
|
import { addConfigAlias, addConfigPickCommand, aliasAccount, aliasArgs, aliasProblem, aliasRefs, editConfigDisplay, editConfigQuotaCheck, handoffSettings, loadConfig, removeConfigAlias, removeConfigPickCommand, } from './core/config.js';
|
|
4
4
|
import { createAccount } from './core/create.js';
|
|
5
5
|
import { bindDesktopDeps, checkAppData } from './core/desktop-app.js';
|
|
@@ -10,11 +10,13 @@ import { planHandoff } from './core/handoff.js';
|
|
|
10
10
|
import { handoffFindings } from './core/handoff-doctor.js';
|
|
11
11
|
import { selectNext } from './core/handoff-select.js';
|
|
12
12
|
import { identityOf } from './core/identity.js';
|
|
13
|
+
import { inboundFindings } from './core/inbound.js';
|
|
13
14
|
import { mergeDoctorHistory, readDoctorHistory, writeDoctorHistory, } from './core/last-doctor.js';
|
|
14
15
|
import { accountEnv, brokenOnPath, launchCommand, prepareLaunch, which, } from './core/launch.js';
|
|
15
16
|
import { memoStore } from './core/memo-store.js';
|
|
16
17
|
import { resolvePaths } from './core/paths.js';
|
|
17
18
|
import { choosePick, suggestPickName } from './core/pick-commands.js';
|
|
19
|
+
import { categoryReader } from './core/project-categories.js';
|
|
18
20
|
import { fetchedQuota, quotaCheckOff, shownQuota } from './core/quota-fetch.js';
|
|
19
21
|
import { remoteControlGroups, turnRemoteControlOff, turnRemoteControlOn, undoRemoteControlOff, } from './core/remote-control.js';
|
|
20
22
|
import { findResumeRoute } from './core/resume.js';
|
|
@@ -24,6 +26,7 @@ import { SHELLS, shellInitScript, writeShellInitFile, } from './core/shell-init.
|
|
|
24
26
|
import { groupSuggestion, MAX_COMPACT_WINDOW, MIN_COMPACT_WINDOW, } from './core/tuning.js';
|
|
25
27
|
import { applyTune, planTuneApply, readTuneSettings, settingsFileOf, tuneUndoInfo, undoTune, } from './core/tuning-apply.js';
|
|
26
28
|
import { packageVersion } from './core/version.js';
|
|
29
|
+
import { withClaudeMod } from './families/claude/mod.js';
|
|
27
30
|
import { BUILTIN_PLUGINS } from './families/index.js';
|
|
28
31
|
import { LOGIN_KEY_READERS } from './families/login-keys.js';
|
|
29
32
|
import { HookBus } from './plugins/bus.js';
|
|
@@ -74,6 +77,7 @@ export async function createRuntime(opts = {}) {
|
|
|
74
77
|
home: paths.home,
|
|
75
78
|
});
|
|
76
79
|
const families = loaded.families;
|
|
80
|
+
const categories = loaded.categories && categoryReader(loaded.categories.def, loaded.categories.owner);
|
|
77
81
|
const ignore = new Set(config.ignore ?? []);
|
|
78
82
|
const now = opts.now ?? (() => new Date());
|
|
79
83
|
const familyOf = (id) => {
|
|
@@ -139,7 +143,10 @@ export async function createRuntime(opts = {}) {
|
|
|
139
143
|
Promise.all(list.map(async (a) => [a.ref, await ownQuota(a, mode)])).then((e) => new Map(e)),
|
|
140
144
|
groupsOf(list),
|
|
141
145
|
]);
|
|
142
|
-
return new Map(list.map((a) => [
|
|
146
|
+
return new Map(list.map((a) => [
|
|
147
|
+
a.ref,
|
|
148
|
+
sharedQuota(a.ref, own, groups.get(a.ref) ?? [], families.get(a.family)?.fetchQuota?.localFallbackOnly),
|
|
149
|
+
]));
|
|
143
150
|
};
|
|
144
151
|
/** A reader's own `from`, `fetched` and `fetchError` are dropped: only sideby sets them (spec §3.21, §3.26). */
|
|
145
152
|
const readerOnly = (q) => {
|
|
@@ -170,7 +177,7 @@ export async function createRuntime(opts = {}) {
|
|
|
170
177
|
// A signed-out Account has nothing to ask about; its kept answer still shows.
|
|
171
178
|
const ask = off || mode === 'never' || (await loginOf(account)) === 'logged-out' ? 'never' : mode;
|
|
172
179
|
const kept = await fetchedQuota(f.fetchQuota, account, readContext(), accountEnv(f, account, env), ask);
|
|
173
|
-
return shownQuota(local, kept, off);
|
|
180
|
+
return shownQuota(local, kept, off, f.fetchQuota.localFallbackOnly);
|
|
174
181
|
}
|
|
175
182
|
finally {
|
|
176
183
|
memos.saveSoon();
|
|
@@ -257,6 +264,8 @@ export async function createRuntime(opts = {}) {
|
|
|
257
264
|
families,
|
|
258
265
|
plugins: loaded.plugins,
|
|
259
266
|
pluginErrors: loaded.errors,
|
|
267
|
+
projectCategories: async (projects) => categories?.(projects),
|
|
268
|
+
...(loaded.categories ? { projectCategoriesFrom: loaded.categories.owner } : {}),
|
|
260
269
|
async familyInfo() {
|
|
261
270
|
return Promise.all([...families.values()].map(async (f) => {
|
|
262
271
|
const installed = (await which(f.bin, env)) !== null;
|
|
@@ -347,6 +356,7 @@ export async function createRuntime(opts = {}) {
|
|
|
347
356
|
},
|
|
348
357
|
async doctorWithHistory(o = {}) {
|
|
349
358
|
let list = await accounts();
|
|
359
|
+
const startArgs = startArgsOf(config, list);
|
|
350
360
|
let fams = families;
|
|
351
361
|
let scope = { kind: 'all' };
|
|
352
362
|
if (o.target) {
|
|
@@ -372,7 +382,11 @@ export async function createRuntime(opts = {}) {
|
|
|
372
382
|
// of that Family keeps its skill warning.
|
|
373
383
|
skillVersion: packageVersion(),
|
|
374
384
|
// Desktop App data folders sideby made for an Account (spec §3.20).
|
|
375
|
-
extraChecks: (a) =>
|
|
385
|
+
extraChecks: async (a) => [
|
|
386
|
+
...(await checkAppData(loaded.plugins, paths.home, a, Boolean(o.force))),
|
|
387
|
+
// Messages held in bypass permission mode (spec §3.32 step 2): the arguments the Account starts with.
|
|
388
|
+
...(await inboundFindings(a, startArgs(a))),
|
|
389
|
+
],
|
|
376
390
|
};
|
|
377
391
|
// Auto Handoff warnings (spec §3.17) join the general Findings; they never fail Doctor.
|
|
378
392
|
const all = await accounts();
|
|
@@ -605,13 +619,21 @@ export async function createRuntime(opts = {}) {
|
|
|
605
619
|
async prepareLaunch(ref, userArgs, command, opts = {}) {
|
|
606
620
|
const all = await accounts();
|
|
607
621
|
const inputs = launchInputs(ref, all, userArgs, command);
|
|
608
|
-
|
|
622
|
+
const p = await prepareLaunch({
|
|
609
623
|
...inputs,
|
|
610
624
|
...(opts.aiTask ? { aiTask: true } : {}),
|
|
611
625
|
label: launchLabel(ref, inputs.account, all),
|
|
612
626
|
baseEnv: env,
|
|
613
627
|
bus,
|
|
614
628
|
});
|
|
629
|
+
// sideby's Claude Code mod (spec §3.32 step 3): a view only, so it comes after every Plugin's `launch.before`.
|
|
630
|
+
if (command === 'run' && p.family.id === 'claude' && config.claudeMod !== false)
|
|
631
|
+
p.args = await withClaudeMod(p.args, {
|
|
632
|
+
bin: await which(p.bin, p.env),
|
|
633
|
+
env: p.env,
|
|
634
|
+
stateDir: paths.stateDir,
|
|
635
|
+
});
|
|
636
|
+
return p;
|
|
615
637
|
},
|
|
616
638
|
async launchCommand(ref, userArgs, command) {
|
|
617
639
|
const inputs = launchInputs(ref, await accounts(), userArgs, command);
|
package/dist/src/types.d.ts
CHANGED
|
@@ -34,11 +34,106 @@ export interface FamilyLogo {
|
|
|
34
34
|
title?: string;
|
|
35
35
|
fillRule?: 'nonzero' | 'evenodd';
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* A Family's vendor website, for Browser Sign-ins (spec §3.24, ADR-0043): "Open in browser" opens `url` in a Chrome
|
|
39
|
+
* browser user. sideby checks it when the Plugin registers; an invalid one is dropped with a plugin error.
|
|
40
|
+
*/
|
|
41
|
+
export interface FamilyWebsite {
|
|
42
|
+
/** An https address such as `https://cursor.com`: letters, digits and `.-_~/` only, no query or fragment. */
|
|
43
|
+
url: string;
|
|
44
|
+
/**
|
|
45
|
+
* How sideby finds the browser user signed in to an Account by itself. Without it the user picks one; a browser
|
|
46
|
+
* user whose Google account is the Account's login email is still found.
|
|
47
|
+
*/
|
|
48
|
+
match?: {
|
|
49
|
+
/** The website origin whose Local Storage key names may hold the id, such as `https://cursor.com`. */
|
|
50
|
+
origin: string;
|
|
51
|
+
/**
|
|
52
|
+
* The id the website puts in its Local Storage key names for this Account (8 characters or more), read from the
|
|
53
|
+
* Host's login file. It is compared in memory only: never shown, returned, logged or cached. Return undefined
|
|
54
|
+
* when there is none; a throw becomes an entry in the Browser Report's problems.
|
|
55
|
+
*/
|
|
56
|
+
signInId(account: Account): Promise<string | undefined>;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** One record file that holds one Session. */
|
|
60
|
+
export interface HistoryFile {
|
|
61
|
+
path: string;
|
|
62
|
+
/** Changes whenever what `parse` reads changes (size, mtime and inode of the files it reads). */
|
|
63
|
+
sig: string;
|
|
64
|
+
/** Last change of the file, ms; the newest files are read first. */
|
|
65
|
+
mtimeMs: number;
|
|
66
|
+
/** The Session id of the Session that started this one (a Claude subagent), when the file layout says so. */
|
|
67
|
+
parent?: string;
|
|
68
|
+
}
|
|
69
|
+
/** Where a Session Title came from: the user's own name, the Host's title, or the first prompt. */
|
|
70
|
+
export type TitleSource = 'user' | 'host' | 'prompt' | 'none';
|
|
71
|
+
/** A Session as a Family reads it from its record, before sideby adds the Account, Project and commands. */
|
|
72
|
+
export interface ParsedSession {
|
|
73
|
+
sessionId: string;
|
|
74
|
+
cwd?: string;
|
|
75
|
+
/** The repository root the Host recorded, used when `cwd` no longer exists (Grok's `git_root_dir`). */
|
|
76
|
+
gitRoot?: string;
|
|
77
|
+
title?: string;
|
|
78
|
+
titleFrom: TitleSource;
|
|
79
|
+
branch?: string;
|
|
80
|
+
model?: string;
|
|
81
|
+
startedAt?: string;
|
|
82
|
+
updatedAt?: string;
|
|
83
|
+
/** Prompts plus replies. */
|
|
84
|
+
messages: number;
|
|
85
|
+
/** A Script Session: started by a script, an SDK or another agent. */
|
|
86
|
+
script: boolean;
|
|
87
|
+
parent?: string;
|
|
88
|
+
/** What the person typed, injected context cut out. */
|
|
89
|
+
prompts: string[];
|
|
90
|
+
/** The text of the model's replies; never tool calls, tool output or reasoning. */
|
|
91
|
+
replies: string[];
|
|
92
|
+
/** True when the Session had more text than is kept for search (`SESSION_TEXT_MAX`). */
|
|
93
|
+
cut?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/** One entry of a Session as `sideby history show` and the Panel's viewer show it. */
|
|
96
|
+
export interface HistoryMessage {
|
|
97
|
+
role: 'user' | 'assistant' | 'tool';
|
|
98
|
+
text: string;
|
|
99
|
+
at?: string;
|
|
100
|
+
/** For `tool`: the tool's name. Its input and output are never shown. */
|
|
101
|
+
tool?: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* A plugin Family's Session History reader (spec §3.33, ADR-0044). It reads the Host's own session records
|
|
105
|
+
* read-only: never a credential file, and `parse` returns only what the person typed and the model's replies, never
|
|
106
|
+
* tool calls, tool output, injected context or reasoning, because sideby keeps that text in its History Index.
|
|
107
|
+
*/
|
|
108
|
+
export interface FamilyHistory {
|
|
109
|
+
/**
|
|
110
|
+
* The Account's record files, one per Session. A missing sessions folder is no Session; another error throws and
|
|
111
|
+
* is named for the Account. `sig` must change whenever what `parse` reads changes.
|
|
112
|
+
*/
|
|
113
|
+
list(account: Account, problems: string[]): Promise<HistoryFile[]>;
|
|
114
|
+
/** The Session in one file; undefined when it holds no Session (no id, nothing said). */
|
|
115
|
+
parse(file: HistoryFile, account: Account): Promise<ParsedSession | undefined>;
|
|
116
|
+
/** The Session's messages in order, for reading it. A tool entry gives the tool's name only. */
|
|
117
|
+
messages(path: string): AsyncIterable<HistoryMessage>;
|
|
118
|
+
/** The text of the Session's tool calls and results, read only while someone searches tool output. */
|
|
119
|
+
toolText?(path: string): AsyncIterable<string>;
|
|
120
|
+
/** Titles the Host keeps apart from the record, by Session id. */
|
|
121
|
+
titles?(account: Account): Promise<Map<string, string>>;
|
|
122
|
+
/** The Host arguments that resume a Session, for example `['--resume', id]`. */
|
|
123
|
+
resumeArgs(sessionId: string): string[];
|
|
124
|
+
}
|
|
37
125
|
export interface FamilyDef {
|
|
38
126
|
id: string;
|
|
39
127
|
title: string;
|
|
40
128
|
/** Mark shown on the Panel's cards, lists and the Tool select; without one the Panel shows the id's initials. */
|
|
41
129
|
logo?: FamilyLogo;
|
|
130
|
+
/** The vendor website "Open in browser" goes to (spec §3.24). Built-in Families have theirs set by sideby. */
|
|
131
|
+
website?: FamilyWebsite;
|
|
132
|
+
/**
|
|
133
|
+
* How sideby reads this Host's past Sessions for Session History (spec §3.33, ADR-0044). Without it the Family's
|
|
134
|
+
* Accounts are listed as having no history sideby can read.
|
|
135
|
+
*/
|
|
136
|
+
history?: FamilyHistory;
|
|
42
137
|
/** Host executable looked up on PATH. */
|
|
43
138
|
bin: string;
|
|
44
139
|
installUrl: string;
|
|
@@ -124,7 +219,7 @@ export interface FamilyDef {
|
|
|
124
219
|
readQuota?(account: Account, ctx: ReadContext): Promise<QuotaResult>;
|
|
125
220
|
/**
|
|
126
221
|
* Quota that costs a request, such as asking the Host's own CLI (spec §3.26, ADR-0025). sideby decides when to call
|
|
127
|
-
* it and keeps its last answer; the newer of that answer and `readQuota`'s is shown
|
|
222
|
+
* it and keeps its last answer; the newer of that answer and `readQuota`'s is shown unless `localFallbackOnly`.
|
|
128
223
|
*/
|
|
129
224
|
fetchQuota?: QuotaFetch;
|
|
130
225
|
readUsage?(account: Account, ctx: ReadContext): Promise<UsageResult>;
|
|
@@ -262,6 +357,11 @@ export interface QuotaFetch {
|
|
|
262
357
|
everyMinutes: number;
|
|
263
358
|
/** What a fetch does, in one plain sentence, shown next to the setting that turns it off. */
|
|
264
359
|
summary: string;
|
|
360
|
+
/**
|
|
361
|
+
* Use local readings only until a successful fetch exists (default false). For Hosts that replay cached quota
|
|
362
|
+
* with new event timestamps, those events must not overwrite a fetched answer (Codex, ADR-0038).
|
|
363
|
+
*/
|
|
364
|
+
localFallbackOnly?: boolean;
|
|
265
365
|
/**
|
|
266
366
|
* The Account's Quota now. An error, or an `unavailable` result, keeps the last good answer on show. Stop when
|
|
267
367
|
* `ctx.signal` aborts (after 20 seconds).
|
|
@@ -493,8 +593,23 @@ export interface PluginFs {
|
|
|
493
593
|
/** Atomic write via a temp file in the same directory; `mode` defaults to 0o600. */
|
|
494
594
|
writeFileAtomic(path: string, data: string | Uint8Array, mode?: number): Promise<void>;
|
|
495
595
|
}
|
|
596
|
+
/**
|
|
597
|
+
* Sorts Projects into Project Categories for Session History (spec §3.33): the Panel can group Sessions by them and
|
|
598
|
+
* nest Projects under them. Only the first Plugin that registers one is used.
|
|
599
|
+
*/
|
|
600
|
+
export interface ProjectCategoriesDef {
|
|
601
|
+
/** What the categories are called on screen, for example "Workspace"; "Category" when left out. */
|
|
602
|
+
label?: string;
|
|
603
|
+
/**
|
|
604
|
+
* The category of each Project path it knows, asked for many paths at once; leave a path out when it has none.
|
|
605
|
+
* Answers are kept for about a minute, and one that takes longer than 3 s counts as failed.
|
|
606
|
+
*/
|
|
607
|
+
categoriesOf(projects: string[]): Record<string, string> | Promise<Record<string, string>>;
|
|
608
|
+
}
|
|
496
609
|
export interface PluginApi {
|
|
497
610
|
family(def: FamilyDef): void;
|
|
611
|
+
/** Registers this Plugin's Project Categories; see ProjectCategoriesDef. */
|
|
612
|
+
projectCategories(def: ProjectCategoriesDef): void;
|
|
498
613
|
on<E extends HookEvent>(event: E, handler: HookHandler<E>): void;
|
|
499
614
|
on<E extends HookEvent>(event: E, filter: HookFilter, handler: HookHandler<E>): void;
|
|
500
615
|
/**
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -22,6 +22,11 @@ export interface FakeHostOptions {
|
|
|
22
22
|
* the file a Host hook would write. It may call `process.exit`.
|
|
23
23
|
*/
|
|
24
24
|
onStart?: string;
|
|
25
|
+
/**
|
|
26
|
+
* What the fake prints for `--version`, as the real Host does (`2.1.304 (Claude Code)`). `--version` is answered
|
|
27
|
+
* without a start record either way; left out, it prints nothing, as a Host whose version cannot be told.
|
|
28
|
+
*/
|
|
29
|
+
version?: string;
|
|
25
30
|
}
|
|
26
31
|
/**
|
|
27
32
|
* Installs a fake Host executable named `name` that appends its argv, selected env and received signals
|
package/dist/testing/index.js
CHANGED
|
@@ -57,6 +57,11 @@ export async function fakeHost(h, name, opts = {}) {
|
|
|
57
57
|
const fs = require('node:fs')
|
|
58
58
|
const log = ${JSON.stringify(log)}
|
|
59
59
|
const rec = (o) => fs.appendFileSync(log, JSON.stringify(o) + '\\n')
|
|
60
|
+
// A version question starts no session, so it leaves no record.
|
|
61
|
+
if (process.argv.length === 3 && process.argv[2] === '--version') {
|
|
62
|
+
process.stdout.write(${JSON.stringify(opts.version ? `${opts.version}\n` : '')})
|
|
63
|
+
process.exit(0)
|
|
64
|
+
}
|
|
60
65
|
// Handlers first: tests signal the Host as soon as the start record appears.
|
|
61
66
|
for (const s of ['SIGINT', 'SIGTERM', 'SIGHUP', 'SIGQUIT']) process.on(s, () => { rec({ signal: s }); process.exit(${opts.sleep ? 100 : 0}) })
|
|
62
67
|
rec({ argv: process.argv.slice(2), env: process.env, pid: process.pid })
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "modules": ["./register.js"] }
|