refactor(agent-core-v2): extract externalHooks into a scope-organized feature - #2805
refactor(agent-core-v2): extract externalHooks into a scope-organized feature#2805sailist wants to merge 1 commit into
Conversation
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c7a105398
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| this.contributeService( | ||
| LifecycleScope.App, | ||
| IExternalHooksRunnerService, | ||
| ExternalHooksRunnerService, | ||
| ); |
There was a problem hiding this comment.
Preserve seeded hook-runner overrides
Previously IExternalHooksRunnerService was a registerScopedService, so bootstrap(..., extraSeeds) / createAppScope({ extra }) callers could seed a noop or custom runner and the static registration was skipped. This feature contribution materializes through ScopeUnits during app creation and unconditionally provides the production ExternalHooksRunnerService, so those callers silently lose their override and configured shell hooks can run anyway; preserve the seed check before contributing/providing the hook services.
AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L28-L28
Useful? React with 👍 / 👎.
… feature Move the external hook services out of app/externalHooksRunner, session/externalHooks, and agent/externalHooks into features/externalHooks, assembled as the ExternalHooksFeature unit: - services live under per-scope subdirectories (app/, session/, agent/); shared pure helpers (types, hook matching/dispatch, process spawn, prompt result rendering) live under internal/ - the runner and the two observers are contributed through the Feature seams (ScopeUnits materialization); the hooks config section stays on the static import=register channel - update the package entry leaf exports, the plugin domain imports, the kap-server events-zod import, and the affected tests; regenerate the state manifest
2c7a105 to
ea74229
Compare
commit: |
Related Issue
No linked issue — this is an internal refactor; the problem is explained below.
Problem
The external hook capability predates the
features/seam in agent-core-v2: its services lived in three flat per-scope domains (app/externalHooksRunner,session/externalHooks,agent/externalHooks) with their ownindex.tsbarrels, while built-in capabilities are being unified as self-contained Feature units (planwas the first). The runner engine, the two per-scope observers, and the shared pure helpers were also mixed together, making the scope boundaries hard to see.What changed
packages/agent-core-v2/src/features/externalHooks/asExternalHooksFeature— one App-scope Feature unit contributing the App-scope runner, the Session-scope observer, and the per-Agent observer through theScopeUnitsseam, so retracting the unit withdraws all of them across the scope tree. Thehooksconfig section stays on the static import=register channel, keeping the config manifest discoverable.app//session//agent/, and the shared pure helpers (hook types, matching/dispatch, process spawn, prompt result rendering) underinternal/.lint:imports+ typecheck green on both agent-core-v2 and kap-server, and verified end-to-end on a live server: SessionStart/UserPromptSubmit hooks fire with the expected payloads, and an exit-2 hook blocks a matching prompt while non-matching prompts run.Checklist
gen-changesetsskill, or this PR needs no changeset. (Needs none: internal agent-core-v2 refactor, not user-perceivable.)gen-docsskill, or this PR needs no doc update. (No behavior or configuration change.)