@termhub/agent 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/dist/cli.js +28 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -626,8 +626,9 @@ SESSION=$(tmux display-message -p -t "$TMUX_PANE" '#{session_name}' 2>/dev/null)
|
|
|
626
626
|
[ -n "$SESSION" ] || exit 0
|
|
627
627
|
if [ "$TOOL" = codex ]; then EVENT="$2"; else EVENT=$(cat 2>/dev/null); fi
|
|
628
628
|
[ -n "$EVENT" ] || EVENT='{}'
|
|
629
|
-
# Tool calls: only the tool's name travels (never its input),
|
|
630
|
-
# last one for this session \u2014 twenty edits in a row
|
|
629
|
+
# Tool calls: only the tool's name travels (never its input), with the spinner's verb when one is on
|
|
630
|
+
# screen, and only when the pair changed since the last one for this session \u2014 twenty edits in a row
|
|
631
|
+
# are one request as long as the verb stays the same (a new verb mid-run is a new request). The marker is per tmux
|
|
631
632
|
# session, under TMPDIR, with the session name reduced to filename-safe characters.
|
|
632
633
|
MARK="\${TMPDIR:-/tmp}/termhub-hook-$(printf '%s' "$SESSION" | tr -c 'A-Za-z0-9_-' '_')"
|
|
633
634
|
case "$EVENT" in
|
|
@@ -643,9 +644,30 @@ case "$EVENT" in
|
|
|
643
644
|
REST=\${REST#*'"'}
|
|
644
645
|
NAME=\${REST%%'"'*}
|
|
645
646
|
case "$NAME" in '' | *[!A-Za-z0-9_.-]*) exit 0 ;; esac
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
647
|
+
# Claude Code's spinner verb ("\u273B Moonwalking\u2026 (12s \xB7 esc to interrupt)"): the visible pane is
|
|
648
|
+
# read here, on the machine, and only the verb may leave it \u2014 one word of 2 to 24 ASCII letters
|
|
649
|
+
# right after a spinner glyph at column 0 and a single space, immediately followed by "\u2026" or
|
|
650
|
+
# "...", then the end of the line or a space. Column 0 because Claude Code draws its spinner
|
|
651
|
+
# there, while a draft in the input box or indented tool output can look just like one. The
|
|
652
|
+
# lowest such line of the last 24 non-blank rows wins (the live spinner sits above the todo list
|
|
653
|
+
# and the input box; blank rows under a short session are skipped). Both grep and sed run under
|
|
654
|
+
# LC_ALL=C: bytes the locale calls invalid then neither trip grep's "binary file matches" (which
|
|
655
|
+
# would also swallow the rest of the screen) nor sed's "illegal byte sequence" on macOS, and
|
|
656
|
+
# the match works the same on GNU, BSD and busybox. ASCII only on purpose: a customised verb
|
|
657
|
+
# with accents is dropped rather than half-matched. The case below checks the result again, so
|
|
658
|
+
# the hand-built JSON only ever gets letters.
|
|
659
|
+
VERB=$(tmux capture-pane -p -t "$TMUX_PANE" 2>/dev/null | LC_ALL=C grep -v '^[[:space:]]*$' 2>/dev/null | tail -n 24 |
|
|
660
|
+
LC_ALL=C sed -n -E 's/^(\xB7|\u2722|\u2733|\u2736|\u273B|\u273D|\\*) ([A-Za-z]{2,24})(\u2026|\\.\\.\\.)( .*)?$/\\2/p' | tail -n 1)
|
|
661
|
+
case "$VERB" in *[!A-Za-z]*) VERB= ;; esac
|
|
662
|
+
[ "\${#VERB}" -le 24 ] || VERB=
|
|
663
|
+
KEY="$NAME\${VERB:+ $VERB}"
|
|
664
|
+
[ "$(cat "$MARK" 2>/dev/null)" = "$KEY" ] && exit 0
|
|
665
|
+
printf '%s' "$KEY" 2>/dev/null > "$MARK"
|
|
666
|
+
if [ -n "$VERB" ]; then
|
|
667
|
+
EVENT=$(printf '{"hook_event_name":"PreToolUse","tool_name":"%s","verb":"%s"}' "$NAME" "$VERB")
|
|
668
|
+
else
|
|
669
|
+
EVENT=$(printf '{"hook_event_name":"PreToolUse","tool_name":"%s"}' "$NAME")
|
|
670
|
+
fi
|
|
649
671
|
;;
|
|
650
672
|
# A new turn starts fresh, and so does an answered notification: a permission prompt takes the tab
|
|
651
673
|
# out of working, and the tool the person approves is the same one that set the marker, so without
|
|
@@ -1866,7 +1888,7 @@ async function status3() {
|
|
|
1866
1888
|
}
|
|
1867
1889
|
|
|
1868
1890
|
// src/version.ts
|
|
1869
|
-
var AGENT_VERSION = "0.4.
|
|
1891
|
+
var AGENT_VERSION = "0.4.2";
|
|
1870
1892
|
|
|
1871
1893
|
// src/rpc/update.ts
|
|
1872
1894
|
var PACKAGE = "@termhub/agent";
|
package/package.json
CHANGED