claude-remote 0.4.1 → 0.4.2
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/server.js +27 -14
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -158,11 +158,12 @@ let CWD = _parsedCwd;
|
|
|
158
158
|
const CLAUDE_HOME = path.join(os.homedir(), '.claude');
|
|
159
159
|
const CLAUDE_STATE_FILE = path.join(os.homedir(), '.claude.json');
|
|
160
160
|
const PROJECTS_DIR = path.join(CLAUDE_HOME, 'projects');
|
|
161
|
-
const AUTH_HELLO_TIMEOUT_MS = 5000;
|
|
162
|
-
const WS_CLOSE_AUTH_FAILED = 4001;
|
|
163
|
-
const WS_CLOSE_AUTH_TIMEOUT = 4002;
|
|
164
|
-
const WS_CLOSE_REASON_AUTH_FAILED = 'auth_failed';
|
|
165
|
-
const WS_CLOSE_REASON_AUTH_TIMEOUT = 'auth_timeout';
|
|
161
|
+
const AUTH_HELLO_TIMEOUT_MS = 5000;
|
|
162
|
+
const WS_CLOSE_AUTH_FAILED = 4001;
|
|
163
|
+
const WS_CLOSE_AUTH_TIMEOUT = 4002;
|
|
164
|
+
const WS_CLOSE_REASON_AUTH_FAILED = 'auth_failed';
|
|
165
|
+
const WS_CLOSE_REASON_AUTH_TIMEOUT = 'auth_timeout';
|
|
166
|
+
const DEBUG_TTY_INPUT = process.env.CLAUDE_REMOTE_DEBUG_TTY_INPUT === '1';
|
|
166
167
|
|
|
167
168
|
// --- State ---
|
|
168
169
|
let claudeProc = null;
|
|
@@ -208,10 +209,15 @@ const PARTIAL_AUTO_ALLOW = new Set(['Read', 'Glob', 'Grep', 'Write', 'Edit']);
|
|
|
208
209
|
// --- Logging → file only (never pollute the terminal) ---
|
|
209
210
|
const LOG_FILE = path.join(os.homedir(), '.claude', 'bridge.log');
|
|
210
211
|
fs.writeFileSync(LOG_FILE, `--- Bridge started ${new Date().toISOString()} ---\n`);
|
|
211
|
-
function log(msg) {
|
|
212
|
-
const line = `[${new Date().toISOString()}] ${msg}\n`;
|
|
213
|
-
fs.appendFileSync(LOG_FILE, line);
|
|
214
|
-
}
|
|
212
|
+
function log(msg) {
|
|
213
|
+
const line = `[${new Date().toISOString()}] ${msg}\n`;
|
|
214
|
+
fs.appendFileSync(LOG_FILE, line);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function formatTtyInputChunk(chunk) {
|
|
218
|
+
const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
219
|
+
return `len=${buf.length} hex=${buf.toString('hex')} base64=${buf.toString('base64')} utf8=${JSON.stringify(buf.toString('utf8'))}`;
|
|
220
|
+
}
|
|
215
221
|
|
|
216
222
|
function wsLabel(ws) {
|
|
217
223
|
const clientId = ws && ws._clientInstanceId ? ` client=${ws._clientInstanceId}` : '';
|
|
@@ -273,11 +279,18 @@ function setTurnState(phase, { sessionId = currentSessionId, reason = '', force
|
|
|
273
279
|
}
|
|
274
280
|
|
|
275
281
|
function attachTtyForwarders() {
|
|
276
|
-
if (!isTTY || ttyInputForwarderAttached) return;
|
|
277
|
-
|
|
278
|
-
ttyInputHandler = (chunk) => {
|
|
279
|
-
if (
|
|
280
|
-
|
|
282
|
+
if (!isTTY || ttyInputForwarderAttached) return;
|
|
283
|
+
|
|
284
|
+
ttyInputHandler = (chunk) => {
|
|
285
|
+
if (DEBUG_TTY_INPUT) {
|
|
286
|
+
try {
|
|
287
|
+
log(`TTY input ${formatTtyInputChunk(chunk)}`);
|
|
288
|
+
} catch (err) {
|
|
289
|
+
log(`TTY input log error: ${err.message}`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (claudeProc) claudeProc.write(chunk);
|
|
293
|
+
};
|
|
281
294
|
ttyResizeHandler = () => {
|
|
282
295
|
if (claudeProc) claudeProc.resize(process.stdout.columns, process.stdout.rows);
|
|
283
296
|
};
|