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.
Files changed (161) hide show
  1. package/README.md +7 -4
  2. package/ai-tasks.json +28 -0
  3. package/dist/build.json +1 -1
  4. package/dist/src/cli/commands.d.ts +22 -1
  5. package/dist/src/cli/commands.js +815 -21
  6. package/dist/src/cli/format.d.ts +4 -0
  7. package/dist/src/cli/format.js +42 -4
  8. package/dist/src/cli/json-schemas.js +334 -4
  9. package/dist/src/cli/main.js +159 -13
  10. package/dist/src/core/accounts.d.ts +6 -0
  11. package/dist/src/core/accounts.js +12 -0
  12. package/dist/src/core/autostart.d.ts +11 -0
  13. package/dist/src/core/autostart.js +32 -5
  14. package/dist/src/core/browser-profiles.d.ts +23 -2
  15. package/dist/src/core/browser-profiles.js +148 -37
  16. package/dist/src/core/claude-settings-file.d.ts +18 -0
  17. package/dist/src/core/claude-settings-file.js +52 -3
  18. package/dist/src/core/config.d.ts +5 -0
  19. package/dist/src/core/config.js +12 -1
  20. package/dist/src/core/edit-settings.d.ts +7 -0
  21. package/dist/src/core/edit-settings.js +10 -5
  22. package/dist/src/core/file-memo.js +26 -4
  23. package/dist/src/core/history-group.d.ts +28 -0
  24. package/dist/src/core/history-group.js +47 -0
  25. package/dist/src/core/history-index.d.ts +145 -0
  26. package/dist/src/core/history-index.js +447 -0
  27. package/dist/src/core/history-project.d.ts +13 -0
  28. package/dist/src/core/history-project.js +87 -0
  29. package/dist/src/core/history.d.ts +210 -0
  30. package/dist/src/core/history.js +952 -0
  31. package/dist/src/core/inbound.d.ts +62 -0
  32. package/dist/src/core/inbound.js +215 -0
  33. package/dist/src/core/launch.d.ts +9 -1
  34. package/dist/src/core/launch.js +58 -24
  35. package/dist/src/core/live-sessions-copy.d.ts +5 -0
  36. package/dist/src/core/live-sessions-copy.js +46 -0
  37. package/dist/src/core/live-sessions-procs.d.ts +89 -0
  38. package/dist/src/core/live-sessions-procs.js +296 -0
  39. package/dist/src/core/live-sessions-title.d.ts +28 -0
  40. package/dist/src/core/live-sessions-title.js +80 -0
  41. package/dist/src/core/live-sessions.d.ts +68 -0
  42. package/dist/src/core/live-sessions.js +163 -0
  43. package/dist/src/core/login-check.d.ts +15 -0
  44. package/dist/src/core/login-check.js +32 -0
  45. package/dist/src/core/messages.d.ts +83 -0
  46. package/dist/src/core/messages.js +433 -0
  47. package/dist/src/core/project-categories.d.ts +14 -0
  48. package/dist/src/core/project-categories.js +48 -0
  49. package/dist/src/core/quota-fetch.d.ts +3 -3
  50. package/dist/src/core/quota-fetch.js +5 -5
  51. package/dist/src/core/quota-levels.d.ts +5 -0
  52. package/dist/src/core/quota-levels.js +5 -0
  53. package/dist/src/core/remote-control.d.ts +2 -0
  54. package/dist/src/core/remote-control.js +34 -59
  55. package/dist/src/core/run-link.d.ts +76 -0
  56. package/dist/src/core/run-link.js +245 -0
  57. package/dist/src/core/same-login.d.ts +4 -3
  58. package/dist/src/core/same-login.js +10 -7
  59. package/dist/src/core/session-select.d.ts +31 -0
  60. package/dist/src/core/session-select.js +44 -0
  61. package/dist/src/families/browser.d.ts +7 -18
  62. package/dist/src/families/browser.js +19 -8
  63. package/dist/src/families/claude/deliver.d.ts +2 -0
  64. package/dist/src/families/claude/deliver.js +43 -0
  65. package/dist/src/families/claude/history.d.ts +2 -0
  66. package/dist/src/families/claude/history.js +192 -0
  67. package/dist/src/families/claude/live-sessions.d.ts +13 -0
  68. package/dist/src/families/claude/live-sessions.js +117 -0
  69. package/dist/src/families/claude/messaging.d.ts +69 -0
  70. package/dist/src/families/claude/messaging.js +165 -0
  71. package/dist/src/families/claude/mod.d.ts +26 -0
  72. package/dist/src/families/claude/mod.js +105 -0
  73. package/dist/src/families/claude/session-files.d.ts +21 -0
  74. package/dist/src/families/claude/session-files.js +54 -0
  75. package/dist/src/families/codex/deliver.d.ts +5 -0
  76. package/dist/src/families/codex/deliver.js +76 -0
  77. package/dist/src/families/codex/history.d.ts +7 -0
  78. package/dist/src/families/codex/history.js +174 -0
  79. package/dist/src/families/codex/index.js +2 -0
  80. package/dist/src/families/codex/live-sessions.d.ts +12 -0
  81. package/dist/src/families/codex/live-sessions.js +193 -0
  82. package/dist/src/families/codex/quota.d.ts +3 -0
  83. package/dist/src/families/codex/quota.js +123 -0
  84. package/dist/src/families/codex/rate-limits.js +2 -0
  85. package/dist/src/families/codex/rollout.js +1 -1
  86. package/dist/src/families/grok/browser.d.ts +3 -0
  87. package/dist/src/families/grok/browser.js +5 -0
  88. package/dist/src/families/grok/history.d.ts +2 -0
  89. package/dist/src/families/grok/history.js +157 -0
  90. package/dist/src/families/grok/live-sessions.d.ts +4 -0
  91. package/dist/src/families/grok/live-sessions.js +80 -0
  92. package/dist/src/families/grok/login-key.d.ts +14 -0
  93. package/dist/src/families/grok/login-key.js +37 -0
  94. package/dist/src/families/history.d.ts +20 -0
  95. package/dist/src/families/history.js +81 -0
  96. package/dist/src/families/live-sessions.d.ts +26 -0
  97. package/dist/src/families/live-sessions.js +9 -0
  98. package/dist/src/families/login-keys.js +5 -1
  99. package/dist/src/families/messaging.d.ts +27 -0
  100. package/dist/src/families/messaging.js +6 -0
  101. package/dist/src/families/pi/history.d.ts +2 -0
  102. package/dist/src/families/pi/history.js +124 -0
  103. package/dist/src/families/pi/live-sessions.d.ts +2 -0
  104. package/dist/src/families/pi/live-sessions.js +70 -0
  105. package/dist/src/families/shared/history-text.d.ts +65 -0
  106. package/dist/src/families/shared/history-text.js +261 -0
  107. package/dist/src/menubar/hotkey.d.ts +86 -0
  108. package/dist/src/menubar/hotkey.js +159 -0
  109. package/dist/src/menubar/script.d.ts +2 -0
  110. package/dist/src/menubar/script.js +118 -22
  111. package/dist/src/menubar/snapshot.d.ts +8 -4
  112. package/dist/src/menubar/snapshot.js +45 -13
  113. package/dist/src/menubar/strings.d.ts +24 -6
  114. package/dist/src/menubar/strings.js +24 -6
  115. package/dist/src/panel/handler.d.ts +69 -0
  116. package/dist/src/panel/handler.js +686 -15
  117. package/dist/src/panel/i18n.d.ts +304 -3
  118. package/dist/src/panel/i18n.js +669 -67
  119. package/dist/src/panel/orca.d.ts +48 -0
  120. package/dist/src/panel/orca.js +153 -0
  121. package/dist/src/panel/page-logic.d.ts +255 -13
  122. package/dist/src/panel/page-logic.js +483 -1
  123. package/dist/src/panel/page-script.js +2265 -207
  124. package/dist/src/panel/page-styles.js +404 -32
  125. package/dist/src/panel/page.js +1 -0
  126. package/dist/src/plugins/account-script.js +61 -27
  127. package/dist/src/plugins/check.js +16 -4
  128. package/dist/src/plugins/loader.d.ts +8 -1
  129. package/dist/src/plugins/loader.js +72 -7
  130. package/dist/src/runtime.d.ts +5 -0
  131. package/dist/src/runtime.js +27 -5
  132. package/dist/src/types.d.ts +116 -1
  133. package/dist/testing/index.d.ts +5 -0
  134. package/dist/testing/index.js +5 -0
  135. package/mods/claude/.claude-plugin/plugin.json +7 -0
  136. package/mods/claude/hooks/hooks.json +1 -0
  137. package/mods/claude/hooks/register.js +261 -0
  138. package/package.json +5 -2
  139. package/schemas/autostart.json +74 -1
  140. package/schemas/browser-set.json +110 -0
  141. package/schemas/browser.json +22 -2
  142. package/schemas/config.json +26 -1
  143. package/schemas/history-index.json +209 -0
  144. package/schemas/history-projects.json +133 -0
  145. package/schemas/history-show.json +275 -0
  146. package/schemas/history.json +410 -0
  147. package/schemas/menubar-hotkey.json +139 -0
  148. package/schemas/menubar-snapshot.json +36 -2
  149. package/schemas/menubar.json +74 -1
  150. package/schemas/messages-inbound.json +258 -0
  151. package/schemas/messages.json +164 -0
  152. package/schemas/send.json +165 -0
  153. package/schemas/sessions-copy.json +113 -0
  154. package/schemas/sessions-open-run.json +97 -0
  155. package/schemas/sessions.json +237 -0
  156. package/skills/sideby/SKILL.md +10 -5
  157. package/skills/sideby/references/accounts.md +11 -0
  158. package/skills/sideby/references/ai-tasks.md +17 -1
  159. package/skills/sideby/references/panel.md +6 -4
  160. package/skills/sideby/references/quota.md +2 -2
  161. package/skills/sideby/references/sessions.md +79 -0
