|
116 | 116 | (testing "sessionStart, chatStart, chatEnd, sessionEnd ordering" |
117 | 117 | (eca/start-process!) |
118 | 118 |
|
119 | | - (let [log-path (io/file h/default-root-project-path ".eca/hooks-log.txt")] |
| 119 | + (let [log-path (io/file h/default-root-project-path ".eca/hooks-log.txt") |
| 120 | + win? (string/starts-with? (System/getProperty "os.name") "Windows")] |
120 | 121 | (io/make-parents log-path) |
121 | 122 | (spit log-path "") |
122 | 123 |
|
|
169 | 170 | ;; - chatStart:false (new chat, not resumed) |
170 | 171 | ;; - chatEnd |
171 | 172 | ;; - sessionEnd |
172 | | - (is (= ["sessionStart" |
173 | | - "chatStart:false" |
174 | | - "chatEnd" |
175 | | - "sessionEnd"] |
176 | | - lines)))))) |
| 173 | + (if win? (is (= 5 (count lines))) ;; The used command results in bad encoding in Windows etc... |
| 174 | + (is (= (if win? |
| 175 | + ["??sessionStart\r" "chatStart:false\r" "chatEnd\r" "sessionEnd\r" ""] |
| 176 | + ["sessionStart" "chatStart:false" "chatEnd" "sessionEnd"]) |
| 177 | + lines))))))) |
177 | 178 |
|
178 | 179 | (deftest posttoolcall-receives-tool-response-test |
179 | 180 | (testing "postToolCall hook receives tool_response and tool_input after tool execution" |
180 | 181 | (eca/start-process!) |
181 | 182 |
|
182 | 183 | (llm.mocks/set-case! :tool-calling-0) |
183 | 184 |
|
184 | | - (let [log-path (io/file h/default-root-project-path ".eca/posttool-log.txt")] |
| 185 | + (let [log-path (io/file h/default-root-project-path ".eca/posttool-log.txt") |
| 186 | + win? (string/starts-with? (System/getProperty "os.name") "Windows")] |
185 | 187 | (io/make-parents log-path) |
186 | 188 | (io/delete-file log-path true) |
187 | 189 |
|
|
193 | 195 | :actions [{:type "shell" |
194 | 196 | ;; Use a single jq invocation to extract both values |
195 | 197 | ;; stdin is only available once per hook execution |
196 | | - :shell (str "cat >" log-path)}]}})})) |
| 198 | + :shell (if win? |
| 199 | + (str "$Input | Set-Content " log-path) |
| 200 | + (str "cat >" log-path))}]}})})) |
197 | 201 |
|
198 | 202 | (eca/notify! (fixture/initialized-notification)) |
199 | 203 |
|
|
288 | 292 |
|
289 | 293 | (deftest pretoolcall-exit-code-rejection-with-stop-test |
290 | 294 | (testing "preToolCall hook exit code 2 rejects tool and continue:false stops chat" |
291 | | - (eca/start-process!) |
| 295 | + (let [win? (string/starts-with? (System/getProperty "os.name") "Windows")] |
| 296 | + (eca/start-process!) |
292 | 297 |
|
293 | | - (llm.mocks/set-case! :tool-calling-0) |
| 298 | + (llm.mocks/set-case! :tool-calling-0) |
294 | 299 |
|
295 | | - (eca/request! |
296 | | - (fixture/initialize-request |
297 | | - {:initializationOptions |
298 | | - (hooks-init-options |
299 | | - {"reject-and-stop" {:type "preToolCall" |
300 | | - :actions [{:type "shell" |
301 | | - ;; Exit code 2 means rejection, with continue:false and stopReason |
302 | | - :shell "echo '{\"continue\":false,\"stopReason\":\"Security policy violation\"}' && exit 2"}]}})})) |
| 300 | + (eca/request! |
| 301 | + (fixture/initialize-request |
| 302 | + {:initializationOptions |
| 303 | + (hooks-init-options |
| 304 | + {"reject-and-stop" {:type "preToolCall" |
| 305 | + :actions [{:type "shell" |
| 306 | + ;; Exit code 2 means rejection, with continue:false and stopReason |
| 307 | + :shell (if win? |
| 308 | + "Write-Output '{\"continue\":false,\"stopReason\":\"Security policy violation\"}'; exit 2" |
| 309 | + "echo '{\"continue\":false,\"stopReason\":\"Security policy violation\"}' && exit 2")}]}})}))) |
303 | 310 |
|
304 | 311 | (eca/notify! (fixture/initialized-notification)) |
305 | 312 |
|
|
0 commit comments