mirror of
https://github.com/openai/codex.git
synced 2026-04-24 06:35:50 +00:00
- add `PreToolUse` hook for bash-like tool execution only at first - block shell execution before dispatch with deny-only hook behavior - introduces common.rs matcher framework for matching when hooks are run example run: ``` › run three parallel echo commands, and the second one should echo "[block-pre-tool-use]" as a test • Running the three echo commands in parallel now and I’ll report the output directly. • Running PreToolUse hook: name for demo pre tool use hook • Running PreToolUse hook: name for demo pre tool use hook • Running PreToolUse hook: name for demo pre tool use hook PreToolUse hook (completed) warning: wizard-tower PreToolUse demo inspected Bash: echo "first parallel echo" PreToolUse hook (blocked) warning: wizard-tower PreToolUse demo blocked a Bash command on purpose. feedback: PreToolUse demo blocked the command. Remove [block-pre-tool-use] to continue. PreToolUse hook (completed) warning: wizard-tower PreToolUse demo inspected Bash: echo "third parallel echo" • Ran echo "first parallel echo" └ first parallel echo • Ran echo "third parallel echo" └ third parallel echo • Three little waves went out in parallel. 1. printed first parallel echo 2. was blocked before execution because it contained the exact test string [block-pre-tool-use] 3. printed third parallel echo There was also an unrelated macOS defaults warning around the successful commands, but the echoes themselves worked fine. If you want, I can rerun the second one with a slightly modified string so it passes cleanly. ```
163 lines
3.0 KiB
JSON
163 lines
3.0 KiB
JSON
{
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
"definitions": {
|
|
"HookEventName": {
|
|
"enum": [
|
|
"preToolUse",
|
|
"sessionStart",
|
|
"userPromptSubmit",
|
|
"stop"
|
|
],
|
|
"type": "string"
|
|
},
|
|
"HookExecutionMode": {
|
|
"enum": [
|
|
"sync",
|
|
"async"
|
|
],
|
|
"type": "string"
|
|
},
|
|
"HookHandlerType": {
|
|
"enum": [
|
|
"command",
|
|
"prompt",
|
|
"agent"
|
|
],
|
|
"type": "string"
|
|
},
|
|
"HookOutputEntry": {
|
|
"properties": {
|
|
"kind": {
|
|
"$ref": "#/definitions/HookOutputEntryKind"
|
|
},
|
|
"text": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"kind",
|
|
"text"
|
|
],
|
|
"type": "object"
|
|
},
|
|
"HookOutputEntryKind": {
|
|
"enum": [
|
|
"warning",
|
|
"stop",
|
|
"feedback",
|
|
"context",
|
|
"error"
|
|
],
|
|
"type": "string"
|
|
},
|
|
"HookRunStatus": {
|
|
"enum": [
|
|
"running",
|
|
"completed",
|
|
"failed",
|
|
"blocked",
|
|
"stopped"
|
|
],
|
|
"type": "string"
|
|
},
|
|
"HookRunSummary": {
|
|
"properties": {
|
|
"completedAt": {
|
|
"format": "int64",
|
|
"type": [
|
|
"integer",
|
|
"null"
|
|
]
|
|
},
|
|
"displayOrder": {
|
|
"format": "int64",
|
|
"type": "integer"
|
|
},
|
|
"durationMs": {
|
|
"format": "int64",
|
|
"type": [
|
|
"integer",
|
|
"null"
|
|
]
|
|
},
|
|
"entries": {
|
|
"items": {
|
|
"$ref": "#/definitions/HookOutputEntry"
|
|
},
|
|
"type": "array"
|
|
},
|
|
"eventName": {
|
|
"$ref": "#/definitions/HookEventName"
|
|
},
|
|
"executionMode": {
|
|
"$ref": "#/definitions/HookExecutionMode"
|
|
},
|
|
"handlerType": {
|
|
"$ref": "#/definitions/HookHandlerType"
|
|
},
|
|
"id": {
|
|
"type": "string"
|
|
},
|
|
"scope": {
|
|
"$ref": "#/definitions/HookScope"
|
|
},
|
|
"sourcePath": {
|
|
"type": "string"
|
|
},
|
|
"startedAt": {
|
|
"format": "int64",
|
|
"type": "integer"
|
|
},
|
|
"status": {
|
|
"$ref": "#/definitions/HookRunStatus"
|
|
},
|
|
"statusMessage": {
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
]
|
|
}
|
|
},
|
|
"required": [
|
|
"displayOrder",
|
|
"entries",
|
|
"eventName",
|
|
"executionMode",
|
|
"handlerType",
|
|
"id",
|
|
"scope",
|
|
"sourcePath",
|
|
"startedAt",
|
|
"status"
|
|
],
|
|
"type": "object"
|
|
},
|
|
"HookScope": {
|
|
"enum": [
|
|
"thread",
|
|
"turn"
|
|
],
|
|
"type": "string"
|
|
}
|
|
},
|
|
"properties": {
|
|
"run": {
|
|
"$ref": "#/definitions/HookRunSummary"
|
|
},
|
|
"threadId": {
|
|
"type": "string"
|
|
},
|
|
"turnId": {
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
]
|
|
}
|
|
},
|
|
"required": [
|
|
"run",
|
|
"threadId"
|
|
],
|
|
"title": "HookStartedNotification",
|
|
"type": "object"
|
|
} |