mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 22:01:41 +00:00
Update plan: move exec to HookAPI, sessionManager/modelRegistry to contexts
- exec() moves from HookEventContext/HookCommandContext to HookAPI - sessionManager/modelRegistry move from SessionEventBase to HookEventContext - HookCommandContext keeps sessionManager/modelRegistry (command handlers need them) - Both sendMessage and exec accessed via pi closure in command handlers
This commit is contained in:
parent
09e7e9196c
commit
e25aef0594
1 changed files with 21 additions and 2 deletions
|
|
@ -165,6 +165,26 @@ Calls `sessionManager.appendCustomEntry()` directly.
|
||||||
**New: `registerCommand()` (types ✅, wiring TODO)**
|
**New: `registerCommand()` (types ✅, wiring TODO)**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
|
// HookAPI (the `pi` object) - utilities available to all hooks:
|
||||||
|
interface HookAPI {
|
||||||
|
sendMessage(message: HookMessage, triggerTurn?: boolean): void;
|
||||||
|
appendEntry(customType: string, data?: unknown): void;
|
||||||
|
registerCommand(name: string, options: RegisteredCommand): void;
|
||||||
|
registerCustomMessageRenderer(customType: string, renderer: CustomMessageRenderer): void;
|
||||||
|
exec(command: string, args: string[], options?: ExecOptions): Promise<ExecResult>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// HookEventContext - passed to event handlers, has stable context:
|
||||||
|
interface HookEventContext {
|
||||||
|
ui: HookUIContext;
|
||||||
|
hasUI: boolean;
|
||||||
|
cwd: string;
|
||||||
|
sessionManager: SessionManager;
|
||||||
|
modelRegistry: ModelRegistry;
|
||||||
|
}
|
||||||
|
// Note: exec moved to HookAPI, sessionManager/modelRegistry moved from SessionEventBase
|
||||||
|
|
||||||
|
// HookCommandContext - passed to command handlers:
|
||||||
interface HookCommandContext {
|
interface HookCommandContext {
|
||||||
args: string; // Everything after /commandname
|
args: string; // Everything after /commandname
|
||||||
ui: HookUIContext;
|
ui: HookUIContext;
|
||||||
|
|
@ -172,9 +192,8 @@ interface HookCommandContext {
|
||||||
cwd: string;
|
cwd: string;
|
||||||
sessionManager: SessionManager;
|
sessionManager: SessionManager;
|
||||||
modelRegistry: ModelRegistry;
|
modelRegistry: ModelRegistry;
|
||||||
exec(command: string, args: string[], options?: ExecOptions): Promise<ExecResult>;
|
|
||||||
}
|
}
|
||||||
// Note: sendMessage not on context - handler captures `pi` in closure
|
// Note: exec and sendMessage accessed via `pi` closure
|
||||||
|
|
||||||
registerCommand(name: string, options: {
|
registerCommand(name: string, options: {
|
||||||
description?: string;
|
description?: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue