cli-setu 0.3.6 → 0.3.7
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/package.json +1 -1
- package/src/cli-adapters/claude.js +7 -2
- package/src/sessionLifecycle.js +10 -1
- package/src/supervisor.js +3 -2
package/package.json
CHANGED
|
@@ -161,7 +161,11 @@ const ESC_FOOTER_RE = /esc to cancel/i;
|
|
|
161
161
|
// match PROCEED_RE is never mistaken for this one's.
|
|
162
162
|
function distinguishingTextFor(event) {
|
|
163
163
|
const { tool_name, tool_input } = event || {};
|
|
164
|
-
|
|
164
|
+
// 2026-11-16 (real bug, found with the owner's own session log): the FULL path (C:\demo\python.txt) was
|
|
165
|
+
// used here, but Claude Code's prompt line only shows the file NAME ("Do you want to create python.txt?"),
|
|
166
|
+
// so isMenuStillOnScreen never found the path, the first 500 ms poll decided the menu was gone and the
|
|
167
|
+
// phone showed "Resolved at the laptop" for a prompt nobody had answered. The file name is what is on screen.
|
|
168
|
+
if ((tool_name === 'Write' || tool_name === 'Edit' || tool_name === 'Read') && tool_input?.file_path) return String(tool_input.file_path).split(/[\\/]/).pop();
|
|
165
169
|
if ((tool_name === 'Bash' || tool_name === 'PowerShell') && tool_input?.command) return tool_input.command;
|
|
166
170
|
return null;
|
|
167
171
|
}
|
|
@@ -370,7 +374,8 @@ module.exports = {
|
|
|
370
374
|
isMenuStillOnScreen: (scrollbackWindow, distinguishingText) => {
|
|
371
375
|
const clean = stripAnsi(scrollbackWindow);
|
|
372
376
|
if (!PROCEED_RE.test(clean)) return false;
|
|
373
|
-
|
|
377
|
+
// Whitespace-insensitive: a long command wraps across screen lines, which would otherwise hide it.
|
|
378
|
+
if (distinguishingText && !clean.replace(/\s+/g, '').includes(String(distinguishingText).replace(/\s+/g, ''))) return false;
|
|
374
379
|
return true;
|
|
375
380
|
},
|
|
376
381
|
distinguishingTextFor,
|
package/src/sessionLifecycle.js
CHANGED
|
@@ -12,6 +12,15 @@
|
|
|
12
12
|
|
|
13
13
|
const crypto = require('node:crypto');
|
|
14
14
|
|
|
15
|
+
// The readable prefix of a session ID. It is the device name from ~/.cli-setu/config.json (what the
|
|
16
|
+
// Devices tab shows, and what the owner can rename) when there is one, else the machine name, so a
|
|
17
|
+
// renamed device no longer leaks the real computer name through the session ID shown on the phone.
|
|
18
|
+
// Only letters, digits and dashes are kept. Added 2026-11-16 for Play Console screenshots.
|
|
19
|
+
function sessionPrefix(deviceName, hostname) {
|
|
20
|
+
const clean = String(deviceName || '').replace(/[^a-zA-Z0-9-]+/g, '-').replace(/^-+|-+$/g, '');
|
|
21
|
+
return clean || hostname;
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
function newSessionId({ hostname, workingDir }) {
|
|
16
25
|
const dirHash = crypto.createHash('sha1').update(workingDir).digest('hex').slice(0, 8);
|
|
17
26
|
return `${hostname}-${dirHash}-${crypto.randomBytes(8).toString('hex')}`;
|
|
@@ -42,4 +51,4 @@ function isSessionEndedResponse(res) {
|
|
|
42
51
|
return !!res && res.status === 410;
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
module.exports = { newSessionId, endSessionOnBackend, isSessionEndedResponse };
|
|
54
|
+
module.exports = { newSessionId, sessionPrefix, endSessionOnBackend, isSessionEndedResponse };
|
package/src/supervisor.js
CHANGED
|
@@ -47,7 +47,7 @@ const { createDiagnostics } = require('./diagnostics');
|
|
|
47
47
|
const { attachStdinForwarder } = require('./stdinForwarder');
|
|
48
48
|
const { adoptPhoneKey } = require('./sharedKey');
|
|
49
49
|
const { approvalFingerprint, createApprovalDeduper, relayWithRetry } = require('./approvalRelay');
|
|
50
|
-
const { newSessionId, endSessionOnBackend, isSessionEndedResponse } = require('./sessionLifecycle');
|
|
50
|
+
const { newSessionId, sessionPrefix, endSessionOnBackend, isSessionEndedResponse } = require('./sessionLifecycle');
|
|
51
51
|
|
|
52
52
|
// Real bug found by testing: this script's own console.log/console.error
|
|
53
53
|
// calls write to the SAME process.stdout the PTY's raw output is echoed
|
|
@@ -148,7 +148,8 @@ const WORKING_DIR = process.cwd();
|
|
|
148
148
|
// `cli-setu` in the same folder twice at once (e.g. two terminal tabs) never
|
|
149
149
|
// silently shares one session.
|
|
150
150
|
// PROD-003: minted fresh every run and never reused (see sessionLifecycle.js).
|
|
151
|
-
|
|
151
|
+
// The prefix is the device name from config.json (renamable, shown on the phone) when set, else the machine name.
|
|
152
|
+
const SESSION_ID = newSessionId({ hostname: sessionPrefix(config.deviceName, os.hostname()), workingDir: WORKING_DIR });
|
|
152
153
|
|
|
153
154
|
// SETU-005: the real identity a duplicate-session check needs - resolves
|
|
154
155
|
// symlinks (fs.realpathSync) so two different-looking paths to the SAME
|