hop
Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key.
Brought by drakestapleton
hop / Omega / tests / check-ui.sh
| 1 | #!/bin/sh |
| 2 | # macOS arm64 check of the Omega launcher panel (Generated/hoppanel, source Omega/ui/hoppanel.om). |
| 3 | # Needs a logged-in desktop session: the panel opens a real window, in the background, for about six seconds, seven times, |
| 4 | # types "sa" into its own search field, sends itself arrow down, Enter and Escape, and ends. It opens no app and does not take the keyboard. |
| 5 | # Usage, from the Hop tree: sh Omega/tests/check-ui.sh |
| 6 | # 1. Generated/hoppanel and Omega/ui/hoppanel.om match Generated/UI-SHA256SUMS, and the rules inside the panel |
| 7 | # are the functions of Omega/hopcore.om as they are today (the hopcore-block line). |
| 8 | # 2. The panel, signed ad hoc in a temp dir and run with HOPCHECK=1, exits 1 and prints |
| 9 | # "hoppanel apps N shown H first NAME selected R enter APP" with 0 < H < N: the apps were listed, text put in |
| 10 | # through the field's editor narrowed them through hopfuzz, the first row was read back from the list's own |
| 11 | # data source, arrow down moved the list's selection, Enter chose the selected app (and opened nothing), |
| 12 | # Escape hid the panel, a spare global key could be registered and its handler showed the panel again |
| 13 | # ("key 0 hid 1 back 1"). |
| 14 | # 3. With HOPCHECK=type:example.com/page the first row is "Open https://example.com/page" and Enter chooses it |
| 15 | # (the shape of an address is the core's fn weba; the order of the rows its fn swrank); plain text gets no |
| 16 | # address row. |
| 17 | # 4. With a file index of four paths in HOP_CONFIG_DIR: type:quarterly gives the two files that match, the |
| 18 | # one whose name starts so and has the shorter path first; type:example.com gives the folder of exactly that |
| 19 | # name before the web address (the rule that a bare address may as well be a file name). |
| 20 | # 5. Before anything is typed (HOPCHECK=idle): with three remembered launches of Calculator from the app in |
| 21 | # front (HOPFRONT) it is offered first with the reason; without an app in front the most used app is; |
| 22 | # with nothing remembered only running apps are, six at most. |
| 23 | # 6. What is opened is remembered (HOPRECORD): three openings give three launches and a count of 3 that Hop's |
| 24 | # own decoder reads back (Omega/tests/ui-memory), habits.json for the owner only, and the app is offered |
| 25 | # next time; files Hop wrote keep their 400 launches, their other entries and their machine; a file that |
| 26 | # is not what Hop writes is left alone; a check that opens nothing writes nothing. |
| 27 | # 7. Copied things: from a history sealed as Hop seals it (Omega/tests/ui-clips) a web address just copied is |
| 28 | # offered first, or the copied thing itself when a browser is in front; Enter puts text or a picture on a |
| 29 | # clipboard (the check's own); typed words find a copied thing; another key shows nothing; the key is also |
| 30 | # read through the security tool from a Keychain item made and deleted here. |
| 31 | # Recording (HOPCLIPREC, from the check's own board): a text goes in front and Hop's decoder reads the |
| 32 | # history back; a repeated text moves; concealed text is not kept; a picture is a sealed PNG; a first thing |
| 33 | # starts a history; over the limit the oldest unpinned go; a history under another key is left alone. |
| 34 | # Screens and commands: "clipboard" and Enter shows the copied things alone and typing looks in them; |
| 35 | # Pin or Unpin and Delete from History change the history Hop reads; "settings" and "quit hop" find their |
| 36 | # commands; the Accounts screen lists the saved accounts. |
| 37 | # 8. Saved accounts: from two Keychain items the panel itself saves for the check (HOPVAULT, HOPVAULTADD) an account is found by name, shown |
| 38 | # with its kind and note, and Enter copies its value to the check's board; a model whose key is such an |
| 39 | # account is asked with "Authorization: Bearer" and that value; without HOPVAULT no account is read. |
| 40 | # The file index: the program run with "index" writes, for a small tree, byte for byte what Hop's own loop |
| 41 | # writes (Omega/tests/ui-index); the panel then finds a file through it; "reindex" finds the command. |
| 42 | # A conversation: a second question (HOPASK2) carries the first and its answer; after New chat it goes alone. |
| 43 | # The menu of the icon in the menu bar has Hop's items; Clear clipboard history leaves the pinned things. |
| 44 | # Forwarded ports: a link is started (a stand-in, with Hop's ssh options) only for a valid port nothing serves. |
| 45 | # Files on other machines, against stand-ins for ssh and scp: found by Hop's search command and shown with |
| 46 | # the machine; brought over byte for byte; a folder's path copied; a failed copy, an unreachable machine and |
| 47 | # one without a file list are said, and the last is told to build its list by Hop's command. |
| 48 | # The agent: stand-in commands in the settings are run through the login shell with the request behind Hop's |
| 49 | # standing instructions; Claude Code's stream is read; a missing agent is said and none run in its place; a |
| 50 | # check runs nothing before the person's yes; old approval-bypass commands are brought to today's. |
| 51 | # 9. Ask: with settings that name a keyed model and one without a key (played by nc with a streaming server's |
| 52 | # lines), HOPCHECK=ask:what is omega? sends Hop's request to the second and shows "Omega is a language." |
| 53 | # 10. Negative control: a panel that throws the matcher's answer away (Omega/tests/mutant/hoppanel-deaf) must not pass. |
| 54 | # Last line: HOPPANEL-MACOS PASS or FAIL n; only PASS exits 0. |
| 55 | set -eu |
| 56 | cd "$(dirname "$0")/../.." |
| 57 | export LC_ALL=C |
| 58 | [ "$(uname -sm)" = "Darwin arm64" ] || { echo "HOPPANEL-MACOS NOT_RUN (host is $(uname -sm))"; exit 1; } |
| 59 | B=$(mktemp -d "${TMPDIR:-/tmp}/hoppanel.XXXXXX") |
| 60 | fails=0 |
| 61 | pass() { echo "PASS $1"; } |
| 62 | fail() { echo "FAIL $1"; fails=$((fails + 1)); } |
| 63 | if shasum -a 256 -c Generated/UI-SHA256SUMS > "$B/sums.log" 2>&1; then pass "Generated/hoppanel and Omega/ui/hoppanel.om match Generated/UI-SHA256SUMS" |
| 64 | else fail "UI-SHA256SUMS mismatch"; cat "$B/sums.log"; fi |
| 65 | blk=$(sed -n '/^fn isword /,/^fn main to int$/p' Omega/hopcore.om | sed '$d' | shasum -a 256 | cut -c1-64) |
| 66 | if grep -q "^# hopcore-block $blk\$" Generated/UI-SHA256SUMS; then pass "the panel's rules are the functions of Omega/hopcore.om as they are today" |
| 67 | else fail "Omega/hopcore.om changed since the panel was built: rerun Omega/gen-ui.sh"; fi |
| 68 | run() { # run PROGRAM NAME [HOPCHECK]: its status in $st, its output in $B/NAME.out |
| 69 | cp "$1" "$B/$2"; chmod 755 "$B/$2"; codesign --force --sign - "$B/$2" 2> /dev/null |
| 70 | # A run that does not end by itself within 90 seconds is stopped (its status is then over 128): no check may |
| 71 | # sit waiting, for instance on a system dialog. |
| 72 | st=0 |
| 73 | HOP_CONFIG_DIR="$B/cfg" HOPCHECK="${3:-1}" "$B/$2" > "$B/$2.out" 2> "$B/$2.err" & |
| 74 | runpid=$! |
| 75 | ( sleep 90; kill "$runpid" 2> /dev/null ) > /dev/null 2>&1 & |
| 76 | dog=$! |
| 77 | wait "$runpid" || st=$? |
| 78 | kill "$dog" 2> /dev/null || true |
| 79 | wait "$dog" 2> /dev/null || true |
| 80 | } |
| 81 | # Hop's folder for these runs: a file index of four paths, so the file rows do not depend on this Mac's files |
| 82 | mkdir -p "$B/cfg" |
| 83 | printf '%s\n' '/Volumes/Work/Documents/Quarterly Report.pdf' '/Volumes/Work/Documents/old/quarterly-numbers.csv' \ |
| 84 | '/Volumes/Work/Music/song.mp3' '/Volumes/Work/Projects/example.com/' > "$B/cfg/file-index.bin" |
| 85 | run Generated/hoppanel panel |
| 86 | line=$(head -n 1 "$B/panel.out") |
| 87 | n=$(printf '%s\n' "$line" | sed -n 's/^hoppanel apps \([0-9][0-9]*\) shown \([0-9][0-9]*\) first ..* selected [0-9][0-9]* enter ..* key 0 hid 1 back 1$/\1/p') |
| 88 | h=$(printf '%s\n' "$line" | sed -n 's/^hoppanel apps \([0-9][0-9]*\) shown \([0-9][0-9]*\) first ..* selected [0-9][0-9]* enter ..* key 0 hid 1 back 1$/\2/p') |
| 89 | if [ "$st" = 1 ] && [ -n "$n" ] && [ -n "$h" ] && [ "$h" -gt 0 ] && [ "$h" -lt "$n" ] && [ ! -s "$B/panel.err" ] |
| 90 | then pass "the panel lists the apps and narrows them as typed ($line)" |
| 91 | else fail "the panel: status $st, output [$line]"; head -n 3 "$B/panel.err"; fi |
| 92 | run Generated/hoppanel web type:example.com/page |
| 93 | line=$(head -n 1 "$B/web.out") |
| 94 | if [ "$st" = 1 ] && printf '%s\n' "$line" | grep -Eq '^hoppanel apps [0-9]+ shown [1-9][0-9]* first Open https://example\.com/page selected 0 enter https://example\.com/page$' |
| 95 | then pass "a typed web address gets a row that Enter chooses ($line)" |
| 96 | else fail "the web address: status $st, output [$line]"; fi |
| 97 | run Generated/hoppanel plain type:notanaddress |
| 98 | line=$(head -n 1 "$B/plain.out") |
| 99 | if printf '%s\n' "$line" | grep -q 'https://'; then fail "plain text was taken for a web address [$line]" |
| 100 | else pass "plain text gets no address row ($line; status $st)"; fi |
| 101 | run Generated/hoppanel files type:quarterly |
| 102 | line=$(head -n 1 "$B/files.out") |
| 103 | want='hoppanel apps [0-9]+ shown [0-9]+ first Quarterly Report\.pdf - /Volumes/Work/Documents selected 0 enter /Volumes/Work/Documents/Quarterly Report\.pdf' |
| 104 | if [ "$st" = 1 ] && printf '%s\n' "$line" | grep -Eq "^$want\$"; then pass "files from Hop's index are rows, best first, and Enter chooses one ($line)" |
| 105 | else fail "the file rows: status $st, output [$line]"; fi |
| 106 | run Generated/hoppanel named type:example.com |
| 107 | line=$(head -n 1 "$B/named.out") |
| 108 | want='hoppanel apps [0-9]+ shown [0-9]+ first example\.com - /Volumes/Work/Projects selected 0 enter /Volumes/Work/Projects/example\.com/' |
| 109 | if [ "$st" = 1 ] && printf '%s\n' "$line" | grep -Eq "^$want\$"; then pass "a folder with exactly the typed name comes before the web address ($line)" |
| 110 | else fail "the folder before the address: status $st, output [$line]"; fi |
| 111 | # Before anything is typed: the offers of Hop's rule. Three launches of Calculator from the app in front (an id |
| 112 | # given by HOPFRONT), at an hour far from now, and Notes opened four times just now. |
| 113 | hour=$(( ($(date +%H | sed 's/^0//') + 12) % 24 )) |
| 114 | now=$(( $(date +%s) - 978307200 )) |
| 115 | { printf '['; for k in 1 2 3; do printf '{"app":"/System/Applications/Calculator.app","hour":%s,"at":%s,"from":"com.example.editor"},' "$hour" "$k"; done |
| 116 | printf '{"app":"/System/Applications/Notes.app","hour":%s,"at":4,"from":"com.example.other"}]\n' "$hour"; } > "$B/cfg/habits.json" |
| 117 | printf '{"Mac:/System/Applications/Notes.app":{"count":4,"path":"/System/Applications/Notes.app","last":%s}}\n' "$now" > "$B/cfg/recents.json" |
| 118 | HOPFRONT=com.example.editor; export HOPFRONT |
| 119 | run Generated/hoppanel idle1 idle |
| 120 | unset HOPFRONT |
| 121 | line=$(head -n 1 "$B/idle1.out") |
| 122 | if [ "$st" = 1 ] && printf '%s\n' "$line" | grep -Eq '^hoppanel apps [0-9]+ shown [1-6] first Calculator - You often open this from here selected 0 enter Calculator$' |
| 123 | then pass "nothing typed: the app you usually open from the app in front is offered first, with the reason ($line)" |
| 124 | else fail "offers with a habit: status $st, output [$line]"; fi |
| 125 | run Generated/hoppanel idle2 idle |
| 126 | line=$(head -n 1 "$B/idle2.out") |
| 127 | if [ "$st" = 1 ] && printf '%s\n' "$line" | grep -Eq '^hoppanel apps [0-9]+ shown [1-6] first Notes - One of your most used selected 0 enter Notes$' |
| 128 | then pass "nothing typed and no app in front: the most used app is offered first ($line)" |
| 129 | else fail "offers by use: status $st, output [$line]"; fi |
| 130 | rm -f "$B/cfg/habits.json" "$B/cfg/recents.json" |
| 131 | run Generated/hoppanel idle3 idle |
| 132 | line=$(head -n 1 "$B/idle3.out") |
| 133 | if printf '%s\n' "$line" | grep -Eq '^hoppanel apps [0-9]+ shown ([1-6] first .* - Running now selected 0 enter .*|0 first selected .*)$' |
| 134 | then pass "nothing typed and nothing remembered: only running apps are offered, six at most ($line)" |
| 135 | else fail "offers with nothing remembered: status $st, output [$line]"; fi |
| 136 | # Typed text: an app's own use and habits count as in Hop. "cal" finds Calendar and Calculator; Calendar leads |
| 137 | # until Calculator is the one that is used, or the one usually opened from the app in front. |
| 138 | run Generated/hoppanel cal1 'type:cal' |
| 139 | lead=$(head -n 1 "$B/cal1.out" | sed -n 's/.* enter \(.*\)$/\1/p') |
| 140 | printf '{"Mac:/System/Applications/Calculator.app":{"count":6,"path":"/System/Applications/Calculator.app","last":%s}}\n' "$(( $(date +%s) - 978307200 ))" > "$B/cfg/recents.json" |
| 141 | run Generated/hoppanel cal2 'type:cal' |
| 142 | used=$(head -n 1 "$B/cal2.out" | sed -n 's/.* enter \(.*\)$/\1/p') |
| 143 | rm -f "$B/cfg/recents.json" |
| 144 | hour=$(( ($(date +%H | sed 's/^0//') + 12) % 24 )) |
| 145 | { printf '['; for k in 1 2 3; do printf '{"app":"/System/Applications/Calculator.app","hour":%s,"at":%s,"from":"com.example.editor"},' "$hour" "$k"; done |
| 146 | printf '{"app":"/System/Applications/Notes.app","hour":%s,"at":4,"from":"com.example.other"}]\n' "$hour"; } > "$B/cfg/habits.json" |
| 147 | HOPFRONT=com.example.editor; export HOPFRONT |
| 148 | run Generated/hoppanel cal3 'type:cal' |
| 149 | habit=$(head -n 1 "$B/cal3.out" | sed -n 's/.* enter \(.*\)$/\1/p') |
| 150 | HOPFRONT=com.example.other; export HOPFRONT |
| 151 | run Generated/hoppanel cal4 'type:cal' |
| 152 | other=$(head -n 1 "$B/cal4.out" | sed -n 's/.* enter \(.*\)$/\1/p') |
| 153 | unset HOPFRONT |
| 154 | rm -f "$B/cfg/habits.json" |
| 155 | if [ "$lead/$used/$habit/$other" = "Calendar/Calculator/Calculator/Calendar" ] |
| 156 | then pass "for typed text an app that is used more, or usually opened from the app in front, leads ($lead, then $used, $habit, $other)" |
| 157 | else fail "use and habit for typed apps: $lead/$used/$habit/$other"; fi |
| 158 | # What is opened is remembered in Hop's two files, in a shape Hop reads back (Omega/tests/ui-memory decodes them |
| 159 | # exactly as Hop does). HOPRECORD makes a check that opens nothing remember what Enter chose. |
| 160 | EXTRA="" |
| 161 | if [ -f /Library/Developer/CommandLineTools/usr/include/swift/module.modulemap ] && \ |
| 162 | [ -f /Library/Developer/CommandLineTools/usr/include/swift/bridging.modulemap ]; then |
| 163 | sed "s#HOP_DIR#$PWD#" toolchain/overlay.yaml > "$B/overlay.yaml" |
| 164 | EXTRA="-vfsoverlay $B/overlay.yaml -Xcc -ivfsoverlay -Xcc $B/overlay.yaml" |
| 165 | fi |
| 166 | # shellcheck disable=SC2086 |
| 167 | if swiftc -O -swift-version 5 $EXTRA -o "$B/memory" Omega/tests/ui-memory/main.swift > "$B/memory.log" 2>&1; then |
| 168 | run Generated/hoppanel quiet 'type:calculator' |
| 169 | if [ ! -e "$B/cfg/habits.json" ] && [ ! -e "$B/cfg/recents.json" ]; then pass "a check that opens nothing writes nothing" |
| 170 | else fail "a check without HOPRECORD wrote Hop's files"; fi |
| 171 | HOPRECORD=1; HOPFRONT=com.example.editor; export HOPRECORD HOPFRONT |
| 172 | for k in 1 2 3; do run Generated/hoppanel rec$k 'type:calculator'; done |
| 173 | got=$("$B/memory" "$B/cfg" | tr '\n' ';') |
| 174 | want='habits 3 fresh 3 last /System/Applications/Calculator.app from [com.example.editor] hour-now true;recents 1 Mac:/System/Applications/Calculator.app=3*;' |
| 175 | if [ "$got" = "$want" ] && [ "$(stat -f %Lp "$B/cfg/habits.json")" = 600 ] |
| 176 | then pass "three openings are remembered as Hop remembers them, and Hop's own decoder reads them back ($got)" |
| 177 | else fail "remembering: [$got] mode $(stat -f %Lp "$B/cfg/habits.json" 2> /dev/null)"; fi |
| 178 | unset HOPRECORD |
| 179 | run Generated/hoppanel idle4 idle |
| 180 | line=$(head -n 1 "$B/idle4.out") |
| 181 | if printf '%s\n' "$line" | grep -q ' first Calculator - You often open this from here selected 0 ' |
| 182 | then pass "and what was remembered is what is offered next time" |
| 183 | else fail "the remembered app is not offered: [$line]"; fi |
| 184 | # Files Hop wrote: 400 launches (the most kept) and two entries, one of another machine. All of it must survive. |
| 185 | python3 -I - "$B/cfg" <<'PYEOF' |
| 186 | import json, sys, time |
| 187 | d = sys.argv[1]; now = time.time() - 978307200 |
| 188 | json.dump([{"app": "/System/Applications/Notes.app", "from": "", "hour": 3, "at": now - 9000 + k} for k in range(400)], open(d + "/habits.json", "w")) |
| 189 | json.dump({"spark:/srv/data/report.txt": {"path": "/srv/data/report.txt", "machine": "spark", "count": 7, "last": now - 86400.5}, |
| 190 | "Mac:/System/Applications/Notes.app": {"path": "/System/Applications/Notes.app", "count": 2, "last": now - 4000}}, open(d + "/recents.json", "w")) |
| 191 | PYEOF |
| 192 | HOPRECORD=1; export HOPRECORD |
| 193 | run Generated/hoppanel rec4 'type:calculator' |
| 194 | run Generated/hoppanel rec5 'type:quarterly' |
| 195 | got=$("$B/memory" "$B/cfg" | tr '\n' ';') |
| 196 | want='habits 400 fresh 1 last /System/Applications/Calculator.app from [com.example.editor] hour-now true;recents 4 Mac:/System/Applications/Calculator.app=1* Mac:/System/Applications/Notes.app=2 Mac:/Volumes/Work/Documents/Quarterly Report.pdf=1* spark:/srv/data/report.txt=7@spark;' |
| 197 | if [ "$got" = "$want" ]; then pass "what Hop wrote is kept: the newest 400 launches, the other entries and their machine; an opened file is counted too" |
| 198 | else fail "Hop's own entries: [$got]"; fi |
| 199 | # 500 entries is the most: with one more the one that weighs least goes (here the one opened longest ago) |
| 200 | python3 -I - "$B/cfg" <<'PYEOF' |
| 201 | import json, sys, time |
| 202 | d = sys.argv[1]; now = time.time() - 978307200 |
| 203 | json.dump({"Mac:/Volumes/Work/old/%d" % k: {"path": "/Volumes/Work/old/%d" % k, "count": 1, "last": now - 86400 * (1 + k)} for k in range(500)}, open(d + "/recents.json", "w")) |
| 204 | PYEOF |
| 205 | run Generated/hoppanel rec7 'type:calculator' |
| 206 | got=$(python3 -I -c 'import json,sys; r=json.load(open(sys.argv[1])); print(len(r), "Mac:/Volumes/Work/old/499" in r, "Mac:/Volumes/Work/old/498" in r, "Mac:/System/Applications/Calculator.app" in r)' "$B/cfg/recents.json") |
| 207 | if [ "$got" = "500 False True True" ]; then pass "over 500 remembered entries the one that weighs least goes" |
| 208 | else fail "the 501st entry: [$got]"; fi |
| 209 | printf 'not what Hop writes\n' > "$B/cfg/habits.json"; printf '[1, 2]\n' > "$B/cfg/recents.json" |
| 210 | cp "$B/cfg/habits.json" "$B/habits.keep"; cp "$B/cfg/recents.json" "$B/recents.keep" |
| 211 | run Generated/hoppanel rec6 'type:calculator' |
| 212 | if cmp -s "$B/cfg/habits.json" "$B/habits.keep" && cmp -s "$B/cfg/recents.json" "$B/recents.keep" |
| 213 | then pass "a file that is not what Hop writes is left alone" |
| 214 | else fail "the panel wrote over a file it could not read"; fi |
| 215 | unset HOPRECORD HOPFRONT |
| 216 | else fail "Omega/tests/ui-memory does not build"; head -n 5 "$B/memory.log"; fi |
| 217 | rm -f "$B/cfg/habits.json" "$B/cfg/recents.json" |
| 218 | # Copied things: a history sealed exactly as Hop seals it (Omega/tests/ui-clips, CryptoKit) under a key made here, |
| 219 | # which the panel is given (HOPCLIPKEY). Four things: a web address copied 20 seconds ago, two lines of text, a |
| 220 | # picture, and a pinned text. A check pastes into a board of its own, never the real clipboard. |
| 221 | # shellcheck disable=SC2086 |
| 222 | if swiftc -O -swift-version 5 $EXTRA -o "$B/clips" Omega/tests/ui-clips/main.swift > "$B/clips.log" 2>&1; then |
| 223 | key=$(head -c 32 /dev/urandom | base64) |
| 224 | "$B/clips" write "$B/cfg" "$key" 20 > /dev/null |
| 225 | HOPCLIPKEY=$key; export HOPCLIPKEY |
| 226 | run Generated/hoppanel clip1 idle |
| 227 | line=$(head -n 1 "$B/clip1.out"); rows=$(printf '%s\n' "$line" | sed -n 's/.* shown \([0-9]*\) .*/\1/p') |
| 228 | if printf '%s\n' "$line" | grep -q ' first Open https://example.com/docs - You copied a web address selected 0 enter https://example.com/docs$' |
| 229 | then pass "nothing typed: a web address just copied is offered to open first ($rows rows)" |
| 230 | else fail "the copied address: [$line]"; fi |
| 231 | HOPFRONT=com.apple.Safari; HOPRECORD=1; export HOPFRONT HOPRECORD |
| 232 | run Generated/hoppanel clip2 idle |
| 233 | line=$(head -n 1 "$B/clip2.out") |
| 234 | if printf '%s\n' "$line" | grep -q ' first Paste: https://example.com/docs - You just copied this selected 0 enter https://example.com/docs pasted https://example.com/docs$' |
| 235 | then pass "with a browser in front the copied thing itself comes first, and Enter puts it on the clipboard" |
| 236 | else fail "pasting the newest copied thing: [$line]"; fi |
| 237 | unset HOPFRONT |
| 238 | HOPROW=$((rows - 1)); export HOPROW |
| 239 | run Generated/hoppanel clip3 idle |
| 240 | unset HOPROW |
| 241 | line=$(head -n 1 "$B/clip3.out") |
| 242 | if printf '%s\n' "$line" | grep -q " selected $((rows - 1)) enter Image pasted png 70\$" |
| 243 | then pass "the rest of the history follows the apps; a picture is unsealed and put on the clipboard as it was (70 bytes)" |
| 244 | else fail "pasting a picture: [$line]"; fi |
| 245 | run Generated/hoppanel clip4 'type:MEETING line' |
| 246 | line=$(head -n 1 "$B/clip4.out") |
| 247 | if printf '%s\n' "$line" | grep -q ' first Paste: meeting notes ⏎ line "two" with café selected 0 enter meeting notes ⏎ line "two" with café pasted meeting notes line "two" with café $' |
| 248 | then pass "typed words find a copied thing that has them all, whatever the case; what is pasted is the text as it was copied" |
| 249 | else fail "searching copied things: [$line]"; fi |
| 250 | unset HOPRECORD |
| 251 | rm -f "$B/cfg/habits.json" "$B/cfg/recents.json" |
| 252 | HOPCLIPKEY=$(head -c 32 /dev/urandom | base64); export HOPCLIPKEY |
| 253 | run Generated/hoppanel clip5 idle |
| 254 | line=$(head -n 1 "$B/clip5.out") |
| 255 | if ! printf '%s\n' "$line" | grep -q -e 'Paste: ' -e 'example.com'; then pass "under another key the history stays shut: nothing of it is shown" |
| 256 | else fail "a wrong key showed the history: [$line]"; fi |
| 257 | # the key the way Hop gets it: from a Keychain item of the security tool, here one of this check's own |
| 258 | item="com.aienos.hop.omega.check.$$" |
| 259 | if security add-generic-password -s "$item" -a storage-key-v2 -w "$key" -T /usr/bin/security -D internal -j "Hop Omega check, safe to delete" > /dev/null 2>&1; then |
| 260 | HOPCLIPKEY="tool:$item"; export HOPCLIPKEY |
| 261 | run Generated/hoppanel clip6 idle |
| 262 | security delete-generic-password -s "$item" -a storage-key-v2 > /dev/null 2>&1 |
| 263 | line=$(head -n 1 "$B/clip6.out") |
| 264 | if printf '%s\n' "$line" | grep -q ' first Open https://example.com/docs - You copied a web address ' |
| 265 | then pass "the key is read through the security tool from a Keychain item, the way Hop reads its own" |
| 266 | else fail "the key through the security tool: [$line]"; fi |
| 267 | else echo "NOT_RUN the key through the security tool (no Keychain item could be made here)"; fi |
| 268 | # Recording what is copied (HOPCLIPREC: once, from the check's own board), read back as Hop reads it |
| 269 | # (ui-clips read: CryptoKit and Hop's Codable shape). |
| 270 | unset HOPCLIPKEY; HOPCLIPKEY=$key; HOPCLIPREC=1; export HOPCLIPKEY HOPCLIPREC |
| 271 | rm -f "$B/cfg/habits.json" "$B/cfg/recents.json" |
| 272 | "$B/clips" write "$B/cfg" "$key" 20 > /dev/null |
| 273 | "$B/clips" board-text "fresh words from the check" |
| 274 | run Generated/hoppanel rc1 idle |
| 275 | got=$("$B/clips" read "$B/cfg" "$key" | head -n 3 | tr '\n' ';') |
| 276 | want='items 5 mode 600 fillers 0;text[fresh words from the check] from[] pinned false fresh true id 36;text[https://example.com/docs] from[Safari] pinned false fresh true id 36;' |
| 277 | if [ "$got" = "$want" ] && [ -f "$B/cfg/clipboard.before-hop-omega.bin" ] && head -n 1 "$B/rc1.out" | grep -q ' first Paste: fresh words from the check - You just copied this ' |
| 278 | then pass "a copied text is added in front of the history, sealed so that Hop reads it back; the history as it was is set aside first" |
| 279 | else fail "recording a text: [$got]"; fi |
| 280 | "$B/clips" board-text "a pinned snippet" |
| 281 | run Generated/hoppanel rc2 idle |
| 282 | got=$("$B/clips" read "$B/cfg" "$key" | head -n 2 | tr '\n' ';') |
| 283 | if [ "$got" = 'items 5 mode 600 fillers 0;text[a pinned snippet] from[] pinned true fresh true id 36;' ] |
| 284 | then pass "a text that is already there moves to the front and stays pinned; nothing is added twice" |
| 285 | else fail "recording a text again: [$got]"; fi |
| 286 | "$B/clips" board-concealed "do-not-keep-this" |
| 287 | run Generated/hoppanel rc3 idle |
| 288 | got=$("$B/clips" read "$B/cfg" "$key" | tr '\n' ';') |
| 289 | case "$got" in 'items 5 mode 600 fillers 0;text[a pinned snippet]'*) ok=1;; *) ok=0;; esac |
| 290 | if [ "$ok" = 1 ] && ! printf '%s' "$got" | grep -q 'do-not-keep'; then pass "what is marked concealed is not kept" |
| 291 | else fail "a concealed text: [$got]"; fi |
| 292 | "$B/clips" board-picture |
| 293 | run Generated/hoppanel rc4 idle |
| 294 | got=$("$B/clips" read "$B/cfg" "$key" | head -n 2 | tr '\n' ';') |
| 295 | if [ "$got" = 'items 6 mode 600 fillers 0;picture[3x2] from[] pinned false fresh true id 36;' ] |
| 296 | then pass "a copied picture is kept as a sealed PNG of its own that Hop can unseal and read (3 by 2 pixels)" |
| 297 | else fail "recording a picture: [$got]"; fi |
| 298 | rm -rf "$B/cfg/clipboard.bin" "$B/cfg/clip-images" |
| 299 | "$B/clips" board-text "the very first" |
| 300 | run Generated/hoppanel rc5 idle |
| 301 | got=$("$B/clips" read "$B/cfg" "$key" | tr '\n' ';') |
| 302 | if [ "$got" = 'items 1 mode 600 fillers 0;text[the very first] from[] pinned false fresh true id 36;' ] |
| 303 | then pass "with no history yet the first copied thing starts one" |
| 304 | else fail "starting a history: [$got]"; fi |
| 305 | "$B/clips" write "$B/cfg" "$key" 20 60 > /dev/null |
| 306 | "$B/clips" board-text "one more" |
| 307 | run Generated/hoppanel rc6 idle |
| 308 | got=$("$B/clips" read "$B/cfg" "$key" | head -n 2 | tr '\n' ';') |
| 309 | if [ "$got" = 'items 51 mode 600 fillers 46;text[one more] from[] pinned false fresh true id 36;' ] |
| 310 | then pass "over the limit the oldest unpinned things go: 50 unpinned and the pinned one are left of 65" |
| 311 | else fail "the limit: [$got]"; fi |
| 312 | cp "$B/cfg/clipboard.bin" "$B/clipboard.keep" |
| 313 | HOPCLIPKEY=$(head -c 32 /dev/urandom | base64); export HOPCLIPKEY |
| 314 | "$B/clips" board-text "under another key" |
| 315 | run Generated/hoppanel rc7 idle |
| 316 | if cmp -s "$B/cfg/clipboard.bin" "$B/clipboard.keep"; then pass "a history that this key does not open is left alone" |
| 317 | else fail "the panel wrote over a history it could not read"; fi |
| 318 | # The Clipboard screen, the two commands, and pinning and deleting a copied thing |
| 319 | unset HOPCLIPREC |
| 320 | HOPCLIPKEY=$key; export HOPCLIPKEY |
| 321 | rm -rf "$B/cfg/clipboard.bin" "$B/cfg/clip-images" |
| 322 | "$B/clips" write "$B/cfg" "$key" 20 > /dev/null |
| 323 | run Generated/hoppanel sc1 'type:clipboard' |
| 324 | line=$(head -n 1 "$B/sc1.out") |
| 325 | if printf '%s\n' "$line" | grep -q ' shown 4 first Paste: a pinned snippet - pinned selected 0 enter a pinned snippet screen 1$' |
| 326 | then pass "typing \"clipboard\" and Enter shows the copied things alone, the pinned one first" |
| 327 | else fail "the Clipboard screen: [$line]"; fi |
| 328 | HOPSCREEN=clipboard; HOPRECORD=1; export HOPSCREEN HOPRECORD |
| 329 | run Generated/hoppanel sc2 'type:MEETING' |
| 330 | line=$(head -n 1 "$B/sc2.out") |
| 331 | if printf '%s\n' "$line" | grep -q ' shown 1 first Paste: meeting notes ⏎ line "two" with café selected 0 .* pasted .* screen 1$' |
| 332 | then pass "in that screen typing looks in the copied things, and Enter pastes the one found" |
| 333 | else fail "searching in the Clipboard screen: [$line]"; fi |
| 334 | unset HOPRECORD |
| 335 | HOPROW=1; HOPCLIPDO=pin; export HOPROW HOPCLIPDO |
| 336 | run Generated/hoppanel sc3 idle |
| 337 | unset HOPROW |
| 338 | got=$("$B/clips" read "$B/cfg" "$key" | head -n 2 | tr '\n' ';') |
| 339 | if [ "$got" = 'items 4 mode 600 fillers 0;text[https://example.com/docs] from[Safari] pinned true fresh true id 36;' ] && head -n 1 "$B/sc3.out" | grep -q ' first Paste: https://example.com/docs - pinned ' |
| 340 | then pass "Pin or Unpin pins the selected copied thing in the history Hop reads, and the list shows it" |
| 341 | else fail "pinning: [$got] [$(head -n 1 "$B/sc3.out")]"; fi |
| 342 | HOPCLIPDO=delete; export HOPCLIPDO |
| 343 | run Generated/hoppanel sc4 'type:image' |
| 344 | unset HOPCLIPDO HOPSCREEN |
| 345 | got=$("$B/clips" read "$B/cfg" "$key" | head -n 1) |
| 346 | if [ "$got" = 'items 3 mode 600 fillers 0' ] && [ -z "$(ls "$B/cfg/clip-images")" ] |
| 347 | then pass "Delete from History takes the selected copied thing out, and a picture's sealed file with it" |
| 348 | else fail "deleting: [$got] files [$(ls "$B/cfg/clip-images")]"; fi |
| 349 | run Generated/hoppanel cm1 'type:settings' |
| 350 | one=$(head -n 1 "$B/cm1.out") |
| 351 | run Generated/hoppanel cm2 'type:quit hop' |
| 352 | two=$(head -n 1 "$B/cm2.out") |
| 353 | if printf '%s\n' "$one" | grep -q " first Settings - opens Hop's settings file selected 0 " && printf '%s\n' "$two" | grep -q ' first Quit Hop Omega selected 0 ' |
| 354 | then pass "the words of a command find it: Settings, and Quit Hop Omega" |
| 355 | else fail "commands: [$one] [$two]"; fi |
| 356 | HOPCLIPDO=clear; export HOPCLIPDO |
| 357 | run Generated/hoppanel sc5 idle |
| 358 | unset HOPCLIPDO |
| 359 | got=$("$B/clips" read "$B/cfg" "$key" | tr '\n' ';') |
| 360 | if [ "$got" = 'items 2 mode 600 fillers 0;text[https://example.com/docs] from[Safari] pinned true fresh true id 36;text[a pinned snippet] from[] pinned true fresh false id 36;' ] |
| 361 | then pass "Clear clipboard history takes out the copied thing that is not pinned and leaves the two pinned ones" |
| 362 | else fail "clearing the history: [$got]"; fi |
| 363 | "$B/clips" board-clear |
| 364 | unset HOPCLIPREC |
| 365 | unset HOPCLIPKEY |
| 366 | rm -rf "$B/cfg/clipboard.bin" "$B/cfg/clip-images" "$B/cfg/clipboard.before-hop-omega.bin" |
| 367 | else fail "Omega/tests/ui-clips does not build"; head -n 5 "$B/clips.log"; fi |
| 368 | # Saved accounts: two Keychain items under a service of this check's own, named to the panel by HOPVAULT and |
| 369 | # saved there by the panel itself (HOPVAULTADD), because macOS lets a program read back without a dialog only |
| 370 | # what it saved; the panel deletes them when it ends. A check never reads Hop's own items and raises no dialog. |
| 371 | svc="com.aienos.hop.omega.check.vault.$$" |
| 372 | HOPVAULT=$svc; HOPVAULTADD='OpenRouter|API key|for the factory|check-value-1;zeta-login|Login||check-value-2'; HOPRECORD=1 |
| 373 | export HOPVAULT HOPVAULTADD HOPRECORD |
| 374 | run Generated/hoppanel acct1 'type:OPENROUTER' |
| 375 | line=$(head -n 1 "$B/acct1.out") |
| 376 | if printf '%s\n' "$line" | grep -q ' first OpenRouter - API key · for the factory selected 0 enter OpenRouter pasted check-value-1$' |
| 377 | then pass "a saved account is found by its name whatever the case, shown with its kind and note, and Enter copies its value" |
| 378 | else fail "a saved account: status $st, [$line]"; fi |
| 379 | run Generated/hoppanel acct2 'type:zeta-l' |
| 380 | line=$(head -n 1 "$B/acct2.out") |
| 381 | if printf '%s\n' "$line" | grep -q ' first zeta-login - Login selected 0 enter zeta-login pasted check-value-2$' |
| 382 | then pass "an account without a note shows its kind alone; each account gives its own value" |
| 383 | else fail "the second saved account: status $st, [$line]"; fi |
| 384 | unset HOPRECORD |
| 385 | HOPSCREEN=accounts; export HOPSCREEN |
| 386 | run Generated/hoppanel acct4 idle |
| 387 | unset HOPSCREEN |
| 388 | line=$(head -n 1 "$B/acct4.out") |
| 389 | if printf '%s |
| 390 | ' "$line" | grep -q ' shown 2 first OpenRouter - API key · for the factory selected 0 enter OpenRouter screen 2$' |
| 391 | then pass "the Accounts screen lists every saved account in order" |
| 392 | else fail "the Accounts screen: [$line]"; fi |
| 393 | # a model whose key is a saved account: the request carries it |
| 394 | port=$((21000 + ($$ + 7) % 20000)) |
| 395 | printf '{"defaultModel":"Keyed","models":[{"name":"Keyed","baseURL":"http://127.0.0.1:%s/v1","model":"keyed-model","kind":"openai","keychainKey":"OpenRouter"}]}\n' "$port" > "$B/cfg/config.json" |
| 396 | { sleep 4; printf 'HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\nConnection: close\r\n\r\n' |
| 397 | printf 'data: {"choices":[{"delta":{"content":"With a key."}}]}\n\ndata: [DONE]\n\n'; } | nc -l 127.0.0.1 "$port" > "$B/request2.txt" 2> /dev/null & |
| 398 | ncpid=$! |
| 399 | run Generated/hoppanel ask2 'ask:does it work?' |
| 400 | kill "$ncpid" 2> /dev/null || true |
| 401 | wait "$ncpid" 2> /dev/null || true |
| 402 | line=$(head -n 1 "$B/ask2.out") |
| 403 | if [ "$st" = 1 ] && printf '%s\n' "$line" | grep -q ' first Ask Keyed: does it work? .* answer With a key\.$' && grep -qi '^authorization: Bearer check-value-1' "$B/request2.txt" |
| 404 | then pass "a model whose key is a saved account is asked with that key in the request" |
| 405 | else fail "a keyed model: status $st, output [$line]"; fi |
| 406 | rm -f "$B/cfg/config.json" |
| 407 | unset HOPVAULT HOPVAULTADD |
| 408 | run Generated/hoppanel acct3 'type:OPENROUTER' |
| 409 | line=$(head -n 1 "$B/acct3.out") |
| 410 | if ! printf '%s\n' "$line" | grep -q 'OpenRouter'; then pass "without a service named to it a check reads no account" |
| 411 | else fail "a check read accounts it was not given: [$line]"; fi |
| 412 | if security find-generic-password -s "$svc" > /dev/null 2>&1; then |
| 413 | fail "the check's Keychain items were left behind" |
| 414 | security delete-generic-password -s "$svc" > /dev/null 2>&1; security delete-generic-password -s "$svc" > /dev/null 2>&1 |
| 415 | else pass "the Keychain items the check made are gone when it ends"; fi |
| 416 | # Building the file index: the Omega program run with "index" against Hop's own loop (Omega/tests/ui-index), |
| 417 | # on a small tree with a hidden folder and file, a folder to skip, an app, a link to a folder and a name with |
| 418 | # accents. Then the panel finds a file through the index it built. |
| 419 | # shellcheck disable=SC2086 |
| 420 | if swiftc -O -swift-version 5 $EXTRA -o "$B/index" Omega/tests/ui-index/main.swift > "$B/index.log" 2>&1; then |
| 421 | tree="$B/tree" |
| 422 | mkdir -p "$tree/Sub/Deeper" "$tree/.hidden" "$tree/node_modules/pkg" "$tree/Thing.app/Contents/MacOS" "$tree/café" "$tree/Empty" |
| 423 | touch "$tree/a.txt" "$tree/Sub/b.txt" "$tree/Sub/Deeper/c file.txt" "$tree/.hidden/x" "$tree/.dotfile" \ |
| 424 | "$tree/node_modules/pkg/index.js" "$tree/Thing.app/Contents/MacOS/thing" "$tree/café/ü.txt" |
| 425 | ln -s "$tree/Sub" "$tree/link-to-sub" |
| 426 | cp "$B/cfg/file-index.bin" "$B/file-index.keep" |
| 427 | printf '{"indexRoots":["%s"],"indexSkipNames":["node_modules"]}\n' "$tree" > "$B/cfg/config.json" |
| 428 | cp Generated/hoppanel "$B/indexer"; chmod 755 "$B/indexer"; codesign --force --sign - "$B/indexer" 2> /dev/null |
| 429 | said=$(HOP_CONFIG_DIR="$B/cfg" "$B/indexer" index 2> /dev/null) || said="status $?" |
| 430 | "$B/index" "$B/hop-index.bin" "$tree" node_modules > /dev/null |
| 431 | if [ "$said" = "indexed 10 items" ] && cmp -s "$B/cfg/file-index.bin" "$B/hop-index.bin" && [ "$(stat -f %Lp "$B/cfg/file-index.bin")" = 600 ] \ |
| 432 | && ! grep -q -e hidden -e dotfile -e node_modules -e Contents "$B/cfg/file-index.bin" && grep -q '/Thing.app$' "$B/cfg/file-index.bin" |
| 433 | then pass "the index the Omega program builds is byte for byte the one Hop's loop builds (10 lines: no hidden thing, no skipped folder, an app as one line)" |
| 434 | else fail "building the index: [$said]"; sed "s#$tree#TREE#" "$B/cfg/file-index.bin" | head -n 12; fi |
| 435 | rm -f "$B/cfg/config.json" |
| 436 | run Generated/hoppanel ix1 'type:c file' |
| 437 | line=$(head -n 1 "$B/ix1.out") |
| 438 | if printf '%s\n' "$line" | grep -q ' first c file.txt - .*/tree/Sub/Deeper selected 0 ' |
| 439 | then pass "and the panel finds a file through the index it built" |
| 440 | else fail "searching the built index: [$line]"; fi |
| 441 | run Generated/hoppanel ix2 'type:reindex' |
| 442 | line=$(head -n 1 "$B/ix2.out") |
| 443 | if printf '%s\n' "$line" | grep -q ' first Rebuild file index selected 0 '; then pass "\"reindex\" finds the command Rebuild file index" |
| 444 | else fail "the Rebuild command: [$line]"; fi |
| 445 | cp "$B/file-index.keep" "$B/cfg/file-index.bin" |
| 446 | else fail "Omega/tests/ui-index does not build"; head -n 5 "$B/index.log"; fi |
| 447 | # A conversation: a second question in the same run carries the first question and its answer; after New chat |
| 448 | # it goes alone. Two servers in a row on one port, each answering one request. |
| 449 | # One answer of a stand-in model, given only once the request's headers have come and a moment more for its |
| 450 | # body: an answer sent at once could close the connection before the request was read, and the panel would |
| 451 | # rightly say the connection was lost (seen in about one run of five). |
| 452 | serve() { # serve PORT REQUESTFILE ANSWER [MORE]: MORE is sent a moment later, as a server's next packet |
| 453 | pipe=$B/serve.$1.pipe; rm -f "$pipe" "$pipe.seen"; mkfifo "$pipe" |
| 454 | ( exec 3> "$pipe"; tries=0 |
| 455 | while [ ! -e "$pipe.seen" ] && [ "$tries" -lt 600 ]; do sleep 0.05; tries=$((tries + 1)); done |
| 456 | sleep 0.2 |
| 457 | printf 'HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\nConnection: close\r\n\r\n%b' "$3" >&3 |
| 458 | if [ -n "${4:-}" ]; then sleep 0.4; printf '%b' "$4" >&3; fi ) & |
| 459 | nc -l 127.0.0.1 "$1" < "$pipe" 2> /dev/null | { cr=$(printf '\r') |
| 460 | while IFS= read -r got; do printf '%s\n' "$got"; if [ "$got" = "$cr" ]; then : > "$pipe.seen"; break; fi; done |
| 461 | cat; } > "$2" |
| 462 | } |
| 463 | talk() { # talk NAME [new]: ask twice; the second request's body in $B/NAME.2 |
| 464 | port=$((21000 + ($$ + 31) % 20000)) |
| 465 | printf '{"defaultModel":"Test","models":[{"name":"Test","baseURL":"http://127.0.0.1:%s/v1","model":"test-model","kind":"openai"}]}\n' "$port" > "$B/cfg/config.json" |
| 466 | ( serve "$port" "$B/$1.1" 'data: {"choices":[{"delta":{"content":"Omega is a language."}}]}\n\ndata: [DONE]\n\n' |
| 467 | serve "$port" "$B/$1.2" 'data: {"choices":[{"delta":{"content":"Because it is small."}}]}\n\ndata: [DONE]\n\n' ) & |
| 468 | srv=$! |
| 469 | HOPASK2='and why is that?'; export HOPASK2 |
| 470 | if [ "${2:-}" = new ]; then HOPASKNEW=1; export HOPASKNEW; fi |
| 471 | run Generated/hoppanel "$1" 'ask:what is omega?' |
| 472 | unset HOPASK2 HOPASKNEW |
| 473 | kill "$srv" 2> /dev/null || true |
| 474 | pkill -f "nc -l 127.0.0.1 $port" 2> /dev/null || true |
| 475 | wait "$srv" 2> /dev/null || true |
| 476 | rm -f "$B/cfg/config.json" |
| 477 | } |
| 478 | talk talk1 |
| 479 | line=$(head -n 1 "$B/talk1.out") |
| 480 | if [ "$st" = 1 ] && printf '%s\n' "$line" | grep -q ' first Ask Test: and why is that? .* answer Because it is small\.$' \ |
| 481 | && grep -q '"messages":\[{"content":"what is omega?","role":"user"},{"content":"Omega is a language.","role":"assistant"},{"content":"and why is that?","role":"user"}\]' "$B/talk1.2" |
| 482 | then pass "Ask is a conversation: the second question is sent with the first one and its answer" |
| 483 | else fail "the conversation: status $st, [$line]"; tail -n 1 "$B/talk1.2" 2> /dev/null | cut -c1-300; fi |
| 484 | talk talk2 new |
| 485 | if grep -q '"messages":\[{"content":"and why is that?","role":"user"}\]' "$B/talk2.2" |
| 486 | then pass "after New chat a question goes alone" |
| 487 | else fail "New chat"; tail -n 1 "$B/talk2.2" 2> /dev/null | cut -c1-300; fi |
| 488 | # An answer that comes in two packets, the second beginning with the line break that ends an event. Before this |
| 489 | # was mended the panel stopped there with status 103 (it read the byte before an empty first line). |
| 490 | port=$((21000 + ($$ + 53) % 20000)) |
| 491 | printf '{"defaultModel":"Test","models":[{"name":"Test","baseURL":"http://127.0.0.1:%s/v1","model":"test-model","kind":"openai"}]}\n' "$port" > "$B/cfg/config.json" |
| 492 | serve "$port" "$B/split.req" 'data: {"choices":[{"delta":{"content":"Split "}}]}\n' '\ndata: {"choices":[{"delta":{"content":"answer."}}]}\n\ndata: [DONE]\n\n' & |
| 493 | srv=$! |
| 494 | run Generated/hoppanel split1 'ask:what is omega?' |
| 495 | kill "$srv" 2> /dev/null || true |
| 496 | pkill -f "nc -l 127.0.0.1 $port" 2> /dev/null || true |
| 497 | wait "$srv" 2> /dev/null || true |
| 498 | rm -f "$B/cfg/config.json" |
| 499 | line=$(head -n 1 "$B/split1.out") |
| 500 | if [ "$st" = 1 ] && printf '%s\n' "$line" | grep -q ' answer Split answer\.$' |
| 501 | then pass "an answer whose second packet begins with a line break is read whole" |
| 502 | else fail "an answer in two packets: status $st, [$line]"; fi |
| 503 | # The icon in the menu bar: a check has none, and with HOPMENU says the items its menu would have |
| 504 | HOPMENU=1; export HOPMENU |
| 505 | run Generated/hoppanel menu1 idle |
| 506 | unset HOPMENU |
| 507 | line=$(grep '^menu ' "$B/menu1.out" | head -n 1) |
| 508 | if [ "$line" = 'menu Open Hop Omega (Option Space)||Rebuild file index|Allow paste into apps ...|Open at login|Settings (edit config file) ...|Clear clipboard history||Quit Hop Omega' ] |
| 509 | then pass "the menu of the icon in the menu bar has Hop's items, in Hop's order" |
| 510 | else fail "the menu bar icon's menu: [$line]"; fi |
| 511 | # Forwarded ports: a stand-in is started in place of ssh (a check never starts ssh itself) and writes down the |
| 512 | # words it was given. One port nothing serves, one that nc serves, entries that are not ports, a port named |
| 513 | # twice, and the knowledge base on another computer. |
| 514 | FAKE_ROOT=$B/link-root; export FAKE_ROOT; mkdir -p "$FAKE_ROOT" |
| 515 | cat > "$B/fake-link" <<'STANDIN' |
| 516 | #!/bin/sh |
| 517 | printf '%s\n' "$*" >> "$FAKE_ROOT/links.log" |
| 518 | STANDIN |
| 519 | chmod 755 "$B/fake-link" |
| 520 | lp1=$((21000 + ($$ + 61) % 20000)); lp2=$((lp1 + 1)); lp3=$((lp1 + 2)) |
| 521 | printf '{"tunnels":[{"localPort":%s,"remotePort":8080,"sshHost":"far"},{"localPort":%s,"remotePort":9090,"sshHost":"far"},{"localPort":0,"remotePort":1,"sshHost":"far"},{"localPort":%s,"remotePort":70000,"sshHost":"far"},{"localPort":"x","remotePort":null,"sshHost":"far"},{"localPort":%s.9,"remotePort":8082,"sshHost":"far"},{"localPort":%s,"remotePort":true,"sshHost":"far"},{"localPort":%s,"remotePort":8081,"sshHost":"other"}],"cortex":{"enabled":true,"url":"http://127.0.0.1:%s","host":"brain","remotePort":7700}}\n' \ |
| 522 | "$lp1" "$lp2" "$((lp1 + 9))" "$((lp1 + 5))" "$((lp1 + 6))" "$lp1" "$lp3" > "$B/cfg/config.json" |
| 523 | nc -l 127.0.0.1 "$lp2" > /dev/null 2>&1 & |
| 524 | ncpid=$! |
| 525 | sleep 0.5 |
| 526 | HOPSSH=$B/fake-link; export HOPSSH |
| 527 | run Generated/hoppanel link1 idle |
| 528 | unset HOPSSH |
| 529 | kill "$ncpid" 2> /dev/null || true |
| 530 | wait "$ncpid" 2> /dev/null || true |
| 531 | got=$(sort "$FAKE_ROOT/links.log" 2> /dev/null | tr '\n' ';') |
| 532 | opts='-N -o ControlMaster=no -o ControlPath=none -o BatchMode=yes -o ExitOnForwardFailure=yes -o ServerAliveInterval=15 -o ServerAliveCountMax=3 -o ConnectTimeout=8 -L' |
| 533 | # (the two links are started together and write in either order: the lines are sorted) |
| 534 | if [ "$st" = 1 ] && [ "$got" = "$opts 127.0.0.1:$lp1:127.0.0.1:8080 far;$opts 127.0.0.1:$lp3:127.0.0.1:7700 brain;" ] && head -n 1 "$B/link1.out" | grep -q ' links 2$' |
| 535 | then pass "a forwarded port nothing serves gets its link with Hop's ssh options, and so does the knowledge base's; a served port, a port named twice and entries that are not whole ports get none" |
| 536 | else fail "forwarded ports: [$got]"; fi |
| 537 | rm -f "$FAKE_ROOT/links.log" |
| 538 | run Generated/hoppanel link2 idle |
| 539 | # (the panel itself says how many links it started, whatever program it would have started them with: a log the |
| 540 | # stand-in did not write would not show a link started with the real ssh) |
| 541 | if [ "$st" = 1 ] && head -n 1 "$B/link2.out" | grep -q ' links 0$' && [ ! -e "$FAKE_ROOT/links.log" ] |
| 542 | then pass "without its stand-in a check starts no link: the panel counts none" |
| 543 | else fail "a check without a stand-in: status $st, [$(head -n 1 "$B/link2.out")]"; fi |
| 544 | # Settings a person wrote wrongly: a null, a list, a group or a text where a yes, a number or a list belongs |
| 545 | # must not stop the program (before this was mended a null where a yes belongs did) |
| 546 | cat > "$B/cfg/config.json" <<'SETTINGS' |
| 547 | {"cortex":{"enabled":null,"url":7,"host":[],"remotePort":"x"},"clipboardLimit":null,"agentConfirmed":[],"enterSendsToAgent":{}, |
| 548 | "keepAgentFlags":"yes","ownerName":3,"tunnels":[{"localPort":null,"remotePort":[],"sshHost":{}},7,null],"machines":[null,{"name":1,"ssh":null}], |
| 549 | "agentEngines":[null,{"name":null,"command":"x"}],"agentEngine":null,"models":[null,{"name":[]}],"factoryURL":false} |
| 550 | SETTINGS |
| 551 | HOPSSH=$B/fake-link; export HOPSSH |
| 552 | run Generated/hoppanel wrong1 'type:saf' |
| 553 | unset HOPSSH |
| 554 | line=$(head -n 1 "$B/wrong1.out") |
| 555 | if [ "$st" = 1 ] && printf '%s\n' "$line" | grep -q '^hoppanel apps [0-9]* shown [0-9]* first ' && [ ! -e "$FAKE_ROOT/links.log" ] |
| 556 | then pass "settings with a null, a list, a group or a text in the wrong places do not stop the panel, and start nothing" |
| 557 | else fail "wrongly written settings: status $st, [$line]"; fi |
| 558 | # A link that stays, as ssh does: the check ends it when it ends, and leaves no asker behind |
| 559 | cat > "$B/fake-stay" <<'STANDIN' |
| 560 | #!/bin/sh |
| 561 | echo $$ > "$FAKE_ROOT/stay.pid" |
| 562 | exec sleep 60 |
| 563 | STANDIN |
| 564 | chmod 755 "$B/fake-stay" |
| 565 | printf '{"tunnels":[{"localPort":%s,"remotePort":8080,"sshHost":"far"}]}\n' "$lp1" > "$B/cfg/config.json" |
| 566 | HOPSSH=$B/fake-stay; export HOPSSH |
| 567 | run Generated/hoppanel link3 idle |
| 568 | unset HOPSSH |
| 569 | staypid=$(cat "$FAKE_ROOT/stay.pid" 2> /dev/null || echo none) |
| 570 | sleep 0.5 |
| 571 | if [ "$st" = 1 ] && [ "$staypid" != none ] && ! kill -0 "$staypid" 2> /dev/null && head -n 1 "$B/link3.out" | grep -q ' links 1$' |
| 572 | then pass "a link that stays is ended when the check ends" |
| 573 | else fail "a link that stays: status $st, pid $staypid, [$(head -n 1 "$B/link3.out")]"; kill "$staypid" 2> /dev/null || true; fi |
| 574 | unset FAKE_ROOT |
| 575 | rm -f "$B/cfg/config.json" |
| 576 | # Files on other machines: stand-ins for ssh and scp (a check never reaches a real machine). "server" is a folder |
| 577 | # of this scratch space that holds a file list as Hop's machines keep it, "down" cannot be reached, "fresh" has |
| 578 | # no file list yet. |
| 579 | FAKE_ROOT=$B/far-root; export FAKE_ROOT |
| 580 | mkdir -p "$FAKE_ROOT/far/.cache/hop/shards" "$FAKE_ROOT/far/srv/reports" "$FAKE_ROOT/empty" |
| 581 | printf 'quarterly zebra report\n' > "$FAKE_ROOT/far/srv/reports/zebra-report.txt" |
| 582 | printf '%s\n' /srv/reports/zebra-report.txt /srv/reports/ /srv/other/zebra-notes.md /srv/zebra-archive/ > "$FAKE_ROOT/far/.cache/hop/shards/s00" |
| 583 | printf '%s\n' /srv/unrelated.txt > "$FAKE_ROOT/far/.cache/hop/shards/s01" |
| 584 | cat > "$B/fake-ssh" <<'STANDIN' |
| 585 | #!/bin/sh |
| 586 | while [ "$1" = -o ]; do shift 2; done |
| 587 | host=$1; shift |
| 588 | printf '%s: %s\n' "$host" "$*" >> "$FAKE_ROOT/ssh.log" |
| 589 | case "$host" in |
| 590 | down) exit 255;; |
| 591 | fresh) HOME="$FAKE_ROOT/empty"; export HOME; case "$1" in mkdir*) sh -n -c "$1" && echo fresh-parses >> "$FAKE_ROOT/ssh.log"; echo ok; exit 0;; esac; exec sh -c "$1";; |
| 592 | server) case "$1" in "stat -c %s -- "*) p=${1#stat -c %s -- }; p=$(eval "printf '%s' $p"); wc -c < "$FAKE_ROOT/far$p" | tr -d ' '; exit 0;; esac |
| 593 | HOME="$FAKE_ROOT/far"; export HOME; exec sh -c "$1";; |
| 594 | esac |
| 595 | exit 255 |
| 596 | STANDIN |
| 597 | cat > "$B/fake-scp" <<'STANDIN' |
| 598 | #!/bin/sh |
| 599 | while [ "$1" = -q ] || [ "$1" = -o ]; do if [ "$1" = -o ]; then shift 2; else shift; fi; done |
| 600 | src=${1#*:}; cp "$FAKE_ROOT/far$src" "$2" |
| 601 | STANDIN |
| 602 | chmod 755 "$B/fake-ssh" "$B/fake-scp" |
| 603 | HOPSSH=$B/fake-ssh; HOPSCP=$B/fake-scp; HOPLATE=1; export HOPSSH HOPSCP HOPLATE |
| 604 | printf '{"machines":[{"name":"Server","ssh":"server","roots":["/srv"]},{"name":"Attic","ssh":"down","roots":["/"]}]}\n' > "$B/cfg/config.json" |
| 605 | run Generated/hoppanel far1 'type:zebra report' |
| 606 | line=$(head -n 1 "$B/far1.out") |
| 607 | if printf '%s\n' "$line" | grep -q ' first zebra-report.txt - /srv/reports on Server selected 0 ' && printf '%s\n' "$line" | grep -q ' machine 1 says 1$' \ |
| 608 | && grep -q "^server: d=~/.cache/hop/shards; .*grep -F -i -- 'report' \"\$s\" | LC_ALL=C grep -F -i -- 'zebra' | head -300" "$FAKE_ROOT/ssh.log" |
| 609 | then pass "a file on another machine is found there by Hop's search command and shown with its machine; a machine that cannot be reached is said" |
| 610 | else fail "files on other machines: [$line]"; fi |
| 611 | HOPRECORD=1; export HOPRECORD |
| 612 | run Generated/hoppanel far2 'type:zebra report' |
| 613 | line=$(head -n 1 "$B/far2.out") |
| 614 | if printf '%s\n' "$line" | grep -q ' fetched 1' && cmp -s "$B/cfg/remote/Server/srv/reports/zebra-report.txt" "$FAKE_ROOT/far/srv/reports/zebra-report.txt" \ |
| 615 | && grep -q "^server: stat -c %s -- '/srv/reports/zebra-report.txt'$" "$FAKE_ROOT/ssh.log" |
| 616 | then pass "Enter on such a file asks its size, then brings it over under the machine's name, byte for byte" |
| 617 | else fail "bringing a file over: [$line]"; fi |
| 618 | run Generated/hoppanel far3 'type:zebra-archive' |
| 619 | line=$(head -n 1 "$B/far3.out") |
| 620 | if printf '%s\n' "$line" | grep -q ' first zebra-archive - /srv on Server .* pasted server:/srv/zebra-archive machine 0 says 4$' |
| 621 | then pass "Enter on a folder of another machine puts its ssh name and path on the clipboard" |
| 622 | else fail "a folder on another machine: [$line]"; fi |
| 623 | HOPSCP=/usr/bin/false; export HOPSCP |
| 624 | rm -rf "$B/cfg/remote" |
| 625 | run Generated/hoppanel far4 'type:zebra report' |
| 626 | line=$(head -n 1 "$B/far4.out") |
| 627 | if printf '%s\n' "$line" | grep -q ' pasted server:/srv/reports/zebra-report.txt machine 0 says 5$' && [ ! -e "$B/cfg/remote/Server/srv/reports/zebra-report.txt" ] |
| 628 | then pass "when the copy fails nothing is opened, the path goes to the clipboard and that is said" |
| 629 | else fail "a failed copy: [$line]"; fi |
| 630 | unset HOPRECORD |
| 631 | printf '{"machines":[{"name":"Newbox","ssh":"fresh","roots":["/data","/mnt/x y"],"skip":["cache","node_modules"]}]}\n' > "$B/cfg/config.json" |
| 632 | : > "$FAKE_ROOT/ssh.log" |
| 633 | run Generated/hoppanel far5 'type:zebra report' |
| 634 | line=$(head -n 1 "$B/far5.out") |
| 635 | flat=$(tr -d "'\\\\" < "$FAKE_ROOT/ssh.log") |
| 636 | if printf '%s\n' "$line" | grep -q ' machine 0 says 2$' && grep -q "^fresh: mkdir -p ~/.cache/hop; f=~/.cache/hop/shards/s00$" "$FAKE_ROOT/ssh.log" && grep -q '^fresh-parses$' "$FAKE_ROOT/ssh.log" \ |
| 637 | && printf '%s' "$flat" | grep -qF 'nohup nice -n 19 ionice -c3 sh -c cd ~/.cache/hop && find /data /mnt/x y -xdev ( -path */.* -o -name cache -o -name node_modules ) -prune -o -type d -printf %p/n -o -printf %pn > index.tmp 2>/dev/null && rm -rf shards.new && mkdir shards.new && split -n l/20 -d -a 2 index.tmp shards.new/s && rm -f index.tmp index.txt' |
| 638 | then pass "a machine without a file list is told to build one, by Hop's command with its folders and skips, and that is said" |
| 639 | else fail "a machine without a file list: [$line] $(grep -c . "$FAKE_ROOT/ssh.log") lines"; fi |
| 640 | HOPSSH_KEPT=$HOPSSH; unset HOPSSH |
| 641 | printf '{"machines":[{"name":"Server","ssh":"server","roots":["/srv"]}]}\n' > "$B/cfg/config.json" |
| 642 | : > "$FAKE_ROOT/ssh.log" |
| 643 | run Generated/hoppanel far6 'type:zebra report' |
| 644 | line=$(head -n 1 "$B/far6.out") |
| 645 | if ! printf '%s\n' "$line" | grep -q -e ' on Server' -e ' machine ' && [ ! -s "$FAKE_ROOT/ssh.log" ] |
| 646 | then pass "without its stand-in a check reaches no machine at all" |
| 647 | else fail "a check without a stand-in: [$line]"; fi |
| 648 | unset HOPSCP HOPLATE FAKE_ROOT HOPSSH_KEPT |
| 649 | rm -f "$B/cfg/config.json" |
| 650 | # The agent: stand-in commands in the settings (a check never runs a real coding agent, and uses names no real |
| 651 | # one has). What the agent prints is the answer; the request rides behind Hop's standing instructions. |
| 652 | agent() { # agent NAME: send "fix the thing please" to the agent of $B/cfg/config.json; the answer in $ans |
| 653 | run Generated/hoppanel "$1" 'agent:fix the thing please' |
| 654 | ans=$(head -n 1 "$B/$1.out" | sed -n 's/.* answer \(.*\)$/\1/p') |
| 655 | } |
| 656 | cat > "$B/cfg/config.json" <<'SETTINGS' |
| 657 | {"agentEngines":[{"name":"Check Tail","command":["/bin/sh","-c","printf '%s' \"$1\" | tail -c 70 | tr '\\n' ' '","x","{prompt}"]}], |
| 658 | "agentEngine":"Check Tail","agentConfirmed":true,"ownerName":"sam","machines":[{"name":"Server","ssh":"server","roots":[]}]} |
| 659 | SETTINGS |
| 660 | agent ag1 |
| 661 | if [ "$st" = 1 ] && [ "$ans" = "tive changes. Reply short, plain words. Request: fix the thing please " ] |
| 662 | then pass "the agent of the settings is run with the request behind Hop's standing instructions, and what it prints is shown" |
| 663 | else fail "the agent: status $st, [$ans]"; fi |
| 664 | cat > "$B/cfg/config.json" <<'SETTINGS' |
| 665 | {"agentEngines":[{"name":"Check Head","command":["/bin/sh","-c","printf '%s' \"$1\" | head -c 96","x","{prompt}"]}], |
| 666 | "agentEngine":"Check Head","agentConfirmed":true,"ownerName":"sam","machines":[{"name":"Server","ssh":"server","roots":[]}]} |
| 667 | SETTINGS |
| 668 | agent ag2 |
| 669 | if [ "$ans" = "Sam's agent. All machines = one box; never ask which. Mac = here. Server: ssh server '<cmd>' (au " ] |
| 670 | then pass "the standing instructions name the person and how each machine is reached, as Hop writes them" |
| 671 | else fail "the standing instructions: [$ans]"; fi |
| 672 | cat > "$B/cfg/config.json" <<'SETTINGS' |
| 673 | {"agentEngines":[{"name":"Check Stream","command":["/bin/sh","-c","printf '%s\\n' '{\"type\":\"system\"}' '{\"type\":\"assistant\",\"message\":{\"content\":[{\"type\":\"text\",\"text\":\"Fixed it.\"},{\"type\":\"tool_use\",\"name\":\"Bash\"}]}}' '{\"type\":\"result\",\"session_id\":\"s-1\",\"is_error\":false,\"result\":\"Fixed it.\"}'; echo oops >&2; exit 3","x","{prompt}"]}], |
| 674 | "agentEngine":"Check Stream","agentConfirmed":true} |
| 675 | SETTINGS |
| 676 | agent ag3 |
| 677 | case "$ans" in *'Fixed it. > Bash '*) a=1;; *) a=0;; esac |
| 678 | case "$ans" in *'! oops'*) b=1;; *) b=0;; esac |
| 679 | case "$ans" in *'Agent stopped (exit 3).'*) c=1;; *) c=0;; esac |
| 680 | if [ "$a$b$c" = 111 ] && ! printf '%s' "$ans" | grep -q -e session_id -e '"type"' |
| 681 | then pass "the lines of Claude Code's stream are read for their text and tools; errors and a failed end are said" |
| 682 | else fail "the agent's stream: [$ans]"; fi |
| 683 | cat > "$B/cfg/config.json" <<'SETTINGS' |
| 684 | {"agentEngines":[{"name":"Check Missing","command":["hop-check-no-such-tool","{prompt}"]},{"name":"Check Here","command":["/usr/bin/touch","RAN","{prompt}"]}], |
| 685 | "agentEngine":"Check Missing","agentConfirmed":true} |
| 686 | SETTINGS |
| 687 | sed -i '' "s#RAN#$B/ran-1#" "$B/cfg/config.json" |
| 688 | agent ag4 |
| 689 | case "$ans" in 'Check Missing is set as your agent but is not installed on this Mac. Installed here: Check Here.'*) ok=1;; *) ok=0;; esac |
| 690 | if [ "$ok" = 1 ] && [ ! -e "$B/ran-1" ]; then pass "an agent that is not installed is said to be missing, and no other one is run in its place" |
| 691 | else fail "a missing agent: [$ans]"; fi |
| 692 | printf '{"agentEngines":[{"name":"Check Here","command":["/usr/bin/touch","%s","{prompt}"]}],"agentEngine":"Check Here"}\n' "$B/ran-2" > "$B/cfg/config.json" |
| 693 | agent ag5 |
| 694 | if [ "$ans" = "Let the agent work on this Mac? " ] && [ ! -e "$B/ran-2" ]; then pass "until the person has said yes to the agent, a check runs nothing" |
| 695 | else fail "an agent not yet allowed: [$ans]"; fi |
| 696 | cat > "$B/cfg/config.json" <<'SETTINGS' |
| 697 | {"agentEngines":[{"name":"Codex","command":["codex","exec","--skip-git-repo-check","--dangerously-bypass-approvals-and-sandbox","{prompt}"]}, |
| 698 | {"name":"Grok","command":["grok","--always-approve","-p","{prompt}"]},{"name":"Check Mine","command":["check-mine","--yolo","{prompt}"]}],"agentEngine":"Check Mine"} |
| 699 | SETTINGS |
| 700 | HOPAGENTS=1; export HOPAGENTS |
| 701 | run Generated/hoppanel ag6 idle |
| 702 | safe=$(grep '^engine ' "$B/ag6.out" | tr '\n' ';') |
| 703 | sed -i '' 's/"agentEngine":"Check Mine"/"agentEngine":"Check Mine","keepAgentFlags":true/' "$B/cfg/config.json" |
| 704 | run Generated/hoppanel ag7 idle |
| 705 | kept=$(grep '^engine ' "$B/ag7.out" | tr '\n' ';') |
| 706 | unset HOPAGENTS |
| 707 | if [ "$safe" = 'engine Codex: codex exec --skip-git-repo-check {prompt};engine Grok: grok -p {prompt};engine Check Mine: check-mine --yolo {prompt};' ] \ |
| 708 | && [ "$kept" = 'engine Codex: codex exec --skip-git-repo-check --dangerously-bypass-approvals-and-sandbox {prompt};engine Grok: grok --always-approve -p {prompt};engine Check Mine: check-mine --yolo {prompt};' ] |
| 709 | then pass "old built-in commands that switched approval prompts off are brought to today's, a command the person wrote is not, and keepAgentFlags keeps all as written" |
| 710 | else fail "the agents' commands: [$safe] [$kept]"; fi |
| 711 | printf '{"enterSendsToAgent":true,"agentConfirmed":true,"agentEngines":[{"name":"Check Here","command":["/bin/echo","{prompt}"]}],"agentEngine":"Check Here"}\n' > "$B/cfg/config.json" |
| 712 | run Generated/hoppanel ag8 'type:please tidy my desktop folder' |
| 713 | line=$(head -n 1 "$B/ag8.out") |
| 714 | if printf '%s\n' "$line" | grep -q ' first Agent fixes it: please tidy my desktop folder selected 0 ' |
| 715 | then pass "with the setting on, a sentence that matches nothing gets the agent's row first" |
| 716 | else fail "the agent's row: [$line]"; fi |
| 717 | rm -f "$B/cfg/config.json" |
| 718 | # Ask: a model that needs no key, played by nc on this Mac with the lines a streaming server sends. The settings |
| 719 | # also name a model with a key before it, which the panel must pass over. |
| 720 | port=$((21000 + $$ % 20000)) |
| 721 | printf '{"defaultModel":"Keyed","models":[{"name":"Keyed","baseURL":"http://127.0.0.1:9/v1","model":"k","keychainKey":"k"},{"name":"Test","baseURL":"http://127.0.0.1:%s/v1/","model":"test-model","kind":"openai"}]}\n' "$port" > "$B/cfg/config.json" |
| 722 | { sleep 4; printf 'HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\nConnection: close\r\n\r\n' |
| 723 | printf 'data: {"choices":[{"delta":{"role":"assistant","content":"Omega is "}}]}\n\ndata: {"choices":[{"delta":{"content":"a language."}}]}\n\ndata: [DONE]\n\n'; } | nc -l 127.0.0.1 "$port" > "$B/request.txt" 2> /dev/null & |
| 724 | ncpid=$! |
| 725 | run Generated/hoppanel ask 'ask:what is omega?' |
| 726 | wait "$ncpid" 2> /dev/null || true |
| 727 | line=$(head -n 1 "$B/ask.out") |
| 728 | if [ "$st" = 1 ] && printf '%s\n' "$line" | grep -Eq '^hoppanel apps [0-9]+ shown [0-9]+ first Ask Test: what is omega\? selected 0 enter Ask Test: what is omega\? answer Omega is a language\.$' |
| 729 | then pass "the Ask row asks the model without a key and shows the answer as it streams in ($line)" |
| 730 | else fail "Ask: status $st, output [$line]"; fi |
| 731 | if grep -q '^POST /v1/chat/completions ' "$B/request.txt" && grep -q '"content":"what is omega?"' "$B/request.txt" \ |
| 732 | && grep -q '"model":"test-model"' "$B/request.txt" && grep -q '"stream":true' "$B/request.txt" && grep -qi '^content-type: application/json' "$B/request.txt" |
| 733 | then pass "the request is Hop's: POST /v1/chat/completions with the model, the question and stream true" |
| 734 | else fail "the request the panel sent"; head -c 600 "$B/request.txt"; fi |
| 735 | rm -f "$B/cfg/config.json" |
| 736 | run Omega/tests/mutant/hoppanel-deaf deaf |
| 737 | if [ "$st" != 1 ]; then pass "negative control: a panel without the matcher's answer is told apart (status $st, $(head -n 1 "$B/deaf.out"))" |
| 738 | else fail "the panel without the matcher's answer passed"; fi |
| 739 | rm -rf "$B" |
| 740 | if [ $fails -eq 0 ]; then echo "HOPPANEL-MACOS PASS"; else echo "HOPPANEL-MACOS FAIL $fails"; exit 1; fi |