@earendil-works/pi-coding-agent 0.80.3 → 0.80.6

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 (172) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +2 -2
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +4 -4
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/cli/config-selector.d.ts +4 -2
  7. package/dist/cli/config-selector.d.ts.map +1 -1
  8. package/dist/cli/config-selector.js +1 -1
  9. package/dist/cli/config-selector.js.map +1 -1
  10. package/dist/core/agent-session.d.ts +20 -4
  11. package/dist/core/agent-session.d.ts.map +1 -1
  12. package/dist/core/agent-session.js +95 -22
  13. package/dist/core/agent-session.js.map +1 -1
  14. package/dist/core/auth-storage.d.ts.map +1 -1
  15. package/dist/core/auth-storage.js +13 -5
  16. package/dist/core/auth-storage.js.map +1 -1
  17. package/dist/core/cache-stats.d.ts +49 -0
  18. package/dist/core/cache-stats.d.ts.map +1 -0
  19. package/dist/core/cache-stats.js +101 -0
  20. package/dist/core/cache-stats.js.map +1 -0
  21. package/dist/core/compaction/compaction.d.ts +1 -2
  22. package/dist/core/compaction/compaction.d.ts.map +1 -1
  23. package/dist/core/compaction/compaction.js +56 -81
  24. package/dist/core/compaction/compaction.js.map +1 -1
  25. package/dist/core/extensions/index.d.ts +1 -1
  26. package/dist/core/extensions/index.d.ts.map +1 -1
  27. package/dist/core/extensions/index.js.map +1 -1
  28. package/dist/core/extensions/loader.d.ts.map +1 -1
  29. package/dist/core/extensions/loader.js +6 -0
  30. package/dist/core/extensions/loader.js.map +1 -1
  31. package/dist/core/extensions/runner.d.ts +5 -3
  32. package/dist/core/extensions/runner.d.ts.map +1 -1
  33. package/dist/core/extensions/runner.js +38 -0
  34. package/dist/core/extensions/runner.js.map +1 -1
  35. package/dist/core/extensions/types.d.ts +33 -11
  36. package/dist/core/extensions/types.d.ts.map +1 -1
  37. package/dist/core/extensions/types.js.map +1 -1
  38. package/dist/core/index.d.ts +1 -1
  39. package/dist/core/index.d.ts.map +1 -1
  40. package/dist/core/index.js.map +1 -1
  41. package/dist/core/keybindings.d.ts.map +1 -1
  42. package/dist/core/keybindings.js +3 -6
  43. package/dist/core/keybindings.js.map +1 -1
  44. package/dist/core/model-registry.d.ts +4 -6
  45. package/dist/core/model-registry.d.ts.map +1 -1
  46. package/dist/core/model-registry.js +34 -8
  47. package/dist/core/model-registry.js.map +1 -1
  48. package/dist/core/model-resolver.d.ts +10 -0
  49. package/dist/core/model-resolver.d.ts.map +1 -1
  50. package/dist/core/model-resolver.js +14 -17
  51. package/dist/core/model-resolver.js.map +1 -1
  52. package/dist/core/package-manager.d.ts +4 -1
  53. package/dist/core/package-manager.d.ts.map +1 -1
  54. package/dist/core/package-manager.js +68 -26
  55. package/dist/core/package-manager.js.map +1 -1
  56. package/dist/core/provider-attribution.d.ts.map +1 -1
  57. package/dist/core/provider-attribution.js +0 -10
  58. package/dist/core/provider-attribution.js.map +1 -1
  59. package/dist/core/resource-loader.d.ts +2 -2
  60. package/dist/core/resource-loader.d.ts.map +1 -1
  61. package/dist/core/resource-loader.js +6 -7
  62. package/dist/core/resource-loader.js.map +1 -1
  63. package/dist/core/sdk.d.ts +1 -1
  64. package/dist/core/sdk.d.ts.map +1 -1
  65. package/dist/core/sdk.js +8 -1
  66. package/dist/core/sdk.js.map +1 -1
  67. package/dist/core/session-manager.d.ts +20 -1
  68. package/dist/core/session-manager.d.ts.map +1 -1
  69. package/dist/core/session-manager.js +97 -68
  70. package/dist/core/session-manager.js.map +1 -1
  71. package/dist/core/settings-manager.d.ts +9 -3
  72. package/dist/core/settings-manager.d.ts.map +1 -1
  73. package/dist/core/settings-manager.js +10 -1
  74. package/dist/core/settings-manager.js.map +1 -1
  75. package/dist/core/slash-commands.d.ts +1 -0
  76. package/dist/core/slash-commands.d.ts.map +1 -1
  77. package/dist/core/slash-commands.js +3 -3
  78. package/dist/core/slash-commands.js.map +1 -1
  79. package/dist/core/tools/bash.d.ts.map +1 -1
  80. package/dist/core/tools/bash.js +20 -5
  81. package/dist/core/tools/bash.js.map +1 -1
  82. package/dist/core/tools/edit.d.ts.map +1 -1
  83. package/dist/core/tools/edit.js +2 -2
  84. package/dist/core/tools/edit.js.map +1 -1
  85. package/dist/index.d.ts +3 -2
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +2 -1
  88. package/dist/index.js.map +1 -1
  89. package/dist/main.d.ts +2 -2
  90. package/dist/main.d.ts.map +1 -1
  91. package/dist/main.js +1 -0
  92. package/dist/main.js.map +1 -1
  93. package/dist/modes/interactive/components/config-selector.d.ts +34 -3
  94. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  95. package/dist/modes/interactive/components/config-selector.js +280 -25
  96. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  97. package/dist/modes/interactive/components/custom-entry.d.ts +19 -0
  98. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
  99. package/dist/modes/interactive/components/custom-entry.js +52 -0
  100. package/dist/modes/interactive/components/custom-entry.js.map +1 -0
  101. package/dist/modes/interactive/components/footer.d.ts +4 -0
  102. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  103. package/dist/modes/interactive/components/footer.js +1 -1
  104. package/dist/modes/interactive/components/footer.js.map +1 -1
  105. package/dist/modes/interactive/components/oauth-selector.d.ts +3 -1
  106. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  107. package/dist/modes/interactive/components/oauth-selector.js +17 -6
  108. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  109. package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
  110. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  111. package/dist/modes/interactive/components/settings-selector.js +12 -1
  112. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  113. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  114. package/dist/modes/interactive/components/thinking-selector.js +2 -1
  115. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  116. package/dist/modes/interactive/interactive-mode.d.ts +15 -3
  117. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  118. package/dist/modes/interactive/interactive-mode.js +302 -61
  119. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  120. package/dist/modes/interactive/theme/dark.json +1 -0
  121. package/dist/modes/interactive/theme/light.json +1 -0
  122. package/dist/modes/interactive/theme/theme-schema.json +6 -2
  123. package/dist/modes/interactive/theme/theme.d.ts +3 -2
  124. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  125. package/dist/modes/interactive/theme/theme.js +10 -3
  126. package/dist/modes/interactive/theme/theme.js.map +1 -1
  127. package/dist/modes/print-mode.d.ts.map +1 -1
  128. package/dist/modes/print-mode.js +1 -1
  129. package/dist/modes/print-mode.js.map +1 -1
  130. package/dist/modes/rpc/rpc-client.d.ts +6 -6
  131. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  132. package/dist/modes/rpc/rpc-client.js +3 -3
  133. package/dist/modes/rpc/rpc-client.js.map +1 -1
  134. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  135. package/dist/modes/rpc/rpc-mode.js +4 -1
  136. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  137. package/dist/package-manager-cli.d.ts +2 -2
  138. package/dist/package-manager-cli.d.ts.map +1 -1
  139. package/dist/package-manager-cli.js +71 -17
  140. package/dist/package-manager-cli.js.map +1 -1
  141. package/dist/utils/clipboard-image.d.ts.map +1 -1
  142. package/dist/utils/clipboard-image.js +1 -1
  143. package/dist/utils/clipboard-image.js.map +1 -1
  144. package/docs/custom-provider.md +4 -3
  145. package/docs/extensions.md +75 -18
  146. package/docs/models.md +49 -8
  147. package/docs/packages.md +2 -2
  148. package/docs/rpc.md +15 -5
  149. package/docs/sdk.md +51 -1
  150. package/docs/session-format.md +18 -8
  151. package/docs/settings.md +3 -2
  152. package/docs/themes.md +5 -3
  153. package/docs/tui.md +1 -1
  154. package/docs/usage.md +2 -2
  155. package/examples/extensions/README.md +1 -0
  156. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  157. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  158. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  159. package/examples/extensions/entry-renderer.ts +41 -0
  160. package/examples/extensions/gondolin/package-lock.json +2 -2
  161. package/examples/extensions/gondolin/package.json +1 -1
  162. package/examples/extensions/preset.ts +2 -2
  163. package/examples/extensions/question.ts +1 -0
  164. package/examples/extensions/reload-runtime.ts +2 -2
  165. package/examples/extensions/sandbox/package-lock.json +2 -2
  166. package/examples/extensions/sandbox/package.json +1 -1
  167. package/examples/extensions/with-deps/package-lock.json +2 -2
  168. package/examples/extensions/with-deps/package.json +1 -1
  169. package/examples/sdk/12-full-control.ts +1 -1
  170. package/examples/sdk/README.md +1 -1
  171. package/npm-shrinkwrap.json +12 -12
  172. package/package.json +4 -4
