mirror of
https://github.com/openai/codex.git
synced 2026-05-01 03:42:05 +03:00
## Why Plugins can bundle lifecycle hooks, but Codex previously only discovered hooks from user, project, and managed config layers. This adds the plugin discovery and runtime plumbing needed for plugin-bundled hooks while keeping execution behind the `plugin_hooks` feature flag. ## What - Discovers plugin hook sources from each plugin's default `hooks/hooks.json`. - Supports `plugin.json` manifest `hooks` entries as either relative paths or inline hook objects. - Plumbs discovered plugin hook sources through plugin loading into the hook runtime when `plugin_hooks` is enabled. - Marks plugin-originated hook runs as `HookSource::Plugin`. - Injects `PLUGIN_ROOT` and `CLAUDE_PLUGIN_ROOT` into plugin hook command environments. - Updates generated schemas and hook source metadata for the plugin hook source. ## Stack 1. This PR - openai/codex#19705 2. openai/codex#19778 3. openai/codex#19840 4. openai/codex#19882 ## Reviewer Notes - Core logic is in `codex-rs/core-plugins/src/loader.rs` and `codex-rs/hooks/src/engine/discovery.rs` - Moved existing / adding new tests to `codex-rs/core-plugins/src/loader_tests.rs` hence the large diff there - Otherwise mostly plumbing and minor schema updates ### Core Changes The `codex-rs/core` changes are limited to wiring plugin hook support into existing core flows: - `core/src/session/session.rs` conditionally pulls effective plugin hook sources and plugin hook load warnings from `PluginsManager` when `plugin_hooks` is enabled, then passes them into `HooksConfig`. - `core/src/hook_runtime.rs` adds the `plugin` metric tag for `HookSource::Plugin`. - `core/config.schema.json` picks up the new `plugin_hooks` feature flag, and `core/src/plugins/manager_tests.rs` updates fixtures for the added plugin hook fields. --------- Co-authored-by: Codex <noreply@openai.com>
191 lines
4.0 KiB
JSON
Generated
191 lines
4.0 KiB
JSON
Generated
{
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
"definitions": {
|
|
"AbsolutePathBuf": {
|
|
"description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
|
|
"type": "string"
|
|
},
|
|
"HookEventName": {
|
|
"enum": [
|
|
"preToolUse",
|
|
"permissionRequest",
|
|
"postToolUse",
|
|
"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"
|
|
},
|
|
"source": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/HookSource"
|
|
}
|
|
],
|
|
"default": "unknown"
|
|
},
|
|
"sourcePath": {
|
|
"$ref": "#/definitions/AbsolutePathBuf"
|
|
},
|
|
"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"
|
|
},
|
|
"HookSource": {
|
|
"enum": [
|
|
"system",
|
|
"user",
|
|
"project",
|
|
"mdm",
|
|
"sessionFlags",
|
|
"plugin",
|
|
"legacyManagedConfigFile",
|
|
"legacyManagedConfigMdm",
|
|
"unknown"
|
|
],
|
|
"type": "string"
|
|
}
|
|
},
|
|
"properties": {
|
|
"run": {
|
|
"$ref": "#/definitions/HookRunSummary"
|
|
},
|
|
"threadId": {
|
|
"type": "string"
|
|
},
|
|
"turnId": {
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
]
|
|
}
|
|
},
|
|
"required": [
|
|
"run",
|
|
"threadId"
|
|
],
|
|
"title": "HookCompletedNotification",
|
|
"type": "object"
|
|
} |