mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 08:02:48 +00:00
Add before/after session events with cancellation support
- Merge branch event into session with before_branch/branch reasons
- Add before_switch, before_clear, shutdown reasons
- before_* events can be cancelled with { cancel: true }
- Update RPC commands to return cancelled status
- Add shutdown event on process exit
- New example hooks: confirm-destructive, dirty-repo-guard, auto-commit-on-exit
fixes #278
This commit is contained in:
parent
99081fce30
commit
42d7d9d9b6
20 changed files with 426 additions and 124 deletions
|
|
@ -205,8 +205,8 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
|
|||
}
|
||||
|
||||
case "reset": {
|
||||
await session.reset();
|
||||
return success(id, "reset");
|
||||
const cancelled = !(await session.reset());
|
||||
return success(id, "reset", { cancelled });
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
|
|
@ -339,13 +339,13 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
|
|||
}
|
||||
|
||||
case "switch_session": {
|
||||
await session.switchSession(command.sessionPath);
|
||||
return success(id, "switch_session");
|
||||
const cancelled = !(await session.switchSession(command.sessionPath));
|
||||
return success(id, "switch_session", { cancelled });
|
||||
}
|
||||
|
||||
case "branch": {
|
||||
const result = await session.branch(command.entryIndex);
|
||||
return success(id, "branch", { text: result.selectedText, skipped: result.skipped });
|
||||
return success(id, "branch", { text: result.selectedText, cancelled: result.cancelled });
|
||||
}
|
||||
|
||||
case "get_branch_messages": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue