mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
docs(coding-agent): document extension resource lifecycle
This commit is contained in:
parent
c48f656f88
commit
3fcfb7abf7
1 changed files with 7 additions and 1 deletions
|
|
@ -216,6 +216,12 @@ export default async function (pi: ExtensionAPI) {
|
|||
|
||||
This pattern makes the fetched models available during normal startup and to `pi --list-models`.
|
||||
|
||||
### Long-lived resources and shutdown
|
||||
|
||||
Extension factories may run in invocations that never start a session. Do not start background resources such as processes, sockets, file watchers, or timers from the factory.
|
||||
|
||||
Defer background resource startup until `session_start` or the command/tool/event that needs the resource. Register an idempotent `session_shutdown` handler to close any session-scoped resources you start.
|
||||
|
||||
### Extension Styles
|
||||
|
||||
**Single file** - simplest, for small extensions:
|
||||
|
|
@ -471,7 +477,7 @@ pi.on("session_tree", async (event, ctx) => {
|
|||
|
||||
#### session_shutdown
|
||||
|
||||
Fired before an extension runtime is torn down.
|
||||
Fired before a started session runtime is torn down. Use this to clean up resources opened from `session_start` or other session-scoped hooks.
|
||||
|
||||
```typescript
|
||||
pi.on("session_shutdown", async (event, ctx) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue