Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/en/guides/extensions/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,13 @@ For most hooks, choose an execution mode based on whether the current operation

An asynchronous hook (`async`) does not delay the event that triggered it or the current operation. When the current turn or session ends, if an applicable asynchronous hook is still running, iCode waits for it to finish before ending the turn or session. iCode does not wait for asynchronous hooks triggered by `user_interrupt`. The wait limit at session end is configurable in [Global settings](../../reference/hooks.md#global-settings). To retry unfinished tasks after iCode exits, also configure `delivery: durable`.

In a chat, the bottom-right corner shows the hook that is running; select it to see the hooks iCode loaded.
## See which hooks ran

In a chat, the bottom-right corner shows the hook iCode is waiting for. Select it to open the **Hooks** tab of the sidebar (**Ctrl+G** shows or hides the sidebar) and, when a hook is shown there, that hook's details over it; the list scrolls to that hook's row and marks it.

The **Hooks** tab lists the hooks that ran since iCode started, in every chat session (hooks that workflows run aren't listed), numbered in the order they started, the newest at the bottom: those still running or waiting for their turn, and the 100 that ended last. Each row shows its number, the hook, the tool or event that triggered it (and the sub-agent, when one did), its result, such as `exit 1`, `timed out`, `blocked`, `modified args` or `added context`, and at the right end how long it ran. A hook that is still running shows its time counting up, highlighted. A hook that failed is marked `✗`. **Clear ended** removes the runs that ended from the list; running ones stay. Cleared runs can't be shown again, and new runs keep counting from the last number. Once more than 100 runs have ended, the top of the list says that only the latest 100 are kept.

Click a run to see its details. **Input** shows the payload iCode gave the hook and how it was run; **Output** shows its result file, what iCode took from it (or why it took nothing), and what it printed to stdout and stderr. Click a box to copy its text, or press **c** to copy the whole tab; very long text shows only in part, but a copy still takes all of it. The list starts empty each time iCode starts; to see the hooks iCode loaded, enter `/runtime` and open the **Hooks** tab.

## Use global hooks

Expand Down
8 changes: 7 additions & 1 deletion docs/zh-Hans/guides/extensions/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,13 @@ with open(os.environ["CHRYS_HOOK_RESULT"], "w", encoding="utf-8") as result_file

异步钩子(`async`)不会延迟触发它的事件或当前操作。当前轮或会话结束时,如果相应的异步钩子仍在运行,iCode 会等待它完成后再结束当前轮或会话。`user_interrupt` 触发的异步钩子不会被等待。会话结束时的等待上限可在[全局设置](../../reference/hooks.md#全局设置)中配置。需要在 iCode 退出后重试未完成的任务时,还应配置 `delivery: durable`。

在对话中,右下角会显示正在运行的钩子;点击它可以查看 iCode 加载的钩子。
## 查看运行过的钩子

在对话中,右下角会显示 iCode 正在等待的钩子。点击它会打开侧栏的“钩子”标签页(按 **Ctrl+G** 显示或隐藏侧栏);右下角显示着某个钩子时,还会在上面打开这个钩子的详情,并且列表会滚动到这一行并标出它。

“钩子”标签页列出 iCode 启动以来所有对话会话中运行过的钩子(工作流运行的钩子不在其中),按开始顺序编号,最新的在最下面:包括正在运行和排队等待的,以及最近结束的 100 次。每行显示编号、钩子、触发它的工具或事件(由子智能体触发时还显示子智能体)和结果,例如“退出码 1”、“已超时”、“已阻止”、“修改了参数”或“追加了上下文”,最右侧是运行时长。仍在运行的钩子,其时长会高亮显示并不断增加。运行失败的钩子标为 `✗`。点击“清除已结束”可从列表中移除已结束的运行,正在运行的会保留。清除后的运行无法再显示,新的运行接着原来的编号往下数。结束的运行超过 100 次后,列表顶部会提示只保留最近 100 次。

点击一行可查看详情。“输入”显示 iCode 交给钩子的 payload 以及钩子的运行方式;“输出”显示结果文件、iCode 采纳了哪些内容(或为什么没有采纳),以及钩子输出到 stdout 和 stderr 的内容。点击某个方框即可复制其中的内容,按 **c** 复制整个标签页;很长的内容只显示一部分,但复制时仍会复制全部内容。每次启动 iCode 时列表为空;要查看 iCode 加载了哪些钩子,输入 `/runtime` 并打开“钩子”标签页。

## 使用全局钩子

Expand Down
Loading
Loading