@@ -0,0 +1,48 @@
1
+ import type { Env } from '../types.ts';
2
+ export declare const ORCA_HANDLE_VAR = "ORCA_TERMINAL_HANDLE";
3
+ /** Where the Orca app keeps its CLI on macOS, for a user who never added `orca` to PATH. */
4
+ export declare const ORCA_APP_CLI = "/Applications/Orca.app/Contents/Resources/bin/orca";
5
+ export interface OrcaDeps {
6
+ /**
7
+ * Runs the Orca CLI with these arguments: its exit code and output. Throws only when Orca cannot be run or does not
8
+ * finish in time.
9
+ */
10
+ run(args: string[]): Promise<{
11
+ exitCode: number;
12
+ stdout: string;
13
+ }>;
14
+ /** The value of one environment variable of a running process. */
15
+ envVar(pid: number, name: string): Promise<string | undefined>;
16
+ }
17
+ /** The only texts a failed switch shows, so nothing of the command, the handle or Orca's output reaches the page. */
18
+ export declare const ORCA_MESSAGES: {
19
+ readonly notRunning: 'Orca is not running or did not answer. Open Orca and try again.';
20
+ readonly gone: 'That Orca tab no longer exists. Refresh the list and try again.';
21
+ readonly unconfirmed: 'Orca did not confirm the switch. Look in Orca, then try again.';
22
+ };
23
+ /**
24
+ * Runs a program without a shell and always settles: after `timeoutMs` it gets SIGTERM, and SIGKILL `graceMs` later if
25
+ * it is still there. Gives the exit code and stdout; stderr is dropped. Rejects when the program cannot start, does
26
+ * not finish, or prints more than 8 MB.
27
+ */
28
+ export declare function runBounded(file: string, args: string[], env: Env, opts?: {
29
+ timeoutMs?: number;
30
+ graceMs?: number;
31
+ }): Promise<{
32
+ exitCode: number;
33
+ stdout: string;
34
+ }>;
35
+ /** The real Orca CLI (`orca` on PATH, else the macOS app's copy) and the real process environment reader. */
36
+ export declare function systemOrca(env: Env): OrcaDeps;
37
+ /** The handles of the terminals Orca runs now; empty when Orca is missing, not running or answers something else. */
38
+ export declare function orcaHandles(deps: OrcaDeps): Promise<Set<string>>;
39
+ /**
40
+ * The Orca terminal of each Session that runs in one, by Session id. Asks Orca only when some Session has a process
41
+ * id; a Session whose process has no listed handle is left out.
42
+ */
43
+ export declare function orcaTabs(deps: OrcaDeps, sessions: readonly {
44
+ sessionId: string;
45
+ pid?: number;
46
+ }[]): Promise<Map<string, string>>;
47
+ /** Brings one Orca terminal tab to the front; a refusal throws one of ORCA_MESSAGES and nothing else. */
48
+ export declare function switchOrcaTab(deps: OrcaDeps, handle: string): Promise<void>;
@@ -0,0 +1,153 @@
1
+ // "Go to its Orca tab" on the Sessions page (spec §3.32, ADR-0039). Orca sets `ORCA_TERMINAL_HANDLE` in every
2
+ // terminal it runs, and `orca terminal list --json` lists the handles of its live terminals: a Live Session whose Host
3
+ // process carries a listed handle runs in that tab. A handle that is not listed (Orca restarted, the tab closed) offers
4
+ // nothing. Tried with Orca 1.4.230 on macOS on 2026-10-20. Every Orca call goes through OrcaDeps, without a shell.
5
+ // What the page gets back is one of three fixed sentences: never the command, the handle or anything Orca printed.
6
+ import { spawn } from 'node:child_process';
7
+ import { access, constants } from 'node:fs/promises';
8
+ import { UserError } from '../core/errors.js';
9
+ import { which } from '../core/launch.js';
10
+ import { systemDeps } from '../core/live-sessions-procs.js';
11
+ export const ORCA_HANDLE_VAR = 'ORCA_TERMINAL_HANDLE';
12
+ /** Where the Orca app keeps its CLI on macOS, for a user who never added `orca` to PATH. */
13
+ export const ORCA_APP_CLI = '/Applications/Orca.app/Contents/Resources/bin/orca';
14
+ /** The only texts a failed switch shows, so nothing of the command, the handle or Orca's output reaches the page. */
15
+ export const ORCA_MESSAGES = {
16
+ notRunning: 'Orca is not running or did not answer. Open Orca and try again.',
17
+ gone: 'That Orca tab no longer exists. Refresh the list and try again.',
18
+ unconfirmed: 'Orca did not confirm the switch. Look in Orca, then try again.',
19
+ };
20
+ /** Orca error codes that mean the terminal is gone (Orca 1.4.230 answers `terminal_handle_stale`). */
21
+ const GONE_CODES = new Set(['terminal_handle_stale', 'terminal_not_found']);
22
+ const MAX_OUTPUT = 8 * 1024 * 1024;
23
+ /**
24
+ * Runs a program without a shell and always settles: after `timeoutMs` it gets SIGTERM, and SIGKILL `graceMs` later if
25
+ * it is still there. Gives the exit code and stdout; stderr is dropped. Rejects when the program cannot start, does
26
+ * not finish, or prints more than 8 MB.
27
+ */
28
+ export function runBounded(file, args, env, opts = {}) {
29
+ const timeoutMs = opts.timeoutMs ?? 5000;
30
+ const graceMs = opts.graceMs ?? 1000;
31
+ return new Promise((resolve, reject) => {
32
+ let settled = false;
33
+ let stdout = '';
34
+ let failure;
35
+ const child = spawn(file, args, { env: env, stdio: ['ignore', 'pipe', 'ignore'] });
36
+ let killTimer;
37
+ const stop = (why) => {
38
+ failure ??= why;
39
+ child.kill('SIGTERM');
40
+ killTimer ??= setTimeout(() => child.kill('SIGKILL'), graceMs);
41
+ // The last word: a child that survives even SIGKILL (or never reports its exit) still ends the call.
42
+ setTimeout(() => finish(), graceMs + 500).unref();
43
+ };
44
+ const finish = (exitCode) => {
45
+ if (settled)
46
+ return;
47
+ settled = true;
48
+ clearTimeout(timer);
49
+ clearTimeout(killTimer);
50
+ if (failure || typeof exitCode !== 'number')
51
+ reject(failure ?? new Error('the program did not finish'));
52
+ else
53
+ resolve({ exitCode, stdout });
54
+ };
55
+ const timer = setTimeout(() => stop(new Error('the program did not finish in time')), timeoutMs);
56
+ child.stdout.setEncoding('utf8');
57
+ child.stdout.on('data', (chunk) => {
58
+ stdout += chunk;
59
+ if (stdout.length > MAX_OUTPUT)
60
+ stop(new Error('the program printed too much'));
61
+ });
62
+ child.on('error', (err) => {
63
+ failure ??= err;
64
+ finish();
65
+ });
66
+ child.on('close', (code) => finish(code));
67
+ });
68
+ }
69
+ /** The real Orca CLI (`orca` on PATH, else the macOS app's copy) and the real process environment reader. */
70
+ export function systemOrca(env) {
71
+ const bin = async () => {
72
+ const onPath = await which('orca', env);
73
+ if (onPath)
74
+ return onPath;
75
+ if (process.platform === 'darwin') {
76
+ try {
77
+ await access(ORCA_APP_CLI, constants.X_OK);
78
+ return ORCA_APP_CLI;
79
+ }
80
+ catch { }
81
+ }
82
+ throw new Error('Orca is not installed');
83
+ };
84
+ const procs = systemDeps(env);
85
+ return {
86
+ run: async (args) => runBounded(await bin(), args, env),
87
+ envVar: (pid, name) => procs.envVar(pid, name),
88
+ };
89
+ }
90
+ /** Orca's JSON answer when it is an object that says `ok: true` and the CLI exited 0; else undefined. */
91
+ function confirmed(answer) {
92
+ try {
93
+ const out = JSON.parse(answer.stdout);
94
+ if (answer.exitCode !== 0 || !out || typeof out !== 'object' || Array.isArray(out))
95
+ return undefined;
96
+ return out.ok === true ? out : undefined;
97
+ }
98
+ catch {
99
+ return undefined;
100
+ }
101
+ }
102
+ /** The handles of the terminals Orca runs now; empty when Orca is missing, not running or answers something else. */
103
+ export async function orcaHandles(deps) {
104
+ try {
105
+ const out = confirmed(await deps.run(['terminal', 'list', '--json', '--limit', '1000']));
106
+ const terminals = out?.result?.terminals;
107
+ if (!Array.isArray(terminals))
108
+ return new Set();
109
+ return new Set(terminals
110
+ .filter((t) => !!t && typeof t.handle === 'string' && t.handle !== '' && t.connected !== false)
111
+ .map((t) => t.handle));
112
+ }
113
+ catch {
114
+ return new Set();
115
+ }
116
+ }
117
+ /**
118
+ * The Orca terminal of each Session that runs in one, by Session id. Asks Orca only when some Session has a process
119
+ * id; a Session whose process has no listed handle is left out.
120
+ */
121
+ export async function orcaTabs(deps, sessions) {
122
+ const out = new Map();
123
+ const withPid = sessions.filter((s) => typeof s.pid === 'number' && s.pid > 0);
124
+ if (!withPid.length)
125
+ return out;
126
+ const live = await orcaHandles(deps);
127
+ if (!live.size)
128
+ return out;
129
+ await Promise.all(withPid.map(async (s) => {
130
+ const handle = await deps.envVar(s.pid, ORCA_HANDLE_VAR).catch(() => undefined);
131
+ if (handle && live.has(handle))
132
+ out.set(s.sessionId, handle);
133
+ }));
134
+ return out;
135
+ }
136
+ /** Brings one Orca terminal tab to the front; a refusal throws one of ORCA_MESSAGES and nothing else. */
137
+ export async function switchOrcaTab(deps, handle) {
138
+ let answer;
139
+ try {
140
+ answer = await deps.run(['terminal', 'switch', '--terminal', handle, '--json']);
141
+ }
142
+ catch {
143
+ throw new UserError(ORCA_MESSAGES.notRunning);
144
+ }
145
+ if (confirmed(answer))
146
+ return;
147
+ let code;
148
+ try {
149
+ code = JSON.parse(answer.stdout)?.error?.code;
150
+ }
151
+ catch { }
152
+ throw new UserError(typeof code === 'string' && GONE_CODES.has(code) ? ORCA_MESSAGES.gone : ORCA_MESSAGES.unconfirmed);
153
+ }
@@ -32,18 +32,22 @@ export interface LogicAccount {
32
32
  };
33
33
  /** The other Accounts of its Same Login (spec §3.21). */
34
34
  sameLogin?: string[];
35
- usage?: {
36
- status: string;
37
- inputTokens?: number;
38
- cacheReadTokens?: number;
39
- cacheWriteTokens?: number;
40
- totalTokens?: number;
41
- daily?: {
42
- date: string;
43
- totalTokens: number;
44
- }[];
45
- lastActivityAt?: string;
46
- };
35
+ usage?: LogicUsage;
36
+ }
37
+ /** The parts of an Account's usage the helpers read. */
38
+ export interface LogicUsage {
39
+ status: string;
40
+ sessions?: number;
41
+ inputTokens?: number;
42
+ outputTokens?: number;
43
+ cacheReadTokens?: number;
44
+ cacheWriteTokens?: number;
45
+ totalTokens?: number;
46
+ daily?: {
47
+ date: string;
48
+ totalTokens: number;
49
+ }[];
50
+ lastActivityAt?: string;
47
51
  }
48
52
  /** A short countdown such as `2h 05m`, `3d 4h` or `12m` (`2小时05分` in Chinese); fixed shape so it does not jump. */
49
53
  export declare function formatDuration(ms: number, lang: string): string;
@@ -162,6 +166,11 @@ export declare function mergeDaily(lists: ({
162
166
  date: string;
163
167
  totalTokens: number;
164
168
  }[];
169
+ /**
170
+ * One usage for the directories of a Same Login (spec §3.21): their token counts and days added up, their newest
171
+ * use. Directories without readable usage are left out; with none readable it is the first one's usage as it is.
172
+ */
173
+ export declare function mergeUsage(usages: (LogicUsage | undefined)[]): LogicUsage | undefined;
165
174
  /** The soonest Quota reset still ahead of `now`, with the window label and Account. */
166
175
  export declare function nextReset(accounts: LogicAccount[], now: number): {
167
176
  at: number;
@@ -291,6 +300,119 @@ export declare function updatedAge(ms: number): {
291
300
  key: string;
292
301
  n?: number;
293
302
  };
303
+ /** What the Sessions page needs of a Live Session (spec §3.32); the full shape is `LiveSession` in core/live-sessions.ts. */
304
+ export interface LogicSession {
305
+ account: string;
306
+ accountLabel?: string;
307
+ sessionId: string;
308
+ title?: string;
309
+ label?: string;
310
+ status: string;
311
+ cwd?: string;
312
+ startedAt?: string;
313
+ updatedAt?: string;
314
+ }
315
+ /**
316
+ * The Sessions page order: a Session that needs the user first, then the most recent activity (`updatedAt`, else
317
+ * `startedAt`), then the label, so two answers with the same Sessions keep the same order.
318
+ */
319
+ export declare function sortSessions<T extends LogicSession>(list: readonly T[]): T[];
320
+ /**
321
+ * The order a refresh shows: Sessions already on screen keep their places (`shown`, their ids in screen order), so a
322
+ * Session that just answered does not jump past another. A Session that needs the user still goes first, and one not
323
+ * shown before comes ahead of the shown ones, in `sortSessions` order.
324
+ */
325
+ export declare function steadyOrder<T extends LogicSession>(shown: readonly string[], list: readonly T[]): T[];
326
+ /** How long ago a Session was last active, as a message key and count; null when it has no time at all. */
327
+ export declare function sessionAge(s: LogicSession, now: number): {
328
+ key: string;
329
+ n?: number;
330
+ } | null;
331
+ /**
332
+ * The three parts of a Session Label as the row shows them: the Account's short name (bold), the Host's title (the
333
+ * working directory's name when the Host gave none) and the first 8 characters of the id (monospace).
334
+ */
335
+ export declare function sessionLabelParts(s: LogicSession): {
336
+ account: string;
337
+ title: string;
338
+ id: string;
339
+ };
340
+ /** What "Send to it" needs of a Message receipt (spec §3.32 step 2); the full shape is `MessageReceipt` in core/messages.ts. */
341
+ export interface LogicMessage {
342
+ status: string;
343
+ pasteText?: string;
344
+ note?: string;
345
+ needsApproval?: boolean;
346
+ }
347
+ /**
348
+ * What the "Send to it" dialog shows after a send: `done` (the Host took it; `hint` is any note, shown as a yellow
349
+ * hint), `approve` (it took it, but the target shows it only once the user approves it there; `reason` says how, ADR-0045),
350
+ * `paste` (the user pastes `pasteText`; `reason` says why, `jump` offers the
351
+ * target's Orca tab) or `stored` (kept as a file only; `pasteText` for reference). `key` is the headline's message key.
352
+ */
353
+ export declare function sendResultView(m: LogicMessage, orca: boolean): {
354
+ kind: 'done' | 'approve' | 'paste' | 'stored';
355
+ key: string;
356
+ pasteText: string;
357
+ reason: string;
358
+ hint: string;
359
+ jump: boolean;
360
+ };
361
+ /** The chip a Sessions row shows for the latest Message to it, or null when there is none worth showing. */
362
+ export declare function messageChip(status: string | undefined, needsApproval?: boolean): {
363
+ key: string;
364
+ tone: 'ok' | 'warn' | 'accent';
365
+ } | null;
366
+ /** The latest Message to one Session, as `/api/sessions/messages` gives it (`PanelMessageStatus` in handler.ts). */
367
+ export interface LogicMessageStatus {
368
+ id: string;
369
+ status: string;
370
+ sentAt?: string;
371
+ to?: string;
372
+ from?: string;
373
+ needsApproval?: boolean;
374
+ }
375
+ /** A Session Label without its short id: `cc002 · knip cleanup · 61230c3d` → `cc002 · knip cleanup`. */
376
+ export declare function shortSessionLabel(label: string | undefined): string;
377
+ export type MessageNewsKind = 'new' | 'approve' | 'read' | 'paste';
378
+ /**
379
+ * What changed between two readings of the latest Messages, for the Panel's notices (spec §3.32): `new` (a Message
380
+ * reached a Session), `approve` (it reached one that shows it only once the user approves it, ADR-0045), `read` (its
381
+ * Session read it) or `paste` (it waits for the user to paste it). The first reading (`before` null) only sets the
382
+ * baseline, so opening the Panel announces nothing that was already there.
383
+ */
384
+ export declare function messageNews(before: Record<string, LogicMessageStatus> | null, after: Record<string, LogicMessageStatus>): {
385
+ kind: MessageNewsKind;
386
+ sessionId: string;
387
+ id: string;
388
+ to: string;
389
+ from: string;
390
+ }[];
391
+ /**
392
+ * Whether "Send to it" must wait: any screenshot that failed (refused, or its upload broke) stops the send, so a
393
+ * message never goes without a picture the user added. `names` lists them for the note; null lets it go.
394
+ */
395
+ export declare function sendBlock(files: readonly {
396
+ name: string;
397
+ status: string;
398
+ }[]): {
399
+ key: 'send.blocked';
400
+ names: string;
401
+ } | null;
402
+ /**
403
+ * Why "Send to it" refuses a file before uploading it, as a message key, or null when it may go: images only (PNG,
404
+ * JPEG, GIF, WebP), at most 20 MB each, at most 5. `kept` is how many the dialog already holds. The server checks all
405
+ * three again; this only says it sooner.
406
+ */
407
+ export declare function sendFileProblem(file: {
408
+ type?: string;
409
+ size: number;
410
+ }, kept: number): 'send.max' | 'send.notImage' | 'send.tooBig' | null;
411
+ /**
412
+ * A working directory short enough for one row: whole when it fits in `max` characters, else its root (`~` or the
413
+ * first folder) and its last two folders around an ellipsis, else only the end. Empty when there is none.
414
+ */
415
+ export declare function shortCwd(cwd: string | undefined, max?: number): string;
294
416
  /**
295
417
  * The Panel's language: a host `lang` of `en` or `zh` wins; `auto` uses the viewer's saved choice, then the browser
296
418
  * language (`zh*` gives Chinese, anything else English).
@@ -390,7 +512,7 @@ export declare function stripSecrets(text: string): {
390
512
  removed: boolean;
391
513
  };
392
514
  /** The kinds of AI Task (spec §3.28); anything else is refused. */
393
- export declare const AI_TASK_KINDS: readonly ['free', 'fix', 'quota', 'account', 'host', 'plugin', 'terminal', 'handoff'];
515
+ export declare const AI_TASK_KINDS: readonly ['free', 'fix', 'quota', 'account', 'host', 'plugin', 'terminal', 'handoff', 'menubar', 'hotkey'];
394
516
  export type AiTaskKind = (typeof AI_TASK_KINDS)[number];
395
517
  /**
396
518
  * The message keys of the AI dialog for `task` (spec §3.28 "每个入口的提示"): its title, the text box placeholder and
@@ -548,10 +670,28 @@ export declare function panelMigration(config: {
548
670
  * The line under the start-at-login switch (spec §3.29) as a message key, whether it is on, whether the switch can
549
671
  * be moved, and the action beside it: `fix` turns it on again so it starts this sideby. Read-only: no switch, no action.
550
672
  */
673
+ /**
674
+ * A key press in the Panel's shortcut recorder as config `menubar.hotkey` writes it (`ctrl+opt+s`), or null while only
675
+ * modifiers are held or the key is not a letter or digit. Reads `code`, not `key`: on a Mac ⌥S types "ß".
676
+ */
677
+ export declare function hotkeyFromKey(e: {
678
+ code: string;
679
+ ctrlKey: boolean;
680
+ altKey: boolean;
681
+ shiftKey: boolean;
682
+ metaKey: boolean;
683
+ }): string | null;
684
+ /**
685
+ * Whether a key press in the shortcut recorder is only a modifier being held (`wait`: the letter is still to come) or
686
+ * a key the menu bar shortcut cannot use (`unsupported`: an arrow, F-key, Space and the like), so the recorder can say
687
+ * so at once instead of looking stuck. A letter or digit is neither (see `hotkeyFromKey`).
688
+ */
689
+ export declare function hotkeyPressKind(code: string): 'key' | 'wait' | 'unsupported';
551
690
  export declare function autostartNote(s: {
552
691
  supported: boolean;
553
692
  state: string;
554
693
  current: boolean;
694
+ loaded?: boolean;
555
695
  } | null, readOnly: boolean): {
556
696
  key: string;
557
697
  on: boolean;
@@ -605,3 +745,105 @@ export declare function widthFollower<T>(shown: T, tierOf: (width: number) => T,
605
745
  set: (fn: () => void, ms: number) => unknown;
606
746
  clear: (id: unknown) => void;
607
747
  }): (width: number) => void;
748
+ /** When a History row was last active: "x min ago" within a week, then its date (key `time.on`). */
749
+ /**
750
+ * Whether the end of a list is close enough to load its next page: within `margin` px of the bottom of what can be
751
+ * seen, which is the viewport where the list's box grows with its rows (the page scrolls, not the box).
752
+ */
753
+ export declare function tailInView(tailTop: number, boxBottom: number, viewHeight: number, margin?: number): boolean;
754
+ export declare function historyWhen(iso: string | undefined, now: number): {
755
+ key: string;
756
+ n?: number;
757
+ date?: string;
758
+ } | null;
759
+ /** `text` cut into the parts that match one of `words` (any case) and the parts between, for highlighting. */
760
+ export declare function highlightParts(text: string, words: readonly string[]): {
761
+ text: string;
762
+ hit: boolean;
763
+ }[];
764
+ /**
765
+ * What an empty History list says, and which way out it offers: a wider time range, searching tool output too.
766
+ * Null while there are rows.
767
+ */
768
+ export declare function historyEmpty(v: {
769
+ q: string;
770
+ since: string;
771
+ state: string;
772
+ total: number;
773
+ tools: boolean;
774
+ project: string;
775
+ /** Accounts sideby found, and the Sessions stored for all of them, in any time. */
776
+ accounts: number;
777
+ stored: number;
778
+ /** The chosen AI is one sideby reads no past Sessions of. */
779
+ unreadable?: boolean;
780
+ }): {
781
+ key: string;
782
+ widen: boolean;
783
+ tools: boolean;
784
+ accounts?: boolean;
785
+ everywhere?: boolean;
786
+ } | null;
787
+ /** A Session's messages for reading, with each run of tool calls folded into one line naming the tools. */
788
+ export declare function foldToolCalls<T extends {
789
+ role: string;
790
+ text: string;
791
+ tool?: string;
792
+ n: number;
793
+ at?: string;
794
+ }>(messages: readonly T[]): (T | {
795
+ role: 'tools';
796
+ tools: string[];
797
+ n: number;
798
+ at?: string;
799
+ })[];
800
+ /** One block of a message read as Markdown, for the conversation viewer. Text stays text: the page builds nodes. */
801
+ export type MdBlock = {
802
+ type: 'p';
803
+ text: string;
804
+ } | {
805
+ type: 'h';
806
+ level: number;
807
+ text: string;
808
+ } | {
809
+ type: 'code';
810
+ lang: string;
811
+ text: string;
812
+ } | {
813
+ type: 'quote';
814
+ text: string;
815
+ } | {
816
+ type: 'list';
817
+ ordered: boolean;
818
+ items: string[];
819
+ } | {
820
+ type: 'table';
821
+ head: string[];
822
+ align: ('left' | 'center' | 'right' | '')[];
823
+ rows: string[][];
824
+ } | {
825
+ type: 'hr';
826
+ };
827
+ /**
828
+ * Splits a message into Markdown blocks: headings, fenced code, quotes, lists, GitHub tables, rules and paragraphs.
829
+ * An unclosed fence (a message cut short) runs to the end. Anything else is a paragraph, line breaks kept.
830
+ */
831
+ export declare function mdBlocks(text: string): MdBlock[];
832
+ /** Inline Markdown in one block: `code`, **bold**, *italic*, and [links](https://…) with a web address only. */
833
+ export declare function mdInline(text: string): {
834
+ t: 'text' | 'code' | 'b' | 'i' | 'a';
835
+ text: string;
836
+ href?: string;
837
+ }[];
838
+ /** The History filters a reload keeps. A tool-output search is left out: it reads every file again. */
839
+ export type HistFilters = {
840
+ q: string;
841
+ since: string;
842
+ family: string;
843
+ account: string;
844
+ project: string;
845
+ category: string;
846
+ scripts: boolean;
847
+ };
848
+ /** The History filters saved before a reload, each dropped back to its default when it is missing or malformed. */
849
+ export declare function histFilters(raw: unknown): HistFilters;