@mariozechner/pi-coding-agent 0.63.2 → 0.65.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/README.md +11 -5
  3. package/dist/cli/args.d.ts +7 -4
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +37 -15
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/core/agent-session-runtime.d.ts +83 -0
  8. package/dist/core/agent-session-runtime.d.ts.map +1 -0
  9. package/dist/core/agent-session-runtime.js +232 -0
  10. package/dist/core/agent-session-runtime.js.map +1 -0
  11. package/dist/core/agent-session-services.d.ts +86 -0
  12. package/dist/core/agent-session-services.d.ts.map +1 -0
  13. package/dist/core/agent-session-services.js +116 -0
  14. package/dist/core/agent-session-services.js.map +1 -0
  15. package/dist/core/agent-session.d.ts +10 -42
  16. package/dist/core/agent-session.d.ts.map +1 -1
  17. package/dist/core/agent-session.js +58 -237
  18. package/dist/core/agent-session.js.map +1 -1
  19. package/dist/core/export-html/tool-renderer.d.ts +2 -0
  20. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  21. package/dist/core/export-html/tool-renderer.js +2 -2
  22. package/dist/core/export-html/tool-renderer.js.map +1 -1
  23. package/dist/core/extensions/index.d.ts +2 -2
  24. package/dist/core/extensions/index.d.ts.map +1 -1
  25. package/dist/core/extensions/index.js +1 -1
  26. package/dist/core/extensions/index.js.map +1 -1
  27. package/dist/core/extensions/runner.d.ts.map +1 -1
  28. package/dist/core/extensions/runner.js +1 -0
  29. package/dist/core/extensions/runner.js.map +1 -1
  30. package/dist/core/extensions/types.d.ts +20 -28
  31. package/dist/core/extensions/types.d.ts.map +1 -1
  32. package/dist/core/extensions/types.js +10 -0
  33. package/dist/core/extensions/types.js.map +1 -1
  34. package/dist/core/footer-data-provider.d.ts +5 -1
  35. package/dist/core/footer-data-provider.d.ts.map +1 -1
  36. package/dist/core/footer-data-provider.js +70 -8
  37. package/dist/core/footer-data-provider.js.map +1 -1
  38. package/dist/core/index.d.ts +3 -1
  39. package/dist/core/index.d.ts.map +1 -1
  40. package/dist/core/index.js +3 -1
  41. package/dist/core/index.js.map +1 -1
  42. package/dist/core/keybindings.d.ts +14 -1
  43. package/dist/core/keybindings.d.ts.map +1 -1
  44. package/dist/core/keybindings.js +13 -14
  45. package/dist/core/keybindings.js.map +1 -1
  46. package/dist/core/model-registry.d.ts +3 -1
  47. package/dist/core/model-registry.d.ts.map +1 -1
  48. package/dist/core/model-registry.js +7 -1
  49. package/dist/core/model-registry.js.map +1 -1
  50. package/dist/core/package-manager.d.ts +20 -0
  51. package/dist/core/package-manager.d.ts.map +1 -1
  52. package/dist/core/package-manager.js +32 -0
  53. package/dist/core/package-manager.js.map +1 -1
  54. package/dist/core/resource-loader.d.ts.map +1 -1
  55. package/dist/core/resource-loader.js +21 -0
  56. package/dist/core/resource-loader.js.map +1 -1
  57. package/dist/core/sdk.d.ts +5 -2
  58. package/dist/core/sdk.d.ts.map +1 -1
  59. package/dist/core/sdk.js +5 -2
  60. package/dist/core/sdk.js.map +1 -1
  61. package/dist/core/session-manager.d.ts +3 -0
  62. package/dist/core/session-manager.d.ts.map +1 -1
  63. package/dist/core/session-manager.js +13 -6
  64. package/dist/core/session-manager.js.map +1 -1
  65. package/dist/core/settings-manager.d.ts +1 -1
  66. package/dist/core/settings-manager.d.ts.map +1 -1
  67. package/dist/core/settings-manager.js +2 -1
  68. package/dist/core/settings-manager.js.map +1 -1
  69. package/dist/core/tools/edit.d.ts.map +1 -1
  70. package/dist/core/tools/edit.js +15 -4
  71. package/dist/core/tools/edit.js.map +1 -1
  72. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  73. package/dist/core/tools/tool-definition-wrapper.js +2 -0
  74. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  75. package/dist/index.d.ts +3 -3
  76. package/dist/index.d.ts.map +1 -1
  77. package/dist/index.js +3 -3
  78. package/dist/index.js.map +1 -1
  79. package/dist/main.d.ts.map +1 -1
  80. package/dist/main.js +205 -427
  81. package/dist/main.js.map +1 -1
  82. package/dist/migrations.d.ts.map +1 -1
  83. package/dist/migrations.js +20 -0
  84. package/dist/migrations.js.map +1 -1
  85. package/dist/modes/interactive/components/assistant-message.d.ts +3 -1
  86. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  87. package/dist/modes/interactive/components/assistant-message.js +14 -3
  88. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  89. package/dist/modes/interactive/components/footer.d.ts +1 -0
  90. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  91. package/dist/modes/interactive/components/footer.js +4 -1
  92. package/dist/modes/interactive/components/footer.js.map +1 -1
  93. package/dist/modes/interactive/components/tree-selector.d.ts +4 -2
  94. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  95. package/dist/modes/interactive/components/tree-selector.js +48 -15
  96. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  97. package/dist/modes/interactive/interactive-mode.d.ts +12 -4
  98. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  99. package/dist/modes/interactive/interactive-mode.js +146 -96
  100. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  101. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  102. package/dist/modes/interactive/theme/theme.js +6 -11
  103. package/dist/modes/interactive/theme/theme.js.map +1 -1
  104. package/dist/modes/print-mode.d.ts +2 -2
  105. package/dist/modes/print-mode.d.ts.map +1 -1
  106. package/dist/modes/print-mode.js +41 -36
  107. package/dist/modes/print-mode.js.map +1 -1
  108. package/dist/modes/rpc/rpc-mode.d.ts +2 -2
  109. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  110. package/dist/modes/rpc/rpc-mode.js +95 -64
  111. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  112. package/dist/package-manager-cli.d.ts +4 -0
  113. package/dist/package-manager-cli.d.ts.map +1 -0
  114. package/dist/package-manager-cli.js +234 -0
  115. package/dist/package-manager-cli.js.map +1 -0
  116. package/docs/compaction.md +4 -2
  117. package/docs/extensions.md +133 -40
  118. package/docs/json.md +5 -2
  119. package/docs/keybindings.md +2 -0
  120. package/docs/rpc.md +21 -7
  121. package/docs/sdk.md +239 -83
  122. package/docs/settings.md +1 -1
  123. package/docs/tree.md +6 -3
  124. package/examples/extensions/README.md +1 -0
  125. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  126. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  127. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  128. package/examples/extensions/custom-provider-qwen-cli/package.json +1 -1
  129. package/examples/extensions/hello.ts +18 -17
  130. package/examples/extensions/hidden-thinking-label.ts +53 -0
  131. package/examples/extensions/rpc-demo.ts +3 -9
  132. package/examples/extensions/sandbox/index.ts +4 -0
  133. package/examples/extensions/status-line.ts +0 -8
  134. package/examples/extensions/todo.ts +0 -2
  135. package/examples/extensions/tools.ts +0 -5
  136. package/examples/extensions/widget-placement.ts +4 -12
  137. package/examples/extensions/with-deps/package-lock.json +2 -2
  138. package/examples/extensions/with-deps/package.json +1 -1
  139. package/examples/sdk/02-custom-model.ts +1 -1
  140. package/examples/sdk/09-api-keys-and-oauth.ts +3 -3
  141. package/examples/sdk/12-full-control.ts +1 -1
  142. package/examples/sdk/13-session-runtime.ts +67 -0
  143. package/examples/sdk/README.md +7 -4
  144. package/package.json +4 -4
