claude-tmux 1.0.14 → 1.0.16
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 +9 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { writeFileSync } from "fs";
|
|
|
8
8
|
const SESSION_PREFIX = "claude-";
|
|
9
9
|
const TIMEOUT_MS = 900000; // 15 minutes
|
|
10
10
|
const POLL_INTERVAL_MS = 2000; // 2 seconds
|
|
11
|
-
const INITIAL_DELAY_MS =
|
|
11
|
+
const INITIAL_DELAY_MS = 10000; // 10 seconds
|
|
12
12
|
const CAPTURE_LINES = 100;
|
|
13
13
|
const IDLE_THRESHOLD = 5; // consecutive idle polls
|
|
14
14
|
function runTmux(args) {
|
|
@@ -43,8 +43,9 @@ function isBusy(output) {
|
|
|
43
43
|
}
|
|
44
44
|
function isDone(output) {
|
|
45
45
|
// Claude shows "✻ [verb] for [duration]" when task completes
|
|
46
|
-
// e.g., "✻ Baked for 1m 35s", "✻
|
|
47
|
-
|
|
46
|
+
// e.g., "✻ Baked for 1m 35s", "✻ Sautéed for 2m 10s"
|
|
47
|
+
// Use \S+ instead of \w+ to support Unicode characters like é
|
|
48
|
+
return /✻\s+\S+\s+for\s+\d+[ms]/.test(output);
|
|
48
49
|
}
|
|
49
50
|
function filterUIChrome(output) {
|
|
50
51
|
const lines = output.split('\n');
|
|
@@ -113,7 +114,7 @@ Spawn Claude Code instances in tmux sessions for long-running tasks.
|
|
|
113
114
|
## Tips
|
|
114
115
|
- Verify completion before killing. Idle sessions are fine.`,
|
|
115
116
|
});
|
|
116
|
-
server.tool("spawn", "
|
|
117
|
+
server.tool("spawn", "Start a Claude Code instance in a tmux session.", {
|
|
117
118
|
name: z.string().min(1).max(50).describe("Unique session name (e.g., 'refactor-auth', 'debug-api')"),
|
|
118
119
|
prompt: z.string().describe("Initial prompt to send to Claude on startup"),
|
|
119
120
|
workdir: z.string().describe("Working directory for Claude to operate in"),
|
|
@@ -128,7 +129,7 @@ server.tool("spawn", "Launch a new Claude Code instance in a tmux session. Creat
|
|
|
128
129
|
}
|
|
129
130
|
const tempFile = `/tmp/claude-prompt-${session}.txt`;
|
|
130
131
|
writeFileSync(tempFile, prompt);
|
|
131
|
-
runTmux(`send-keys -t "${session}" 'claude --dangerously-skip-permissions
|
|
132
|
+
runTmux(`send-keys -t "${session}" 'cat ${tempFile} | claude --dangerously-skip-permissions && rm ${tempFile}' Enter`);
|
|
132
133
|
return response(`Started ${session}`);
|
|
133
134
|
});
|
|
134
135
|
server.tool("read", "Wait for a Claude session to finish working and return the terminal output. You can continue other work while waiting.", {
|
|
@@ -141,7 +142,7 @@ server.tool("read", "Wait for a Claude session to finish working and return the
|
|
|
141
142
|
const output = await waitForIdle(session);
|
|
142
143
|
return response(output);
|
|
143
144
|
});
|
|
144
|
-
server.tool("send", "Send a
|
|
145
|
+
server.tool("send", "Send a message to a running session.", {
|
|
145
146
|
name: z.string().describe("Session name (as provided to spawn)"),
|
|
146
147
|
text: z.string().describe("Message to send to Claude"),
|
|
147
148
|
}, async ({ name, text }) => {
|
|
@@ -163,7 +164,7 @@ server.tool("send", "Send a follow-up message to a running Claude session. Use t
|
|
|
163
164
|
return response(`Error: ${errorMessage(e)}`);
|
|
164
165
|
}
|
|
165
166
|
});
|
|
166
|
-
server.tool("kill", "Terminate a
|
|
167
|
+
server.tool("kill", "Terminate a session.", {
|
|
167
168
|
name: z.string().describe("Session name (as provided to spawn)"),
|
|
168
169
|
}, async ({ name }) => {
|
|
169
170
|
const session = sessionName(name);
|
|
@@ -178,7 +179,7 @@ server.tool("kill", "Terminate a Claude tmux session and clean up resources.", {
|
|
|
178
179
|
return response(`Error: ${errorMessage(e)}`);
|
|
179
180
|
}
|
|
180
181
|
});
|
|
181
|
-
server.tool("list", "List
|
|
182
|
+
server.tool("list", "List active sessions.", {}, async () => {
|
|
182
183
|
const output = runTmuxSafe(`list-sessions -F "#{session_name}"`) ?? "";
|
|
183
184
|
const sessions = output.split('\n')
|
|
184
185
|
.filter(s => s.startsWith(SESSION_PREFIX))
|