@selesai/code 0.13.26 → 0.13.28

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 (125) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/dist/cli/args.js +1 -0
  3. package/dist/cli/session-picker.d.ts +1 -1
  4. package/dist/config.d.ts +9 -0
  5. package/dist/config.js +47 -1
  6. package/dist/core/agent-session-auto-handoff.test.js +2 -1
  7. package/dist/core/agent-session-length-continuation.test.js +2 -1
  8. package/dist/core/agent-session.d.ts +58 -7
  9. package/dist/core/agent-session.js +334 -167
  10. package/dist/core/bug-report-upload.d.ts +11 -0
  11. package/dist/core/bug-report-upload.js +21 -0
  12. package/dist/core/bug-report.d.ts +175 -0
  13. package/dist/core/bug-report.js +291 -0
  14. package/dist/core/cache-stats.js +12 -1
  15. package/dist/core/cache-warmer.d.ts +101 -0
  16. package/dist/core/cache-warmer.js +341 -0
  17. package/dist/core/compaction/branch-summarization.js +2 -2
  18. package/dist/core/compaction/compaction.d.ts +6 -5
  19. package/dist/core/compaction/compaction.js +49 -42
  20. package/dist/core/crash-log.d.ts +21 -0
  21. package/dist/core/crash-log.js +70 -0
  22. package/dist/core/experimental.d.ts +0 -4
  23. package/dist/core/experimental.js +0 -4
  24. package/dist/core/extensions/index.d.ts +1 -1
  25. package/dist/core/extensions/jiti-loader.d.ts +1 -0
  26. package/dist/core/extensions/jiti-loader.js +3 -0
  27. package/dist/core/extensions/jiti-static-loader.d.ts +1 -0
  28. package/dist/core/extensions/jiti-static-loader.js +3 -0
  29. package/dist/core/extensions/loader.js +39 -49
  30. package/dist/core/extensions/runner.d.ts +10 -7
  31. package/dist/core/extensions/runner.js +85 -67
  32. package/dist/core/extensions/types.d.ts +66 -52
  33. package/dist/core/extensions/virtual-modules.d.ts +2 -0
  34. package/dist/core/extensions/virtual-modules.js +39 -0
  35. package/dist/core/extensions/wrapper.js +1 -20
  36. package/dist/core/index.d.ts +2 -1
  37. package/dist/core/keybindings.d.ts +1 -1
  38. package/dist/core/keybindings.js +1 -1
  39. package/dist/core/messages.js +1 -0
  40. package/dist/core/model-config.d.ts +101 -20
  41. package/dist/core/model-config.js +25 -18
  42. package/dist/core/model-resolver.js +2 -1
  43. package/dist/core/model-runtime.js +5 -3
  44. package/dist/core/provider-composer.d.ts +7 -2
  45. package/dist/core/provider-composer.js +10 -5
  46. package/dist/core/radius.d.ts +3 -0
  47. package/dist/core/radius.js +6 -0
  48. package/dist/core/sdk.js +60 -38
  49. package/dist/core/session-export.d.ts +6 -2
  50. package/dist/core/session-export.js +14 -13
  51. package/dist/core/session-format.test.d.ts +1 -0
  52. package/dist/core/session-format.test.js +96 -0
  53. package/dist/core/session-manager.d.ts +29 -6
  54. package/dist/core/session-manager.js +159 -96
  55. package/dist/core/settings-manager.d.ts +22 -5
  56. package/dist/core/settings-manager.js +56 -23
  57. package/dist/core/slash-commands.js +1 -0
  58. package/dist/core/system-prompt.d.ts +49 -4
  59. package/dist/core/system-prompt.js +155 -102
  60. package/dist/core/system-prompt.test.js +61 -23
  61. package/dist/core/tools/bash.d.ts +2 -1
  62. package/dist/core/tools/bash.js +10 -4
  63. package/dist/core/tools/edit.js +1 -2
  64. package/dist/core/tools/read.js +1 -2
  65. package/dist/core/tools/renderers/bash.js +9 -1
  66. package/dist/core/tools/write.js +1 -2
  67. package/dist/core/usage-totals.d.ts +1 -1
  68. package/dist/core/usage-totals.js +5 -1
  69. package/dist/defaults/settings.json +16 -0
  70. package/dist/extensions/auto-model.test.ts +438 -0
  71. package/dist/extensions/auto-model.ts +357 -0
  72. package/dist/extensions/package.json +1 -0
  73. package/dist/extensions/pi-web-agent/src/backends/factory.ts +14 -6
  74. package/dist/extensions/pi-web-agent/src/extension.ts +3 -1
  75. package/dist/extensions/pi-web-agent/src/orchestration/answer-synthesizer.ts +7 -3
  76. package/dist/extensions/pi-web-agent/src/orchestration/research-orchestrator.ts +3 -0
  77. package/dist/extensions/pi-web-agent/src/orchestration/research-types.ts +2 -0
  78. package/dist/extensions/pi-web-agent/src/presentation/explore-presentation.ts +4 -2
  79. package/dist/extensions/pi-web-agent/src/search/tokenin.ts +4 -1
  80. package/dist/extensions/pi-web-agent/src/tools/web-explore.ts +2 -1
  81. package/dist/extensions/pi-web-agent/src/types.ts +4 -0
  82. package/dist/index.d.ts +3 -2
  83. package/dist/main.js +13 -9
  84. package/dist/migrations.js +2 -2
  85. package/dist/modes/interactive/bug-report.d.ts +15 -0
  86. package/dist/modes/interactive/bug-report.js +205 -0
  87. package/dist/modes/interactive/chat-viewport.js +1 -1
  88. package/dist/modes/interactive/components/branch-summary-message.js +12 -5
  89. package/dist/modes/interactive/components/compaction-summary-message.js +12 -5
  90. package/dist/modes/interactive/components/custom-editor.d.ts +3 -3
  91. package/dist/modes/interactive/components/extension-editor.d.ts +4 -1
  92. package/dist/modes/interactive/components/extension-editor.js +7 -2
  93. package/dist/modes/interactive/components/extension-input.d.ts +2 -0
  94. package/dist/modes/interactive/components/extension-input.js +6 -0
  95. package/dist/modes/interactive/components/extension-selector.d.ts +1 -0
  96. package/dist/modes/interactive/components/extension-selector.js +4 -0
  97. package/dist/modes/interactive/components/footer.js +4 -1
  98. package/dist/modes/interactive/components/session-selector.d.ts +5 -5
  99. package/dist/modes/interactive/components/session-selector.js +74 -48
  100. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  101. package/dist/modes/interactive/components/settings-selector.js +11 -0
  102. package/dist/modes/interactive/components/skill-invocation-message.js +11 -4
  103. package/dist/modes/interactive/components/status-indicator.d.ts +2 -2
  104. package/dist/modes/interactive/components/status-indicator.js +7 -7
  105. package/dist/modes/interactive/components/tool-execution.js +18 -9
  106. package/dist/modes/interactive/components/tree-selector.js +2 -0
  107. package/dist/modes/interactive/interactive-mode.d.ts +15 -2
  108. package/dist/modes/interactive/interactive-mode.js +257 -81
  109. package/dist/modes/interactive/session-share.d.ts +2 -0
  110. package/dist/modes/interactive/session-share.js +8 -4
  111. package/dist/modes/interactive/tui-renderer.js +2 -2
  112. package/dist/modes/rpc/rpc-mode.js +2 -2
  113. package/dist/utils/clipboard-command.d.ts +6 -0
  114. package/dist/utils/clipboard-command.js +44 -0
  115. package/dist/utils/clipboard-image.js +55 -89
  116. package/dist/utils/clipboard.d.ts +1 -1
  117. package/dist/utils/clipboard.js +118 -108
  118. package/dist/utils/wsl.d.ts +2 -0
  119. package/dist/utils/wsl.js +14 -0
  120. package/dist/utils/zip.d.ts +6 -0
  121. package/dist/utils/zip.js +59 -0
  122. package/docs/settings.md +43 -0
  123. package/package.json +9 -9
  124. package/dist/utils/clipboard-native.d.ts +0 -10
  125. package/dist/utils/clipboard-native.js +0 -19