@@ -37,6 +37,7 @@ See [examples/extensions/](../examples/extensions/) for working implementations.
37
37
  - [Extension Styles](#extension-styles)
38
38
  - [Events](#events)
39
39
  - [Lifecycle Overview](#lifecycle-overview)
40
+ - [Resource Events](#resource-events)
40
41
  - [Session Events](#session-events)
41
42
  - [Agent Events](#agent-events)
42
43
  - [Tool Events](#tool-events)
@@ -225,10 +226,10 @@ Run `npm install` in the extension directory, then imports from `node_modules/`
225
226
  ### Lifecycle Overview
226
227
 
227
228
  ```
228
- pi starts (CLI only)
229
+ pi starts
229
230
 
230
- ├─► session_directory (CLI startup only, no ctx)
231
- └─► session_start
231
+ ├─► session_start { reason: "startup" }
232
+ └─► resources_discover { reason: "startup" }
232
233
 
233
234
 
234
235
  user sends prompt ─────────────────────────────────────────┐
@@ -261,11 +262,15 @@ user sends another prompt ◄─────────────────
261
262
 
262
263
  /new (new session) or /resume (switch session)
263
264
  ├─► session_before_switch (can cancel)
264
- └─► session_switch
265
+ ├─► session_shutdown
266
+ ├─► session_start { reason: "new" | "resume", previousSessionFile? }
267
+ └─► resources_discover { reason: "startup" }
265
268
 
266
269
  /fork
267
270
  ├─► session_before_fork (can cancel)
268
- └─► session_fork
271
+ ├─► session_shutdown
272
+ ├─► session_start { reason: "fork", previousSessionFile }
273
+ └─► resources_discover { reason: "startup" }
269
274
 
270
275
  /compact or auto-compaction
271
276
  ├─► session_before_compact (can cancel or customize)
@@ -282,44 +287,44 @@ exit (Ctrl+C, Ctrl+D)
282
287
  └─► session_shutdown
283
288
  ```
284
289
 
285
- ### Session Events
286
-
287
- See [session.md](session.md) for session storage internals and the SessionManager API.
288
-
289
- #### session_directory
290
+ ### Resource Events
290
291
 
291
- Fired by the `pi` CLI during startup session resolution, before the initial session manager is created.
292
+ #### resources_discover
292
293
 
293
- This event is:
294
- - CLI-only. It is not emitted in SDK mode.
295
- - Startup-only. It is not emitted for later interactive `/new` or `/resume` actions.
296
- - Lower priority than `--session-dir` and `sessionDir` in `settings.json`.
297
- - Special-cased to receive no `ctx` argument.
298
-
299
- If multiple extensions return `sessionDir`, the last one wins.
300
- Combined precedence is: `--session-dir` CLI flag, then `sessionDir` in settings, then extension `session_directory` hooks.
294
+ Fired after `session_start` so extensions can contribute additional skill, prompt, and theme paths.
295
+ The startup path uses `reason: "startup"`. Reload uses `reason: "reload"`.
301
296
 
302
297
  ```typescript
303
- pi.on("session_directory", async (event) => {
298
+ pi.on("resources_discover", async (event, _ctx) => {
299
+ // event.cwd - current working directory
300
+ // event.reason - "startup" | "reload"
304
301
  return {
305
- sessionDir: `/tmp/pi-sessions/${encodeURIComponent(event.cwd)}`,
302
+ skillPaths: ["/path/to/skills"],
303
+ promptPaths: ["/path/to/prompts"],
304
+ themePaths: ["/path/to/themes"],
306
305
  };
307
306
  });
308
307
  ```
309
308
 
309
+ ### Session Events
310
+
311
+ See [session.md](session.md) for session storage internals and the SessionManager API.
312
+
310
313
  #### session_start
311
314
 
312
- Fired on initial session load.
315
+ Fired when a session is started, loaded, or reloaded.
313
316
 
314
317
  ```typescript
315
- pi.on("session_start", async (_event, ctx) => {
318
+ pi.on("session_start", async (event, ctx) => {
319
+ // event.reason - "startup" | "reload" | "new" | "resume" | "fork"
320
+ // event.previousSessionFile - present for "new", "resume", and "fork"
316
321
  ctx.ui.notify(`Session: ${ctx.sessionManager.getSessionFile() ?? "ephemeral"}`, "info");
317
322
  });
318
323
  ```
319
324
 
320
- #### session_before_switch / session_switch
325
+ #### session_before_switch
321
326
 
322
- Fired when starting a new session (`/new`) or switching sessions (`/resume`).
327
+ Fired before starting a new session (`/new`) or switching sessions (`/resume`).
323
328
 
324
329
  ```typescript
325
330
  pi.on("session_before_switch", async (event, ctx) => {
@@ -331,14 +336,12 @@ pi.on("session_before_switch", async (event, ctx) => {
331
336
  if (!ok) return { cancel: true };
332
337
  }
333
338
  });
334
-
335
- pi.on("session_switch", async (event, ctx) => {
336
- // event.reason - "new" or "resume"
337
- // event.previousSessionFile - session we came from
338
- });
339
339
  ```
340
340
 
341
- #### session_before_fork / session_fork
341
+ After a successful switch or new-session action, pi emits `session_shutdown` for the old extension instance, reloads and rebinds extensions for the new session, then emits `session_start` with `reason: "new" | "resume"` and `previousSessionFile`.
342
+ Do cleanup work in `session_shutdown`, then reestablish any in-memory state in `session_start`.
343
+
344
+ #### session_before_fork
342
345
 
343
346
  Fired when forking via `/fork`.
344
347
 
@@ -349,12 +352,11 @@ pi.on("session_before_fork", async (event, ctx) => {
349
352
  // OR
350
353
  return { skipConversationRestore: true }; // Fork but don't rewind messages
351
354
  });
352
-
353
- pi.on("session_fork", async (event, ctx) => {
354
- // event.previousSessionFile - previous session file
355
- });
356
355
  ```
357
356
 
357
+ After a successful fork, pi emits `session_shutdown` for the old extension instance, reloads and rebinds extensions for the new session, then emits `session_start` with `reason: "fork"` and `previousSessionFile`.
358
+ Do cleanup work in `session_shutdown`, then reestablish any in-memory state in `session_start`.
359
+
358
360
  #### session_before_compact / session_compact
359
361
 
360
362
  Fired on compaction. See [compaction.md](compaction.md) for details.
@@ -735,9 +737,7 @@ Transforms chain across handlers. See [input-transform.ts](../examples/extension
735
737
 
736
738
  ## ExtensionContext
737
739
 
738
- All handlers except `session_directory` receive `ctx: ExtensionContext`.
739
-
740
- `session_directory` is a CLI startup hook and receives only the event.
740
+ All handlers receive `ctx: ExtensionContext`.
741
741
 
742
742
  ### ctx.ui
743
743
 
@@ -920,6 +920,38 @@ Options:
920
920
  - `replaceInstructions`: If true, `customInstructions` replaces the default prompt instead of being appended
921
921
  - `label`: Label to attach to the branch summary entry (or target entry if not summarizing)
922
922
 
923
+ ### ctx.switchSession(sessionPath)
924
+
925
+ Switch to a different session file:
926
+
927
+ ```typescript
928
+ const result = await ctx.switchSession("/path/to/session.jsonl");
929
+ if (result.cancelled) {
930
+ // An extension cancelled the switch via session_before_switch
931
+ }
932
+ ```
933
+
934
+ To discover available sessions, use the static `SessionManager.list()` or `SessionManager.listAll()` methods:
935
+
936
+ ```typescript
937
+ import { SessionManager } from "@mariozechner/pi-coding-agent";
938
+
939
+ pi.registerCommand("switch", {
940
+ description: "Switch to another session",
941
+ handler: async (args, ctx) => {
942
+ const sessions = await SessionManager.list(ctx.cwd);
943
+ if (sessions.length === 0) return;
944
+ const choice = await ctx.ui.select(
945
+ "Pick session:",
946
+ sessions.map(s => s.file),
947
+ );
948
+ if (choice) {
949
+ await ctx.switchSession(choice);
950
+ }
951
+ },
952
+ });
953
+ ```
954
+
923
955
  ### ctx.reload()
924
956
 
925
957
  Run the same reload flow as `/reload`.
@@ -936,7 +968,7 @@ pi.registerCommand("reload-runtime", {
936
968
 
937
969
  Important behavior:
938
970
  - `await ctx.reload()` emits `session_shutdown` for the current extension runtime
939
- - It then reloads resources and emits `session_start` (and `resources_discover` with reason `"reload"`) for the new runtime
971
+ - It then reloads resources and emits `session_start` with `reason: "reload"` and `resources_discover` with reason `"reload"`
940
972
  - The currently running command handler still continues in the old call frame
941
973
  - Code after `await ctx.reload()` still runs from the pre-reload version
942
974
  - Code after `await ctx.reload()` must not assume old in-memory extension state is still valid
@@ -1008,6 +1040,12 @@ pi.registerTool({
1008
1040
  action: StringEnum(["list", "add"] as const),
1009
1041
  text: Type.Optional(Type.String()),
1010
1042
  }),
1043
+ prepareArguments(args) {
1044
+ // Optional compatibility shim. Runs before schema validation.
1045
+ // Return the current schema shape, for example to fold legacy fields
1046
+ // into the modern parameter object.
1047
+ return args;
1048
+ },
1011
1049
 
1012
1050
  async execute(toolCallId, params, signal, onUpdate, ctx) {
1013
1051
  // Stream progress
@@ -1472,6 +1510,14 @@ pi.registerTool({
1472
1510
  action: StringEnum(["list", "add"] as const), // Use StringEnum for Google compatibility
1473
1511
  text: Type.Optional(Type.String()),
1474
1512
  }),
1513
+ prepareArguments(args) {
1514
+ if (!args || typeof args !== "object") return args;
1515
+ const input = args as { action?: string; oldAction?: string };
1516
+ if (typeof input.oldAction === "string" && input.action === undefined) {
1517
+ return { ...input, action: input.oldAction };
1518
+ }
1519
+ return args;
1520
+ },
1475
1521
 
1476
1522
  async execute(toolCallId, params, signal, onUpdate, ctx) {
1477
1523
  // Check for cancellation
@@ -1515,6 +1561,53 @@ async execute(toolCallId, params) {
1515
1561
 
1516
1562
  **Important:** Use `StringEnum` from `@mariozechner/pi-ai` for string enums. `Type.Union`/`Type.Literal` doesn't work with Google's API.
1517
1563
 
1564
+ **Argument preparation:** `prepareArguments(args)` is optional. If defined, it runs before schema validation and before `execute()`. Use it to mimic an older accepted input shape when pi resumes an older session whose stored tool call arguments no longer match the current schema. Return the object you want validated against `parameters`. Keep the public schema strict. Do not add deprecated compatibility fields to `parameters` just to keep old resumed sessions working.
1565
+
1566
+ Example: an older session may contain an `edit` tool call with top-level `oldText` and `newText`, while the current schema only accepts `edits: [{ oldText, newText }]`.
1567
+
1568
+ ```typescript
1569
+ pi.registerTool({
1570
+ name: "edit",
1571
+ label: "Edit",
1572
+ description: "Edit a single file using exact text replacement",
1573
+ parameters: Type.Object({
1574
+ path: Type.String(),
1575
+ edits: Type.Array(
1576
+ Type.Object({
1577
+ oldText: Type.String(),
1578
+ newText: Type.String(),
1579
+ }),
1580
+ ),
1581
+ }),
1582
+ prepareArguments(args) {
1583
+ if (!args || typeof args !== "object") return args;
1584
+
1585
+ const input = args as {
1586
+ path?: string;
1587
+ edits?: Array<{ oldText: string; newText: string }>;
1588
+ oldText?: unknown;
1589
+ newText?: unknown;
1590
+ };
1591
+
1592
+ if (typeof input.oldText !== "string" || typeof input.newText !== "string") {
1593
+ return args;
1594
+ }
1595
+
1596
+ return {
1597
+ ...input,
1598
+ edits: [...(input.edits ?? []), { oldText: input.oldText, newText: input.newText }],
1599
+ };
1600
+ },
1601
+ async execute(toolCallId, params, signal, onUpdate, ctx) {
1602
+ // params now matches the current schema
1603
+ return {
1604
+ content: [{ type: "text", text: `Applying ${params.edits.length} edit block(s)` }],
1605
+ details: {},
1606
+ };
1607
+ },
1608
+ });
1609
+ ```
1610
+
1518
1611
  ### Overriding Built-in Tools
1519
1612
 
1520
1613
  Extensions can override built-in tools (`read`, `bash`, `edit`, `write`, `grep`, `find`, `ls`) by registering a tool with the same name. Interactive mode displays a warning when this happens.
@@ -2126,7 +2219,7 @@ All examples in [examples/extensions/](../examples/extensions/).
2126
2219
  | **Compaction & Sessions** |||
2127
2220
  | `custom-compaction.ts` | Custom compaction summary | `on("session_before_compact")` |
2128
2221
  | `trigger-compact.ts` | Trigger compaction manually | `compact()` |
2129
- | `git-checkpoint.ts` | Git stash on turns | `on("turn_end")`, `on("session_fork")`, `exec` |
2222
+ | `git-checkpoint.ts` | Git stash on turns | `on("turn_start")`, `on("session_before_fork")`, `exec` |
2130
2223
  | `auto-commit-on-exit.ts` | Commit on shutdown | `on("session_shutdown")`, `exec` |
2131
2224
  | **UI Components** |||
2132
2225
  | `status-line.ts` | Footer status indicator | `setStatus`, session events |
package/docs/json.md CHANGED
@@ -13,12 +13,15 @@ Events are defined in [`AgentSessionEvent`](https://github.com/badlogic/pi-mono/
13
13
  ```typescript
14
14
  type AgentSessionEvent =
15
15
  | AgentEvent
16
- | { type: "auto_compaction_start"; reason: "threshold" | "overflow" }
17
- | { type: "auto_compaction_end"; result: CompactionResult | undefined; aborted: boolean; willRetry: boolean; errorMessage?: string }
16
+ | { type: "queue_update"; steering: readonly string[]; followUp: readonly string[] }
17
+ | { type: "compaction_start"; reason: "manual" | "threshold" | "overflow" }
18
+ | { type: "compaction_end"; reason: "manual" | "threshold" | "overflow"; result: CompactionResult | undefined; aborted: boolean; willRetry: boolean; errorMessage?: string }
18
19
  | { type: "auto_retry_start"; attempt: number; maxAttempts: number; delayMs: number; errorMessage: string }
19
20
  | { type: "auto_retry_end"; success: boolean; attempt: number; finalError?: string };
20
21
  ```
21
22
 
23
+ `queue_update` emits the full pending steering and follow-up queues whenever they change. `compaction_start` and `compaction_end` cover both manual and automatic compaction.
24
+
22
25
  Base events from [`AgentEvent`](https://github.com/badlogic/pi-mono/blob/main/packages/agent/src/types.ts#L179):
23
26
 
24
27
  ```typescript
@@ -128,6 +128,8 @@ Modifier combinations: `ctrl+shift+x`, `alt+ctrl+x`, `ctrl+shift+alt+x`, `ctrl+1
128
128
  |--------|---------|-------------|
129
129
  | `app.tree.foldOrUp` | `ctrl+left`, `alt+left` | Fold current branch segment, or jump to the previous segment start |
130
130
  | `app.tree.unfoldOrDown` | `ctrl+right`, `alt+right` | Unfold current branch segment, or jump to the next segment start or branch end |
131
+ | `app.tree.editLabel` | `shift+l` | Edit the label on the selected tree node |
132
+ | `app.tree.toggleLabelTimestamp` | `shift+t` | Toggle label timestamps in the tree |
131
133
 
132
134
  ## Custom Configuration
133
135
 
package/docs/rpc.md CHANGED
@@ -725,8 +725,9 @@ Events are streamed to stdout as JSON lines during agent operation. Events do NO
725
725
  | `tool_execution_start` | Tool begins execution |
726
726
  | `tool_execution_update` | Tool execution progress (streaming output) |
727
727
  | `tool_execution_end` | Tool completes |
728
- | `auto_compaction_start` | Auto-compaction begins |
729
- | `auto_compaction_end` | Auto-compaction completes |
728
+ | `queue_update` | Pending steering/follow-up queue changed |
729
+ | `compaction_start` | Compaction begins |
730
+ | `compaction_end` | Compaction completes |
730
731
  | `auto_retry_start` | Auto-retry begins (after transient error) |
731
732
  | `auto_retry_end` | Auto-retry completes (success or final failure) |
732
733
  | `extension_error` | Extension threw an error |
@@ -862,19 +863,32 @@ When complete:
862
863
 
863
864
  Use `toolCallId` to correlate events. The `partialResult` in `tool_execution_update` contains the accumulated output so far (not just the delta), allowing clients to simply replace their display on each update.
864
865
 
865
- ### auto_compaction_start / auto_compaction_end
866
+ ### queue_update
866
867
 
867
- Emitted when automatic compaction runs (when context is nearly full).
868
+ Emitted whenever the pending steering or follow-up queue changes.
868
869
 
869
870
  ```json
870
- {"type": "auto_compaction_start", "reason": "threshold"}
871
+ {
872
+ "type": "queue_update",
873
+ "steering": ["Focus on error handling"],
874
+ "followUp": ["After that, summarize the result"]
875
+ }
876
+ ```
877
+
878
+ ### compaction_start / compaction_end
879
+
880
+ Emitted when compaction runs, whether manual or automatic.
881
+
882
+ ```json
883
+ {"type": "compaction_start", "reason": "threshold"}
871
884
  ```
872
885
 
873
- The `reason` field is `"threshold"` (context getting large) or `"overflow"` (context exceeded limit).
886
+ The `reason` field is `"manual"`, `"threshold"`, or `"overflow"`.
874
887
 
875
888
  ```json
876
889
  {
877
- "type": "auto_compaction_end",
890
+ "type": "compaction_end",
891
+ "reason": "threshold",
878
892
  "result": {
879
893
  "summary": "Summary of conversation...",
880
894
  "firstKeptEntryId": "abc123",