|
181 | 181 |
|
182 | 182 | (llm.mocks/set-case! :tool-calling-0) |
183 | 183 |
|
184 | | - (let [log-path (io/file h/default-root-project-path ".eca/posttool-log.txt")] |
| 184 | + (let [log-path (io/file h/default-root-project-path ".eca/posttool-log.txt") |
| 185 | + win? (string/starts-with? (System/getProperty "os.name") "Windows")] |
185 | 186 | (io/make-parents log-path) |
186 | 187 | (io/delete-file log-path true) |
187 | 188 |
|
|
193 | 194 | :actions [{:type "shell" |
194 | 195 | ;; Use a single jq invocation to extract both values |
195 | 196 | ;; stdin is only available once per hook execution |
196 | | - :shell (str "cat >" log-path)}]}})})) |
| 197 | + :shell (if win? |
| 198 | + (str "$Input | Set-Content " log-path) |
| 199 | + (str "cat >" log-path))}]}})})) |
197 | 200 |
|
198 | 201 | (eca/notify! (fixture/initialized-notification)) |
199 | 202 |
|
|
288 | 291 |
|
289 | 292 | (deftest pretoolcall-exit-code-rejection-with-stop-test |
290 | 293 | (testing "preToolCall hook exit code 2 rejects tool and continue:false stops chat" |
291 | | - (eca/start-process!) |
| 294 | + (let [win? (string/starts-with? (System/getProperty "os.name") "Windows")] |
| 295 | + (eca/start-process!) |
292 | 296 |
|
293 | | - (llm.mocks/set-case! :tool-calling-0) |
| 297 | + (llm.mocks/set-case! :tool-calling-0) |
294 | 298 |
|
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"}]}})})) |
| 299 | + (eca/request! |
| 300 | + (fixture/initialize-request |
| 301 | + {:initializationOptions |
| 302 | + (hooks-init-options |
| 303 | + {"reject-and-stop" {:type "preToolCall" |
| 304 | + :actions [{:type "shell" |
| 305 | + ;; Exit code 2 means rejection, with continue:false and stopReason |
| 306 | + :shell (if win? |
| 307 | + "Write-Output '{\"continue\":false,\"stopReason\":\"Security policy violation\"}'; exit 2" |
| 308 | + "echo '{\"continue\":false,\"stopReason\":\"Security policy violation\"}' && exit 2")}]}})}))) |
303 | 309 |
|
304 | 310 | (eca/notify! (fixture/initialized-notification)) |
305 | 311 |
|
|
0 commit comments