Add external plugin hook registration and worker invocation - #2399
Merged
Conversation
Contributor
Reference screenshots ready for reviewReview GitHub’s image diffs in screenshot PR #2601. Rendered for If this source branch moves, a later successful render closes the stale review PR and replaces this link. |
jonathanKingston
force-pushed
the
codex/external-hook-registration
branch
from
September 6, 2026 09:19
7ff20f2 to
ca4f440
Compare
Contributor
🖥️ PR preview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
External plugins can now declare and register function hooks through the existing isolated runtime. A hook-only
copse-plugin.jsoncan declareruntime.hooks, and itsactivate(api)can callregisterHook({ id, event }, handler)without providing tools or model routes.The host validates the exact declared registration IDs and canonical events before enabling the plugin. Explicit
invokeHookcalls travel through the worker protocol with cancellation and error propagation. Handlers receive only{ event, signal }; existing API-v1 workers may omit hook registrations.This is SDK stage 1: hooks load and register, but canonical agent events do not automatically dispatch them yet. Event-specific payload/result validation, result transformations and
next()composition remain follow-up work. The SDK guide and binding decision 15 document this boundary.Validation:
pnpm run check— typecheck, lint, formatting, dead-code and test-selection guards, E2E syntax, and all 8,561 unit tests passed.pnpm run build.pnpm run test:e2e --spec tests/e2e/plugin-hook-loading.e2e.ts— passed in real Electron on macOS with production seatbelt, snapshot materialization and the built worker. Verifies loading a hook-only plugin, sibling module/asset reads, disable/re-enable and restoration after relaunch; activation fails unless outside-file reads and workspace/snapshot writes are denied. The selected source is seeded into an isolated profile; the native folder picker is not exercised.Screenshot: enabled hook-only plugin after relaunch.