claude-code-remote-pilot 0.2.12 → 0.2.13
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/lib/Watcher.js +3 -20
- package/package.json +1 -1
package/lib/Watcher.js
CHANGED
|
@@ -6,7 +6,6 @@ const notifier = require('./notifier');
|
|
|
6
6
|
const LIMIT_RE = /hit your limit|usage limit|rate limit|limit reached|try again|resets/i;
|
|
7
7
|
const RESPONSE_RE = /do you want to proceed|esc to cancel|ctrl\+e to explain|❯\s*\d+\.\s*yes/i;
|
|
8
8
|
const RUNNING_RE = /esc to interrupt/i;
|
|
9
|
-
const IDLE_RE = /^\s*>\s*$/;
|
|
10
9
|
// Claude Code footer: "tokens: ↑1,234 ↓567" or "↑1.2k ↓890"
|
|
11
10
|
const TOKEN_RE = /↑\s*([\d.,]+[km]?)\s*↓\s*([\d.,]+[km]?)/i;
|
|
12
11
|
// Limit reset time: "resets at 2:00 AM" or "resets at 14:30"
|
|
@@ -26,8 +25,6 @@ class Watcher {
|
|
|
26
25
|
this.lastResumeAt = 0;
|
|
27
26
|
this._timer = null;
|
|
28
27
|
this._busy = false;
|
|
29
|
-
this._prevOutputHash = '';
|
|
30
|
-
this._outputUnchangedCount = 0;
|
|
31
28
|
}
|
|
32
29
|
|
|
33
30
|
_stripAnsi(text) {
|
|
@@ -98,25 +95,14 @@ class Watcher {
|
|
|
98
95
|
const raw = this._capture();
|
|
99
96
|
const text = this._stripAnsi(raw);
|
|
100
97
|
const nonEmptyLines = text.split('\n').filter(l => l.trim());
|
|
101
|
-
const lastLine = nonEmptyLines[nonEmptyLines.length - 1] || '';
|
|
102
98
|
const recentLines = nonEmptyLines.slice(-5).join('\n');
|
|
103
99
|
|
|
104
|
-
// Extract token usage from footer whenever
|
|
100
|
+
// Extract token usage from footer whenever visible
|
|
105
101
|
const tokenMatch = recentLines.match(TOKEN_RE);
|
|
106
102
|
if (tokenMatch) {
|
|
107
103
|
this.session.tokens = { sent: tokenMatch[1], received: tokenMatch[2] };
|
|
108
104
|
}
|
|
109
105
|
|
|
110
|
-
// Track output stability
|
|
111
|
-
const outputHash = this._hash(recentLines);
|
|
112
|
-
if (outputHash === this._prevOutputHash) {
|
|
113
|
-
this._outputUnchangedCount++;
|
|
114
|
-
} else {
|
|
115
|
-
this._prevOutputHash = outputHash;
|
|
116
|
-
this._outputUnchangedCount = 0;
|
|
117
|
-
}
|
|
118
|
-
const outputIsStable = this._outputUnchangedCount >= 2;
|
|
119
|
-
|
|
120
106
|
if (LIMIT_RE.test(text)) {
|
|
121
107
|
await this._handleLimit(text);
|
|
122
108
|
} else if (RESPONSE_RE.test(recentLines)) {
|
|
@@ -130,14 +116,12 @@ class Watcher {
|
|
|
130
116
|
this.session.status = 'running';
|
|
131
117
|
this.session.resumeAt = null;
|
|
132
118
|
}
|
|
133
|
-
} else
|
|
119
|
+
} else {
|
|
120
|
+
// No "esc to interrupt" visible — Claude is not actively processing
|
|
134
121
|
if (this.session.status !== 'idle') {
|
|
135
122
|
this.session.status = 'idle';
|
|
136
123
|
this.session.resumeAt = null;
|
|
137
124
|
}
|
|
138
|
-
} else if (this.session.status !== 'running') {
|
|
139
|
-
this.session.status = 'running';
|
|
140
|
-
this.session.resumeAt = null;
|
|
141
125
|
}
|
|
142
126
|
} finally {
|
|
143
127
|
this._busy = false;
|
|
@@ -150,7 +134,6 @@ class Watcher {
|
|
|
150
134
|
if ((Date.now() / 1000) - this.lastResumeAt < this.cooldown) return;
|
|
151
135
|
|
|
152
136
|
this.lastHash = hash;
|
|
153
|
-
this._outputUnchangedCount = 0;
|
|
154
137
|
const wait = this._parseWait(text);
|
|
155
138
|
const resetTime = this._parseResetTime(text);
|
|
156
139
|
|
package/package.json
CHANGED