@@ -294,6 +294,7 @@ user sends prompt ────────────────────
294
294
  │ │ │ │
295
295
  │ ├─► turn_start │ │
296
296
  │ ├─► context (can modify messages) │ │
297
+ │ ├─► before_provider_headers (can mutate headers) |
297
298
  │ ├─► before_provider_request (can inspect or replace payload)
298
299
  │ ├─► after_provider_response (status + headers, before stream consume)
299
300
  │ │ │ │
@@ -306,7 +307,8 @@ user sends prompt ────────────────────
306
307
  │ │ │ │
307
308
  │ └─► turn_end │ │
308
309
  │ │
309
- └─► agent_end │
310
+ ├─► agent_end │
311
+ └─► agent_settled (no retry/compaction/follow-up left) │
310
312
  │
311
313
  user sends another prompt ◄────────────────────────────────┘
312
314
 
@@ -545,15 +547,19 @@ The `systemPromptOptions` field gives extensions access to the same structured d
545
547
 
546
548
  Inside `before_agent_start`, `event.systemPrompt` and `ctx.getSystemPrompt()` both reflect the chained system prompt as of the current handler. Later `before_agent_start` handlers can still modify it again.
547
549
 
548
- #### agent_start / agent_end
550
+ #### agent_start / agent_end / agent_settled
549
551
 
550
- Fired once per user prompt.
552
+ `agent_start` fires when a low-level agent run begins. `agent_end` fires when that run ends, but Pi may still auto-retry, auto-compact and retry, or continue with queued follow-up messages. Use `agent_settled` for status integrations that need to know Pi will not continue running automatically.
551
553
 
552
554
  ```typescript
553
555
  pi.on("agent_start", async (_event, ctx) => {});
554
556
 
555
557
  pi.on("agent_end", async (event, ctx) => {
556
- // event.messages - messages from this prompt
558
+ // event.messages - messages from this low-level run
559
+ });
560
+
561
+ pi.on("agent_settled", async (_event, ctx) => {
562
+ // ctx.isIdle() is true here unless another extension started a new run.
557
563
  });
558
564
  ```
559
565
 
@@ -643,6 +649,24 @@ pi.on("context", async (event, ctx) => {
643
649
  });
644
650
  ```
645
651
 
652
+ #### before_provider_headers
653
+
654
+ Fired after the outgoing HTTP headers are assembled. Use it to add, override, or remove request headers.
655
+
656
+ Handlers mutate `event.headers` in place. Set a key to a string to add or override it, or to `null` to delete it.
657
+
658
+ ```typescript
659
+ pi.on("before_provider_headers", (event, ctx) => {
660
+ // Add or override — e.g. a session id for gateway tracing/attribution
661
+ event.headers["x-session-id"] = ctx.sessionManager.getSessionId();
662
+
663
+ // Drop a tracking header pi adds for this call
664
+ event.headers["X-OpenRouter-Title"] = null;
665
+ });
666
+ ```
667
+
668
+ Runs once per provider request; retries reuse the same headers rather than re-firing the hook.
669
+
646
670
  #### before_provider_request
647
671
 
648
672
  Fired after the provider-specific payload is built, right before the request is sent. Handlers run in extension load order. Returning `undefined` keeps the payload unchanged. Returning any other value replaces the payload for later handlers and for the actual request.
@@ -944,9 +968,10 @@ Read-only access to session state. See [Session Format](session-format.md) for t
944
968
  For `tool_call`, this state is synchronized through the current assistant message before handlers run. In parallel tool execution mode it is still not guaranteed to include sibling tool results from the same assistant message.
945
969
 
946
970
  ```typescript
947
- ctx.sessionManager.getEntries() // All entries
948
- ctx.sessionManager.getBranch() // Current branch
949
- ctx.sessionManager.getLeafId() // Current leaf entry ID
971
+ ctx.sessionManager.getEntries() // All entries
972
+ ctx.sessionManager.getBranch() // Current branch
973
+ ctx.sessionManager.buildContextEntries() // Active branch entries with compaction applied
974
+ ctx.sessionManager.getLeafId() // Current leaf entry ID
950
975
  ```
951
976
 
952
977
  ### ctx.modelRegistry / ctx.model
@@ -980,7 +1005,7 @@ pi.on("tool_result", async (event, ctx) => {
980
1005
 
981
1006
  ### ctx.isIdle() / ctx.abort() / ctx.hasPendingMessages()
982
1007
 
983
- Control flow helpers.
1008
+ Control flow helpers. `ctx.isIdle()` is false while Pi is processing an agent run, automatic retry, auto-compaction retry, or queued continuation.
984
1009
 
985
1010
  ### ctx.shutdown()
986
1011
 
@@ -1062,7 +1087,7 @@ This reports the current base prompt inputs. It does not include per-turn `befor
1062
1087
 
1063
1088
  ### ctx.waitForIdle()
1064
1089
 
1065
- Wait for the agent to finish streaming:
1090
+ Wait for the agent to fully settle, including automatic retries, auto-compaction retries, and queued continuations:
1066
1091
 
1067
1092
  ```typescript
1068
1093
  pi.registerCommand("my-cmd", {
@@ -1243,7 +1268,7 @@ Run the same reload flow as `/reload`.
1243
1268
 
1244
1269
  ```typescript
