@yanzc/claude-pro 0.9.8 → 0.11.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 +69 -21
- package/package.json +5 -2
- package/src/agent.js +12 -3
- package/src/api.js +85 -43
- package/src/browser/session.js +11 -1
- package/src/commands.js +390 -84
- package/src/config.js +139 -17
- package/src/gateway.js +27 -71
- package/src/main.js +10 -10
- package/src/openai-chat.js +379 -0
- package/src/peers.js +23 -6
- package/src/providers.js +331 -0
- package/src/remote.js +53 -12
- package/src/tools/bash.js +2 -8
- package/src/tools/peers.js +6 -5
- package/src/ui/dialogs.js +77 -1
- package/src/ui/repl.js +122 -38
- package/src/utils/shell.js +4 -5
package/src/ui/repl.js
CHANGED
|
@@ -19,6 +19,7 @@ import { SessionStore, firstUserText, moveSession } from '../session.js';
|
|
|
19
19
|
import { defaultEffort, effortSupported, effortToSend, quickQuery } from '../api.js';
|
|
20
20
|
import { CONFIG_DIR, VERSION, APP_NAME, INSTALL_DIR } from '../config.js';
|
|
21
21
|
import { gatewayLogin, loadGatewayModels, normalizeGatewayUrl, formatUsd } from '../gateway.js';
|
|
22
|
+
import { connectedProviders } from '../providers.js';
|
|
22
23
|
import { TOPIC_TITLE_SYSTEM, topicTitlePrompt } from '../prompts.js';
|
|
23
24
|
import { buildCommands, modelChoices, effortChoices } from '../commands.js';
|
|
24
25
|
import { canRestart, writeRestartState, runSelfCheck, watchSource, restartNote, reloadTiming, RESTART_EXIT_CODE, MAX_RESTARTS, RESTART_WINDOW_MS } from '../restart.js';
|
|
@@ -37,7 +38,8 @@ import { PeerNode, peersEnabled, findPeer, resolvePeer, machineName, cleanName,
|
|
|
37
38
|
import { RemoteControl, transcriptItems, onlineEnabled, remoteCommandsEnabled, REMOTE_WIDTH } from '../remote.js';
|
|
38
39
|
|
|
39
40
|
// A model id as people say it: claude-sonnet-5-5 -> sonnet-5-5, claude-haiku-4-5-20251001 -> haiku-4-5.
|
|
40
|
-
|
|
41
|
+
// (every model with its provider in front: 7bit/opus-5-5, deepseek/deepseek-v4-pro)
|
|
42
|
+
export const modelTag = (model) => `${model?.provider ? `${model.provider}/` : ''}${String(model?.id ?? '').replace(/^claude-/, '').replace(/-\d{8}$/, '')}`;
|
|
41
43
|
|
|
42
44
|
// The model and effort level that requests use now, for the footer and the terminal title. The effort
|
|
43
45
|
// is left out when none is sent (auto) and for a model that does not take one.
|
|
@@ -276,10 +278,11 @@ export class App {
|
|
|
276
278
|
this.turnPeers = []; // tasks from other sessions that the running turn answers: [{msg}]
|
|
277
279
|
this.userSentToPeers = new Set(); // ids of messages the user sent to other sessions with @name
|
|
278
280
|
this.remote = null; // the browser page that watches and steers this session (see remote.js), when it is on
|
|
281
|
+
this.remoteControl = false; // /rc: the page shows the conversation (online without it: messages between sessions only)
|
|
279
282
|
this.remoteMuted = 0; // > 0 while printing something the page is told about in its own terms
|
|
280
283
|
this.remoteDialogs = 0;
|
|
281
284
|
this.remoteStarting = null;
|
|
282
|
-
this.remoteRefused = null; // a gateway key the gateway refused: not tried again by itself (a new /
|
|
285
|
+
this.remoteRefused = null; // a gateway key the gateway refused: not tried again by itself (a new /connect is)
|
|
283
286
|
this.seedOutput = []; // lines the page is shown after the conversation when it starts from it (see resumeAfterRestart)
|
|
284
287
|
this.selfCheck = selfCheck;
|
|
285
288
|
this.sessionName = flags?.restart?.peerName || null; // this session's name when the sessions of this computer do not know it (CLAUDE_PRO_PEERS=0)
|
|
@@ -383,15 +386,15 @@ export class App {
|
|
|
383
386
|
}, 120);
|
|
384
387
|
if (restart) this.continueAfterRestart(restart);
|
|
385
388
|
else if (initialPrompt?.trim()) this.onSubmit(initialPrompt, initialPrompt);
|
|
386
|
-
// Nothing configured yet
|
|
387
|
-
else if (!gatewayLogin(this.config.gatewayUrl)) {
|
|
388
|
-
Promise.resolve(this.commands.get('
|
|
389
|
+
// Nothing configured yet (no gateway login, no provider): /connect, where the gateway comes first.
|
|
390
|
+
else if (!gatewayLogin(this.config.gatewayUrl) && !connectedProviders().length) {
|
|
391
|
+
Promise.resolve(this.commands.get('connect').run('')).catch((e) => this.logError(e)).finally(() => this.screen.schedule());
|
|
389
392
|
}
|
|
390
393
|
this.startSourceWatch();
|
|
391
394
|
if (!this.driven) {
|
|
392
395
|
// Updates are deliberately manual: /update checks npm and installs the selected release.
|
|
393
396
|
// Do not query the registry or install/restart a running session in the background.
|
|
394
|
-
// online or offline as this computer's gateway login changes (/
|
|
397
|
+
// online or offline as this computer's gateway login changes (/connect or /disconnect of 7bit.fun in another window)
|
|
395
398
|
this.loginTimer = setInterval(() => this.syncRemote(), 10_000);
|
|
396
399
|
this.loginTimer.unref?.();
|
|
397
400
|
}
|
|
@@ -547,7 +550,7 @@ export class App {
|
|
|
547
550
|
let found = resolvePeer(local, this.remotePeers, target);
|
|
548
551
|
if (!found.peer && !found.error && this.remote) found = resolvePeer(local, await this.refreshRemotePeers(), target);
|
|
549
552
|
if (!found.peer) {
|
|
550
|
-
const offline = this.remote ? '' : ' Sessions on your other computers can be reached once this one is online at the gateway (/
|
|
553
|
+
const offline = this.remote ? '' : ' Sessions on your other computers can be reached once this one is online at the gateway (/connect 7bit.fun).';
|
|
551
554
|
throw new Error(found.error || `No running session called "${String(target).replace(/^[@&&]/, '')}". /peers lists them.${offline}`);
|
|
552
555
|
}
|
|
553
556
|
peer = found.peer;
|
|
@@ -562,20 +565,30 @@ export class App {
|
|
|
562
565
|
}
|
|
563
566
|
|
|
564
567
|
// The account's sessions on other computers that are online now, from the gateway (what was known stays when
|
|
565
|
-
// it cannot be asked). Sessions of this computer are left
|
|
568
|
+
// it cannot be asked), and those of its contacts (other people, /contacts). Sessions of this computer are left
|
|
569
|
+
// out: they are reached directly.
|
|
566
570
|
refreshRemotePeers() {
|
|
567
571
|
if (!this.remote?.registered) return Promise.resolve(this.remotePeers);
|
|
568
572
|
this.remotePeersLoading ??= (async () => {
|
|
569
573
|
try {
|
|
570
574
|
const near = new Set([this.peers?.id, ...(this.peers?.peers() || []).map((p) => p.id)].filter(Boolean));
|
|
571
|
-
const
|
|
572
|
-
this.remotePeers =
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
575
|
+
const { own, contacts } = await this.remote.sessions();
|
|
576
|
+
this.remotePeers = [
|
|
577
|
+
...own
|
|
578
|
+
.filter((p) => p.online && !p.ended && p.id !== this.remote?.id && !near.has(p.peerId))
|
|
579
|
+
.map((p) => {
|
|
580
|
+
const machine = p.machine || p.host || 'computer';
|
|
581
|
+
const name = p.name || 'session';
|
|
582
|
+
return { id: p.id, name, machine, cwd: p.cwd || '', remote: true, label: `${machine}/${name}`, busy: Boolean(p.busy), title: p.title || '' };
|
|
583
|
+
}),
|
|
584
|
+
...contacts
|
|
585
|
+
.filter((p) => p.online && p.account)
|
|
586
|
+
.map((p) => {
|
|
587
|
+
const machine = p.machine || 'computer';
|
|
588
|
+
const name = p.name || 'session';
|
|
589
|
+
return { id: p.id, name, machine, cwd: '', remote: true, contact: true, account: p.account, label: `${p.account}:${machine}/${name}`, busy: Boolean(p.busy), title: '' };
|
|
590
|
+
}),
|
|
591
|
+
];
|
|
579
592
|
this.remotePeersAt = Date.now();
|
|
580
593
|
} catch { /* the gateway cannot be asked now */ } finally {
|
|
581
594
|
this.remotePeersLoading = null;
|
|
@@ -592,19 +605,64 @@ export class App {
|
|
|
592
605
|
return {
|
|
593
606
|
me: { name, cwd: this.agent?.cwd || this.cwd, label: `${machineName(this.config.env)}/${name}` },
|
|
594
607
|
local: this.peers?.peers() || [],
|
|
595
|
-
remote: this.remotePeers,
|
|
608
|
+
remote: this.remotePeers.filter((p) => !p.contact),
|
|
609
|
+
contacts: this.remotePeers.filter((p) => p.contact),
|
|
596
610
|
online: Boolean(this.remote?.online),
|
|
597
611
|
};
|
|
598
612
|
}
|
|
599
613
|
|
|
614
|
+
// 通讯录 events from the gateway: another account asked this one to be a contact, or accepted its request.
|
|
615
|
+
onContactEvent(ev) {
|
|
616
|
+
const handle = String(ev.handle || '').replace(/[^\w-]/g, '');
|
|
617
|
+
if (!handle || this.exiting) return;
|
|
618
|
+
if (ev.event === 'request') {
|
|
619
|
+
this.screen.log(`${c.blue('✉')} ${c.bold(handle)} asks to be your contact: their claude-pro sessions and yours could then send each other tasks.`,
|
|
620
|
+
c.dim(` /contacts accept ${handle} · /contacts reject ${handle} · /contacts block ${handle} (or 通讯录 on the gateway's web page)`), '');
|
|
621
|
+
} else if (ev.event === 'accepted') {
|
|
622
|
+
this.screen.log(`${c.blue('✉')} ${c.bold(handle)} accepted you as a contact: their online sessions show in /peers as @${handle}:computer/name.`, '');
|
|
623
|
+
this.refreshRemotePeers();
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// A task from a contact's session (another person) runs only once the user allows it here, unless the user set
|
|
628
|
+
// that contact's tasks to run by themselves (trust "auto", /contacts trust). Resolves with whether it runs.
|
|
629
|
+
async allowContactTask(msg) {
|
|
630
|
+
if (msg.from.trust === 'auto') return true;
|
|
631
|
+
const preview = msg.text.length > 1200 ? `${msg.text.slice(0, 1200)}…` : msg.text;
|
|
632
|
+
const choice = await this.showDialog(new SelectDialog({
|
|
633
|
+
title: `Task from the contact ${msg.from.account}`,
|
|
634
|
+
body: [c.dim(`From their session @${msg.from.name}, another person's agent, not you:`), ...preview.split('\n').flatMap((line) => wordWrap(line, Math.max(20, this.width - 8))).slice(0, 20)],
|
|
635
|
+
question: 'Let this session work on it? Its final answer is sent back to them.',
|
|
636
|
+
color: c.yellow,
|
|
637
|
+
options: [
|
|
638
|
+
{ label: 'Run it', value: 'run', description: 'This task only' },
|
|
639
|
+
{ label: 'Decline', value: 'decline', description: 'They are told that you declined it' },
|
|
640
|
+
{ label: `Always run tasks from ${msg.from.account}`, value: 'always', description: 'Their later tasks run without asking (/contacts trust to change it)' },
|
|
641
|
+
],
|
|
642
|
+
}));
|
|
643
|
+
if (choice === 'always') {
|
|
644
|
+
this.remote?.contacts('trust', { handle: msg.from.account, trust: 'auto' }).catch((e) => this.notice(`Could not save that at the gateway: ${e.message}`, 'warn'));
|
|
645
|
+
}
|
|
646
|
+
return choice === 'run' || choice === 'always';
|
|
647
|
+
}
|
|
648
|
+
|
|
600
649
|
onPeerMessage(msg) {
|
|
601
650
|
if (this.exiting) return;
|
|
651
|
+
if (msg.kind === 'task' && msg.from.account && !msg.confirmed && msg.from.trust !== 'auto') {
|
|
652
|
+
this.allowContactTask(msg).then((ok) => {
|
|
653
|
+
if (ok) { this.onPeerMessage({ ...msg, confirmed: true }); return; }
|
|
654
|
+
this.screen.log(c.dim(` ✉ Declined the task from @${msg.from.name}`), '');
|
|
655
|
+
this.replyToPeer(msg, `The user of ${this.peerLabel()} declined this task.`);
|
|
656
|
+
}, (e) => this.logError(e));
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
602
659
|
const from = c.bold(`@${msg.from.name}`);
|
|
603
660
|
const width = this.width - 1;
|
|
604
661
|
if (msg.kind === 'reply' && this.userSentToPeers.delete(`${msg.from.id}:${msg.inReplyTo}`)) {
|
|
605
662
|
// the answer to something the user sent: shown, and noted for the model, without a turn of its own
|
|
606
663
|
this.screen.log(`${c.blue('✉')} ${from} ${c.dim('answered:')}`, ...renderMarkdown(msg.text, { width: width - 2 }).map((l) => ' ' + l), '');
|
|
607
|
-
|
|
664
|
+
const whose = msg.from.account ? `of the contact "${msg.from.account}" (another person)` : `(${msg.from.cwd})`;
|
|
665
|
+
this.agent.addReminder(`The user sent a message to another claude-pro session, ${msg.from.name} ${whose}, which answered:\n${msg.text}`);
|
|
608
666
|
return;
|
|
609
667
|
}
|
|
610
668
|
const display = `✉ ${msg.kind === 'reply' ? 'answer from' : 'task from'} @${msg.from.name}: ${msg.text}`;
|
|
@@ -673,6 +731,8 @@ export class App {
|
|
|
673
731
|
// Online at the gateway from the start when this computer is logged in, and after a restart with the same
|
|
674
732
|
// session id so that an already-open page keeps following it.
|
|
675
733
|
autoStartRemote(restart) {
|
|
734
|
+
// Remote control (the web page shows and steers the session) only after /rc or --rc, and through restarts.
|
|
735
|
+
this.remoteControl = Boolean(restart ? restart.remoteControl : this.flags.remoteControl);
|
|
676
736
|
const id = restart?.remote?.id || null;
|
|
677
737
|
if (!id && !this.onlineWanted()) return;
|
|
678
738
|
this.startRemote({ id }).catch((e) => {
|
|
@@ -682,7 +742,7 @@ export class App {
|
|
|
682
742
|
}
|
|
683
743
|
|
|
684
744
|
// Connect this session to the gateway (see remote.js): the web page and the sessions on the account's other
|
|
685
|
-
// computers reach it from then on. Needs the gateway login from /
|
|
745
|
+
// computers reach it from then on. Needs the gateway login from /connect; throws
|
|
686
746
|
// {code: 'NO_GATEWAY_LOGIN'} without it. A gateway that cannot be reached now is tried again in the background;
|
|
687
747
|
// one that refuses the key throws, and that key is not tried again (see syncRemote).
|
|
688
748
|
startRemote({ id } = {}) {
|
|
@@ -691,7 +751,7 @@ export class App {
|
|
|
691
751
|
return this.remoteStarting;
|
|
692
752
|
}
|
|
693
753
|
|
|
694
|
-
// Online or offline as this computer's gateway login is now: after /
|
|
754
|
+
// Online or offline as this computer's gateway login is now: after /connect and /disconnect, and every few seconds (a
|
|
695
755
|
// login or a logout in another window, another account). Resolves with the connection, or null.
|
|
696
756
|
syncRemote() {
|
|
697
757
|
if (this.exiting) return Promise.resolve(null);
|
|
@@ -710,7 +770,7 @@ export class App {
|
|
|
710
770
|
|
|
711
771
|
async connectRemote({ id }) {
|
|
712
772
|
const login = gatewayLogin(this.config.gatewayUrl);
|
|
713
|
-
if (!login) throw Object.assign(new Error(`this computer is not logged in to the gateway ${this.config.gatewayUrl} (/
|
|
773
|
+
if (!login) throw Object.assign(new Error(`this computer is not logged in to the gateway ${this.config.gatewayUrl} (/connect 7bit.fun connects it)`), { code: 'NO_GATEWAY_LOGIN' });
|
|
714
774
|
// What the page may do here, besides watching (see remote.js): nothing with CLAUDE_PRO_REMOTE_COMMANDS=0.
|
|
715
775
|
const commands = remoteCommandsEnabled(this.config.env) ? {
|
|
716
776
|
send: (body) => this.remoteSend(body.text, body.images),
|
|
@@ -724,6 +784,7 @@ export class App {
|
|
|
724
784
|
const remote = new RemoteControl({
|
|
725
785
|
gateway: { url: login.url || this.config.gatewayUrl, apiKey: login.apiKey },
|
|
726
786
|
id,
|
|
787
|
+
rc: this.remoteControl,
|
|
727
788
|
handlers: {
|
|
728
789
|
info: () => ({
|
|
729
790
|
name: this.peerLabel(), machine: machineName(this.config.env), peerId: this.peers?.id || null, title: this.sessionLabel() || '',
|
|
@@ -737,6 +798,7 @@ export class App {
|
|
|
737
798
|
status: () => this.remoteStatus(),
|
|
738
799
|
...commands,
|
|
739
800
|
peerMessage: (msg) => this.onPeerMessage(msg),
|
|
801
|
+
contactEvent: (ev) => this.onContactEvent(ev),
|
|
740
802
|
changed: () => {
|
|
741
803
|
this.screen.schedule();
|
|
742
804
|
if (remote.online && Date.now() - this.remotePeersAt > 10_000) this.refreshRemotePeers();
|
|
@@ -745,7 +807,7 @@ export class App {
|
|
|
745
807
|
refused: () => {
|
|
746
808
|
this.remoteRefused = login.apiKey;
|
|
747
809
|
if (this.remote === remote) { this.remote = null; this.remotePeers = []; }
|
|
748
|
-
this.notice('The gateway refused this computer\'s key: this session is offline there now (/
|
|
810
|
+
this.notice('The gateway refused this computer\'s key: this session is offline there now (/connect 7bit.fun to enter another key).', 'warn');
|
|
749
811
|
},
|
|
750
812
|
},
|
|
751
813
|
});
|
|
@@ -765,6 +827,21 @@ export class App {
|
|
|
765
827
|
return remote;
|
|
766
828
|
}
|
|
767
829
|
|
|
830
|
+
// /rc: the web page (远程控制) shows this session's conversation and may steer it, or (off) only messages between
|
|
831
|
+
// sessions go through the gateway. Resolves with what to tell the user.
|
|
832
|
+
async setRemoteControl(on) {
|
|
833
|
+
this.remoteControl = Boolean(on);
|
|
834
|
+
this.screen.schedule();
|
|
835
|
+
if (!on) {
|
|
836
|
+
if (this.remote) await this.remote.setRc(false);
|
|
837
|
+
return 'Remote control is off: the web page no longer shows this session (messages between sessions still go through the gateway).';
|
|
838
|
+
}
|
|
839
|
+
const remote = this.remote || await this.syncRemote();
|
|
840
|
+
if (!remote) return `Remote control is on, but this session is not online at the gateway: ${stripAnsi(this.remoteState().text)}`;
|
|
841
|
+
await remote.setRc(true);
|
|
842
|
+
return 'Remote control is on: 远程控制 on the gateway\'s web page shows this session and can send it messages and commands. /rc off turns it off.';
|
|
843
|
+
}
|
|
844
|
+
|
|
768
845
|
stopRemote() {
|
|
769
846
|
this.remote?.close();
|
|
770
847
|
this.remote = null;
|
|
@@ -778,14 +855,14 @@ export class App {
|
|
|
778
855
|
if (r) {
|
|
779
856
|
const who = r.account ? ` as ${r.account}` : '';
|
|
780
857
|
const pages = r.viewers ? c.dim(` · ${r.viewers} page${r.viewers === 1 ? '' : 's'} open now`) : '';
|
|
781
|
-
const readOnly = r.commands.length ? '' : c.dim(' · read-only on the page (CLAUDE_PRO_REMOTE_COMMANDS=0)');
|
|
858
|
+
const readOnly = !r.rc ? c.dim(' · remote control off (/rc turns it on)') : r.commands.length ? c.dim(' · remote control on') : c.dim(' · remote control on, read-only on the page (CLAUDE_PRO_REMOTE_COMMANDS=0)');
|
|
782
859
|
const text = r.online ? `${c.green('online')}${who}${pages}${readOnly}` : r.registered ? c.yellow(`not connected now, retrying${who}`) : `connecting to ${r.base}${who}…`;
|
|
783
860
|
return { text };
|
|
784
861
|
}
|
|
785
862
|
if (this.remoteStarting) return { text: 'connecting…' };
|
|
786
863
|
const login = gatewayLogin(this.config.gatewayUrl);
|
|
787
|
-
if (!login) return { text: c.dim(`offline: this computer is not logged in to the gateway ${this.config.gatewayUrl} (/
|
|
788
|
-
if (login.apiKey === this.remoteRefused) return { text: c.red('offline: the gateway refused this computer\'s key (/
|
|
864
|
+
if (!login) return { text: c.dim(`offline: this computer is not logged in to the gateway ${this.config.gatewayUrl} (/connect 7bit.fun)`) };
|
|
865
|
+
if (login.apiKey === this.remoteRefused) return { text: c.red('offline: the gateway refused this computer\'s key (/connect 7bit.fun to enter another)') };
|
|
789
866
|
if (!onlineEnabled(this.config.env)) return { text: c.dim('offline (CLAUDE_PRO_ONLINE=0)') };
|
|
790
867
|
return { text: c.dim('offline') };
|
|
791
868
|
}
|
|
@@ -925,7 +1002,8 @@ export class App {
|
|
|
925
1002
|
const cfg = this.config;
|
|
926
1003
|
const [models, efforts] = await Promise.all([modelChoices(cfg), effortChoices(cfg)]);
|
|
927
1004
|
const chosen = cfg.modelOverride || 'default';
|
|
928
|
-
const
|
|
1005
|
+
const same = (m) => m.id === cfg.model.id && m.provider === cfg.model.provider;
|
|
1006
|
+
const current = models.find((o) => o.value === chosen) || models.find((o) => o.value !== 'default' && same(cfg.resolveModel(o.value)));
|
|
929
1007
|
const effortChosen = cfg.effortOverride || 'default';
|
|
930
1008
|
const { effort } = modelInfo(cfg);
|
|
931
1009
|
return {
|
|
@@ -1055,8 +1133,6 @@ export class App {
|
|
|
1055
1133
|
continueWith: request.continueTurn ? restartNote(request) : '',
|
|
1056
1134
|
cwd: request.cwd || this.cwd,
|
|
1057
1135
|
changedDirectory: Boolean(request.cwd),
|
|
1058
|
-
// where the agent's shell is (a `cd` in Bash moves it): the next process goes on there, not at the project's root
|
|
1059
|
-
agentCwd: request.cwd ? null : this.agent.cwd,
|
|
1060
1136
|
// the browser instance in use (it may be any of several): the next process connects to it again, where the
|
|
1061
1137
|
// tab ids in the conversation are still its tabs'
|
|
1062
1138
|
browser: browserSession.preferred || null,
|
|
@@ -1079,6 +1155,7 @@ export class App {
|
|
|
1079
1155
|
peerName: request.cwd && !this.customTitle ? null : this.peers?.name || this.sessionName,
|
|
1080
1156
|
peerId: this.peers?.id,
|
|
1081
1157
|
remote: this.remote?.handoff() || null,
|
|
1158
|
+
remoteControl: this.remoteControl, // /rc stays on through a restart
|
|
1082
1159
|
};
|
|
1083
1160
|
try {
|
|
1084
1161
|
writeRestartState(state);
|
|
@@ -1116,9 +1193,6 @@ export class App {
|
|
|
1116
1193
|
this.loadSession(state.sessionFile, state.sessionId, { quiet: true });
|
|
1117
1194
|
if (Array.isArray(state.todos)) this.agent.todos = state.todos;
|
|
1118
1195
|
if (state.checkpoints) this.runtime.checkpoints.adopt(state.checkpoints);
|
|
1119
|
-
if (typeof state.agentCwd === 'string' && state.agentCwd !== this.cwd) {
|
|
1120
|
-
try { if (fs.statSync(state.agentCwd).isDirectory()) this.agent.cwd = state.agentCwd; } catch { /* gone: the project's root */ }
|
|
1121
|
-
}
|
|
1122
1196
|
}
|
|
1123
1197
|
if (state.browser && typeof state.browser === 'object' && typeof state.browser.dir === 'string') browserSession.preferred = state.browser;
|
|
1124
1198
|
if (typeof state.draft === 'string' && state.draft) this.editor.restoreDraft(state.draft, state.draftCursor, state.draftParts);
|
|
@@ -1304,7 +1378,10 @@ export class App {
|
|
|
1304
1378
|
c.claude(glyphs.bottomLeft + '─'.repeat(w - 2) + glyphs.bottomRight),
|
|
1305
1379
|
];
|
|
1306
1380
|
lines.push('', c.dim(' Full access: every tool runs immediately, nothing is ever asked. File edits are checkpointed;'), c.dim(' /rewind puts files and/or the conversation back (shell-command changes are not tracked).'));
|
|
1307
|
-
|
|
1381
|
+
// (the model in use cannot be reached: said, with what connects it)
|
|
1382
|
+
const provider = cfg.model.provider;
|
|
1383
|
+
if (!cfg.anyProviderConnected) lines.push('', c.yellow(' ⚠ No model provider is connected. Run /connect.'));
|
|
1384
|
+
else if (!cfg.providerConnected(provider)) lines.push('', c.yellow(` ⚠ ${cfg.model.label} is a model of ${cfg.providerName(provider)}, which is not connected. Run /connect ${provider === '7bit' ? '7bit.fun' : provider}, or /model for another.`));
|
|
1308
1385
|
const mcp = this.runtime.mcp.status();
|
|
1309
1386
|
if (mcp.length) {
|
|
1310
1387
|
const ok = mcp.filter((m) => m.status === 'connected').length;
|
|
@@ -1574,7 +1651,7 @@ export class App {
|
|
|
1574
1651
|
});
|
|
1575
1652
|
const items = [...peers, ...fileItems];
|
|
1576
1653
|
if (!items.length) {
|
|
1577
|
-
if (!q && m.index === 0 && !m[1] && !quiet && !this.fileIndex.loading) this.flash(this.remote ? 'No file or session is available here or online at the gateway' : 'No file or other session is available on this computer
|
|
1654
|
+
if (!q && m.index === 0 && !m[1] && !quiet && !this.fileIndex.loading) this.flash(this.remote ? 'No file or session is available here or online at the gateway' : 'No file or other session is available on this computer');
|
|
1578
1655
|
return null;
|
|
1579
1656
|
}
|
|
1580
1657
|
return { items, from: cursor - q.length - (quoted ? 2 : 1), to: cursor };
|
|
@@ -1590,7 +1667,7 @@ export class App {
|
|
|
1590
1667
|
}
|
|
1591
1668
|
const items = this.peerSuggestionItems(q);
|
|
1592
1669
|
if (!items.length) {
|
|
1593
|
-
if (!q && atStart && !quiet) this.flash(this.remote ? 'No other session is running here or online at the gateway' : 'No other session is running on this computer
|
|
1670
|
+
if (!q && atStart && !quiet) this.flash(this.remote ? 'No other session is running here or online at the gateway' : 'No other session is running on this computer');
|
|
1594
1671
|
return null;
|
|
1595
1672
|
}
|
|
1596
1673
|
return { items, from: cursor - q.length - 1, to: cursor };
|
|
@@ -1882,7 +1959,8 @@ export class App {
|
|
|
1882
1959
|
|
|
1883
1960
|
// What `@name` in a message the user wrote stands for, told to the model: which session, and how to reach it.
|
|
1884
1961
|
async peerMentions(prompt) {
|
|
1885
|
-
|
|
1962
|
+
// (a colon inside is a contact's session, yzc:computer/name; one at the end is punctuation)
|
|
1963
|
+
const refs = [...new Set([...String(prompt).matchAll(/(?:^|\s)@([^\s@"&,。;;:!!??、))]+)/gu)].map((m) => m[1].replace(/:+$/, '')).filter(Boolean))];
|
|
1886
1964
|
if (!refs.length) return [];
|
|
1887
1965
|
const local = this.peers?.peers() || [];
|
|
1888
1966
|
const notes = [];
|
|
@@ -1890,7 +1968,8 @@ export class App {
|
|
|
1890
1968
|
let found = resolvePeer(local, this.remotePeers, ref, { ids: false });
|
|
1891
1969
|
if (!found.peer && !found.ambiguous && this.remote) found = resolvePeer(local, await this.refreshRemotePeers(), ref, { ids: false });
|
|
1892
1970
|
const p = found.peer;
|
|
1893
|
-
if (p) notes.push(`@${ref} is the claude-pro session "${p.label
|
|
1971
|
+
if (p?.contact) notes.push(`@${ref} is the claude-pro session "${p.label}" of the contact "${p.account}", another person (not the user)`);
|
|
1972
|
+
else if (p) notes.push(`@${ref} is the claude-pro session "${p.label || p.name}" ${p.remote ? `on the user's computer "${p.machine}"` : 'on this computer'}, working in ${p.cwd}`);
|
|
1894
1973
|
else if (found.ambiguous) notes.push(found.error);
|
|
1895
1974
|
}
|
|
1896
1975
|
if (!notes.length) return [];
|
|
@@ -1935,6 +2014,11 @@ export class App {
|
|
|
1935
2014
|
} finally {
|
|
1936
2015
|
this.flushStreaming();
|
|
1937
2016
|
this.flushActive(true);
|
|
2017
|
+
// When the answer came and how long the turn took, under the answer (the user asked for the time, 2026-11-21).
|
|
2018
|
+
if (result && !result.interrupted && !error) {
|
|
2019
|
+
const at = new Date().toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit', hour12: false });
|
|
2020
|
+
this.screen.log(c.dim(`✻ Done at ${at} · worked ${formatDuration(Date.now() - this.turnStart)}`), '');
|
|
2021
|
+
}
|
|
1938
2022
|
this.answerPeers(result, error);
|
|
1939
2023
|
this.busy = false;
|
|
1940
2024
|
this.controller = null;
|
|
@@ -2516,14 +2600,14 @@ export class App {
|
|
|
2516
2600
|
return { lines, cursor, input };
|
|
2517
2601
|
}
|
|
2518
2602
|
|
|
2519
|
-
// In the input box's top border: the directory
|
|
2603
|
+
// In the input box's top border: the session's directory (only /cd changes it), and this
|
|
2520
2604
|
// session's name for the other sessions.
|
|
2521
2605
|
boxTitle() {
|
|
2522
2606
|
const dir = this.agent?.cwd || this.cwd;
|
|
2523
2607
|
const home = os.homedir();
|
|
2524
2608
|
const shown = dir.toLowerCase().startsWith(home.toLowerCase()) ? '~' + dir.slice(home.length) : dir;
|
|
2525
2609
|
const name = this.peers || this.remote ? `@${this.peerLabel()}` : '';
|
|
2526
|
-
return { left: shown.replace(/\\/g, '/'), right: name && this.remote?.online ? `⇄ ${name}` : name };
|
|
2610
|
+
return { left: shown.replace(/\\/g, '/'), right: name && this.remote?.online && this.remoteControl ? `⇄ ${name}` : name };
|
|
2527
2611
|
}
|
|
2528
2612
|
|
|
2529
2613
|
// The prompt cache clock, as in Claude Code's VS Code extension: the minutes the conversation's cache has left
|
package/src/utils/shell.js
CHANGED
|
@@ -279,7 +279,7 @@ export function hasRipgrep(config) { return ripgrepPath(config) !== null; }
|
|
|
279
279
|
|
|
280
280
|
// `stdin`: text to feed the command on standard input (hooks get their event JSON this way).
|
|
281
281
|
// Without it the command's stdin is closed, so nothing can hang waiting for input.
|
|
282
|
-
export function spawnShell(shell, command, { cwd, env,
|
|
282
|
+
export function spawnShell(shell, command, { cwd, env, stdin }) {
|
|
283
283
|
const withStdin = typeof stdin === 'string';
|
|
284
284
|
const stdio = [withStdin ? 'pipe' : 'ignore', 'pipe', 'pipe'];
|
|
285
285
|
const feed = (child) => {
|
|
@@ -291,20 +291,19 @@ export function spawnShell(shell, command, { cwd, env, cwdFile, stdin }) {
|
|
|
291
291
|
cwd, env, windowsHide: true, windowsVerbatimArguments: true, stdio,
|
|
292
292
|
}));
|
|
293
293
|
}
|
|
294
|
-
// The command is evaluated via an env var so no quoting is needed
|
|
295
|
-
//
|
|
294
|
+
// The command is evaluated via an env var so no quoting is needed. Each command starts in the session's
|
|
295
|
+
// directory: a `cd` lasts for that command only (the user's choice, 2026-11-21). On Windows the script first
|
|
296
296
|
// writes its own (MSYS) process id to a file, which is how killTree finds everything under it.
|
|
297
297
|
const pidFile = isWin ? path.join(os.tmpdir(), `claude-pro-pid-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`) : null;
|
|
298
298
|
const script = [
|
|
299
299
|
...(pidFile ? ['if [ -n "$CLAUDE_PRO_PID_FILE" ]; then echo $$ > "$CLAUDE_PRO_PID_FILE"; fi'] : []),
|
|
300
300
|
`eval "$CLAUDE_PRO_COMMAND"${withStdin ? '' : ' < /dev/null'}`,
|
|
301
301
|
'__ccc_status=$?',
|
|
302
|
-
'if [ -n "$CLAUDE_PRO_CWD_FILE" ]; then { pwd -W 2>/dev/null || pwd -P; } > "$CLAUDE_PRO_CWD_FILE" 2>/dev/null; fi',
|
|
303
302
|
'exit $__ccc_status',
|
|
304
303
|
].join('\n');
|
|
305
304
|
const child = spawn(shell.path, ['-c', script], {
|
|
306
305
|
cwd,
|
|
307
|
-
env: { ...env, CLAUDE_PRO_COMMAND: command,
|
|
306
|
+
env: { ...env, CLAUDE_PRO_COMMAND: command, CLAUDE_PRO_PID_FILE: pidFile || '' },
|
|
308
307
|
windowsHide: true,
|
|
309
308
|
detached: !isWin,
|
|
310
309
|
stdio,
|