package/CHANGELOG.md CHANGED
@@ -2,6 +2,109 @@
2
2
 
3
3
  All notable changes to `@selesai/code` will be documented in this file.
4
4
 
5
+ ## [0.13.28] - 2026-09-22
6
+
7
+ ### Automatic model routing
8
+
9
+ A new bundled `auto-model` extension routes each idle, top-level prompt to one of four configured
10
+ tiers — `simple`, `medium`, `complex`, and `reasoning` — by asking the Jev decisions model
11
+ (`jev-1.13`) through the Token-In gateway which tier fits the request.
12
+
13
+ - **Four-tier routing.** `settings.json` gains an `autoModel` block: a classifier (`provider` and
14
+ `model`, default `tokenin` / `jev-1.13`) plus one model per tier. The extension builds Jev's
15
+ `{state, questions}` decisions payload from the current ask, a bounded window of prior user turns,
16
+ and the active system prompt, reads the answered tier back, and calls `pi.setModel()` on the
17
+ matching model before the turn starts. Disabled by default.
18
+ - **Tier model syntax.** Each tier value is `provider/modelId` with an optional `:thinkingLevel`
19
+ suffix (`tokenin/celestial-max:max`) applied through `pi.setThinkingLevel()`.
20
+ - **Safe scope.** Only idle, top-level prompts are routed. Queued steering/follow-up input and
21
+ extension-injected messages are skipped because `pi.setModel()` is session-global, and `/`
22
+ commands are left untouched. A manual `/model` choice suspends routing for the rest of the session.
23
+ - **Graceful failures.** A classifier timeout, error, malformed or low-confidence answer, missing or
24
+ out-of-scope model, or unavailable credentials keeps the current model or falls back to
25
+ `autoModel.fallbackTier` (default `medium`).
26
+
27
+ ### Graft
28
+
29
+ - **Deep-build model default for existing installs.** `bootstrapAgentDir` now seeds `graft.deepModel`
30
+ (`deepseek-v4.1-flash`) into an existing user `settings.json` when the key is absent. It merges
31
+ into a present `graft` object, keeps the original formatting when it inserts a new section, and
32
+ never overwrites a user-chosen model.
33
+
34
+ ## [0.13.27] - 2026-09-21
35
+
36
+ ### Upstream sync: Pi v0.86.1
37
+
38
+ Ported the coding-agent source from Pi v0.85.1 to v0.86.1 per file, and bumped
39
+ `@earendil-works/pi-ai`, `pi-agent-core` and `pi-tui` to 0.86.1. The package now declares
40
+ `engines.node >= 22.19.0`, matching upstream's floor.
41
+
42
+ **Adopted from upstream**
43
+
44
+ - **Custom-provider request contract.** Stream handlers now receive a normalized transcript:
45
+ the prompt and tool declarations live in its system messages and are read with the platform's
46
+ accessors, and handlers invoke the outgoing-payload hook before sending and the response hook
47
+ before consuming the body. Selesai's own providers never read the request context, so this
48
+ landed as a signature-and-type change at the forwarding boundary rather than a rewrite — your
49
+ `models.json` configuration and extension-registered providers are unaffected.
50
+ - **Sectioned system prompt with a transcript-backed record.** A session now records the prompt
51
+ and tool changes it ran under, so resuming a session or navigating to an earlier branch
52
+ restores the instructions and tools that were actually in effect instead of applying today's.
53
+ Your prompt cache stays warm across resume and branch navigation.
54
+ - **Whole-prompt replacement for one turn.** An extension can now replace the instruction for a
55
+ turn rather than only appending to it, so a preset or persona can take effect.
56
+ - **Per-model compaction budgets.** The reserved and kept-recent token budgets can be set per
57
+ model, so a large-context model is no longer compacted with a small model's budget.
58
+ - **Session runtime rebase.** Prompt and tool loadout are prepared as an explicit step with the
59
+ resulting state retained for the run; one shared abort controller per operation expresses
60
+ cancellation by throwing, so a cancellation arriving while compaction is still obtaining
61
+ credentials is no longer ignored; provider request settings (timeouts, retries, headers) come
62
+ from one builder and apply uniformly to a main turn, a compaction request and an extension's
63
+ model call; and the agent-level retry-backoff cap is configurable, so a transient provider
64
+ outage cannot hold you for minutes.
65
+ - **Strict JSON-schema sampling by default.** Built-in tools prefer strict sampling without you
66
+ setting an environment variable, and a tool whose schema cannot be expressed strictly can opt out.
67
+ - **Wider default tool set.** The default active set includes the search and listing tools, so a
68
+ fresh session can explore a repository without enabling tools by hand; each is still
69
+ individually disableable.
70
+ - **Extension authoring.** Event subscriptions now return an unsubscribe handle, so a reload or
71
+ session replacement cannot leave a stale handler behind; tool-call arguments and tool-result
72
+ details are restricted to JSON-compatible values so they survive session persistence; shell
73
+ hooks now fail loudly instead of silently when a handler throws or returns something malformed;
74
+ and the embedded-module map moved into its own module that branches on runtime kind (compiled
75
+ binary, TypeScript source, unbundled Node).
76
+ - **Interactive workspace.** Deferred extension-catalogue refresh, the new settings surfaces, and
77
+ the crash notice and bug report.
78
+
79
+ **Fork fixes carried in this release**
80
+
81
+ - **Clipboard failures are now surfaced.** A failed paste reports a warning instead of being
82
+ swallowed.
83
+ - **Overflow recovery no longer loses its guard.** A response that stopped at the output-token
84
+ limit no longer clears the overflow-recovery attempt flag, so recovery is not re-armed into a
85
+ loop.
86
+ - **Upstream path leak in a doc comment.** The session-manager documentation named
87
+ `~/.pi/agent/sessions`; runtime resolution was already correct, and the comment now names
88
+ `.selesai/agent/sessions`.
89
+
90
+ **Dependency removed**
91
+
92
+ - **`@mariozechner/clipboard` is gone.** The optional native clipboard dependency was retired in
93
+ favour of the clipboard helpers bundled with `@earendil-works/pi-tui`, so an install is smaller
94
+ and has one fewer native supply-chain boundary. Paste, copy-on-select and image paste are
95
+ unchanged.
96
+
97
+ **Deliberately not adopted**
98
+
99
+ - **Mermaid rendering.** Upstream's optional Mermaid path is not adopted, so no rendering
100
+ dependency or settings item was added.
101
+ - **Fork behaviour kept.** Automatic handoff, the bounded length-continuation of an
102
+ output-limit-truncated response, the vision caption relay, the compaction-failure event and the
103
+ capability gateway all still behave as before, re-planted on the new upstream shapes.
104
+
105
+ **Verification.** 53 test files / 1008 tests pass, the tree typechecks against Pi 0.86.1, the build
106
+ succeeds, and a 37-row delta inventory proves each Selesai-owned behaviour survived the port.
107
+
5
108
  ## [0.13.26] - 2026-09-18
