Commit graph

23 commits

Author SHA1 Message Date
DennisYu07
b5115e731e
feat(hooks): Add HTTP Hook, Function Hook and Async Hook support (#2827)
* add http/async/function type

* fix url error

* resolve comment

* align cc non blocking error

* fix hookRunner for async

* fix(hooks): update hook type validation to support http and function types

- Change validated hook types from ['command', 'plugin'] to ['command', 'http', 'function']
- Add validation for HTTP hooks requiring url field
- Add validation for function hooks requiring callback field
- Add comprehensive test coverage for all hook type validations

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(hooks): align SSRF protection with Claude Code behavior

- Allow 127.0.0.0/8 (loopback) for local dev hooks
- Allow localhost hostname for local dev hooks
- Allow ::1 (IPv6 loopback) for local dev hooks
- Add 100.64.0.0/10 (CGNAT) to blocked ranges (RFC 6598)
- Update tests to match Claude Code's ssrfGuard.ts behavior

This fixes HTTP hooks failing to connect to local dev servers.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* refactor(hooks): align HTTP hook security with Claude Code behavior

- Add CRLF/NUL sanitization for env var interpolation (header injection)
- Implement combined abort signal (external signal + timeout)
- Upgrade SSRF protection to DNS-level with ssrfGuard
  - Allow loopback (127.0.0.0/8, ::1) for local dev hooks
  - Block CGNAT (100.64.0.0/10) and IPv6 private ranges
- Increase default HTTP hook timeout to 10 minutes
- Fix VS Code hooks schema to support http type
  - Add url, headers, allowedEnvVars, async, once, statusMessage, shell fields
  - Note: "function" type is SDK-only (callback cannot be serialized to JSON)

* feat(hooks): enhance Function Hook with messages, skillRoot, shell, and matcher support

- Add MessagesProvider for automatic conversation history passing to function hooks
- Add FunctionHookContext with messages, toolUseID, and signal
- Add skillRoot support for skill-scoped session hooks
- Add shell parameter support for command hooks (bash/powershell)
- Add regex matcher support for hook pattern matching
- Add statusMessage to CommandHookConfig
- Change default function hook timeout from 60s to 5s
- Add comprehensive unit tests for all new features

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* add session hook for skill

* fix function hook parsing

* refactor ui for http hook/async hook/function hook

* update doc and add integration test

* change telemetryn type and refactor SSRF

* fix project level bug

---------

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-04-16 10:10:33 +08:00
DennisYu07
5221002831 remove hooks experimental and refactor hook Config 2026-04-01 11:50:23 +08:00
DennisYu07
4b80e4a3b7 reduce some useless case 2026-03-10 19:59:15 -07:00
DennisYu07
ddf2290ccd add integration test for PreToolUse PostToolUse PostToolUseFailure PreCompact 2026-03-10 19:39:55 -07:00
DennisYu07
f547785da7 add integration test for notification 2026-03-10 04:26:15 -07:00
DennisYu07
31b40ca653 add integration test for SubagentStart and SubagentEnd 2026-03-10 01:45:31 -07:00
DennisYu07
98fb607ad1 merge main 2026-03-10 00:29:08 -07:00
DennisYu07
5774fa47af remove useless expect 2026-03-09 23:31:10 -07:00
DennisYu07
f945f95540 refactor test case 2026-03-09 20:38:38 -07:00
DennisYu07
e529b62fd2 refactor expect for stop hook 2026-03-09 20:05:17 -07:00
DennisYu07
b359929a90 implementation integration test for PermissionRequest 2026-03-09 04:45:13 -07:00
DennisYu07
ab368e15b0 add matcher for SessionStart and SessionEnd and rafactor integration test 2026-03-09 02:34:33 -07:00
DennisYu07
c0c8da9aeb refactor integration test for SessionStart and SessionEnd 2026-03-08 20:45:12 -07:00
DennisYu07
3458c1d68b merge main de resolve conflict 2026-03-06 16:00:51 -08:00
DennisYu07
08ecaf50aa remove non-deterministic test 2026-03-06 09:58:42 -08:00
DennisYu07
b467369fd5 align command output with online env 2026-03-06 07:37:42 -08:00
DennisYu07
d7b9024d29 move enable from hooks to hookConfig and add max turns 2026-03-06 02:33:14 -08:00
DennisYu07
b71904d24e fix intergration test 2026-03-06 01:02:24 -08:00
DennisYu07
5ef7894e86 reslove aggregator for userpromptsubmit 2026-03-05 23:59:43 -08:00
DennisYu07
f0cc28f80f implementation SessionStart and SessionEnd hook 2026-03-03 23:39:57 -08:00
DennisYu07
4a44eb7a17 add more integration test for hooks 2026-03-02 23:32:10 -08:00
DennisYu07
7b0929d00c add integration test and --experimental-hooks 2026-03-02 19:05:28 -08:00
DennisYu07
3bf30d9684 add ut 2026-03-02 06:08:21 -08:00