mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 08:03:39 +00:00
feat(coding-agent): make ctx.shutdown() available for extensions (#542)
This commit is contained in:
parent
7f3fa417c4
commit
6845c4b85e
11 changed files with 164 additions and 2 deletions
|
|
@ -556,6 +556,24 @@ Access to models and API keys.
|
|||
|
||||
Control flow helpers.
|
||||
|
||||
### ctx.shutdown()
|
||||
|
||||
Request a graceful shutdown of pi.
|
||||
|
||||
- **Interactive mode:** Deferred until the agent becomes idle (after processing all queued steering and follow-up messages).
|
||||
- **RPC mode:** Deferred until the next idle state (after completing the current command response, when waiting for the next command).
|
||||
- **Print mode:** No-op. The process exits automatically when all prompts are processed.
|
||||
|
||||
Emits `session_shutdown` event to all extensions before exiting. Available in all contexts (event handlers, tools, commands, shortcuts).
|
||||
|
||||
```typescript
|
||||
pi.on("tool_call", (event, ctx) => {
|
||||
if (isFatal(event.input)) {
|
||||
ctx.shutdown();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## ExtensionCommandContext
|
||||
|
||||
Command handlers receive `ExtensionCommandContext`, which extends `ExtensionContext` with session control methods. These are only available in commands because they can deadlock if called from event handlers.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue