baychat 0.56.0 → 0.58.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/.claude-plugin/plugin.json +1 -1
- package/README.md +9 -1
- package/dist/approval-wait.js +1 -1
- package/dist/bay-gone.js +35 -0
- package/dist/bay-mcp.js +22 -8
- package/dist/channel/launch.js +10 -3
- package/dist/channel/mcp-server.js +37 -0
- package/dist/channel/server.js +6 -20
- package/dist/claude-command.js +130 -0
- package/dist/claude-register.js +162 -0
- package/dist/claude-user-config.js +215 -0
- package/dist/codex-onboarding.js +16 -2
- package/dist/commands.js +22 -187
- package/dist/connect-claude.js +26 -5
- package/dist/connect-link-budget.js +2 -0
- package/dist/connect-link-check.js +96 -0
- package/dist/connect-link-setup.js +17 -0
- package/dist/connect-link.js +41 -34
- package/dist/doctor-claude-file.js +17 -0
- package/dist/doctor-command.js +3 -0
- package/dist/doctor-questions.js +22 -0
- package/dist/doctor.js +13 -12
- package/dist/mcp-todos.js +49 -0
- package/dist/mcp.js +5 -5
- package/dist/notify-answer.js +53 -31
- package/dist/protocol-content.js +1 -1
- package/dist/quiet-claude-env.js +15 -0
- package/dist/refresh-clients.js +4 -6
- package/dist/relay/autostart-here.js +141 -0
- package/dist/relay/autostart.js +11 -60
- package/dist/relay/commands.js +9 -28
- package/dist/relay/launcher/blocking-screen.fixtures.js +147 -0
- package/dist/relay/launcher/blocking-screen.js +68 -0
- package/dist/relay/launcher/capabilities.js +8 -1
- package/dist/relay/launcher/dev-channel-screen.js +1 -1
- package/dist/relay/launcher/handle.js +3 -2
- package/dist/relay/launcher/loop.js +3 -0
- package/dist/relay/launcher/multiplexer.js +26 -0
- package/dist/relay/launcher/pane-watch.js +16 -0
- package/dist/relay/launcher/reset-time.js +82 -0
- package/dist/relay/launcher/session-watch-deps.js +116 -0
- package/dist/relay/launcher/session-watch.js +252 -0
- package/dist/relay/windows-task-xml.js +67 -0
- package/dist/relay/wsl-keeper.js +278 -0
- package/dist/runtimes.js +1 -3
- package/dist/tool-defs-outputs.js +73 -0
- package/dist/tool-defs.js +14 -24
- package/dist/tool-hints.js +13 -5
- package/dist/waiting-cards.js +33 -3
- package/package.json +2 -2
package/dist/relay/autostart.js
CHANGED
|
@@ -68,6 +68,7 @@ const fs = __importStar(require("fs"));
|
|
|
68
68
|
const os = __importStar(require("os"));
|
|
69
69
|
const path = __importStar(require("path"));
|
|
70
70
|
const util_1 = require("util");
|
|
71
|
+
const windows_task_xml_1 = require("./windows-task-xml");
|
|
71
72
|
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
72
73
|
/** The reverse-DNS name macOS and Windows both want, and the systemd unit's stem.
|
|
73
74
|
* One constant so a rename cannot half-happen: a plist labelled one thing and
|
|
@@ -163,8 +164,8 @@ const launchd = {
|
|
|
163
164
|
<string>${exports.SERVICE_LABEL}</string>
|
|
164
165
|
<key>ProgramArguments</key>
|
|
165
166
|
<array>
|
|
166
|
-
<string>${escapeXml(node)}</string>
|
|
167
|
-
<string>${escapeXml(entry)}</string>
|
|
167
|
+
<string>${(0, windows_task_xml_1.escapeXml)(node)}</string>
|
|
168
|
+
<string>${(0, windows_task_xml_1.escapeXml)(entry)}</string>
|
|
168
169
|
<string>relay</string>
|
|
169
170
|
<string>start</string>
|
|
170
171
|
<string>--foreground</string>
|
|
@@ -181,9 +182,9 @@ const launchd = {
|
|
|
181
182
|
<string>${exports.MAC_SEARCH_PATH}</string>
|
|
182
183
|
</dict>
|
|
183
184
|
<key>StandardOutPath</key>
|
|
184
|
-
<string>${escapeXml(launchdLogPath())}</string>
|
|
185
|
+
<string>${(0, windows_task_xml_1.escapeXml)(launchdLogPath())}</string>
|
|
185
186
|
<key>StandardErrorPath</key>
|
|
186
|
-
<string>${escapeXml(launchdLogPath())}</string>
|
|
187
|
+
<string>${(0, windows_task_xml_1.escapeXml)(launchdLogPath())}</string>
|
|
187
188
|
<key>ProcessType</key>
|
|
188
189
|
<string>Background</string>
|
|
189
190
|
</dict>
|
|
@@ -314,51 +315,12 @@ function prepareLaunchdLog() {
|
|
|
314
315
|
*/
|
|
315
316
|
const scheduledTask = {
|
|
316
317
|
name: "Task Scheduler",
|
|
317
|
-
unit: (cmd) =>
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
<LogonTrigger>
|
|
324
|
-
<Enabled>true</Enabled>
|
|
325
|
-
<UserId>${escapeXml(windowsUserId())}</UserId>
|
|
326
|
-
</LogonTrigger>
|
|
327
|
-
</Triggers>
|
|
328
|
-
<Principals>
|
|
329
|
-
<Principal id="Author">
|
|
330
|
-
<UserId>${escapeXml(windowsUserId())}</UserId>
|
|
331
|
-
<LogonType>InteractiveToken</LogonType>
|
|
332
|
-
<RunLevel>LeastPrivilege</RunLevel>
|
|
333
|
-
</Principal>
|
|
334
|
-
</Principals>
|
|
335
|
-
<Settings>
|
|
336
|
-
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
|
|
337
|
-
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
|
|
338
|
-
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
|
|
339
|
-
<StartWhenAvailable>true</StartWhenAvailable>
|
|
340
|
-
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
|
|
341
|
-
<IdleSettings>
|
|
342
|
-
<StopOnIdleEnd>false</StopOnIdleEnd>
|
|
343
|
-
<RestartOnIdle>false</RestartOnIdle>
|
|
344
|
-
</IdleSettings>
|
|
345
|
-
<AllowHardTerminate>true</AllowHardTerminate>
|
|
346
|
-
<Enabled>true</Enabled>
|
|
347
|
-
<Hidden>true</Hidden>
|
|
348
|
-
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
|
|
349
|
-
<RestartOnFailure>
|
|
350
|
-
<Interval>PT1M</Interval>
|
|
351
|
-
<Count>999</Count>
|
|
352
|
-
</RestartOnFailure>
|
|
353
|
-
</Settings>
|
|
354
|
-
<Actions Context="Author">
|
|
355
|
-
<Exec>
|
|
356
|
-
<Command>${escapeXml(path.win32.join(process.env.SystemRoot || "C:\\Windows", "System32", "wscript.exe"))}</Command>
|
|
357
|
-
<Arguments>//B //NoLogo ${escapeXml(`"${windowsLauncherPath()}" "${cmd.node}" "${cmd.entry}"`)} relay start --foreground</Arguments>
|
|
358
|
-
</Exec>
|
|
359
|
-
</Actions>
|
|
360
|
-
</Task>
|
|
361
|
-
`,
|
|
318
|
+
unit: (cmd) => (0, windows_task_xml_1.windowsTaskXml)({
|
|
319
|
+
description: "BayChat relay — wakes local agent sessions on new messages",
|
|
320
|
+
userId: windowsUserId(),
|
|
321
|
+
command: path.win32.join(process.env.SystemRoot || "C:\\Windows", "System32", "wscript.exe"),
|
|
322
|
+
args: `//B //NoLogo "${windowsLauncherPath()}" "${cmd.node}" "${cmd.entry}" relay start --foreground`,
|
|
323
|
+
}),
|
|
362
324
|
// Written beside the credentials rather than in %TEMP%: schtasks reads it once,
|
|
363
325
|
// but keeping it means `relay status` can show what was actually registered.
|
|
364
326
|
unitPath: () => path.join(configHome(), "relay-task.xml"),
|
|
@@ -421,17 +383,6 @@ function windowsUserId() {
|
|
|
421
383
|
function configHome() {
|
|
422
384
|
return process.env.BAYCHAT_CONFIG_DIR || path.join(os.homedir(), ".baychat");
|
|
423
385
|
}
|
|
424
|
-
/** The five characters that would otherwise end the element early. Paths can
|
|
425
|
-
* legally contain `&` on every platform this ships to, and a home directory with
|
|
426
|
-
* one in it would produce a plist launchd rejects with no useful message. */
|
|
427
|
-
function escapeXml(value) {
|
|
428
|
-
return value
|
|
429
|
-
.replace(/&/g, "&")
|
|
430
|
-
.replace(/</g, "<")
|
|
431
|
-
.replace(/>/g, ">")
|
|
432
|
-
.replace(/"/g, """)
|
|
433
|
-
.replace(/'/g, "'");
|
|
434
|
-
}
|
|
435
386
|
const BY_PLATFORM = {
|
|
436
387
|
linux: systemd,
|
|
437
388
|
darwin: launchd,
|
package/dist/relay/commands.js
CHANGED
|
@@ -57,6 +57,7 @@ const adapters_1 = require("./adapters");
|
|
|
57
57
|
const profiles_1 = require("./profiles");
|
|
58
58
|
const provider_env_1 = require("./provider-env");
|
|
59
59
|
const autostart_1 = require("./autostart");
|
|
60
|
+
const autostart_here_1 = require("./autostart-here");
|
|
60
61
|
const runtime_binary_1 = require("../runtime-binary");
|
|
61
62
|
const terminal_pane_1 = require("./terminal-pane");
|
|
62
63
|
const owner_pid_1 = require("./owner-pid");
|
|
@@ -131,6 +132,8 @@ async function cmdRelayStart(opts = {}) {
|
|
|
131
132
|
// DEFAULT Bay's, exactly as before; every other Bay login gets its own daemon in a child
|
|
132
133
|
// process scoped to that Bay. A per-Bay child supervises nothing and stops with its parent.
|
|
133
134
|
const child = (0, bay_relays_1.isBayRelayChild)();
|
|
135
|
+
if (!child)
|
|
136
|
+
void (0, autostart_here_1.ensureStartsWithWindows)((line) => console.log((0, log_line_1.relayLogLine)(line)));
|
|
134
137
|
const supervisor = child
|
|
135
138
|
? undefined
|
|
136
139
|
: new bay_relays_1.BayRelaySupervisor({
|
|
@@ -168,32 +171,7 @@ async function cmdRelayStart(opts = {}) {
|
|
|
168
171
|
}
|
|
169
172
|
return;
|
|
170
173
|
}
|
|
171
|
-
|
|
172
|
-
console.log("Relay is already running. `baychat relay status` for details.");
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
const autostart = (0, autostart_1.autostartForPlatform)();
|
|
176
|
-
if (!autostart) {
|
|
177
|
-
console.log(`No automatic startup is available on ${process.platform}. Run the daemon`);
|
|
178
|
-
console.log("yourself with:");
|
|
179
|
-
console.log(" baychat relay start --foreground");
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
try {
|
|
183
|
-
await autostart.install((0, autostart_1.relayCommand)());
|
|
184
|
-
console.log(`Relay started and enabled at boot (${autostart.name}).`);
|
|
185
|
-
}
|
|
186
|
-
catch (err) {
|
|
187
|
-
if (!(err instanceof autostart_1.LingerUnavailable))
|
|
188
|
-
throw err;
|
|
189
|
-
// The relay IS installed and running; only the boot-time half is missing.
|
|
190
|
-
// Reported rather than swallowed, because "enabled at boot" would be a lie
|
|
191
|
-
// and the user would not find out until the machine next rebooted unattended.
|
|
192
|
-
console.log(`Relay started and enabled at login (${autostart.name}).`);
|
|
193
|
-
console.log(`Note: ${err.message}.`);
|
|
194
|
-
}
|
|
195
|
-
console.log(" baychat relay status — see sessions, cursor, pending deliveries");
|
|
196
|
-
console.log(" baychat relay stop — stop it");
|
|
174
|
+
await (0, autostart_here_1.startRelayInBackground)();
|
|
197
175
|
}
|
|
198
176
|
/**
|
|
199
177
|
* Best-effort relay setup, run as the last step of `baychat connect`.
|
|
@@ -213,7 +191,7 @@ async function ensureRelayInstalled() {
|
|
|
213
191
|
}
|
|
214
192
|
if (await (0, socket_1.probeSocket)((0, socket_1.socketPath)()))
|
|
215
193
|
return "Relay: running. Join a session to connect incoming messages.";
|
|
216
|
-
const autostart = (0,
|
|
194
|
+
const autostart = (0, autostart_here_1.autostartHere)();
|
|
217
195
|
if (!autostart) {
|
|
218
196
|
return `Relay: no automatic startup on ${process.platform}. Run \`baychat relay start --foreground\` to wake sessions instantly.`;
|
|
219
197
|
}
|
|
@@ -311,6 +289,8 @@ async function cmdRelayStatus() {
|
|
|
311
289
|
console.log(` last error: ${status.lastError}`);
|
|
312
290
|
if (status.autoUpdate)
|
|
313
291
|
console.log(` auto-update: ${(0, describe_1.describeAutoUpdate)(status.autoUpdate, Date.now())}`);
|
|
292
|
+
for (const line of await (0, autostart_here_1.startsWithWindowsLines)())
|
|
293
|
+
console.log(line);
|
|
314
294
|
for (const line of await bayRelayLines())
|
|
315
295
|
console.log(line);
|
|
316
296
|
// Computed before the session list so a line can report its own last failure.
|
|
@@ -450,7 +430,8 @@ async function cmdRelayStop() {
|
|
|
450
430
|
// relay is back within the minute — systemd's Restart=always, launchd's
|
|
451
431
|
// KeepAlive and the scheduled task's RestartOnFailure all exist to make that
|
|
452
432
|
// happen, and all three would make `relay stop` look like it silently failed.
|
|
453
|
-
|
|
433
|
+
(0, autostart_here_1.rememberStoppedByHand)();
|
|
434
|
+
const autostart = (0, autostart_here_1.autostartHere)();
|
|
454
435
|
if (autostart && fs.existsSync(autostart.unitPath())) {
|
|
455
436
|
try {
|
|
456
437
|
await autostart.uninstall();
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pane captures for the session-long watch (session-watch.ts, blocking-screen.ts).
|
|
4
|
+
*
|
|
5
|
+
* FOLDER_TRUST_2_1_332 is VERBATIM (`tmux capture-pane -p`, Claude Code 2.1.332, 120 columns, Mac
|
|
6
|
+
* mini, 28 Nov 2026; only the folder path was shortened). The survey and usage-limit screens cannot
|
|
7
|
+
* be called up on demand, so they are built from Claude Code 2.1.332's own strings, read out of its
|
|
8
|
+
* binary on 28 Nov: the survey's question "How is Claude doing this session? (optional)" and its keys
|
|
9
|
+
* (1 Bad, 2 Fine, 3 Good, 0 Dismiss); the usage-limit menu's rows ("Stop and wait for limit to reset",
|
|
10
|
+
* "Upgrade your plan", "Don’t continue automatically") and its auto-continue lines ("Usage limit
|
|
11
|
+
* reached · set to continue automatically {when}", "Automatic continue was turned off · …").
|
|
12
|
+
* The layout around those strings is representative, not captured.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MODEL_PICKER_2_1_332 = exports.ASK_USER_QUESTION_2_1_332 = exports.UNNUMBERED_PICKER = exports.SOME_DIALOG = exports.USAGE_LIMIT_NO_AUTO = exports.USAGE_LIMIT_AUTO = exports.USAGE_LIMIT_MENU = exports.FEEDBACK_SURVEY_TEXT_TYPED = exports.FEEDBACK_SURVEY = exports.IDLE_PROMPT = exports.FOLDER_TRUST_2_1_332 = void 0;
|
|
16
|
+
exports.FOLDER_TRUST_2_1_332 = [
|
|
17
|
+
"────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────",
|
|
18
|
+
" Accessing workspace:",
|
|
19
|
+
"",
|
|
20
|
+
" /Users/k/projects/web",
|
|
21
|
+
"",
|
|
22
|
+
" Quick safety check: Is this a project you created or one you trust? (Like your own code, a well-known open source",
|
|
23
|
+
" project, or work from your team). If not, take a moment to review what's in this folder first.",
|
|
24
|
+
"",
|
|
25
|
+
" Claude Code'll be able to read, edit, and execute files here.",
|
|
26
|
+
"",
|
|
27
|
+
" Security guide",
|
|
28
|
+
"",
|
|
29
|
+
" ❯ No, exit",
|
|
30
|
+
" Yes, I trust this folder",
|
|
31
|
+
"",
|
|
32
|
+
" Enter to confirm · Esc to cancel"
|
|
33
|
+
].join("\n");
|
|
34
|
+
/** Claude Code's ordinary prompt with nothing typed: what a working session looks like. */
|
|
35
|
+
exports.IDLE_PROMPT = [
|
|
36
|
+
"● Joined BAYCHAT as Mac_unblock. Listening.",
|
|
37
|
+
"",
|
|
38
|
+
"────────────────────────────────────────────────────────────────────────────────",
|
|
39
|
+
"❯ ",
|
|
40
|
+
"────────────────────────────────────────────────────────────────────────────────",
|
|
41
|
+
" ? for shortcuts",
|
|
42
|
+
"",
|
|
43
|
+
].join("\n");
|
|
44
|
+
/** The rating survey over an empty prompt (Rocky, 28 Nov). */
|
|
45
|
+
exports.FEEDBACK_SURVEY = [
|
|
46
|
+
"● Joined BAYCHAT as Rocky. Listening.",
|
|
47
|
+
"",
|
|
48
|
+
"● How is Claude doing this session? (optional)",
|
|
49
|
+
" 1: Bad 2: Fine 3: Good 0: Dismiss",
|
|
50
|
+
"",
|
|
51
|
+
"────────────────────────────────────────────────────────────────────────────────",
|
|
52
|
+
"❯ ",
|
|
53
|
+
"────────────────────────────────────────────────────────────────────────────────",
|
|
54
|
+
" ? for shortcuts",
|
|
55
|
+
"",
|
|
56
|
+
].join("\n");
|
|
57
|
+
/** The same survey while something is typed in the prompt: a "0" would land in that text. */
|
|
58
|
+
exports.FEEDBACK_SURVEY_TEXT_TYPED = exports.FEEDBACK_SURVEY.replace("❯ \n", "❯ fix the tests\n");
|
|
59
|
+
/** The usage-limit menu Claude Code opens when a turn hits the limit. */
|
|
60
|
+
exports.USAGE_LIMIT_MENU = [
|
|
61
|
+
" ⎿ You've hit your limit · resets 5pm (Europe/Ljubljana)",
|
|
62
|
+
"",
|
|
63
|
+
" What do you want to do?",
|
|
64
|
+
"",
|
|
65
|
+
" ❯ 1. Stop and wait for limit to reset",
|
|
66
|
+
" 2. Upgrade your plan",
|
|
67
|
+
" 3. Don’t continue automatically",
|
|
68
|
+
"",
|
|
69
|
+
" Enter to confirm · Esc to cancel",
|
|
70
|
+
"",
|
|
71
|
+
].join("\n");
|
|
72
|
+
/** Claude Code waiting by itself: it continues at the reset with no help. */
|
|
73
|
+
exports.USAGE_LIMIT_AUTO = [
|
|
74
|
+
" ⎿ Usage limit reached · set to continue automatically at 5pm",
|
|
75
|
+
"",
|
|
76
|
+
"────────────────────────────────────────────────────────────────────────────────",
|
|
77
|
+
"❯ ",
|
|
78
|
+
"────────────────────────────────────────────────────────────────────────────────",
|
|
79
|
+
" Continuing automatically at 5pm · Esc to cancel",
|
|
80
|
+
"",
|
|
81
|
+
].join("\n");
|
|
82
|
+
/** Waiting with automatic continue off: nothing will wake it after the reset. */
|
|
83
|
+
exports.USAGE_LIMIT_NO_AUTO = [
|
|
84
|
+
" ⎿ You've hit your limit · resets 5pm (Europe/Ljubljana)",
|
|
85
|
+
" ⎿ Automatic continue was turned off · this task will not resume on its own",
|
|
86
|
+
"",
|
|
87
|
+
"────────────────────────────────────────────────────────────────────────────────",
|
|
88
|
+
"❯ ",
|
|
89
|
+
"────────────────────────────────────────────────────────────────────────────────",
|
|
90
|
+
"",
|
|
91
|
+
].join("\n");
|
|
92
|
+
/** A numbered dialog nobody here has a name for: answered with its own options. */
|
|
93
|
+
exports.SOME_DIALOG = [
|
|
94
|
+
"╭──────────────────────────────────────────────────────────────╮",
|
|
95
|
+
'│ The MCP server "github" asks to sign in again. │',
|
|
96
|
+
"╰──────────────────────────────────────────────────────────────╯",
|
|
97
|
+
" Open the sign-in page now?",
|
|
98
|
+
"",
|
|
99
|
+
" ❯ 1. Yes",
|
|
100
|
+
" 2. No, continue without it",
|
|
101
|
+
"",
|
|
102
|
+
" Esc to cancel",
|
|
103
|
+
"",
|
|
104
|
+
].join("\n");
|
|
105
|
+
/** A picker with no numbers and no known phrase: only Esc or Stop is ever offered. */
|
|
106
|
+
exports.UNNUMBERED_PICKER = [
|
|
107
|
+
" Pick a theme",
|
|
108
|
+
"",
|
|
109
|
+
" ❯ Dark",
|
|
110
|
+
" Light",
|
|
111
|
+
"",
|
|
112
|
+
" Enter to confirm · Esc to cancel",
|
|
113
|
+
"",
|
|
114
|
+
].join("\n");
|
|
115
|
+
/** VERBATIM: Claude Code 2.1.332's question picker (AskUserQuestion), mid-session, 160 columns, Mac mini, 29 Nov 2026 (the live run). Each option has a description under it; the last two rows ask for typing. */
|
|
116
|
+
exports.ASK_USER_QUESTION_2_1_332 = [
|
|
117
|
+
"⏺ Working… (ctrl+o to expand)",
|
|
118
|
+
"────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────",
|
|
119
|
+
" ☐ Colour",
|
|
120
|
+
"",
|
|
121
|
+
"Which colour should we test with?",
|
|
122
|
+
"",
|
|
123
|
+
"❯ 1. Red",
|
|
124
|
+
" Test with red",
|
|
125
|
+
" 2. Blue",
|
|
126
|
+
" Test with blue",
|
|
127
|
+
" 3. Green",
|
|
128
|
+
" Test with green",
|
|
129
|
+
" 4. Type something.",
|
|
130
|
+
"────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────",
|
|
131
|
+
" 5. Chat about this",
|
|
132
|
+
"",
|
|
133
|
+
"Enter to select · ↑/↓ to navigate · Esc to cancel",
|
|
134
|
+
].join("\n");
|
|
135
|
+
/** VERBATIM: the `/model` picker, 29 Nov 2026 (the live run), from its first row. Numbered, but no question and other lines under the rows: an unknown picker. */
|
|
136
|
+
exports.MODEL_PICKER_2_1_332 = [
|
|
137
|
+
" ❯ 1. Default (recommended) ✔ Opus 5.5 · Best for everyday, complex tasks",
|
|
138
|
+
" 2. Opus 5.5 For complex work and everyday tasks",
|
|
139
|
+
" 3. Fable 5.2 For your toughest challenges",
|
|
140
|
+
" 4. Sonnet 5.5 Most efficient for simpler tasks",
|
|
141
|
+
" 5. Haiku 5.5 Fastest for quick answers",
|
|
142
|
+
" ▸ More models",
|
|
143
|
+
"",
|
|
144
|
+
" ◐ Medium effort (default) ←/→ to adjust",
|
|
145
|
+
"",
|
|
146
|
+
" s to use this session only · Enter to save · Esc to cancel",
|
|
147
|
+
].join("\n");
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SURVEY_QUESTION = void 0;
|
|
4
|
+
exports.readBlockingScreen = readBlockingScreen;
|
|
5
|
+
exports.promptEmpty = promptEmpty;
|
|
6
|
+
exports.surveyDismissable = surveyDismissable;
|
|
7
|
+
const notify_answer_1 = require("../../notify-answer");
|
|
8
|
+
const dev_channel_screen_1 = require("./dev-channel-screen");
|
|
9
|
+
/** The survey's question, as Claude Code 2.1.332 writes it. */
|
|
10
|
+
exports.SURVEY_QUESTION = "How is Claude doing this session?";
|
|
11
|
+
/** Its key row: "1: Bad … 0: Dismiss" on one line. */
|
|
12
|
+
const SURVEY_KEYS = /\b1:\s*Bad\b.*\b0:\s*Dismiss\b/;
|
|
13
|
+
/** Claude Code's input line with nothing typed in it ("❯ " or "> ", maybe inside a box border). */
|
|
14
|
+
const EMPTY_PROMPT = /^[\s│]*[❯>]\s*│?\s*$/;
|
|
15
|
+
/** The usage-limit lines (2.1.332): the menu's first row, and the two auto-continue states. */
|
|
16
|
+
const LIMIT_MENU_ROW = "Stop and wait for limit to reset";
|
|
17
|
+
const LIMIT_LINE = /hit your limit|usage limit reached/i;
|
|
18
|
+
const AUTO_ON = /set to continue automatically\s+(?:at\s+)?([^·│\n]+?)\s*(?:[·│]|$)/i;
|
|
19
|
+
const AUTO_OFF = /automatic continue (?:was turned off|cancelled|stopped)/i;
|
|
20
|
+
const RESETS = /\bresets\s+(?:at\s+)?([^·│\n]+?)\s*(?:[·│]|$)/i;
|
|
21
|
+
function surveyShown(lines) {
|
|
22
|
+
const at = lines.findIndex((line) => line.includes(exports.SURVEY_QUESTION));
|
|
23
|
+
// The key row sits right under the question; a chat line quoting the question has none.
|
|
24
|
+
return at >= 0 && lines.slice(at + 1, at + 3).some((line) => SURVEY_KEYS.test(line));
|
|
25
|
+
}
|
|
26
|
+
function usageLimit(text, lines) {
|
|
27
|
+
const menu = text.includes(LIMIT_MENU_ROW);
|
|
28
|
+
const limitLines = lines.filter((line) => LIMIT_LINE.test(line));
|
|
29
|
+
if (!menu && limitLines.length === 0)
|
|
30
|
+
return undefined;
|
|
31
|
+
const auto = lines.map((line) => AUTO_ON.exec(line)?.[1]).find((v) => v !== undefined);
|
|
32
|
+
const resets = auto ?? limitLines.map((line) => RESETS.exec(line)?.[1]).find((v) => v !== undefined);
|
|
33
|
+
const dialog = menu ? (0, notify_answer_1.readDialog)(text) : undefined;
|
|
34
|
+
const autoContinue = !menu && auto !== undefined && !lines.some((line) => AUTO_OFF.test(line));
|
|
35
|
+
return { kind: "usage-limit", ...(resets ? { resets: resets.trim() } : {}), autoContinue, ...(dialog ? { dialog } : {}) };
|
|
36
|
+
}
|
|
37
|
+
function readBlockingScreen(text) {
|
|
38
|
+
const lines = text.split("\n");
|
|
39
|
+
const known = (0, dev_channel_screen_1.classifyPane)(text);
|
|
40
|
+
if (known === "folder-trust")
|
|
41
|
+
return { kind: "folder-trust" };
|
|
42
|
+
if (known === "dev-channel-warning" || known === "code-mode-opt-in")
|
|
43
|
+
return { kind: "start-question" };
|
|
44
|
+
if (surveyShown(lines))
|
|
45
|
+
return { kind: "survey" };
|
|
46
|
+
const limit = usageLimit(text, lines);
|
|
47
|
+
if (limit)
|
|
48
|
+
return limit;
|
|
49
|
+
const dialog = (0, notify_answer_1.readDialog)(text);
|
|
50
|
+
if (dialog)
|
|
51
|
+
return { kind: "dialog", dialog };
|
|
52
|
+
if ((0, dev_channel_screen_1.pickerFooterShown)(text))
|
|
53
|
+
return { kind: "unknown-picker" };
|
|
54
|
+
return { kind: "none" };
|
|
55
|
+
}
|
|
56
|
+
/** Is Claude Code's input line on screen with nothing typed in it? */
|
|
57
|
+
function promptEmpty(text) {
|
|
58
|
+
return text.split("\n").some((line) => EMPTY_PROMPT.test(line));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* May "0" be pressed to dismiss the survey? Only while the survey shows and the prompt under it is
|
|
62
|
+
* EMPTY: Claude Code takes the digit as the survey's answer only then, and with text typed the "0"
|
|
63
|
+
* would land in that text.
|
|
64
|
+
*/
|
|
65
|
+
function surveyDismissable(text) {
|
|
66
|
+
const lines = text.split("\n");
|
|
67
|
+
return surveyShown(lines) && lines.some((line) => EMPTY_PROMPT.test(line));
|
|
68
|
+
}
|
|
@@ -37,6 +37,7 @@ exports.RUNTIME_BINARY = exports.PHONE_ALLOW_RUNTIMES = void 0;
|
|
|
37
37
|
exports.buildCapabilities = buildCapabilities;
|
|
38
38
|
exports.legacyCapabilities = legacyCapabilities;
|
|
39
39
|
const os = __importStar(require("os"));
|
|
40
|
+
const machine_name_1 = require("../../machine-name");
|
|
40
41
|
/** The runtimes whose trust the relay can write, so the only ones the phone may allow (spot-request.ts). */
|
|
41
42
|
exports.PHONE_ALLOW_RUNTIMES = ["claude", "codex"];
|
|
42
43
|
/** The executable each launch runtime is resolved by. */
|
|
@@ -87,13 +88,19 @@ function buildCapabilities(policy, deps) {
|
|
|
87
88
|
}
|
|
88
89
|
const phoneOpen = spots.some((s) => s.phoneMayAllow);
|
|
89
90
|
return {
|
|
90
|
-
machine: (deps
|
|
91
|
+
machine: computerName(deps),
|
|
91
92
|
os: deps.platform ?? process.platform,
|
|
92
93
|
multiplexer: deps.multiplexer,
|
|
93
94
|
spots,
|
|
94
95
|
...(phoneOpen ? { installedRuntimes: exports.PHONE_ALLOW_RUNTIMES.filter((r) => resolutionOf(r).ok) } : {}),
|
|
95
96
|
};
|
|
96
97
|
}
|
|
98
|
+
/** The same name the computer's login has (machine-name.ts): a WSL relay is "<host> (WSL)", never the Windows host's own. */
|
|
99
|
+
function computerName(deps) {
|
|
100
|
+
const host = (deps.hostname ?? os.hostname()).replace(/\.local$/, "");
|
|
101
|
+
const wsl = deps.wsl ?? (deps.platform === undefined && (0, machine_name_1.isWsl)());
|
|
102
|
+
return (host ? (0, machine_name_1.machineName)(host, wsl) : "").slice(0, MACHINE_MAX) || "computer";
|
|
103
|
+
}
|
|
97
104
|
/** The report as a server before CLI 0.41 takes it: its strict schema refuses the whole report for one unknown
|
|
98
105
|
* key, which would take every folder of this computer off Start. */
|
|
99
106
|
function legacyCapabilities(caps) {
|
|
@@ -80,7 +80,7 @@ function safeToAnswerCodeMode(text, choice) {
|
|
|
80
80
|
return classifyPane(text) === "code-mode-opt-in" && codeModeSelection(text) === choice;
|
|
81
81
|
}
|
|
82
82
|
/** Claude Code's picker footer, on a line of its own ("Enter to confirm · Esc to …"). */
|
|
83
|
-
const PICKER_FOOTER = /^[\s│]*Enter to confirm\b/;
|
|
83
|
+
const PICKER_FOOTER = /^[\s│]*(?:Enter to confirm\b|(?:[^·]*·\s*)?Enter to (?:select|save)\b.*Esc to cancel)/;
|
|
84
84
|
/**
|
|
85
85
|
* Is Claude Code waiting at a picker of some kind? Its FOOTER ("Enter to confirm") and a `❯`
|
|
86
86
|
* selection row — matched on the footer, not on what the question says, so a question nobody here
|
|
@@ -9,6 +9,7 @@ exports.launchBayEntry = launchBayEntry;
|
|
|
9
9
|
const bays_1 = require("../../bays");
|
|
10
10
|
const detect_1 = require("../../channel/detect");
|
|
11
11
|
const policy_1 = require("../../launch/policy");
|
|
12
|
+
const quiet_claude_env_1 = require("../../quiet-claude-env");
|
|
12
13
|
const acp_launch_1 = require("./acp-launch");
|
|
13
14
|
const argv_1 = require("./argv");
|
|
14
15
|
const approval_settings_1 = require("./approval-settings");
|
|
@@ -289,7 +290,7 @@ function startSession(launch, deps) {
|
|
|
289
290
|
folder: folder.path,
|
|
290
291
|
claudeBin: binary.path,
|
|
291
292
|
channelArgs,
|
|
292
|
-
env: { ...(deps.relayEnv ?? {}), ...channel.env, PATH: deps.pathEnv },
|
|
293
|
+
env: { ...(deps.relayEnv ?? {}), ...quiet_claude_env_1.QUIET_CLAUDE_ENV, ...channel.env, PATH: deps.pathEnv },
|
|
293
294
|
settingsFile,
|
|
294
295
|
mcpConfigFile,
|
|
295
296
|
join: launch.join,
|
|
@@ -306,7 +307,7 @@ function spawnRecorded(launch, deps, command, spot, multiplexer, started, record
|
|
|
306
307
|
deps.log(`launch ${launch.id}: ${command.file} failed: ${res.error?.message ?? (res.stderr.trim() || `exit ${res.status}`)}`);
|
|
307
308
|
return { status: "FAILED", reason: "SPAWN_FAILED" };
|
|
308
309
|
}
|
|
309
|
-
const entry = { name: launch.sessionName, spotId: spot.id, runtime: launch.runtime, multiplexer, launchId: launch.id, startedAt: deps.now().toISOString() };
|
|
310
|
+
const entry = { name: launch.sessionName, spotId: spot.id, runtime: launch.runtime, multiplexer, launchId: launch.id, startedAt: deps.now().toISOString(), ...(launch.bay ? { bayId: launch.bay.id } : {}) };
|
|
310
311
|
(0, started_1.saveStarted)([...started, entry], recordFile);
|
|
311
312
|
deps.log(`launch ${launch.id}: started "${launch.sessionName}" (${launch.runtime}) in "${spot.label}" (${launch.listen}) for ${launch.requestedBy.name}. ${note}.`);
|
|
312
313
|
return { entry };
|
|
@@ -54,6 +54,7 @@ const stop_registered_1 = require("./stop-registered");
|
|
|
54
54
|
const handle_1 = require("./handle");
|
|
55
55
|
const multiplexer_1 = require("./multiplexer");
|
|
56
56
|
const launch_outcome_1 = require("./launch-outcome");
|
|
57
|
+
const session_watch_deps_1 = require("./session-watch-deps");
|
|
57
58
|
/**
|
|
58
59
|
* The launcher: this computer's side of "Start a session from BayChat".
|
|
59
60
|
*
|
|
@@ -76,6 +77,8 @@ const REQUEST_GRACE_MS = 15_000;
|
|
|
76
77
|
async function startLauncher(opts) {
|
|
77
78
|
const { auth, log, signal, onLaunch, deps: overrides } = opts;
|
|
78
79
|
const deps = { ...realLoopDeps(auth, log, signal, opts), ...overrides };
|
|
80
|
+
if (!overrides)
|
|
81
|
+
(0, session_watch_deps_1.startSessionWatch)(auth, log, signal, opts); // No question may stop a session (session-watch.ts).
|
|
79
82
|
let advertised;
|
|
80
83
|
// What was last reported to PUT /launch-sessions; `false` once the server said it has no such
|
|
81
84
|
// route (an older server), so it is not asked again until the relay restarts.
|
|
@@ -46,6 +46,8 @@ exports.tmuxPaneTarget = tmuxPaneTarget;
|
|
|
46
46
|
exports.capturePane = capturePane;
|
|
47
47
|
exports.pressEnter = pressEnter;
|
|
48
48
|
exports.pressDown = pressDown;
|
|
49
|
+
exports.pressKey = pressKey;
|
|
50
|
+
exports.typeLine = typeLine;
|
|
49
51
|
const child_process_1 = require("child_process");
|
|
50
52
|
const fs = __importStar(require("fs"));
|
|
51
53
|
const path = __importStar(require("path"));
|
|
@@ -280,6 +282,30 @@ function pressDown(multiplexer, sessionName, run) {
|
|
|
280
282
|
: run("screen", ["-S", (0, argv_1.multiplexerSessionName)(sessionName), "-X", "stuff", "\u001b[B"]);
|
|
281
283
|
return !res.error && res.status === 0;
|
|
282
284
|
}
|
|
285
|
+
/** Send ONE watch key to the launcher's pane. A digit goes literally (`-l`), never as a key name. */
|
|
286
|
+
function pressKey(multiplexer, sessionName, key, run) {
|
|
287
|
+
if (!/^(?:[0-9]|Escape)$/.test(key))
|
|
288
|
+
return false;
|
|
289
|
+
const tmuxArgs = key === "Escape" ? ["Escape"] : ["-l", "--", key];
|
|
290
|
+
const res = multiplexer === "tmux"
|
|
291
|
+
? run("tmux", ["send-keys", "-t", tmuxPaneTarget(sessionName), ...tmuxArgs])
|
|
292
|
+
: run("screen", ["-S", (0, argv_1.multiplexerSessionName)(sessionName), "-X", "stuff", key === "Escape" ? "\x1b" : key]);
|
|
293
|
+
return !res.error && res.status === 0;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Type ONE fixed line and press Enter: the session watch's wake-up after a usage limit resets. The
|
|
297
|
+
* line is the watch's own constant, never text from the network; control characters are refused.
|
|
298
|
+
*/
|
|
299
|
+
function typeLine(multiplexer, sessionName, text, run) {
|
|
300
|
+
if (!text || /[\x00-\x1f\x7f^\\]/.test(text))
|
|
301
|
+
return false;
|
|
302
|
+
const typed = multiplexer === "tmux"
|
|
303
|
+
? run("tmux", ["send-keys", "-t", tmuxPaneTarget(sessionName), "-l", "--", text])
|
|
304
|
+
: run("screen", ["-S", (0, argv_1.multiplexerSessionName)(sessionName), "-X", "stuff", text]);
|
|
305
|
+
if (typed.error || typed.status !== 0)
|
|
306
|
+
return false;
|
|
307
|
+
return pressEnter(multiplexer, sessionName, run);
|
|
308
|
+
}
|
|
283
309
|
function withoutPrefix(names) {
|
|
284
310
|
return names.filter((n) => n.startsWith(argv_1.LAUNCH_SESSION_PREFIX) && n.length > argv_1.LAUNCH_SESSION_PREFIX.length).map((n) => n.slice(argv_1.LAUNCH_SESSION_PREFIX.length));
|
|
285
311
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.KEY_SETTLE_MS = exports.CODE_MODE_ARM_MS = exports.CONFIRM_DEADLINE_MS = exports.WARNING_POLL_MS = exports.WARNING_WATCH_MS = void 0;
|
|
4
|
+
exports.startWatchActive = startWatchActive;
|
|
4
5
|
exports.watchLaunchPane = watchLaunchPane;
|
|
5
6
|
const dev_channel_screen_1 = require("./dev-channel-screen");
|
|
6
7
|
const started_1 = require("./started");
|
|
@@ -44,7 +45,22 @@ const RETRY_PAUSE_MS = 2_000;
|
|
|
44
45
|
const refused = (reason) => ({ status: "REFUSED", reason });
|
|
45
46
|
const changed = (w, why) => w.stop({ status: "FAILED", reason: "CONFIRM_SCREEN_CHANGED" }, why);
|
|
46
47
|
const untrusted = (w) => w.stop({ status: "FAILED", reason: "FOLDER_NOT_TRUSTED" }, "Claude Code asks whether to trust the folder");
|
|
48
|
+
/** Launch panes whose start questions this watch is handling now: the session watch keeps off them. */
|
|
49
|
+
const startWatching = new Set();
|
|
50
|
+
/** Is `sessionName`'s start still being watched here (session-watch.ts leaves it alone until it ends)? */
|
|
51
|
+
function startWatchActive(sessionName) {
|
|
52
|
+
return startWatching.has(sessionName);
|
|
53
|
+
}
|
|
47
54
|
async function watchLaunchPane(w) {
|
|
55
|
+
startWatching.add(w.entry.name);
|
|
56
|
+
try {
|
|
57
|
+
return await watchStart(w);
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
startWatching.delete(w.entry.name);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function watchStart(w) {
|
|
48
64
|
const { deps, entry, io } = w;
|
|
49
65
|
const now = () => deps.now().getTime();
|
|
50
66
|
let until = now() + exports.WARNING_WATCH_MS;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* When a usage limit resets, from the words Claude Code shows ("resets 5pm (Europe/Ljubljana)",
|
|
4
|
+
* "resets Nov 30, 5:30pm", "at 5pm"). Pure: the session watch (session-watch.ts) wakes a session
|
|
5
|
+
* that will not continue by itself shortly after this moment. Anything it cannot read is
|
|
6
|
+
* undefined, and then nothing is woken: the owner is told to send a message after the reset.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.parseResetAt = parseResetAt;
|
|
10
|
+
const MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
|
11
|
+
const RESET = /^(?:(?<mon>[A-Za-z]{3})[a-z]*\.?\s+(?<day>\d{1,2}),?\s+(?:at\s+)?)?(?<h>\d{1,2})(?::(?<m>\d{2}))?\s*(?<ap>am|pm)\b\s*(?:\((?<tz>[A-Za-z_]+(?:\/[A-Za-z_+-]+)*)\))?\s*$/i;
|
|
12
|
+
/** Minutes east of UTC that `timeZone` is at `at`; undefined for a zone this runtime does not know. */
|
|
13
|
+
function offsetMinutes(timeZone, at) {
|
|
14
|
+
let parts;
|
|
15
|
+
try {
|
|
16
|
+
parts = new Intl.DateTimeFormat("en-US", { timeZone, hourCycle: "h23", year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "numeric" }).formatToParts(at);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const n = (type) => Number(parts.find((p) => p.type === type)?.value);
|
|
22
|
+
const wall = Date.UTC(n("year"), n("month") - 1, n("day"), n("hour") % 24, n("minute"));
|
|
23
|
+
return Math.round((wall - Math.floor(at / 60_000) * 60_000) / 60_000);
|
|
24
|
+
}
|
|
25
|
+
/** The wall-clock moment in `timeZone` (or this computer's zone) as an instant. */
|
|
26
|
+
function instant(y, mo, d, h, mi, timeZone) {
|
|
27
|
+
if (!timeZone)
|
|
28
|
+
return new Date(y, mo, d, h, mi).getTime();
|
|
29
|
+
const guess = Date.UTC(y, mo, d, h, mi);
|
|
30
|
+
const first = offsetMinutes(timeZone, guess);
|
|
31
|
+
if (first === undefined)
|
|
32
|
+
return undefined;
|
|
33
|
+
const at = guess - first * 60_000;
|
|
34
|
+
// Once more at the found instant, for a day the clocks change.
|
|
35
|
+
const second = offsetMinutes(timeZone, at);
|
|
36
|
+
return second === undefined ? undefined : guess - second * 60_000;
|
|
37
|
+
}
|
|
38
|
+
/** The parts of `now` as the clock in `timeZone` (or here) shows them. */
|
|
39
|
+
function wallParts(now, timeZone) {
|
|
40
|
+
if (!timeZone) {
|
|
41
|
+
const t = new Date(now);
|
|
42
|
+
return { y: t.getFullYear(), mo: t.getMonth(), d: t.getDate() };
|
|
43
|
+
}
|
|
44
|
+
const off = offsetMinutes(timeZone, now);
|
|
45
|
+
if (off === undefined)
|
|
46
|
+
return undefined;
|
|
47
|
+
const t = new Date(now + off * 60_000);
|
|
48
|
+
return { y: t.getUTCFullYear(), mo: t.getUTCMonth(), d: t.getUTCDate() };
|
|
49
|
+
}
|
|
50
|
+
function parseResetAt(resets, now) {
|
|
51
|
+
const m = RESET.exec(resets.trim());
|
|
52
|
+
if (!m?.groups)
|
|
53
|
+
return undefined;
|
|
54
|
+
const g = m.groups;
|
|
55
|
+
let h = Number(g.h);
|
|
56
|
+
const mi = g.m ? Number(g.m) : 0;
|
|
57
|
+
if (h < 1 || h > 12 || mi > 59)
|
|
58
|
+
return undefined;
|
|
59
|
+
if (g.ap.toLowerCase() === "pm" && h !== 12)
|
|
60
|
+
h += 12;
|
|
61
|
+
if (g.ap.toLowerCase() === "am" && h === 12)
|
|
62
|
+
h = 0;
|
|
63
|
+
const tz = g.tz;
|
|
64
|
+
const today = wallParts(now, tz);
|
|
65
|
+
if (!today)
|
|
66
|
+
return undefined;
|
|
67
|
+
if (g.mon) {
|
|
68
|
+
const mo = MONTHS.indexOf(g.mon.toLowerCase());
|
|
69
|
+
if (mo < 0)
|
|
70
|
+
return undefined;
|
|
71
|
+
let at = instant(today.y, mo, Number(g.day), h, mi, tz);
|
|
72
|
+
// "Jan 2" seen on 30 Dec is next year's.
|
|
73
|
+
if (at !== undefined && at < now - 24 * 60 * 60_000)
|
|
74
|
+
at = instant(today.y + 1, mo, Number(g.day), h, mi, tz);
|
|
75
|
+
return at;
|
|
76
|
+
}
|
|
77
|
+
const at = instant(today.y, today.mo, today.d, h, mi, tz);
|
|
78
|
+
if (at === undefined)
|
|
79
|
+
return undefined;
|
|
80
|
+
// A time with no date is the next time the clock shows it.
|
|
81
|
+
return at > now ? at : instant(today.y, today.mo, today.d + 1, h, mi, tz);
|
|
82
|
+
}
|