dispatch-agents 0.5.0 → 0.5.1
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/cli.js +19 -29
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -211,8 +211,10 @@ function ensureSession() {
|
|
|
211
211
|
execSync(
|
|
212
212
|
`tmux new-session -d -s "${DISPATCH_SESSION}" -n "dispatch"`
|
|
213
213
|
);
|
|
214
|
-
execSync(`tmux set -t "${DISPATCH_SESSION}"
|
|
215
|
-
execSync(`tmux set -t "${DISPATCH_SESSION}"
|
|
214
|
+
execSync(`tmux set -t "${DISPATCH_SESSION}" mouse on`);
|
|
215
|
+
execSync(`tmux set -t "${DISPATCH_SESSION}" history-limit 50000`);
|
|
216
|
+
execQuiet(`tmux set -t "${DISPATCH_SESSION}" set-titles on`);
|
|
217
|
+
execQuiet(`tmux set -t "${DISPATCH_SESSION}" set-titles-string "#W"`);
|
|
216
218
|
execSync(
|
|
217
219
|
`tmux send-keys -t "${DISPATCH_SESSION}:dispatch" "# Dispatch control window" Enter`
|
|
218
220
|
);
|
|
@@ -241,6 +243,9 @@ function createWindow(id, cwd) {
|
|
|
241
243
|
log.error(`Failed to create tmux window: ${err}`);
|
|
242
244
|
process.exit(1);
|
|
243
245
|
}
|
|
246
|
+
const target = `${DISPATCH_SESSION}:${id}`;
|
|
247
|
+
execQuiet(`tmux setw -t "${target}" allow-passthrough on`);
|
|
248
|
+
execQuiet(`tmux setw -t "${target}" automatic-rename off`);
|
|
244
249
|
const countStr = execQuiet(
|
|
245
250
|
`tmux list-windows -t "${DISPATCH_SESSION}" | wc -l`
|
|
246
251
|
);
|
|
@@ -249,19 +254,9 @@ function createWindow(id, cwd) {
|
|
|
249
254
|
const red = parseInt(hex.slice(0, 2), 16);
|
|
250
255
|
const green = parseInt(hex.slice(2, 4), 16);
|
|
251
256
|
const blue = parseInt(hex.slice(4, 6), 16);
|
|
252
|
-
const target = `${DISPATCH_SESSION}:${id}`;
|
|
253
|
-
execSync(
|
|
254
|
-
`tmux send-keys -t "${target}" "printf '\\\\033]6;1;bg;red;brightness;${red}\\\\007'" Enter`
|
|
255
|
-
);
|
|
256
|
-
execSync(
|
|
257
|
-
`tmux send-keys -t "${target}" "printf '\\\\033]6;1;bg;green;brightness;${green}\\\\007'" Enter`
|
|
258
|
-
);
|
|
259
|
-
execSync(
|
|
260
|
-
`tmux send-keys -t "${target}" "printf '\\\\033]6;1;bg;blue;brightness;${blue}\\\\007'" Enter`
|
|
261
|
-
);
|
|
262
257
|
const badge = Buffer.from(id).toString("base64");
|
|
263
258
|
execSync(
|
|
264
|
-
`tmux send-keys -t "${target}" "printf '\\\\033]1337;SetBadgeFormat=${badge}\\\\007'" Enter`
|
|
259
|
+
`tmux send-keys -t "${target}" "printf '\\\\033]0;${id}\\\\007\\\\033]6;1;bg;red;brightness;${red}\\\\007\\\\033]6;1;bg;green;brightness;${green}\\\\007\\\\033]6;1;bg;blue;brightness;${blue}\\\\007\\\\033]1337;SetBadgeFormat=${badge}\\\\007' && clear" Enter`
|
|
265
260
|
);
|
|
266
261
|
return true;
|
|
267
262
|
}
|
|
@@ -294,19 +289,12 @@ function tmuxAttach(window) {
|
|
|
294
289
|
const target = window ? `${DISPATCH_SESSION}:${window}` : DISPATCH_SESSION;
|
|
295
290
|
const hasTTY = process.stdin.isTTY;
|
|
296
291
|
if (hasTTY) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
});
|
|
302
|
-
} else {
|
|
303
|
-
spawnSync("tmux", ["attach", "-t", target], {
|
|
304
|
-
stdio: "inherit"
|
|
305
|
-
});
|
|
306
|
-
}
|
|
292
|
+
spawnSync("tmux", ["attach", "-t", target], {
|
|
293
|
+
stdio: "inherit",
|
|
294
|
+
env: { ...process.env, TERM_PROGRAM: "dumb" }
|
|
295
|
+
});
|
|
307
296
|
} else if (process.platform === "darwin") {
|
|
308
|
-
const
|
|
309
|
-
const script = openTerminalTabAppleScript(cmd);
|
|
297
|
+
const script = openTerminalTabAppleScript(target);
|
|
310
298
|
if (script) {
|
|
311
299
|
spawnSync("osascript", ["-e", script], { stdio: "pipe" });
|
|
312
300
|
} else {
|
|
@@ -316,7 +304,8 @@ function tmuxAttach(window) {
|
|
|
316
304
|
log.warn(`No TTY available. Run manually: tmux attach -t ${target}`);
|
|
317
305
|
}
|
|
318
306
|
}
|
|
319
|
-
function openTerminalTabAppleScript(
|
|
307
|
+
function openTerminalTabAppleScript(target) {
|
|
308
|
+
const agentName = target.includes(":") ? target.split(":").pop() : target;
|
|
320
309
|
const terminals = [
|
|
321
310
|
{
|
|
322
311
|
name: "iTerm2",
|
|
@@ -326,7 +315,8 @@ function openTerminalTabAppleScript(command) {
|
|
|
326
315
|
tell current window
|
|
327
316
|
create tab with default profile
|
|
328
317
|
tell current session
|
|
329
|
-
|
|
318
|
+
set name to "${agentName}"
|
|
319
|
+
write text "TERM_PROGRAM=dumb tmux attach -t ${target}"
|
|
330
320
|
end tell
|
|
331
321
|
end tell
|
|
332
322
|
end tell`
|
|
@@ -339,7 +329,7 @@ function openTerminalTabAppleScript(command) {
|
|
|
339
329
|
tell application "System Events" to tell process "Warp"
|
|
340
330
|
keystroke "t" using command down
|
|
341
331
|
delay 0.3
|
|
342
|
-
keystroke "${
|
|
332
|
+
keystroke "tmux attach -t ${target}"
|
|
343
333
|
key code 36
|
|
344
334
|
end tell
|
|
345
335
|
end tell`
|
|
@@ -349,7 +339,7 @@ function openTerminalTabAppleScript(command) {
|
|
|
349
339
|
bundleId: "com.apple.Terminal",
|
|
350
340
|
script: `tell application "Terminal"
|
|
351
341
|
activate
|
|
352
|
-
do script "${
|
|
342
|
+
do script "tmux attach -t ${target}"
|
|
353
343
|
end tell`
|
|
354
344
|
}
|
|
355
345
|
];
|