@selesai/code 0.13.25 → 0.13.27
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.
- package/CHANGELOG.md +85 -0
- package/dist/cli/args.js +1 -0
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/core/agent-session-auto-handoff.test.js +14 -4
- package/dist/core/agent-session-length-continuation.test.js +2 -1
- package/dist/core/agent-session.d.ts +58 -7
- package/dist/core/agent-session.js +339 -169
- package/dist/core/bug-report-upload.d.ts +11 -0
- package/dist/core/bug-report-upload.js +21 -0
- package/dist/core/bug-report.d.ts +175 -0
- package/dist/core/bug-report.js +291 -0
- package/dist/core/cache-stats.js +12 -1
- package/dist/core/cache-warmer.d.ts +101 -0
- package/dist/core/cache-warmer.js +341 -0
- package/dist/core/compaction/branch-summarization.js +2 -2
- package/dist/core/compaction/compaction.d.ts +6 -5
- package/dist/core/compaction/compaction.js +49 -42
- package/dist/core/crash-log.d.ts +21 -0
- package/dist/core/crash-log.js +70 -0
- package/dist/core/experimental.d.ts +0 -4
- package/dist/core/experimental.js +0 -4
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/jiti-loader.d.ts +1 -0
- package/dist/core/extensions/jiti-loader.js +3 -0
- package/dist/core/extensions/jiti-static-loader.d.ts +1 -0
- package/dist/core/extensions/jiti-static-loader.js +3 -0
- package/dist/core/extensions/loader.js +39 -49
- package/dist/core/extensions/runner.d.ts +10 -7
- package/dist/core/extensions/runner.js +85 -67
- package/dist/core/extensions/types.d.ts +66 -52
- package/dist/core/extensions/virtual-modules.d.ts +2 -0
- package/dist/core/extensions/virtual-modules.js +39 -0
- package/dist/core/extensions/wrapper.js +1 -20
- package/dist/core/handoff.d.ts +1 -0
- package/dist/core/handoff.js +1 -0
- package/dist/core/index.d.ts +2 -1
- package/dist/core/keybindings.d.ts +1 -1
- package/dist/core/keybindings.js +1 -1
- package/dist/core/messages.js +1 -0
- package/dist/core/model-config.d.ts +101 -20
- package/dist/core/model-config.js +25 -18
- package/dist/core/model-resolver.js +2 -1
- package/dist/core/model-runtime.js +5 -3
- package/dist/core/provider-composer.d.ts +7 -2
- package/dist/core/provider-composer.js +10 -5
- package/dist/core/radius.d.ts +3 -0
- package/dist/core/radius.js +6 -0
- package/dist/core/sdk.js +60 -38
- package/dist/core/session-export.d.ts +6 -2
- package/dist/core/session-export.js +14 -13
- package/dist/core/session-format.test.d.ts +1 -0
- package/dist/core/session-format.test.js +96 -0
- package/dist/core/session-manager.d.ts +29 -6
- package/dist/core/session-manager.js +159 -96
- package/dist/core/settings-manager.d.ts +22 -5
- package/dist/core/settings-manager.js +56 -23
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/system-prompt.d.ts +49 -4
- package/dist/core/system-prompt.js +155 -102
- package/dist/core/system-prompt.test.js +61 -23
- package/dist/core/tools/bash.d.ts +2 -1
- package/dist/core/tools/bash.js +10 -4
- package/dist/core/tools/edit.js +1 -2
- package/dist/core/tools/read.js +1 -2
- package/dist/core/tools/renderers/bash.js +9 -1
- package/dist/core/tools/write.js +1 -2
- package/dist/core/usage-totals.d.ts +1 -1
- package/dist/core/usage-totals.js +5 -1
- package/dist/defaults/models.json +2 -72
- package/dist/extensions/handoff-new.test.ts +13 -13
- package/dist/extensions/handoff-new.ts +17 -6
- package/dist/extensions/pi-web-agent/src/backends/factory.ts +14 -6
- package/dist/extensions/pi-web-agent/src/extension.ts +3 -1
- package/dist/extensions/pi-web-agent/src/orchestration/answer-synthesizer.ts +7 -3
- package/dist/extensions/pi-web-agent/src/orchestration/research-orchestrator.ts +3 -0
- package/dist/extensions/pi-web-agent/src/orchestration/research-types.ts +2 -0
- package/dist/extensions/pi-web-agent/src/presentation/explore-presentation.ts +4 -2
- package/dist/extensions/pi-web-agent/src/search/tokenin.ts +4 -1
- package/dist/extensions/pi-web-agent/src/tools/web-explore.ts +2 -1
- package/dist/extensions/pi-web-agent/src/types.ts +4 -0
- package/dist/index.d.ts +3 -2
- package/dist/main.js +13 -9
- package/dist/migrations.js +2 -2
- package/dist/modes/interactive/bug-report.d.ts +15 -0
- package/dist/modes/interactive/bug-report.js +205 -0
- package/dist/modes/interactive/chat-viewport.js +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +12 -5
- package/dist/modes/interactive/components/compaction-summary-message.js +12 -5
- package/dist/modes/interactive/components/custom-editor.d.ts +3 -3
- package/dist/modes/interactive/components/extension-editor.d.ts +4 -1
- package/dist/modes/interactive/components/extension-editor.js +7 -2
- package/dist/modes/interactive/components/extension-input.d.ts +2 -0
- package/dist/modes/interactive/components/extension-input.js +6 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +1 -0
- package/dist/modes/interactive/components/extension-selector.js +4 -0
- package/dist/modes/interactive/components/footer.js +4 -1
- package/dist/modes/interactive/components/session-selector.d.ts +5 -5
- package/dist/modes/interactive/components/session-selector.js +74 -48
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector.js +11 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +11 -4
- package/dist/modes/interactive/components/status-indicator.d.ts +2 -2
- package/dist/modes/interactive/components/status-indicator.js +7 -7
- package/dist/modes/interactive/components/tool-execution.js +18 -9
- package/dist/modes/interactive/components/tree-selector.js +2 -0
- package/dist/modes/interactive/interactive-mode.d.ts +15 -2
- package/dist/modes/interactive/interactive-mode.js +257 -81
- package/dist/modes/interactive/session-share.d.ts +2 -0
- package/dist/modes/interactive/session-share.js +8 -4
- package/dist/modes/interactive/tui-renderer.js +2 -2
- package/dist/modes/rpc/rpc-mode.js +7 -2
- package/dist/utils/clipboard-command.d.ts +6 -0
- package/dist/utils/clipboard-command.js +44 -0
- package/dist/utils/clipboard-image.js +55 -89
- package/dist/utils/clipboard.d.ts +1 -1
- package/dist/utils/clipboard.js +118 -108
- package/dist/utils/wsl.d.ts +2 -0
- package/dist/utils/wsl.js +14 -0
- package/dist/utils/zip.d.ts +6 -0
- package/dist/utils/zip.js +59 -0
- package/package.json +9 -9
- package/dist/utils/clipboard-native.d.ts +0 -10
- package/dist/utils/clipboard-native.js +0 -19
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,91 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@selesai/code` will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.13.27] - 2026-09-21
|
|
6
|
+
|
|
7
|
+
### Upstream sync: Pi v0.86.1
|
|
8
|
+
|
|
9
|
+
Ported the coding-agent source from Pi v0.85.1 to v0.86.1 per file, and bumped
|
|
10
|
+
`@earendil-works/pi-ai`, `pi-agent-core` and `pi-tui` to 0.86.1. The package now declares
|
|
11
|
+
`engines.node >= 22.19.0`, matching upstream's floor.
|
|
12
|
+
|
|
13
|
+
**Adopted from upstream**
|
|
14
|
+
|
|
15
|
+
- **Custom-provider request contract.** Stream handlers now receive a normalized transcript:
|
|
16
|
+
the prompt and tool declarations live in its system messages and are read with the platform's
|
|
17
|
+
accessors, and handlers invoke the outgoing-payload hook before sending and the response hook
|
|
18
|
+
before consuming the body. Selesai's own providers never read the request context, so this
|
|
19
|
+
landed as a signature-and-type change at the forwarding boundary rather than a rewrite — your
|
|
20
|
+
`models.json` configuration and extension-registered providers are unaffected.
|
|
21
|
+
- **Sectioned system prompt with a transcript-backed record.** A session now records the prompt
|
|
22
|
+
and tool changes it ran under, so resuming a session or navigating to an earlier branch
|
|
23
|
+
restores the instructions and tools that were actually in effect instead of applying today's.
|
|
24
|
+
Your prompt cache stays warm across resume and branch navigation.
|
|
25
|
+
- **Whole-prompt replacement for one turn.** An extension can now replace the instruction for a
|
|
26
|
+
turn rather than only appending to it, so a preset or persona can take effect.
|
|
27
|
+
- **Per-model compaction budgets.** The reserved and kept-recent token budgets can be set per
|
|
28
|
+
model, so a large-context model is no longer compacted with a small model's budget.
|
|
29
|
+
- **Session runtime rebase.** Prompt and tool loadout are prepared as an explicit step with the
|
|
30
|
+
resulting state retained for the run; one shared abort controller per operation expresses
|
|
31
|
+
cancellation by throwing, so a cancellation arriving while compaction is still obtaining
|
|
32
|
+
credentials is no longer ignored; provider request settings (timeouts, retries, headers) come
|
|
33
|
+
from one builder and apply uniformly to a main turn, a compaction request and an extension's
|
|
34
|
+
model call; and the agent-level retry-backoff cap is configurable, so a transient provider
|
|
35
|
+
outage cannot hold you for minutes.
|
|
36
|
+
- **Strict JSON-schema sampling by default.** Built-in tools prefer strict sampling without you
|
|
37
|
+
setting an environment variable, and a tool whose schema cannot be expressed strictly can opt out.
|
|
38
|
+
- **Wider default tool set.** The default active set includes the search and listing tools, so a
|
|
39
|
+
fresh session can explore a repository without enabling tools by hand; each is still
|
|
40
|
+
individually disableable.
|
|
41
|
+
- **Extension authoring.** Event subscriptions now return an unsubscribe handle, so a reload or
|
|
42
|
+
session replacement cannot leave a stale handler behind; tool-call arguments and tool-result
|
|
43
|
+
details are restricted to JSON-compatible values so they survive session persistence; shell
|
|
44
|
+
hooks now fail loudly instead of silently when a handler throws or returns something malformed;
|
|
45
|
+
and the embedded-module map moved into its own module that branches on runtime kind (compiled
|
|
46
|
+
binary, TypeScript source, unbundled Node).
|
|
47
|
+
- **Interactive workspace.** Deferred extension-catalogue refresh, the new settings surfaces, and
|
|
48
|
+
the crash notice and bug report.
|
|
49
|
+
|
|
50
|
+
**Fork fixes carried in this release**
|
|
51
|
+
|
|
52
|
+
- **Clipboard failures are now surfaced.** A failed paste reports a warning instead of being
|
|
53
|
+
swallowed.
|
|
54
|
+
- **Overflow recovery no longer loses its guard.** A response that stopped at the output-token
|
|
55
|
+
limit no longer clears the overflow-recovery attempt flag, so recovery is not re-armed into a
|
|
56
|
+
loop.
|
|
57
|
+
- **Upstream path leak in a doc comment.** The session-manager documentation named
|
|
58
|
+
`~/.pi/agent/sessions`; runtime resolution was already correct, and the comment now names
|
|
59
|
+
`.selesai/agent/sessions`.
|
|
60
|
+
|
|
61
|
+
**Dependency removed**
|
|
62
|
+
|
|
63
|
+
- **`@mariozechner/clipboard` is gone.** The optional native clipboard dependency was retired in
|
|
64
|
+
favour of the clipboard helpers bundled with `@earendil-works/pi-tui`, so an install is smaller
|
|
65
|
+
and has one fewer native supply-chain boundary. Paste, copy-on-select and image paste are
|
|
66
|
+
unchanged.
|
|
67
|
+
|
|
68
|
+
**Deliberately not adopted**
|
|
69
|
+
|
|
70
|
+
- **Mermaid rendering.** Upstream's optional Mermaid path is not adopted, so no rendering
|
|
71
|
+
dependency or settings item was added.
|
|
72
|
+
- **Fork behaviour kept.** Automatic handoff, the bounded length-continuation of an
|
|
73
|
+
output-limit-truncated response, the vision caption relay, the compaction-failure event and the
|
|
74
|
+
capability gateway all still behave as before, re-planted on the new upstream shapes.
|
|
75
|
+
|
|
76
|
+
**Verification.** 53 test files / 1008 tests pass, the tree typechecks against Pi 0.86.1, the build
|
|
77
|
+
succeeds, and a 37-row delta inventory proves each Selesai-owned behaviour survived the port.
|
|
78
|
+
|
|
79
|
+
## [0.13.26] - 2026-09-18
|
|
80
|
+
|
|
81
|
+
### Added
|
|
82
|
+
- **Goal-preserving automatic handoff.** The automatic handoff now runs with the same goal text as an explicit `/handoff-new`, so the continuation prompt keeps the overarching objective, success criteria, key decisions, reference files, and the next concrete action. `AUTO_HANDOFF_GOAL` is exported from the core handoff module.
|
|
83
|
+
|
|
84
|
+
### Changed
|
|
85
|
+
- **Failed handoffs retry instead of silently stopping.** A failed or empty handoff generation now surfaces the underlying error (previously reported as "Cancelled") and rejects the command, and the automatic handoff retries on the next settled turn while the session stays above the threshold.
|
|
86
|
+
- **RPC handoff keeps the session name.** `handoff_new` carries the current session name into the replacement session, matching `/handoff-new`.
|
|
87
|
+
- **Default model catalog refreshed.** Added `glm-5.3` (1M context, text+image), `kimi-k3` (512K), and `gemini-3.7-flash`; `celestial-pro` now accepts images; `deepseek-v4.1-flash` uses 64K max output tokens.
|
|
88
|
+
- **Retired default models.** `deepseek-v4-flash`, `deepseek-v4-flash-vision-exp`, `kimi-k2.7-code`, and `glm-5.2` are no longer in the bundled Token-In catalog (`glm-5.3` supersedes `glm-5.2`). User-level `models.json` entries are unaffected.
|
|
89
|
+
|
|
5
90
|
## [0.13.25] - 2026-09-14
|
|
6
91
|
|
|
7
92
|
### 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.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
|
|
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) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import { AgentSession } from "./agent-session.js";
|
|
4
|
+
import { AUTO_HANDOFF_GOAL } from "./handoff.js";
|
|
5
|
+
import { SessionManager } from "./session-manager.js";
|
|
4
6
|
import { SettingsManager } from "./settings-manager.js";
|
|
5
7
|
function createMockSession({ enabled, threshold = 128_000, tokens, mode = "tui", command, customTools, allowedToolNames, }) {
|
|
6
8
|
const settings = SettingsManager.inMemory({
|
|
@@ -44,7 +46,7 @@ function createMockSession({ enabled, threshold = 128_000, tokens, mode = "tui",
|
|
|
44
46
|
};
|
|
45
47
|
const session = new AgentSession({
|
|
46
48
|
agent: agent,
|
|
47
|
-
sessionManager:
|
|
49
|
+
sessionManager: SessionManager.inMemory(),
|
|
48
50
|
settingsManager: settings,
|
|
49
51
|
cwd: "/tmp",
|
|
50
52
|
resourceLoader: resourceLoader,
|
|
@@ -78,6 +80,11 @@ describe("AgentSession tools", () => {
|
|
|
78
80
|
});
|
|
79
81
|
});
|
|
80
82
|
describe("AgentSession auto handoff", () => {
|
|
83
|
+
it("uses a goal that preserves the overall objective and continuation details", () => {
|
|
84
|
+
expect(AUTO_HANDOFF_GOAL).toMatch(/overall objective/i);
|
|
85
|
+
expect(AUTO_HANDOFF_GOAL).toMatch(/next concrete action/i);
|
|
86
|
+
expect(AUTO_HANDOFF_GOAL).toMatch(/reference files/i);
|
|
87
|
+
});
|
|
81
88
|
it("invokes handoff-new once when enabled and threshold reached in tui mode", async () => {
|
|
82
89
|
const command = { handler: vi.fn() };
|
|
83
90
|
const { session, getCommand, createCommandContext, emitError } = createMockSession({
|
|
@@ -90,7 +97,7 @@ describe("AgentSession auto handoff", () => {
|
|
|
90
97
|
expect(getCommand).toHaveBeenCalledWith("handoff-new");
|
|
91
98
|
expect(createCommandContext).toHaveBeenCalled();
|
|
92
99
|
expect(command.handler).toHaveBeenCalledTimes(1);
|
|
93
|
-
expect(command.handler).toHaveBeenCalledWith(
|
|
100
|
+
expect(command.handler).toHaveBeenCalledWith(AUTO_HANDOFF_GOAL, expect.anything());
|
|
94
101
|
expect(emitError).not.toHaveBeenCalled();
|
|
95
102
|
});
|
|
96
103
|
it("dispatches auto handoff via _emitAgentSettled in tui mode", async () => {
|
|
@@ -156,13 +163,16 @@ describe("AgentSession auto handoff", () => {
|
|
|
156
163
|
await session._checkAutoHandoff();
|
|
157
164
|
expect(getCommand).toHaveBeenCalledWith("handoff-new");
|
|
158
165
|
});
|
|
159
|
-
it("emits error when handoff-new
|
|
166
|
+
it("emits an error and retries on the next check when handoff-new fails", async () => {
|
|
160
167
|
const command = {
|
|
161
168
|
handler: vi.fn(() => Promise.reject(new Error("boom"))),
|
|
162
169
|
};
|
|
163
170
|
const { session, emitError } = createMockSession({ enabled: true, tokens: 200_000, command });
|
|
164
171
|
await expect(session._checkAutoHandoff()).resolves.toBeUndefined();
|
|
165
|
-
expect(
|
|
172
|
+
await expect(session._checkAutoHandoff()).resolves.toBeUndefined();
|
|
173
|
+
expect(command.handler).toHaveBeenCalledTimes(2);
|
|
174
|
+
expect(emitError).toHaveBeenCalledTimes(2);
|
|
175
|
+
expect(emitError).toHaveBeenLastCalledWith({
|
|
166
176
|
extensionPath: "command:handoff-new",
|
|
167
177
|
event: "auto-handoff",
|
|
168
178
|
error: "boom",
|
|
@@ -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:
|
|
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
|
-
/**
|
|
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
|
-
|
|
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
|
|
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[]
|
|
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[]
|
|
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.
|