claude-tmux 1.0.2 → 1.0.3
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/dist/index.js +20 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,6 +35,11 @@ function isBusy(output) {
|
|
|
35
35
|
}
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
38
|
+
function isDone(output) {
|
|
39
|
+
// Claude shows "✻ [verb] for [duration]" when task completes
|
|
40
|
+
// e.g., "✻ Baked for 1m 35s", "✻ Cogitated for 2m 10s"
|
|
41
|
+
return /✻\s+\w+\s+for\s+\d+[ms]/.test(output);
|
|
42
|
+
}
|
|
38
43
|
function filterUIChrome(output) {
|
|
39
44
|
const lines = output.split('\n');
|
|
40
45
|
const filtered = lines.filter(line => {
|
|
@@ -55,22 +60,31 @@ function filterUIChrome(output) {
|
|
|
55
60
|
}
|
|
56
61
|
async function waitForIdle(session) {
|
|
57
62
|
const timeout = 600000; // 10 minutes
|
|
58
|
-
const lines =
|
|
63
|
+
const lines = 100; // Capture more lines to catch done signal
|
|
59
64
|
const startTime = Date.now();
|
|
60
65
|
let lastOutput = "";
|
|
61
|
-
let
|
|
66
|
+
let idleCount = 0;
|
|
62
67
|
while (Date.now() - startTime < timeout) {
|
|
63
68
|
await sleep(2000);
|
|
64
69
|
try {
|
|
65
70
|
const output = runTmux(`capture-pane -t "${session}" -p -S -${lines}`);
|
|
66
|
-
// If busy, keep waiting
|
|
71
|
+
// If busy, reset idle count and keep waiting
|
|
67
72
|
if (isBusy(output)) {
|
|
68
73
|
lastOutput = output;
|
|
69
|
-
|
|
74
|
+
idleCount = 0;
|
|
70
75
|
continue;
|
|
71
76
|
}
|
|
72
|
-
//
|
|
73
|
-
|
|
77
|
+
// Check for positive done signal
|
|
78
|
+
if (isDone(output)) {
|
|
79
|
+
return filterUIChrome(output);
|
|
80
|
+
}
|
|
81
|
+
// Not busy but no done signal - use settling delay
|
|
82
|
+
// Require 2 consecutive idle checks (4 seconds) before returning
|
|
83
|
+
idleCount++;
|
|
84
|
+
if (idleCount >= 2) {
|
|
85
|
+
return filterUIChrome(output);
|
|
86
|
+
}
|
|
87
|
+
lastOutput = output;
|
|
74
88
|
}
|
|
75
89
|
catch (e) {
|
|
76
90
|
return `Error: ${e.message}`;
|