6
109
 
7
110
  ### Added
package/dist/cli/args.js CHANGED
@@ -395,6 +395,7 @@ ${chalk.bold("Environment Variables:")}
395
395
  MOONSHOT_API_KEY - Moonshot AI API key
396
396
  OPENCODE_API_KEY - OpenCode Zen/OpenCode Go API key
397
397
  KIMI_API_KEY - Kimi For Coding API key
398
+ META_API_KEY - Meta Model API key
398
399
  CLOUDFLARE_API_KEY - Cloudflare API token (Workers AI and AI Gateway)
399
400
  CLOUDFLARE_ACCOUNT_ID - Cloudflare account id (required for both)
400
401
  CLOUDFLARE_GATEWAY_ID - Cloudflare AI Gateway slug (required for AI Gateway)
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import type { SessionInfo, SessionListProgress } from "../core/session-manager.ts";
5
5
  import type { SettingsManager } from "../core/settings-manager.ts";
6
- type SessionsLoader = (onProgress?: SessionListProgress) => Promise<SessionInfo[]>;
6
+ type SessionsLoader = (onProgress?: SessionListProgress, signal?: AbortSignal) => Promise<SessionInfo[]>;
7
7
  /** Show TUI session selector and return selected session path or null if cancelled */
8
8
  export declare function selectSession(currentSessionsLoader: SessionsLoader, allSessionsLoader: SessionsLoader, settingsManager: SettingsManager): Promise<string | null>;
