refactor(coding-agent): unify tool and event handler context creation

Tools now use ExtensionRunner.createContext() instead of a separate
inline context factory. This ensures tools and event handlers share
the same context, fixing ctx.shutdown() and other context methods.

- Made ExtensionRunner.createContext() public
- Changed wrapRegisteredTools to accept ExtensionRunner instead of getContext callback
- Create ExtensionRunner when SDK custom tools are present (not just extensions)
- Removed redundant inline context factory from sdk.ts
This commit is contained in:
Mario Zechner 2026-01-08 03:45:39 +01:00
parent cf0466d96c
commit b1fb910625
3 changed files with 23 additions and 49 deletions

View file

@ -296,7 +296,11 @@ export class ExtensionRunner {
this.shutdownHandler();
}
private createContext(): ExtensionContext {
/**
* Create an ExtensionContext for use in event handlers and tool execution.
* Context values are resolved at call time, so changes via initialize() are reflected.
*/
createContext(): ExtensionContext {
return {
ui: this.uiContext,
hasUI: this.hasUI(),