1245
1270
  pi.registerCommand("reload-runtime", {
1246
- description: "Reload extensions, skills, prompts, and themes",
1271
+ description: "Reload extensions, skills, prompts, themes, and context files",
1247
1272
  handler: async (_args, ctx) => {
1248
1273
  await ctx.reload();
1249
1274
  return;
@@ -1271,7 +1296,7 @@ import { Type } from "typebox";
1271
1296
 
1272
1297
  export default function (pi: ExtensionAPI) {
1273
1298
  pi.registerCommand("reload-runtime", {
1274
- description: "Reload extensions, skills, prompts, and themes",
1299
+ description: "Reload extensions, skills, prompts, themes, and context files",
1275
1300
  handler: async (_args, ctx) => {
1276
1301
  await ctx.reload();
1277
1302
  return;
@@ -1281,7 +1306,7 @@ export default function (pi: ExtensionAPI) {
1281
1306
  pi.registerTool({
1282
1307
  name: "reload_runtime",
1283
1308
  label: "Reload Runtime",
1284
- description: "Reload extensions, skills, prompts, and themes",
1309
+ description: "Reload extensions, skills, prompts, themes, and context files",
1285
1310
  parameters: Type.Object({}),
1286
1311
  async execute() {
1287
1312
  pi.sendUserMessage("/reload-runtime", { deliverAs: "followUp" });
@@ -1352,7 +1377,7 @@ pi.registerTool({
1352
1377
 
1353
1378
  ### pi.sendMessage(message, options?)
1354
1379
 
1355
- Inject a custom message into the session.
1380
+ Inject a custom message into the session. Custom messages participate in LLM context. For durable TUI-only content that should not be sent to the LLM, use [`pi.appendEntry()`](#piappendentrycustomtype-data) with [`pi.registerEntryRenderer()`](#piregisterentryrenderercustomtype-renderer).
1356
1381
 
1357
1382
  ```typescript
1358
1383
  pi.sendMessage({
@@ -1403,10 +1428,11 @@ See [send-user-message.ts](../examples/extensions/send-user-message.ts) for a co
1403
1428
 
1404
1429
  ### pi.appendEntry(customType, data?)
1405
1430
 
1406
- Persist extension state (does NOT participate in LLM context).
1431
+ Persist extension data. Custom entries do NOT participate in LLM context. In interactive mode, they can also render inside the chat transcript when paired with `pi.registerEntryRenderer()`.
1407
1432
 
1408
1433
  ```typescript
1409
1434
  pi.appendEntry("my-state", { count: 42 });
1435
+ pi.appendEntry("status-card", { title: "Indexed files", count: 17 });
1410
1436
 
1411
1437
  // Restore on reload
1412
1438
  pi.on("session_start", async (_event, ctx) => {
@@ -1524,7 +1550,27 @@ mode and would not execute if sent via `prompt`.
1524
1550
 
1525
1551
  ### pi.registerMessageRenderer(customType, renderer)
1526
1552
 
1527
- Register a custom TUI renderer for messages with your `customType`. See [Custom UI](#custom-ui).
1553
+ Register a custom TUI renderer for custom messages with your `customType`. Custom messages are created with `pi.sendMessage()` and participate in LLM context. See [Custom UI](#custom-ui).
1554
+
1555
+ ### pi.registerEntryRenderer(customType, renderer)
1556
+
1557
+ Register a custom TUI renderer for custom entries with your `customType`. Custom entries are created with `pi.appendEntry()` and do not participate in LLM context.
1558
+
1559
+ ```typescript
1560
+ import { Box, Text } from "@earendil-works/pi-tui";
1561
+
1562
+ pi.registerEntryRenderer("status-card", (entry, { expanded }, theme) => {
1563
+ const data = entry.data as { title: string; count: number };
1564
+ const box = new Box(1, 1, (text) => theme.bg("customMessageBg", text));
1565
+ box.addChild(new Text(`${theme.bold(data.title)}: ${data.count}`));
1566
+ if (expanded) {
1567
+ box.addChild(new Text(theme.fg("dim", JSON.stringify(data, null, 2))));
1568
+ }
1569
+ return box;
1570
+ });
1571
+
1572
+ pi.appendEntry("status-card", { title: "Indexed files", count: 17 });
1573
+ ```
1528
1574
 
1529
1575
  ### pi.registerShortcut(shortcut, options)
1530
1576
 
@@ -1611,7 +1657,7 @@ if (model) {
1611
1657
  Get or set the thinking level. Level is clamped to model capabilities (non-reasoning models always use "off"). Changes emit `thinking_level_select`.
1612
1658
 
1613
1659
  ```typescript
1614
- const current = pi.getThinkingLevel(); // "off" | "minimal" | "low" | "medium" | "high" | "xhigh"
1660
+ const current = pi.getThinkingLevel(); // "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"
1615
1661
  pi.setThinkingLevel("high");
1616
1662
  ```
1617
1663
 
@@ -2528,9 +2574,9 @@ ctx.ui.setEditorComponent((tui, theme, keybindings) =>
2528
2574
 
2529
2575
  See [tui.md](tui.md) Pattern 7 for a complete example with mode indicator.
2530
2576
 
2531
- ### Message Rendering
2577
+ ### Message and Entry Rendering
2532
2578
 
2533
- Register a custom renderer for messages with your `customType`:
2579
+ Register a custom renderer for messages with your `customType`. Use message renderers for content that should participate in LLM context:
2534
2580
 
2535
2581
  ```typescript
2536
2582
  import { Text } from "@earendil-works/pi-tui";
@@ -2559,6 +2605,16 @@ pi.sendMessage({
2559
2605
  });
2560
2606
  ```
2561
2607
 
2608
+ For TUI-only content that should not be sent to the LLM, render custom entries instead:
2609
+
2610
+ ```typescript
2611
+ pi.registerEntryRenderer("my-card", (entry, options, theme) => {
2612
+ return new Text(theme.fg("accent", JSON.stringify(entry.data)));
2613
+ });
2614
+
2615
+ pi.appendEntry("my-card", { status: "done" });
2616
+ ```
2617
+
2562
2618
  ### Theme Colors
2563
2619
 
2564
2620
  All render functions receive a `theme` object. See [themes.md](themes.md) for creating custom themes and the full color palette.
@@ -2685,6 +2741,7 @@ All examples in [examples/extensions/](../examples/extensions/).
2685
2741
  | `custom-provider-gitlab-duo/` | GitLab Duo integration | `registerProvider` with OAuth |
2686
2742
  | **Messages & Communication** |||
2687
2743
  | `message-renderer.ts` | Custom message rendering | `registerMessageRenderer`, `sendMessage` |
2744
+ | `entry-renderer.ts` | TUI-only custom entry rendering | `registerEntryRenderer`, `appendEntry` |
2688
2745
  | `event-bus.ts` | Inter-extension events | `pi.events` |
2689
2746
  | **Session Metadata** |||
2690
2747
  | `session-name.ts` | Name sessions for selector | `setSessionName`, `getSessionName` |
package/docs/models.md CHANGED
@@ -139,7 +139,7 @@ Set `api` at provider level (default for all models) or model level (override pe
139
139
  | `headers` | Custom headers (see value resolution below) |
140
140
  | `authHeader` | Set `true` to add `Authorization: Bearer <apiKey>` automatically |
141
141
  | `models` | Array of model configurations |
142
- | `modelOverrides` | Per-model overrides for built-in models on this provider |
142
+ | `modelOverrides` | Per-model overrides for built-in or extension-registered models on this provider |
143
143
 
144
144
  For providers with `models`, non-built-in provider configs need `baseUrl` and an `api` value at either provider or model level. `apiKey` is not required to load the file: models become available when auth is configured through `/login`/`auth.json`, CLI `--api-key`, or provider `apiKey`. If no auth is configured, the models load but stay unavailable in `/model` and `--list-models`.
145
145
 
@@ -205,22 +205,44 @@ If your command is slow, expensive, rate-limited, or should keep using a previou
205
205
  | `input` | No | `["text"]` | Input types: `["text"]` or `["text", "image"]` |
206
206
  | `contextWindow` | No | `128000` | Context window size in tokens |
207
207
  | `maxTokens` | No | `16384` | Maximum output tokens |
208
- | `cost` | No | all zeros | `{"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0}` (per million tokens) |
208
+ | `cost` | No | all zeros | Per-million-token rates with optional request-wide input pricing tiers |
209
209
  | `compat` | No | provider `compat` | Provider compatibility overrides. Merged with provider-level `compat` when both are set. |
210
210
 
211
+ A cost tier supplies a complete alternate rate set and applies to the full request when total input usage (`input + cacheRead + cacheWrite`) exceeds `inputTokensAbove`. When multiple tiers match, the highest threshold wins.
212
+
213
+ ```json
214
+ {
215
+ "cost": {
216
+ "input": 5,
217
+ "output": 30,
218
+ "cacheRead": 0.5,
219
+ "cacheWrite": 6.25,
220
+ "tiers": [
221
+ {
222
+ "inputTokensAbove": 272000,
223
+ "input": 10,
224
+ "output": 45,
225
+ "cacheRead": 1,
226
+ "cacheWrite": 12.5
227
+ }
228
+ ]
229
+ }
230
+ }
231
+ ```
232
+
211
233
  Current behavior:
212
234
  - `/model`, `--list-models`, and the interactive footer display entries by model `id`.
213
235
  - The configured `name` is used for model matching and secondary model detail text. It does not replace the footer/status-bar model id.
214
236
 
215
237
  ### Thinking Level Map
216
238
 
217
- Use `thinkingLevelMap` on a model to describe model-specific thinking controls. Keys are pi thinking levels: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`.
239
+ Use `thinkingLevelMap` on a model to describe model-specific thinking controls. Keys are pi thinking levels: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. Maps may contain holes; for example, a model can expose `high` and `max` without exposing `xhigh`.
218
240
 
219
241
  Values are tristate:
220
242
 
221
243
  | Value | Meaning |
222
244
  |-------|---------|
223
- | omitted | Level is supported and uses the provider's default mapping |
245
+ | omitted | Standard levels through `high` use the provider's default mapping; extended `xhigh` and `max` levels are unsupported |
224
246
  | string | Level is supported and this value is sent to the provider |
225
247
  | `null` | Level is unsupported and hidden/skipped/clamped away |
226
248
 
@@ -235,7 +257,8 @@ Example for a model that only supports off, high, and max reasoning:
235
257
  "low": null,
236
258
  "medium": null,
237
259
  "high": "high",
238
- "xhigh": "max"
260
+ "xhigh": null,
261
+ "max": "max"
239
262
  }
240
263
  }
241
264
  ```
@@ -293,7 +316,7 @@ Merge semantics:
293
316
 
294
317
  ## Per-model Overrides
295
318
 
296
- Use `modelOverrides` to customize specific built-in models without replacing the provider's full model list.
319
+ Use `modelOverrides` to customize built-in models and matching extension-registered models without replacing the provider's full model list.
297
320
 
298
321
  ```json
299
322
  {
@@ -314,10 +337,28 @@ Use `modelOverrides` to customize specific built-in models without replacing the
314
337
  }
315
338
  ```
316
339
 
317
- `modelOverrides` supports these fields per model: `name`, `reasoning`, `input`, `cost` (partial), `contextWindow`, `maxTokens`, `headers`, `compat`.
340
+ `modelOverrides` supports these fields per model: `name`, `reasoning`, `thinkingLevelMap`, `input`, `cost` (partial), `contextWindow`, `maxTokens`, `headers`, `compat`.
341
+
342
+ Direct OpenAI GPT-5.6 Sol, Terra, and Luna default to a `272000` context window so requests remain within OpenAI's short-context pricing tier. To opt into OpenAI's 1.05M context window, increase it for each model you use:
343
+
344
+ ```json
345
+ {
346
+ "providers": {
347
+ "openai": {
348
+ "modelOverrides": {
349
+ "gpt-5.6-sol": {
350
+ "contextWindow": 1050000
351
+ }
352
+ }
353
+ }
354
+ }
355
+ }
356
+ ```
357
+
358
+ The override preserves the built-in pricing metadata. Requests with more than 272K total input tokens use GPT-5.6's long-context rates for the entire request. Apply the same override to `gpt-5.6-terra` or `gpt-5.6-luna` when needed.
318
359
 
319
360
  Behavior notes:
320
- - `modelOverrides` are applied to built-in provider models.
361
+ - `modelOverrides` are applied to built-in provider models and matching extension-registered provider models.
321
362
  - Unknown model IDs are ignored.
322
363
  - You can combine provider-level `baseUrl`/`headers` with `modelOverrides`.
323
364
  - Overriding `name` changes model matching and secondary detail text only; the footer and primary model lists continue to show the model `id`.
package/docs/packages.md CHANGED
@@ -216,11 +216,11 @@ Filter what a package loads using the object form in settings:
216
216
 
217
217
  ## Enable and Disable Resources
218
218
 
219
- Use `pi config` to enable or disable extensions, skills, prompt templates, and themes from installed packages and local directories. Works for both global (`~/.pi/agent`) and project (`.pi/`) scopes.
219
+ Use `pi config` to enable or disable extensions, skills, prompt templates, and themes from installed packages and local directories. `pi config` starts in global settings (`~/.pi/agent/settings.json`); press Tab to switch between global and project-local modes. Use `pi config -l` to start in project overrides (`.pi/settings.json`) with inherited global resources dimmed.
220
220
 
221
221
  ## Scope and Deduplication
222
222
 
223
- Packages can appear in both global and project settings. If the same package appears in both, the project entry wins. Identity is determined by:
223
+ Packages can appear in both global and project settings. If the same package appears in both, the project entry wins unless the project entry has `autoload: false`, in which case it is applied as a delta over the global entry. Identity is determined by:
224
224
 
225
225
  - npm: package name
226
226
  - git: repository URL without ref
package/docs/rpc.md CHANGED
@@ -286,9 +286,9 @@ Set the reasoning/thinking level for models that support it.
286
286
  {"type": "set_thinking_level", "level": "high"}
287
287
  ```
288
288
 
289
- Levels: `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`
289
+ Levels: `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`, `"max"`
290
290
 
291
- Note: `"xhigh"` is only supported by OpenAI codex-max models.
291
+ `"xhigh"` and `"max"` are exposed only when supported by the selected model. Some models, including GPT-5.6, expose both.
292
292
 
293
293
  Response:
294
294
  ```json
@@ -808,7 +808,8 @@ Events are streamed to stdout as JSON lines during agent operation. Events do NO
808
808
  | Event | Description |
809
809
  |-------|-------------|
810
810
  | `agent_start` | Agent begins processing |
811
- | `agent_end` | Agent completes (includes all generated messages) |
811
+ | `agent_end` | One low-level agent run completes (may still be followed by retry, compaction, or queued continuations) |
812
+ | `agent_settled` | Agent run is fully settled; no automatic retry, compaction retry, or queued continuation remains |
812
813
  | `turn_start` | New turn begins |
813
814
  | `turn_end` | Turn completes (includes assistant message and tool results) |
814
815
  | `message_start` | Message begins |
@@ -834,15 +835,24 @@ Emitted when the agent begins processing a prompt.
834
835
 
835
836
  ### agent_end
836
837
 
837
- Emitted when the agent completes. Contains all messages generated during this run.
838
+ Emitted when one low-level agent run completes. Contains all messages generated during this run. If `willRetry` is true, an automatic retry will follow.
838
839
 
839
840
  ```json
840
841
  {
841
842
  "type": "agent_end",
842
- "messages": [...]
843
+ "messages": [...],
844
+ "willRetry": false
843
845
  }
844
846
  ```
845
847
 
848
+ ### agent_settled
849
+
850
+ Emitted after the full session-level run settles. At this point Pi will not continue automatically through retry, compaction retry, or queued follow-up messages.
851
+
852
+ ```json
853
+ {"type": "agent_settled"}
854
+ ```
855
+
846
856
  ### turn_start / turn_end
847
857
 
848
858
  A turn consists of one assistant response plus any resulting tool calls and results.
package/docs/sdk.md CHANGED
@@ -387,7 +387,7 @@ const available = await modelRegistry.getAvailable();
387
387
 
388
388
  const { session } = await createAgentSession({
389
389
  model: opus,
390
- thinkingLevel: "medium", // off, minimal, low, medium, high, xhigh
390
+ thinkingLevel: "medium", // off, minimal, low, medium, high, xhigh, max
391
391
 
392
392
  // Models for cycling (Ctrl+P in interactive mode)
393
393
  scopedModels: [
@@ -405,6 +405,32 @@ If no model is provided:
405
405
  2. Uses default from settings
406
406
  3. Falls back to first available model
407
407
 
408
+ To match CLI model parsing, use the exported resolver helpers:
409
+
410
+ ```typescript
411
+ import {
412
+ resolveCliModel,
413
+ resolveModelScopeWithDiagnostics,
414
+ } from "@earendil-works/pi-coding-agent";
415
+
416
+ const cliModel = resolveCliModel({
417
+ cliModel: "anthropic/claude-opus-4-5:high",
418
+ modelRegistry,
419
+ });
420
+ if (cliModel.error) throw new Error(cliModel.error);
421
+ if (cliModel.warning) console.warn(cliModel.warning);
422
+
423
+ const { scopedModels, diagnostics } = await resolveModelScopeWithDiagnostics(
424
+ ["anthropic/*:high", "gpt-5"],
425
+ modelRegistry,
426
+ );
427
+ for (const diagnostic of diagnostics) {
428
+ console.warn(diagnostic.message);
429
+ }
430
+ ```
431
+
432
+ `resolveCliModel()` uses all registered models so `--api-key` style first-time setup can resolve a model before stored auth exists. `resolveModelScopeWithDiagnostics()` matches `--models` and `enabledModels` semantics while returning warnings instead of printing them.
433
+
408
434
  > See [examples/sdk/02-custom-model.ts](../examples/sdk/02-custom-model.ts)
409
435
 
410
436
  ### API Keys and OAuth
@@ -578,6 +604,27 @@ const { session } = await createAgentSession({ resourceLoader: loader });
578
604
 
579
605
  Extensions can register tools, subscribe to events, add commands, and more. See [extensions.md](extensions.md) for the full API.
580
606
 
607
+ **Named inline extensions:** By default, inline factories display as `<inline:1>`, `<inline:2>`, etc. in the startup Extensions list. To show a descriptive name instead, wrap the factory:
608
+
609
+ ```typescript
610
+ import type { InlineExtension } from "@earendil-works/pi-coding-agent";
611
+
612
+ const myProvider: InlineExtension = {
613
+ name: "my-provider",
614
+ factory: (pi) => {
615
+ pi.on("agent_start", () => {
616
+ console.log("[my-provider] Agent starting");
617
+ });
618
+ },
619
+ };
620
+
621
+ const loader = new DefaultResourceLoader({
622
+ extensionFactories: [myProvider],
623
+ });
624
+ ```
625
+
626
+ This displays as `<inline:my-provider>` instead of `<inline:1>`. Bare factory functions are still accepted for backward compatibility.
627
+
581
628
  **Event Bus:** Extensions can communicate via `pi.events`. Pass a shared `eventBus` to `DefaultResourceLoader` if you need to emit or listen from outside:
582
629
 
583
630
  ```typescript
@@ -1104,6 +1151,8 @@ AgentSessionRuntime
1104
1151
  // Auth and Models
1105
1152
  AuthStorage
1106
1153
  ModelRegistry
1154
+ resolveCliModel
1155
+ resolveModelScopeWithDiagnostics
1107
1156
 
1108
1157
  // Resource loading
1109
1158
  DefaultResourceLoader
@@ -1133,6 +1182,7 @@ createGrepTool, createFindTool, createLsTool
1133
1182
  type CreateAgentSessionOptions
1134
1183
  type CreateAgentSessionResult
1135
1184
  type ExtensionFactory
1185
+ type InlineExtension
1136
1186
  type ExtensionAPI
1137
1187
  type ToolDefinition
1138
1188
  type Skill
@@ -255,7 +255,7 @@ Extension state persistence. Does NOT participate in LLM context.
255
255
  {"type":"custom","id":"h8i9j0k1","parentId":"g7h8i9j0","timestamp":"2024-12-03T14:20:00.000Z","customType":"my-extension","data":{"count":42}}
256
256
  ```
257
257
 
258
- Use `customType` to identify your extension's entries on reload.
258
+ Use `customType` to identify your extension's entries on reload. Interactive mode can render custom entries via `pi.registerEntryRenderer(customType, renderer)`, but they still do not participate in LLM context.
259
259
 
260
260
  ### CustomMessageEntry
261
261
 
@@ -306,15 +306,24 @@ Entries form a tree:
306
306
 
307
307
  ## Context Building
308
308
 
309
- `buildSessionContext()` walks from the current leaf to the root, producing the message list for the LLM:
309
+ `buildContextEntries()` walks from the current leaf to the root, producing the active entry list while honoring compaction:
310
310
 
311
311
  1. Collects all entries on the path
312
- 2. Extracts current model and thinking level settings
313
- 3. If a `CompactionEntry` is on the path:
314
- - Emits the summary first
315
- - Then messages from `firstKeptEntryId` to compaction
316
- - Then messages after compaction
317
- 4. Converts `BranchSummaryEntry` and `CustomMessageEntry` to appropriate message formats
312
+ 2. If a `CompactionEntry` is on the path:
313
+ - Includes the compaction entry first
314
+ - Then entries from `firstKeptEntryId` to compaction
315
+ - Then entries after compaction
316
+ 3. Preserves non-message entries in the selected range so interactive mode can render them
317
+
318
+ `buildSessionContext()` builds on that entry list to produce the message list for the LLM:
319
+
320
+ 1. Extracts current model and thinking level settings from the full path
321
+ 2. Converts selected entries to messages:
322
+ - `message` -> stored `AgentMessage`
323
+ - `compaction` -> `compactionSummary`
324
+ - `branch_summary` -> `branchSummary`
325
+ - `custom_message` -> `CustomMessage`
326
+ - `custom` -> no context message
318
327
 
319
328
  ## Parsing Example
320
329
 
@@ -401,6 +410,7 @@ Key methods for working with sessions programmatically.
401
410
  - `branchWithSummary(entryId, summary, details?, fromHook?)` - Branch with context summary
402
411
 
403
412
  ### Instance Methods - Context & Info
413
+ - `buildContextEntries()` - Get active branch entries with compaction applied
404
414
  - `buildSessionContext()` - Get messages, thinkingLevel, and model for LLM
405
415
  - `getEntries()` - All entries (excluding header)
406
416
  - `getHeader()` - Session header metadata
package/docs/settings.md CHANGED
@@ -29,8 +29,9 @@ Use `/trust` in interactive mode to save a project trust decision for future ses
29
29
  |---------|------|---------|-------------|
30
30
  | `defaultProvider` | string | - | Default provider (e.g., `"anthropic"`, `"openai"`) |
31
31
  | `defaultModel` | string | - | Default model ID |
32
- | `defaultThinkingLevel` | string | - | `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"` |
32
+ | `defaultThinkingLevel` | string | - | `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`, `"max"` |
33
33
  | `hideThinkingBlock` | boolean | `false` | Hide thinking blocks in output |
34
+ | `showCacheMissNotices` | boolean | `false` | Show transcript notices for significant prompt-cache misses |
34
35
  | `thinkingBudgets` | object | - | Custom token budgets per thinking level |
35
36
 
36
37
  #### thinkingBudgets
@@ -184,7 +185,7 @@ Keep `retry.provider.maxRetries` at `0` unless provider-level retries are explic
184
185
 
185
186
  | Setting | Type | Default | Description |
186
187
  |---------|------|---------|-------------|
187
- | `shellPath` | string | - | Custom shell path (e.g., for Cygwin on Windows) |
188
+ | `shellPath` | string | - | Custom shell path (e.g., for Cygwin on Windows); supports a leading `~` for the home directory |
188
189
  | `shellCommandPrefix` | string | - | Prefix for every bash command (e.g., `"shopt -s expand_aliases"`) |
189
190
  | `npmCommand` | string[] | - | Command argv used for npm package lookup/install operations (e.g., `["mise", "exec", "node@20", "--", "npm"]`) |
190
191
 
package/docs/themes.md CHANGED
@@ -109,6 +109,7 @@ vim ~/.pi/agent/themes/my-theme.json
109
109
  "thinkingMedium": "#00ffff",
110
110
  "thinkingHigh": "#ff00ff",
111
111
  "thinkingXhigh": "#ff0000",
112
+ "thinkingMax": "#ff0088",
112
113
  "bashMode": "#ffaa00"
113
114
  }
114
115
  }
@@ -139,13 +140,13 @@ vim ~/.pi/agent/themes/my-theme.json
139
140
 
140
141
  - `name` is required, must be unique, and must not contain `/`.
141
142
  - `vars` is optional. Define reusable colors here, then reference them in `colors`.
142
- - `colors` must define all 51 required tokens.
143
+ - `colors` must define all 51 required tokens. `thinkingMax` is optional and falls back to `thinkingXhigh`.
143
144
 
144
145
  The `$schema` field enables editor auto-completion and validation.
145
146
 
146
147
  ## Color Tokens
147
148
 
148
- Every theme must define all 51 color tokens. There are no optional colors.
149
+ Every theme must define all 51 required color tokens. `thinkingMax` is optional for compatibility with existing themes; when omitted, it uses `thinkingXhigh`.
149
150
 
150
151
  ### Core UI (11 colors)
151
152
 
@@ -216,7 +217,7 @@ Every theme must define all 51 color tokens. There are no optional colors.
216
217
  | `syntaxOperator` | Operators |
217
218
  | `syntaxPunctuation` | Punctuation |
218
219
 
219
- ### Thinking Level Borders (6 colors)
220
+ ### Thinking Level Borders (6 required, 1 optional)
220
221
 
221
222
  Editor border colors indicating thinking level (visual hierarchy from subtle to prominent):
222
223
 
@@ -228,6 +229,7 @@ Editor border colors indicating thinking level (visual hierarchy from subtle to
228
229
  | `thinkingMedium` | Medium thinking |
229
230
  | `thinkingHigh` | High thinking |
230
231
  | `thinkingXhigh` | Extra high thinking |
232
+ | `thinkingMax` | Maximum thinking; optional, falls back to `thinkingXhigh` |
231
233
 
232
234
  ### Bash Mode (1 color)
233
235
 
package/docs/tui.md CHANGED
@@ -424,7 +424,7 @@ renderResult(result, options, theme, context) {
424
424
  | Diffs | `toolDiffAdded`, `toolDiffRemoved`, `toolDiffContext` |
425
425
  | Markdown | `mdHeading`, `mdLink`, `mdLinkUrl`, `mdCode`, `mdCodeBlock`, `mdCodeBlockBorder`, `mdQuote`, `mdQuoteBorder`, `mdHr`, `mdListBullet` |
426
426
  | Syntax | `syntaxComment`, `syntaxKeyword`, `syntaxFunction`, `syntaxVariable`, `syntaxString`, `syntaxNumber`, `syntaxType`, `syntaxOperator`, `syntaxPunctuation` |
427
- | Thinking | `thinkingOff`, `thinkingMinimal`, `thinkingLow`, `thinkingMedium`, `thinkingHigh`, `thinkingXhigh` |
427
+ | Thinking | `thinkingOff`, `thinkingMinimal`, `thinkingLow`, `thinkingMedium`, `thinkingHigh`, `thinkingXhigh`, `thinkingMax` |
428
428
  | Modes | `bashMode` |
429
429
 
430
430
  **Background colors** (`theme.bg(color, text)`):
package/docs/usage.md CHANGED
@@ -52,7 +52,7 @@ Type `/` in the editor to open command completion. Extensions can register custo
52
52
  | `/export [file]` | Export session to HTML or JSONL |
53
53
  | `/import <file>` | Import and resume a session from a JSONL file |
54
54
  | `/share` | Upload as private GitHub gist with shareable HTML link |
55
- | `/reload` | Reload keybindings, extensions, skills, prompts, and context files |
55
+ | `/reload` | Reload keybindings, extensions, skills, prompts, themes, and context files |
56
56
  | `/hotkeys` | Show all keyboard shortcuts |
57
57
  | `/changelog` | Display version history |
58
58
  | `/quit` | Quit pi |
@@ -183,7 +183,7 @@ cat README.md | pi -p "Summarize this text"
183
183
  | `--provider <name>` | Provider, such as `anthropic`, `openai`, or `google` |
184
184
  | `--model <pattern>` | Model pattern or ID; supports `provider/id` and optional `:<thinking>` |
185
185
  | `--api-key <key>` | API key, overriding environment variables |
186
- | `--thinking <level>` | `off`, `minimal`, `low`, `medium`, `high`, `xhigh` |
186
+ | `--thinking <level>` | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max` |
187
187
  | `--models <patterns>` | Comma-separated patterns for Ctrl+P cycling |
188
188
  | `--list-models [search]` | List available models |
189
189
 
@@ -112,6 +112,7 @@ cp permission-gate.ts ~/.pi/agent/extensions/
112
112
  | Extension | Description |
113
113
  |-----------|-------------|
114
114
  | `message-renderer.ts` | Custom message rendering with colors and expandable details via `registerMessageRenderer` |
115
+ | `entry-renderer.ts` | TUI-only session entry rendering via `appendEntry` and `registerEntryRenderer` |
115
116
  | `event-bus.ts` | Inter-extension communication via `pi.events` |
116
117
 
117
118
  ### Session Metadata
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider",
3
- "version": "0.80.3",
3
+ "version": "0.80.6",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-custom-provider",
9
- "version": "0.80.3",
9
+ "version": "0.80.6",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.52.0"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-anthropic",
3
3
  "private": true,
4
- "version": "0.80.3",
4
+ "version": "0.80.6",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-gitlab-duo",
3
3
  "private": true,
4
- "version": "0.80.3",
4
+ "version": "0.80.6",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",