9
9
  export {};
package/dist/config.d.ts CHANGED
@@ -147,6 +147,15 @@ export declare function seedDefaultConfigFile(destPath: string, bundledName: str
147
147
  * file that already configures `subagents`, is left untouched.
148
148
  */
149
149
  export declare function seedMissingSubagentSettings(destPath: string, bundledDefaultsDir?: string): boolean;
150
+ /**
151
+ * Add the bundled `graft.deepModel` default to an existing user settings file.
152
+ *
153
+ * The `graft` namespace may already exist without that leaf (graft is configured
154
+ * field-by-field), so a present `graft` object is merged rather than skipped. A
155
+ * user-provided `deepModel` is never overwritten. Returns true when the file was
156
+ * rewritten.
157
+ */
158
+ export declare function seedMissingGraftSettings(destPath: string, bundledDefaultsDir?: string): boolean;
150
159
  /**
151
160
  * Bundled extensions load directly from the installed package. Do not copy them
152
161
  * into the user's agent dir, otherwise startup discovers both copies and tool
package/dist/config.js CHANGED
@@ -281,7 +281,7 @@ export function getSelfUpdateUnavailableInstruction(packageName, npmCommand, upd
281
281
  const method = detectInstallMethod();
282
282
  const target = normalizeSelfUpdatePackageTarget(updatePackageTarget);
283
283
  if (method === "bun-binary") {
284
- return `Download from: https://github.com/earendil-works/pi-mono/releases/latest`;
284
+ return `Download from: https://github.com/earendil-works/pi/releases/latest`;
285
285
  }
286
286
  const command = getSelfUpdateCommandForMethod(method, packageName, target, npmCommand);
287
287
  if (command) {
@@ -676,6 +676,51 @@ export function seedMissingSubagentSettings(destPath, bundledDefaultsDir = getBu
676
676
  return false;
677
677
  }
678
678
  }
679
+ /**
680
+ * Add the bundled `graft.deepModel` default to an existing user settings file.
681
+ *
682
+ * The `graft` namespace may already exist without that leaf (graft is configured
683
+ * field-by-field), so a present `graft` object is merged rather than skipped. A
684
+ * user-provided `deepModel` is never overwritten. Returns true when the file was
685
+ * rewritten.
686
+ */
687
+ export function seedMissingGraftSettings(destPath, bundledDefaultsDir = getBundledDefaultsDir()) {
688
+ if (!existsSync(destPath))
689
+ return false;
690
+ try {
691
+ const raw = readFileSync(destPath, "utf-8");
692
+ const settings = JSON.parse(raw);
693
+ const defaults = JSON.parse(readFileSync(join(bundledDefaultsDir, "settings.json"), "utf-8"));
694
+ if (typeof settings !== "object" || settings === null || Array.isArray(settings))
695
+ return false;
696
+ if (typeof defaults !== "object" || defaults === null || Array.isArray(defaults))
697
+ return false;
698
+ const defaultGraft = defaults.graft;
699
+ const deepModel = typeof defaultGraft === "object" && defaultGraft !== null && !Array.isArray(defaultGraft)
700
+ ? defaultGraft.deepModel
701
+ : undefined;
702
+ if (typeof deepModel !== "string")
703
+ return false;
704
+ const graft = settings.graft;
705
+ if (graft === undefined) {
706
+ const injected = injectRootObjectKey(raw, "graft", defaultGraft);
707
+ if (injected === undefined)
708
+ return false;
709
+ writeFileSync(destPath, injected);
710
+ return true;
711
+ }
712
+ if (typeof graft !== "object" || graft === null || Array.isArray(graft))
713
+ return false;
714
+ if (Object.hasOwn(graft, "deepModel"))
715
+ return false;
716
+ graft.deepModel = deepModel;
717
+ writeFileSync(destPath, `${JSON.stringify(settings, null, 2)}\n`);
718
+ return true;
719
+ }
720
+ catch {
721
+ return false;
722
+ }
723
+ }
679
724
  /**
680
725
  * Recursively copy a bundled directory tree into the user's agent dir,
681
726
  * overwriting any existing file so the bundled copy stays authoritative.
@@ -787,6 +832,7 @@ export function bootstrapAgentDir(agentDir = getAgentDir()) {
787
832
  const settingsPath = join(agentDir, "settings.json");
788
833
  seedDefaultConfigFile(settingsPath, "settings.json");
789
834
  seedMissingSubagentSettings(settingsPath);
835
+ seedMissingGraftSettings(settingsPath);
790
836
  seedDefaultExtensions(agentDir);
791
837
  seedDefaultSkills(agentDir);
792
838
  seedDefaultThemes(agentDir);
@@ -2,6 +2,7 @@ import { describe, expect, it, vi } from "vitest";
2
2
  import { Type } from "typebox";
3
3
  import { AgentSession } from "./agent-session.js";
4
4
  import { AUTO_HANDOFF_GOAL } from "./handoff.js";
5
+ import { SessionManager } from "./session-manager.js";
5
6
  import { SettingsManager } from "./settings-manager.js";
6
7
  function createMockSession({ enabled, threshold = 128_000, tokens, mode = "tui", command, customTools, allowedToolNames, }) {
7
8
  const settings = SettingsManager.inMemory({
@@ -45,7 +46,7 @@ function createMockSession({ enabled, threshold = 128_000, tokens, mode = "tui",
45
46
  };
46
47
  const session = new AgentSession({
47
48
  agent: agent,
48
- sessionManager: { getBranch: () => [] },
49
+ sessionManager: SessionManager.inMemory(),
49
50
  settingsManager: settings,
50
51
  cwd: "/tmp",
51
52
  resourceLoader: resourceLoader,
@@ -1,5 +1,6 @@
1
1
  import { describe, expect, it, vi } from "vitest";
2
2
  import { AgentSession } from "./agent-session.js";
3
+ import { SessionManager } from "./session-manager.js";
3
4
  import { SettingsManager } from "./settings-manager.js";
4
5
  function createMockSession() {
5
6
  const settings = SettingsManager.inMemory({});
@@ -43,7 +44,7 @@ function createMockSession() {
43
44
  };
44
45
  const session = new AgentSession({
45
46
  agent: agent,
46
- sessionManager: { getBranch: () => [], appendMessage: vi.fn() },
47
+ sessionManager: SessionManager.inMemory(),
47
48
  settingsManager: settings,
48
49
  cwd: "/tmp",
49
50
  resourceLoader: resourceLoader,
@@ -15,6 +15,7 @@
15
15
  import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from "@earendil-works/pi-agent-core";
16
16
  import type { ImageContent, Model, TextContent } from "@earendil-works/pi-ai/compat";
17
17
  import { type BashResult } from "./bash-executor.ts";
18
+ import type { CacheWarmer, CacheWarmingStatus } from "./cache-warmer.ts";
18
19
  import { type CompactionResult } from "./compaction/index.ts";
19
20
  import { type ContextUsage, type ExtensionCommandContextActions, type ExtensionErrorListener, type ExtensionMode, ExtensionRunner, type ExtensionUIContext, type InputSource, type ReplacedSessionContext, type SessionStartEvent, type ShutdownHandler, type ToolDefinition, type ToolInfo } from "./extensions/index.ts";
20
21
  import type { CustomMessage } from "./messages.ts";
@@ -22,7 +23,7 @@ import type { ModelRuntime } from "./model-runtime.ts";
22
23
  import { type PromptTemplate } from "./prompt-templates.ts";
23
24
  import type { ResourceLoader } from "./resource-loader.ts";
24
25
  import type { BranchSummaryEntry, SessionEntry, SessionManager } from "./session-manager.ts";
25
- import type { SettingsManager } from "./settings-manager.ts";
26
+ import type { CacheWarmingMode, SettingsManager } from "./settings-manager.ts";
26
27
  import { type BashOperations } from "./tools/bash.ts";
27
28
  /** Parsed skill block from a user message */
28
29
  export interface ParsedSkillBlock {
@@ -131,7 +132,9 @@ export interface AgentSessionConfig {
131
132
  customTools?: ToolDefinition[];
132
133
  /** Canonical model/auth runtime used by coding-agent internals. */
133
134
  modelRuntime: ModelRuntime;
134
- /** Initial active built-in tool names. Default: [read, bash, edit, write, grep, find, ls] */
135
+ /** Keeps the prompt cache entry of the last session request warm. */
136
+ cacheWarmer?: Pick<CacheWarmer, "cancel" | "status" | "onAgentSettled" | "onModeChanged" | "onWarmed">;
137
+ /** Initial active built-in tool names. Default: [read, bash, edit, write] */
135
138
  initialActiveToolNames?: string[];
136
139
  /** Optional allowlist of tool names. When provided, only these tool names are exposed. */
137
140
  allowedToolNames?: string[];
@@ -211,6 +214,7 @@ export declare class AgentSession {
211
214
  private _unsubscribeAgent?;
212
215
  private _eventListeners;
213
216
  private _isAgentRunActive;
217
+ private _agentRunAbortRequested;
214
218
  private _idleWaitPromise;
215
219
  private _resolveIdleWait;
216
220
  /** Tracks pending steering messages for UI display. Removed when delivered. */
@@ -250,13 +254,14 @@ export declare class AgentSession {
250
254
  private _extensionErrorListener?;
251
255
  private _extensionErrorUnsubscriber?;
252
256
  private _modelRuntime;
257
+ private _cacheWarmer?;
253
258
  private _toolRegistry;
254
259
  private _toolDefinitions;
255
260
  private _toolPromptSnippets;
256
261
  private _toolPromptGuidelines;
257
- private _baseSystemPrompt;
258
262
  private _baseSystemPromptOptions;
259
- private _systemPromptOverride?;
263
+ /** Prompt options after before_agent_start mutations for the active run. */
264
+ private _runSystemPromptOptions?;
260
265
  constructor(config: AgentSessionConfig);
261
266
  get modelRuntime(): ModelRuntime;
262
267
  private _getRequiredRequestAuth;
@@ -314,6 +319,10 @@ export declare class AgentSession {
314
319
  dispose(): void;
315
320
  /** Full agent state */
316
321
  get state(): AgentState;
322
+ /** Current cache-warming state and the policy inputs that produced it. */
323
+ get cacheWarmingStatus(): CacheWarmingStatus | undefined;
324
+ /** Persist the cache-warming mode and immediately reconcile active warming. */
325
+ setCacheWarmingMode(mode: CacheWarmingMode): void;
317
326
  /** Current model (may be undefined if not yet selected) */
318
327
  get model(): Model<any> | undefined;
319
328
  /** Current thinking level */
@@ -322,7 +331,7 @@ export declare class AgentSession {
322
331
  get isStreaming(): boolean;
323
332
  /** Whether the session has no active agent run, compaction, branch summary, retry, or queued continuation. */
324
333
  get isIdle(): boolean;
325
- /** Current effective system prompt (includes any per-turn extension modifications) */
334
+ /** Current effective system prompt, including changes not yet sent to the model. */
326
335
  get systemPrompt(): string;
327
336
  /** Current retry attempt (0 if not retrying) */
328
337
  get retryAttempt(): number;
@@ -372,8 +381,33 @@ export declare class AgentSession {
372
381
  private _normalizePromptSnippet;
373
382
  private _normalizePromptGuidelines;
374
383
  private _rebuildSystemPrompt;
384
+ /**
385
+ * Apply a prompt and tool loadout for the next request. Sets the executable tools and
386
+ * returns a system message patching the prompt sections the model currently has (replayed
387
+ * from `messages`), or undefined when the prompt is unchanged. Tool changes are declared by
388
+ * the agent loop before the request.
389
+ *
390
+ * A forced prompt does not affect the transcript: the structured sections are still diffed
391
+ * and persisted, and the forced text is projected onto the request by
392
+ * {@link _installAgentForcedPromptProjection}.
393
+ */
394
+ private _preparePromptAndToolLoadout;
395
+ /**
396
+ * Send a forced prompt as the provider's leading system prompt without recording it.
397
+ *
398
+ * A `before_agent_start` handler that returns `systemPrompt` needs that exact text at the
399
+ * head of the request; a mid-conversation system message would leave the original prompt
400
+ * in place. The forced text is a rendering of the current prompt, so the transcript keeps
401
+ * its structured sections and the request is projected instead: the system messages
402
+ * collapse into one head holding the forced text and the current tools. Runs after the
403
+ * `context` extension handlers.
404
+ */
405
+ private _installAgentForcedPromptProjection;
406
+ /** Restore the active tool loadout declared by the session transcript, if it declares one. */
407
+ private _restoreToolsFromTranscript;
375
408
  private _runAgentPrompt;
376
409
  private _handlePostAgentRun;
410
+ private _runInputHandlers;
377
411
  /**
378
412
  * Send a prompt to the agent.
379
413
  * - Handles extension commands (registered via pi.registerCommand) immediately, even during streaming
@@ -391,23 +425,30 @@ export declare class AgentSession {
391
425
  * Emits errors via extension runner if file read fails.
392
426
  */
393
427
  private _expandSkillCommand;
428
+ private _queueUserInput;
394
429
  /**
395
430
  * Queue a steering message while the agent is running.
396
431
  * Delivered after the current assistant turn finishes executing its tool calls,
397
432
  * before the next LLM call.
398
433
  * Expands skill commands and prompt templates. Errors on extension commands.
399
434
  * @param images Optional image attachments to include with the message
435
+ * @param options Input source; defaults to interactive
400
436
  * @throws Error if text is an extension command
401
437
  */
402
- steer(text: string, images?: ImageContent[]): Promise<void>;
438
+ steer(text: string, images?: ImageContent[], options?: {
439
+ source?: InputSource;
440
+ }): Promise<void>;
403
441
  /**
404
442
  * Queue a follow-up message to be processed after the agent finishes.
405
443
  * Delivered only when agent has no more tool calls or steering messages.
406
444
  * Expands skill commands and prompt templates. Errors on extension commands.
407
445
  * @param images Optional image attachments to include with the message
446
+ * @param options Input source; defaults to interactive
408
447
  * @throws Error if text is an extension command
409
448
  */
410
- followUp(text: string, images?: ImageContent[]): Promise<void>;
449
+ followUp(text: string, images?: ImageContent[], options?: {
450
+ source?: InputSource;
451
+ }): Promise<void>;
411
452
  private _queueSteer;
412
453
  private _queueFollowUp;
413
454
  /**
@@ -540,6 +581,7 @@ export declare class AgentSession {
540
581
  * Saves to settings.
541
582
  */
542
583
  setFollowUpMode(mode: "all" | "one-at-a-time"): void;
584
+ private _runDefaultCompaction;
543
585
  private _clearManualCompactionState;
544
586
  /**
545
587
  * Manually compact the session context.
@@ -589,6 +631,7 @@ export declare class AgentSession {
589
631
  * the TUI needs to render the retry and recreate the underlying indicator.
590
632
  */
591
633
  private _summarizationRetryCallbacks;
634
+ private _finishCancelledRetry;
592
635
  private _prepareRetry;
593
636
  /**
594
637
  * Cancel in-progress retry.
@@ -691,6 +734,14 @@ export declare class AgentSession {
691
734
  * @returns The resolved output file path.
692
735
  */
693
736
  exportToJsonl(outputPath?: string): string;
737
+ /**
738
+ * Ask the current model to describe what went wrong in this session for a bug report.
739
+ * Used when the user declines to share the transcript itself.
740
+ */
741
+ summarizeForBugReport(options: {
742
+ hint?: string;
743
+ signal: AbortSignal;
744
+ }): Promise<string>;
694
745
  /**
695
746
  * Get text content of last assistant message.
696
747
  * Useful for /copy command.