A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
Remove dead parameters, unused remnants, and test-only helpers (#2955)
Sebastian Müllerae2ff905c33d
diff --git a/package-lock.json b/package-lock.jsonindex a7a23c3583..311c7aa681 100644--- a/package-lock.json+++ b/package-lock.json@@ -2565,16 +2565,6 @@"addons/*"]},- "node_modules/@xterm/xterm": {- "version": "6.0.0",- "resolved": "https://registry.npmjs.org/@xterm/xterm/-/xterm-6.0.0.tgz",- "integrity": "sha512-TQwDdQGtwwDt+2cgKDLn0IRaSxYu1tSUjgKarSDkUM0ZNiSRXFpjxEsvc/Zgc5kq5omJ+V0a8/kIM2WD3sMOYg==",- "dev": true,- "license": "MIT",- "workspaces": [- "addons/*"- ]- },"node_modules/accepts": {"version": "2.0.0","resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz",@@ -6850,14 +6840,13 @@"license": "MIT","dependencies": {"@types/mime-types": "^3.0.1",- "chalk": "^5.5.0","get-east-asian-width": "^1.6.0","marked": "^18.0.7","mime-types": "^3.0.1"},"devDependencies": {"@xterm/headless": "^6.0.0",- "@xterm/xterm": "^6.0.0"+ "chalk": "^5.5.0"},"engines": {"node": ">=20.0.0"diff --git a/packages/coding-agent/.changes/remnants-sweep.md b/packages/coding-agent/.changes/remnants-sweep.mdnew file mode 100644index 0000000000..7058166ce3--- /dev/null+++ b/packages/coding-agent/.changes/remnants-sweep.md@@ -0,0 +1 @@+- Removed unused internal code: parameters that every caller set to the same value, a worker message nothing sends, a never-set ACP meta field, five never-set UI component options, a test-only MCP store option, and four test-only helpers.diff --git a/packages/coding-agent/src/cli/owned-session-worker.ts b/packages/coding-agent/src/cli/owned-session-worker.tsindex 10e75d09bb..2d531f0386 100644--- a/packages/coding-agent/src/cli/owned-session-worker.ts+++ b/packages/coding-agent/src/cli/owned-session-worker.ts@@ -536,11 +536,8 @@ export async function runOwnedSessionWorkerFrontend(}}-export async function maybeRunOwnedSessionWorkerFrontend(- args: readonly string[],- forceLegacyFrontend = false,-): Promise<boolean> {- if (!forceLegacyFrontend && process.env.PRIME_AGENT_INTERNAL_LEGACY_OWNED_WORKER_FRONTEND !== "1") {+export async function maybeRunOwnedSessionWorkerFrontend(args: readonly string[]): Promise<boolean> {+ if (process.env.PRIME_AGENT_INTERNAL_LEGACY_OWNED_WORKER_FRONTEND !== "1") {return false;}const profile = classifyOwnedSessionWorkerInvocation(args, process.stdin.isTTY);diff --git a/packages/coding-agent/src/cli/runtime-bootstrap.ts b/packages/coding-agent/src/cli/runtime-bootstrap.tsindex 0fde97dafa..098459fadc 100644--- a/packages/coding-agent/src/cli/runtime-bootstrap.ts+++ b/packages/coding-agent/src/cli/runtime-bootstrap.ts@@ -2,7 +2,7 @@ import { ensureKernelPython } from "../core/kernel/bootstrap.js";import { ensureTool } from "../utils/tools-manager.js";export async function runRuntimeBootstrap(): Promise<void> {- await Promise.all([ensureTool("fd", true), ensureTool("rg", true)]);+ await Promise.all([ensureTool("fd"), ensureTool("rg")]);const python = await ensureKernelPython();console.log(`kernel python: ${python}`);}diff --git a/packages/coding-agent/src/core/auth-storage.ts b/packages/coding-agent/src/core/auth-storage.tsindex 631c5423c4..6cbce03bc8 100644--- a/packages/coding-agent/src/core/auth-storage.ts+++ b/packages/coding-agent/src/core/auth-storage.ts@@ -432,7 +432,7 @@ export class AuthStorage {private getStoredAuthCandidate(provider: string,- options?: { resolveCommandValue?: boolean; resolvedCommandValue?: string },+ options?: { resolvedCommandValue?: string },): AuthSourceCandidate | undefined {const credential = this.data[provider];if (!credential) {@@ -450,9 +450,7 @@ export class AuthStorage {identityMaterial,valueMaterial:commandValueMaterial ??- (isCommandApiKey && !options?.resolveCommandValue- ? undefined- : this.getStoredCredentialValueMaterial(provider, credential)),+ (isCommandApiKey ? undefined : this.getStoredCredentialValueMaterial(provider, credential)),resolveValueMaterial: isCommandApiKey? () => this.getStoredCredentialValueMaterial(provider, credential): undefined,diff --git a/packages/coding-agent/src/core/mcp/connection-store.ts b/packages/coding-agent/src/core/mcp/connection-store.tsindex 07df1e3a01..59a582ac38 100644--- a/packages/coding-agent/src/core/mcp/connection-store.ts+++ b/packages/coding-agent/src/core/mcp/connection-store.ts@@ -119,8 +119,6 @@ type PendingOp =* whether a credential was actually removed.*/authCleanup: (connectionId: string) => boolean;- /** The generic logout route keeps completed records (honest unbound). */- preserveCompletedRecord?: boolean;resolve: (result: McpRemoveAccountResult) => void;};@@ -421,9 +419,7 @@ export class McpConnectionStore {* finalizeAttempt — a concurrent finalize can never re-add an orphan* credential after a disconnect removed the account.*- * Outcomes: "removed" (record gone, write committed), "preserved"- * (credential-only logout semantics: the completed record was kept while- * the credential was removed — it shows the honest unbound state),+ * Outcomes: "removed" (record gone, write committed),* "credential-only" (no record existed; a credential-only integration* logged out), "logged-out" (the logout committed durably but the RECORD* write failed — the partial state is reported honestly and the logout is@@ -466,11 +462,6 @@ export class McpConnectionStore {connectionId: string;/** Returns whether a credential was actually removed. */authCleanup: (connectionId: string) => boolean;- /**- * Credential-only logout semantics (the generic /logout route): pending- * attempts are cancelled, completed records are PRESERVED.- */- preserveCompletedRecord?: boolean;}): Promise<McpRemoveAccountResult> {return new Promise<McpRemoveAccountResult>((resolve) => {let settled = false;@@ -483,7 +474,6 @@ export class McpConnectionStore {kind: "removeAccount",connectionId: options.connectionId,authCleanup: options.authCleanup,- ...(options.preserveCompletedRecord ? { preserveCompletedRecord: true } : {}),resolve: settle,});void this.flush().catch(() => settle("failed"));@@ -806,24 +796,13 @@ export class McpConnectionStore {// SURVIVES a failed logout (nothing was// cancelled or claimed). Cleanup runs even when// no record exists (credential-only logouts).- // The generic logout route preserves COMPLETED- // records (they show the honest unbound state)- // while cancelling PENDING attempts.const credentialRemoved = operation.authCleanup(operation.connectionId);- const existing = records.get(operation.connectionId);- const existed = existing !== undefined;- const removeRecord =- existed && (!operation.preserveCompletedRecord || existing.status === "pending");- if (removeRecord) {- records.delete(operation.connectionId);- }- const outcome: McpRemoveAccountResult = removeRecord+ const existed = records.delete(operation.connectionId);+ const outcome: McpRemoveAccountResult = existed? "removed"- : existed- ? "preserved"- : credentialRemoved- ? "credential-only"- : "missing";+ : credentialRemoved+ ? "credential-only"+ : "missing";deferred.push((didCommit) =>didCommit? operation.resolve(outcome)diff --git a/packages/coding-agent/src/core/model-resolver.ts b/packages/coding-agent/src/core/model-resolver.tsindex d4a9855a67..f34db6eb0f 100644--- a/packages/coding-agent/src/core/model-resolver.ts+++ b/packages/coding-agent/src/core/model-resolver.ts@@ -637,80 +637,3 @@ export async function findSessionModelWithReadinessWait(await modelRegistry.waitForPendingModelRefreshes(readinessTimeoutMs);return findRestorable();}--/**- * Restore model from session, with fallback to available models- */-export async function restoreModelFromSession(- savedProvider: string,- savedModelId: string,- currentModel: Model<Api> | undefined,- shouldPrintMessages: boolean,- modelRegistry: ModelRegistry,- readinessTimeoutMs: number = SESSION_MODEL_RESTORE_READINESS_TIMEOUT_MS,-): Promise<{ model: Model<Api> | undefined; fallbackMessage: string | undefined }> {- let availableModels = await modelRegistry.refreshAvailableModels();- let restoredModel = availableModels.find(- (candidate) => candidate.provider === savedProvider && candidate.id === savedModelId,- );-- if (!restoredModel) {- // refreshAvailableModels() may have resolved while the background catalog- // fetch or private-authorization refresh was still settling (e.g. right- // after a daemon restart). Wait for them, then retry the lookup once- // before concluding the restore failed.- await modelRegistry.waitForPendingModelRefreshes(readinessTimeoutMs);- availableModels = await modelRegistry.refreshAvailableModels();- restoredModel = availableModels.find(- (candidate) => candidate.provider === savedProvider && candidate.id === savedModelId,- );- }-- if (restoredModel) {- if (shouldPrintMessages) {- console.log(chalk.dim(`Restored model: ${savedProvider}/${savedModelId}`));- }- return { model: restoredModel, fallbackMessage: undefined };- }- const registeredModel = modelRegistry.find(savedProvider, savedModelId);- const reason = !registeredModel- ? "model no longer exists"- : !modelRegistry.hasConfiguredAuth(registeredModel)- ? "no auth configured"- : "model is not available";- log.warn("could not restore model", { provider: savedProvider, model: savedModelId, reason });-- if (shouldPrintMessages) {- console.error(chalk.yellow(`Warning: Could not restore model ${savedProvider}/${savedModelId} (${reason}).`));- }- const availableCurrentModel = currentModel- ? availableModels.find((candidate) => modelsAreEqual(candidate, currentModel))- : undefined;- const fallbackCurrentModel =- currentModel && (!isPrivatePrimeInferenceModel(currentModel) || availableCurrentModel)- ? (availableCurrentModel ?? currentModel)- : undefined;- if (fallbackCurrentModel) {- if (shouldPrintMessages) {- console.log(chalk.dim(`Falling back to: ${fallbackCurrentModel.provider}/${fallbackCurrentModel.id}`));- }- return {- model: fallbackCurrentModel,- fallbackMessage: `Could not restore model ${savedProvider}/${savedModelId} (${reason}). Using ${fallbackCurrentModel.provider}/${fallbackCurrentModel.id}.`,- };- }- if (availableModels.length > 0) {- const fallbackModel =- findPreferredDefaultModel(availableModels, getPreferredDefaultModelId()) ?? availableModels[0];-- if (shouldPrintMessages) {- console.log(chalk.dim(`Falling back to: ${fallbackModel.provider}/${fallbackModel.id}`));- }-- return {- model: fallbackModel,- fallbackMessage: `Could not restore model ${savedProvider}/${savedModelId} (${reason}). Using ${fallbackModel.provider}/${fallbackModel.id}.`,- };- }- return { model: undefined, fallbackMessage: undefined };-}diff --git a/packages/coding-agent/src/core/resolve-config-value.ts b/packages/coding-agent/src/core/resolve-config-value.tsindex 1336abc83d..005daea205 100644--- a/packages/coding-agent/src/core/resolve-config-value.ts+++ b/packages/coding-agent/src/core/resolve-config-value.ts@@ -97,9 +97,7 @@ function executeCommand(commandConfig: string): string | undefined {return result;}-/**- * Resolve all header values using the same resolution logic as API keys.- */+/** Like resolveConfigValue, but always re-runs "!" commands instead of reading the command-result cache. */export function resolveConfigValueUncached(config: string): string | undefined {if (config.startsWith("!")) {return executeCommandUncached(config);diff --git a/packages/coding-agent/src/core/session-manager.ts b/packages/coding-agent/src/core/session-manager.tsindex 156fa29238..423d4844f7 100644--- a/packages/coding-agent/src/core/session-manager.ts+++ b/packages/coding-agent/src/core/session-manager.ts@@ -1088,30 +1088,6 @@ function rootRlmDepthFromEnv(): number {return parsed;}-function isValidSessionFile(filePath: string): boolean {- try {- const header = readSessionHeader(filePath);- return header?.type === "session" && typeof header.id === "string";- } catch {- return false;- }-}--export function findMostRecentSession(sessionDir: string): string | null {- try {- const files = readdirSync(sessionDir)- .filter((f) => f.endsWith(".jsonl"))- .map((f) => join(sessionDir, f))- .filter(isValidSessionFile)- .map((path) => ({ path, mtime: statSync(path).mtime }))- .sort((a, b) => b.mtime.getTime() - a.mtime.getTime());-- return files[0]?.path || null;- } catch {- return null;- }-}-function normalizeCwd(cwd: string): string {return resolve(cwd);}diff --git a/packages/coding-agent/src/main.ts b/packages/coding-agent/src/main.tsindex 74962631b7..f93a42aeff 100644--- a/packages/coding-agent/src/main.ts+++ b/packages/coding-agent/src/main.ts@@ -202,18 +202,6 @@ export interface DaemonClientStartupDecision {listModels?: string | true;}-export type InteractiveDaemonStartupDecision = DaemonClientStartupDecision;--/** Retained for callers that only classify persistent interactive startup. */-export function shouldUseDaemonInteractive(options: DaemonClientStartupDecision): boolean {- return (- options.appMode === "interactive" &&- !options.startupBenchmark &&- !options.noSession &&- options.listModels === undefined- );-}-export function shouldUseDaemonClient(options: DaemonClientStartupDecision): boolean {return (options.appMode !== "daemon" && !options.startupBenchmark && !options.help && options.listModels === undefineddiff --git a/packages/coding-agent/src/modes/acp/acp-meta.ts b/packages/coding-agent/src/modes/acp/acp-meta.tsindex acb1dd6444..d014c0a8bd 100644--- a/packages/coding-agent/src/modes/acp/acp-meta.ts+++ b/packages/coding-agent/src/modes/acp/acp-meta.ts@@ -29,7 +29,6 @@ export interface PrimeAgentAutonomousMeta {tokensUsed: number;gateAttempt?: number;gateFailure?: string;- limitReason?: string;}export interface PrimeAgentIpythonAttachmentMeta {diff --git a/packages/coding-agent/src/modes/daemon/daemon-mode.ts b/packages/coding-agent/src/modes/daemon/daemon-mode.tsindex 2ab6b25a9c..5c48e2534c 100644--- a/packages/coding-agent/src/modes/daemon/daemon-mode.ts+++ b/packages/coding-agent/src/modes/daemon/daemon-mode.ts@@ -4013,12 +4013,6 @@ export class AgentDaemon {this.write(client, success(command.id, "attach", summaryForActiveSession(state)));return;}- case "worker_unsubscribe": {- const state = this.getSessionState(command.activeSessionId);- this.detachClientFromSession(client, state);- this.write(client, success(command.id, "detach"));- return;- }case "worker_archive_and_shutdown": {// Close sessions first so direct peers read session_closed "killed", not a daemon shutdown.for (const state of [...this.sessions.values()]) {diff --git a/packages/coding-agent/src/modes/daemon/daemon-protocol.ts b/packages/coding-agent/src/modes/daemon/daemon-protocol.tsindex 2e27cb5b74..50dcc21aec 100644--- a/packages/coding-agent/src/modes/daemon/daemon-protocol.ts+++ b/packages/coding-agent/src/modes/daemon/daemon-protocol.ts@@ -1229,7 +1229,8 @@ export type DaemonOutbound =meta?: DaemonEventMeta;};-export const DAEMON_OUTBOUND_COMPATIBILITY = {+// Compile-time only: forces every DaemonOutbound type to declare its compatibility.+const _DAEMON_OUTBOUND_COMPATIBILITY = {response: LEGACY_DAEMON_COMMAND,session_list_progress: LEGACY_DAEMON_COMMAND,session_list_item: LEGACY_DAEMON_COMMAND,@@ -1380,22 +1381,6 @@ export const UPDATE_RESTART_DRAIN_COMMANDS: ReadonlySet<DaemonCommand["type"]> ="abort_retry",]);-export function createDaemonEventEnvelope<TEvent extends DaemonOutbound>(- event: TEvent,- meta: DaemonEventMeta,-): DaemonEventEnvelope<TEvent> {- return {- type: "event",- id: meta.id,- protocol: meta.protocol,- ...(meta.activeSessionId ? { activeSessionId: meta.activeSessionId } : {}),- ...(meta.sequence !== undefined ? { sequence: meta.sequence } : {}),- ...(meta.cursor ? { cursor: meta.cursor } : {}),- emittedAt: meta.emittedAt,- event,- };-}-export function createDaemonEventMeta(activeSessionId: string,sequence: DaemonEventSequence,diff --git a/packages/coding-agent/src/modes/daemon/daemon-worker-protocol.ts b/packages/coding-agent/src/modes/daemon/daemon-worker-protocol.tsindex 3b14dc7e1e..9e485ffe85 100644--- a/packages/coding-agent/src/modes/daemon/daemon-worker-protocol.ts+++ b/packages/coding-agent/src/modes/daemon/daemon-worker-protocol.ts@@ -115,7 +115,6 @@ export type DaemonWorkerCommand =capabilities?: readonly DaemonClientCapability[];supportsExtensionUi?: boolean;}- | { id?: string; type: "worker_unsubscribe"; activeSessionId: string }| { id?: string; type: "worker_register_peer_transport"; grant: DaemonWorkerPeerGrant }| { id?: string; type: "worker_archive_and_shutdown" }| {diff --git a/packages/coding-agent/src/modes/interactive/components/centered-overlay.ts b/packages/coding-agent/src/modes/interactive/components/centered-overlay.tsindex 9f66f05c70..455b34c001 100644--- a/packages/coding-agent/src/modes/interactive/components/centered-overlay.ts+++ b/packages/coding-agent/src/modes/interactive/components/centered-overlay.ts@@ -12,7 +12,6 @@ import {interface CenteredOverlayOptions {getRows: () => number;maxContentWidth?: number;- verticalOffset?: number;}interface InputHandler {@@ -100,8 +99,7 @@ export class CenteredOverlayComponent implements Component, Focusable {Number.isFinite(requestedRows) && requestedRows > 0? Math.max(contentLines.length, Math.floor(requestedRows)): contentLines.length;- const centeredTop = Math.floor((targetRows - contentLines.length) / 2) + (this.options.verticalOffset ?? 0);- const topPadding = Math.max(0, Math.min(centeredTop, targetRows - contentLines.length));+ const topPadding = Math.floor((targetRows - contentLines.length) / 2);const bottomPadding = Math.max(0, targetRows - contentLines.length - topPadding);return [diff --git a/packages/coding-agent/src/modes/interactive/components/collapsible-error.ts b/packages/coding-agent/src/modes/interactive/components/collapsible-error.tsindex 84ab5a4b30..38d93a169e 100644--- a/packages/coding-agent/src/modes/interactive/components/collapsible-error.ts+++ b/packages/coding-agent/src/modes/interactive/components/collapsible-error.ts@@ -13,7 +13,6 @@ export interface CollapsibleErrorOptions {text: string;summary?: string;expanded?: boolean;- forceCollapse?: boolean;paddingX?: number;}@@ -108,7 +107,7 @@ export class CollapsibleErrorComponent implements Component {return [];}- const collapsible = this.options.forceCollapse ?? shouldCollapseErrorDetails(text);+ const collapsible = shouldCollapseErrorDetails(text);if (!collapsible || this.expanded) {this.clickRegions = [{ line: 0, col: 0, width, height: 1, onClick: () => this.setExpanded(!this.expanded) }];return this.renderText(text, width);diff --git a/packages/coding-agent/src/modes/interactive/components/conversation-components.ts b/packages/coding-agent/src/modes/interactive/components/conversation-components.tsindex 1dd4591988..0d3007f8de 100644--- a/packages/coding-agent/src/modes/interactive/components/conversation-components.ts+++ b/packages/coding-agent/src/modes/interactive/components/conversation-components.ts@@ -50,7 +50,6 @@ export interface ConversationComponentsOptions {getToolDefinition: (name: string) => ToolExecutionDefinition | undefined;markdownTheme?: MarkdownTheme;hideThinkingBlock?: boolean;- toolsExpanded?: boolean;editDiffsExpanded?: boolean;isRecognizedSlashCommand?: (name: string) => boolean;}@@ -161,14 +160,14 @@ export function createShellCompletionComponent(return component;}-/** Build conversation components from a message list, matching tool results to their calls. */+/** Test-only transcript replay; production replays via InteractiveMode.renderSessionContext. */export function buildConversationComponents(messages: readonly AgentMessage[],options: ConversationComponentsOptions,): Component[] {const components: Component[] = [];const pendingTools = new Map<string, ToolExecutionComponent>();- const expanded = options.toolsExpanded ?? false;+ const expanded = false;const editDiffsExpanded = options.editDiffsExpanded ?? false;for (const message of messages) {diff --git a/packages/coding-agent/src/modes/interactive/components/menu-panel.ts b/packages/coding-agent/src/modes/interactive/components/menu-panel.tsindex f0e4ccccc2..5775d0b013 100644--- a/packages/coding-agent/src/modes/interactive/components/menu-panel.ts+++ b/packages/coding-agent/src/modes/interactive/components/menu-panel.ts@@ -85,7 +85,6 @@ interface MenuListLayoutOptions extends MenuViewportProvider {compactItemRows?: number;scrollIndicatorRows?: number;comfortableListPaddingRows?: number;- compactListPaddingRows?: number;}export interface MenuListLayout {@@ -225,13 +224,7 @@ export function getMenuListLayout(options: MenuListLayoutOptions): MenuListLayoureturn { compact: false, visibleItems: comfortableLayout.visibleItems };}- const compactLayout = getLayoutCandidate(- rows,- options,- Math.max(1, options.compactItemRows),- options.compactListPaddingRows ?? 0,- true,- );+ const compactLayout = getLayoutCandidate(rows, options, Math.max(1, options.compactItemRows), 0, true);if (compactLayout.fits && (!comfortableLayout.fits || compactLayout.visibleItems > comfortableLayout.visibleItems)) {return { compact: true, visibleItems: compactLayout.visibleItems };}diff --git a/packages/coding-agent/src/modes/interactive/components/onboarding-picker.ts b/packages/coding-agent/src/modes/interactive/components/onboarding-picker.tsindex 03829998f3..1eeba7af48 100644--- a/packages/coding-agent/src/modes/interactive/components/onboarding-picker.ts+++ b/packages/coding-agent/src/modes/interactive/components/onboarding-picker.ts@@ -15,7 +15,6 @@ interface OnboardingPickerOptions {prompt?: string;searchPlaceholder?: string;note?: string;- continueLabel?: string;visibleRows?: number;rowWidth?: number;requestRender?: () => void;@@ -117,16 +116,7 @@ export class OnboardingPickerComponent implements Component, Focusable {truncateToWidth(field, safeWidth, "", true) + " ".repeat(Math.max(0, safeWidth - visibleWidth(field))),);lines.push(this.line(safeWidth, ""));- lines.push(- this.renderRow(- safeWidth,- rowWidth,- this.config.continueLabel ?? "Continue",- false,- this.selectedIndex === 0,- background,- ),- );+ lines.push(this.renderRow(safeWidth, rowWidth, "Continue", false, this.selectedIndex === 0, background));const end = Math.min(filtered.length, this.scrollTop + visibleRows);for (let index = this.scrollTop; index < end; index++) {diff --git a/packages/coding-agent/src/postinstall.ts b/packages/coding-agent/src/postinstall.tsindex feafbe0452..441054eee4 100644--- a/packages/coding-agent/src/postinstall.ts+++ b/packages/coding-agent/src/postinstall.ts@@ -22,7 +22,7 @@ function oneLine(message: string): string {try {if (bootstrapTools) {- await Promise.all([ensureTool("fd", true), ensureTool("rg", true)]);+ await Promise.all([ensureTool("fd"), ensureTool("rg")]);}if (bootstrapKernel) {await ensureKernelPython();diff --git a/packages/coding-agent/src/utils/tools-manager.ts b/packages/coding-agent/src/utils/tools-manager.tsindex 57aa77e373..fbcabfad89 100644--- a/packages/coding-agent/src/utils/tools-manager.ts+++ b/packages/coding-agent/src/utils/tools-manager.ts@@ -1,4 +1,3 @@-import chalk from "chalk";import extractZip from "extract-zip";import { chmodSync, createWriteStream, existsSync, mkdirSync, readdirSync, renameSync, rmSync } from "fs";import { arch, platform } from "os";@@ -270,12 +269,6 @@ async function downloadTool(tool: ManagedTool): Promise<string> {return binaryPath;}-// Termux package names for tools-const TERMUX_PACKAGES: Record<string, string> = {- fd: "fd",- rg: "ripgrep",-};-function getRipgrepInstallHint(platformName: string): string {switch (platformName) {case "darwin":@@ -320,30 +313,22 @@ export function formatMissingRipgrepMessage(result: ToolUnavailableResult): stri}// Ensure a tool is available, downloading if necessary, and retain why provisioning failed.-export async function ensureToolWithStatus(tool: ManagedTool, silent: boolean = true): Promise<ToolEnsureResult> {+export async function ensureToolWithStatus(tool: ManagedTool): Promise<ToolEnsureResult> {const existingPath = getToolPath(tool);if (existingPath) {return { status: "available", path: existingPath };}- const config = TOOLS[tool];const platformName = platform();const architecture = arch();if (isOfflineModeEnabled()) {- if (!silent) {- console.log(chalk.yellow(`${config.name} not found. Offline mode enabled, skipping download.`));- }return { status: "unavailable", reason: "offline", platform: platformName, architecture };}// On Android/Termux, Linux binaries don't work due to Bionic libc incompatibility.// Users must install via pkg.if (platformName === "android") {- const pkgName = TERMUX_PACKAGES[tool] ?? tool;- if (!silent) {- console.log(chalk.yellow(`${config.name} not found. Install with: pkg install ${pkgName}`));- }return {status: "unavailable",reason: "manual_install_required",@@ -353,20 +338,10 @@ export async function ensureToolWithStatus(tool: ManagedTool, silent: boolean =}// Tool not found - download it- if (!silent) {- console.log(chalk.dim(`${config.name} not found. Downloading...`));- }-try {const path = await downloadTool(tool);- if (!silent) {- console.log(chalk.dim(`${config.name} installed to ${path}`));- }return { status: "available", path };} catch (e) {- if (!silent) {- console.log(chalk.yellow(`Failed to download ${config.name}: ${e instanceof Error ? e.message : e}`));- }return {status: "unavailable",reason: e instanceof UnsupportedToolPlatformError ? "unsupported_platform" : "download_failed",@@ -378,7 +353,7 @@ export async function ensureToolWithStatus(tool: ManagedTool, silent: boolean =}// Compatibility wrapper for callers that only need the resolved executable path.-export async function ensureTool(tool: ManagedTool, silent: boolean = true): Promise<string | undefined> {- const result = await ensureToolWithStatus(tool, silent);+export async function ensureTool(tool: ManagedTool): Promise<string | undefined> {+ const result = await ensureToolWithStatus(tool);return result.status === "available" ? result.path : undefined;}diff --git a/packages/coding-agent/test/daemon-protocol.test.ts b/packages/coding-agent/test/daemon-protocol.test.tsindex 40d42a793c..f5cc6fa059 100644--- a/packages/coding-agent/test/daemon-protocol.test.ts+++ b/packages/coding-agent/test/daemon-protocol.test.ts@@ -2,7 +2,6 @@ import { describe, expect, it } from "vitest";import {createDaemonCommandEnvelope,- createDaemonEventEnvelope,createDaemonEventMeta,createDaemonReplayInfo,DAEMON_COMMAND_COMPATIBILITY,@@ -11,7 +10,6 @@ import {DAEMON_DEFAULT_SERVER_CAPABILITIES,DAEMON_PROTOCOL_INFO,type DaemonCommand,- type DaemonOutbound,getDaemonCommandCompatibilities,isDaemonCommandEnvelope,isSessionPlaneDaemonCommand,@@ -169,35 +167,24 @@ describe("daemon protocol helpers", () => {expect(JSON.stringify(durable)).not.toContain("secret-");});- it("creates versioned command and event envelopes", () => {+ it("creates versioned command envelopes and event meta", () => {const command = { id: "cmd-1", type: "attach", activeSessionId: "active-1" } as const;- const commandEnvelope = createDaemonCommandEnvelope(command, "cmd-1", "client-1");- const eventMeta = createDaemonEventMeta("active-1", 3, "2026-01-01T00:00:00.000Z");- const event: DaemonOutbound = {- type: "session_event",- activeSessionId: "active-1",- event: { type: "agent_end", messages: [] },- meta: eventMeta,- };- expect(commandEnvelope).toEqual({+ expect(createDaemonCommandEnvelope(command, "cmd-1", "client-1")).toEqual({type: "command",id: "cmd-1",protocol: DAEMON_PROTOCOL_INFO,clientId: "client-1",command,});- expect(createDaemonEventEnvelope(event, eventMeta)).toEqual({- type: "event",+ expect(createDaemonEventMeta("active-1", 3, "2026-01-01T00:00:00.000Z")).toEqual({id: "active-1:3",protocol: DAEMON_PROTOCOL_INFO,activeSessionId: "active-1",sequence: 3,cursor: { generation: "active-1", sequence: 3 },emittedAt: "2026-01-01T00:00:00.000Z",- event,});- expect(eventMeta.cursor).toEqual({ generation: "active-1", sequence: 3 });});it("rejects command envelopes from pre-session-action protocols", () => {diff --git a/packages/coding-agent/test/main-interactive-routing.test.ts b/packages/coding-agent/test/main-interactive-routing.test.tsindex 5d170c800a..a03c888e52 100644--- a/packages/coding-agent/test/main-interactive-routing.test.ts+++ b/packages/coding-agent/test/main-interactive-routing.test.ts@@ -5,10 +5,10 @@ import { describe, expect, test } from "vitest";import { mergeAgentSessionRuntimeConfig } from "../src/core/agent-session-config.js";import type { CreateAgentSessionOptions } from "../src/core/sdk.js";import {+ type DaemonClientStartupDecision,type DaemonInteractiveSessionManagerDecision,daemonServerDefaultSessionConfig,findActiveDaemonSessionSummaryForSessionFile,- type InteractiveDaemonStartupDecision,isClientOwnedDaemonSession,parseAgentsViewCommand,resolveActiveSessionLookupFailure,@@ -20,7 +20,6 @@ import {shouldRejectNonInteractiveBareResume,shouldUseDaemonClient,shouldUseDaemonClientRuntime,- shouldUseDaemonInteractive,shouldUseEphemeralSessionManagerForDaemonInteractive,} from "../src/main.js";import { DaemonSessionRecoveringError } from "../src/modes/daemon/daemon-errors.js";@@ -46,7 +45,7 @@ describe("interactive startup routing", () => {["startup benchmark", { appMode: "interactive", startupBenchmark: true }, false],["help", { appMode: "interactive", startupBenchmark: false, help: true }, false],["model listing", { appMode: "interactive", startupBenchmark: false, listModels: true }, false],- ] satisfies Array<[string, InteractiveDaemonStartupDecision, boolean]>)(+ ] satisfies Array<[string, DaemonClientStartupDecision, boolean]>)("routes %s to the daemon client runtime: %s",(_label, decision, expected) => {expect(shouldUseDaemonClient(decision)).toBe(expected);@@ -70,23 +69,6 @@ describe("interactive startup routing", () => {).toBe(false);});- test.each([- ["normal interactive startup", { appMode: "interactive", startupBenchmark: false }, true],- ["print mode", { appMode: "print", startupBenchmark: false }, false],- ["json mode", { appMode: "json", startupBenchmark: false }, false],- ["rpc mode", { appMode: "rpc", startupBenchmark: false }, false],- ["daemon mode", { appMode: "daemon", startupBenchmark: false }, false],- ["startup benchmark", { appMode: "interactive", startupBenchmark: true }, false],- ["--no-session", { appMode: "interactive", startupBenchmark: false, noSession: true }, false],- ["--list-models", { appMode: "interactive", startupBenchmark: false, listModels: true }, false],- ["--list-models search", { appMode: "interactive", startupBenchmark: false, listModels: "claude" }, false],- ] satisfies Array<[string, InteractiveDaemonStartupDecision, boolean]>)(- "uses daemon-backed interactive mode for %s: %s",- (_label, decision, expected) => {- expect(shouldUseDaemonInteractive(decision)).toBe(expected);- },- );-test("rejects interactive-only selectors before non-interactive startup", () => {expect(shouldRejectNonInteractiveAttach("worker", "print")).toBe(true);expect(shouldRejectNonInteractiveAttach("worker", "interactive")).toBe(false);diff --git a/packages/coding-agent/test/mcp-connection-store.test.ts b/packages/coding-agent/test/mcp-connection-store.test.tsindex 2a3708ea79..92ba032812 100644--- a/packages/coding-agent/test/mcp-connection-store.test.ts+++ b/packages/coding-agent/test/mcp-connection-store.test.ts@@ -718,7 +718,6 @@ describe("ENG-6108 durable account reservations", () => {const outcome = await client.removeAccount({connectionId: "acme-2",- preserveCompletedRecord: true,authCleanup: () => {// removeVerified throws on an auth-file write failure.throw new Error("simulated auth write failure");@@ -877,15 +876,13 @@ describe("ENG-6108 durable account reservations", () => {});});- it("removeAccount with preserveCompletedRecord cancels PENDING attempts but PRESERVES finished accounts", async () => {- const tempDir = mkdtempSync(join(tmpdir(), "preserve-logout-"));+ it("removeAccount cancels a PENDING attempt and removes a finished account's record", async () => {+ const tempDir = mkdtempSync(join(tmpdir(), "remove-account-"));const path = join(tempDir, "mcp-connections.json");const client = McpConnectionStore.open(path);const at = Date.now();- // A pending attempt: cancelled by the credential-only logout.const pendingMine = nonce();await client.reserveConnectionId(record("acme-2", at, pendingMine));- // A FINISHED account: preserved (honest unbound state after logout).const finishedMine = nonce();await client.reserveConnectionId(record("acme-4", at + 1, finishedMine));const finished = await client.finalizeAttempt({@@ -895,19 +892,8 @@ describe("ENG-6108 durable account reservations", () => {});expect(finished).toBe("committed");- const removedCredentialOnly = await client.removeAccount({- connectionId: "acme-2",- preserveCompletedRecord: true,- authCleanup: () => true,- });- const preservedFinished = await client.removeAccount({- connectionId: "acme-4",- preserveCompletedRecord: true,- authCleanup: () => true,- });-- expect(removedCredentialOnly).toBe("removed");- expect(preservedFinished).toBe("preserved");+ const removedPending = await client.removeAccount({ connectionId: "acme-2", authCleanup: () => true });+ expect(removedPending).toBe("removed");// The stale attempt loses ownership and can NEVER re-activate.const denied = await client.finalizeAttempt({connectionId: "acme-2",@@ -916,14 +902,8 @@ describe("ENG-6108 durable account reservations", () => {});expect(denied).toBe("denied");expect(McpConnectionStore.open(path).get("acme-2")).toBeUndefined();- // The finished account survives with its record (unbound display).- expect(McpConnectionStore.open(path).get("acme-4")?.status).toBe("connected");- // Without the flag, the same call removes the record entirely.- const removed = await client.removeAccount({- connectionId: "acme-4",- authCleanup: () => false,- });- expect(removed).toBe("removed");+ const removedFinished = await client.removeAccount({ connectionId: "acme-4", authCleanup: () => false });+ expect(removedFinished).toBe("removed");expect(McpConnectionStore.open(path).get("acme-4")).toBeUndefined();rmSync(tempDir, { recursive: true, force: true, maxRetries: 20, retryDelay: 50 });});diff --git a/packages/coding-agent/test/session-manager/file-operations.test.ts b/packages/coding-agent/test/session-manager/file-operations.test.tsindex 634e7ab292..7dbb4312ac 100644--- a/packages/coding-agent/test/session-manager/file-operations.test.ts+++ b/packages/coding-agent/test/session-manager/file-operations.test.ts@@ -36,7 +36,6 @@ vi.mock("node:fs", async (importOriginal) => {import { computeOwnAndTotalUsage } from "../../src/core/context-tree.js";import {type FileEntry,- findMostRecentSession,loadEntriesFromFile,loadEntriesFromFileAsync,migrateSessionEntries,@@ -355,66 +354,6 @@ describe("session tree metadata", () => {});});-describe("findMostRecentSession", () => {- let tempDir: string;-- beforeEach(() => {- tempDir = join(tmpdir(), `session-test-${Date.now()}`);- mkdirSync(tempDir, { recursive: true });- });-- afterEach(() => {- rmSync(tempDir, { recursive: true, force: true });- });-- function writeSession(name: string, id: string, mtimeSeconds?: number): string {- const file = join(tempDir, name);- writeFileSync(file, `{"type":"session","id":"${id}","timestamp":"2025-01-01T00:00:00Z","cwd":"/tmp"}\n`);- if (mtimeSeconds !== undefined) utimesSync(file, mtimeSeconds, mtimeSeconds);- return file;- }-- it.each<[string, () => { dir: string; expected: string | null }]>([- [- "ignores non-jsonl files",- () => {- writeFileSync(join(tempDir, "file.txt"), "hello");- writeFileSync(join(tempDir, "file.json"), "{}");- return { dir: tempDir, expected: null };- },- ],- [- "ignores jsonl files without a valid session header",- () => {- writeFileSync(join(tempDir, "invalid.jsonl"), '{"type":"message"}\n');- return { dir: tempDir, expected: null };- },- ],- [- "returns the single valid session file",- () => ({ dir: tempDir, expected: writeSession("session.jsonl", "abc") }),- ],- [- "returns the most recently modified session",- () => {- writeSession("older.jsonl", "old", 1000);- return { dir: tempDir, expected: writeSession("newer.jsonl", "new", 2000) };- },- ],- [- "skips invalid files and returns the valid one",- () => {- writeFileSync(join(tempDir, "invalid.jsonl"), '{"type":"not-session"}\n');- return { dir: tempDir, expected: writeSession("valid.jsonl", "abc") };- },- ],- ])("%s", (_label, build) => {- const { dir, expected } = build();-- expect(findMostRecentSession(dir)).toBe(expected);- });-});-describe("SessionManager.setSessionFile with corrupted files", () => {let tempDir: string;diff --git a/packages/coding-agent/test/suite/regressions/session-restore-model-readiness.test.ts b/packages/coding-agent/test/suite/regressions/session-restore-model-readiness.test.tsindex 00fe96349c..5a703da28a 100644--- a/packages/coding-agent/test/suite/regressions/session-restore-model-readiness.test.ts+++ b/packages/coding-agent/test/suite/regressions/session-restore-model-readiness.test.ts@@ -5,14 +5,13 @@ import { getModels } from "@earendil-works/pi-ai";import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";import { AuthStorage } from "../../../src/core/auth-storage.js";import { ModelRegistry } from "../../../src/core/model-registry.js";-import { findSessionModelWithReadinessWait, restoreModelFromSession } from "../../../src/core/model-resolver.js";+import { findSessionModelWithReadinessWait } from "../../../src/core/model-resolver.js";import { createAgentSession } from "../../../src/core/sdk.js";import { SessionManager } from "../../../src/core/session-manager.js";const SAVED_PROVIDER = "prime-inference";/** A public Prime Inference model that exists only in the (delayed) live catalog. */const CATALOG_ONLY_MODEL_ID = "test/catalog-only-restore-canary";-const FALLBACK_MODEL_ID = "z-ai/glm-5.3";function sleep(ms: number): Promise<void> {return new Promise((resolve) => {@@ -88,44 +87,6 @@ describe("session model restore waits for catalog readiness", () => {}});- test("restoreModelFromSession restores a saved model once the delayed catalog refresh settles", async () => {- stubDelayedCatalogFetch(40);- const registry = ModelRegistry.create(primeAuthStorage(), join(tempDirs[0]!, "models.json"));-- const restored = await restoreModelFromSession(- SAVED_PROVIDER,- CATALOG_ONLY_MODEL_ID,- undefined,- false,- registry,- 2_000,- );-- expect(restored.model).toMatchObject({ provider: SAVED_PROVIDER, id: CATALOG_ONLY_MODEL_ID });- expect(restored.fallbackMessage).toBeUndefined();- });-- test("restoreModelFromSession falls back to the current model when the bounded wait expires", async () => {- stubDelayedCatalogFetch(150);- const registry = ModelRegistry.create(primeAuthStorage(), join(tempDirs[0]!, "models.json"));- const currentModel = registry.find(SAVED_PROVIDER, FALLBACK_MODEL_ID);- expect(currentModel).toBeDefined();-- const restored = await restoreModelFromSession(- SAVED_PROVIDER,- CATALOG_ONLY_MODEL_ID,- currentModel,- false,- registry,- 25,- );-- expect(restored.model).toMatchObject({ provider: SAVED_PROVIDER, id: FALLBACK_MODEL_ID });- expect(restored.fallbackMessage).toBe(- `Could not restore model ${SAVED_PROVIDER}/${CATALOG_ONLY_MODEL_ID} (model no longer exists). Using ${SAVED_PROVIDER}/${FALLBACK_MODEL_ID}.`,- );- });-test("findSessionModelWithReadinessWait restores a saved model after the delayed refresh settles", async () => {stubDelayedCatalogFetch(40);const registry = ModelRegistry.create(primeAuthStorage(), join(tempDirs[0]!, "models.json"));diff --git a/packages/tui/.changes/remnants-sweep.md b/packages/tui/.changes/remnants-sweep.mdnew file mode 100644index 0000000000..1ddd642e7f--- /dev/null+++ b/packages/tui/.changes/remnants-sweep.md@@ -0,0 +1 @@+- Moved `chalk` to devDependencies (only tests use it) and removed the unused `@xterm/xterm` devDependency.diff --git a/packages/tui/package.json b/packages/tui/package.jsonindex 08a7b85262..970a745295 100644--- a/packages/tui/package.json+++ b/packages/tui/package.json@@ -37,7 +37,6 @@"types": "./dist/index.d.ts","dependencies": {"@types/mime-types": "^3.0.1",- "chalk": "^5.5.0","get-east-asian-width": "^1.6.0","marked": "^18.0.7","mime-types": "^3.0.1"@@ -47,6 +46,6 @@},"devDependencies": {"@xterm/headless": "^6.0.0",- "@xterm/xterm": "^6.0.0"+ "chalk": "^5.5.0"}}diff --git a/tsconfig.json b/tsconfig.jsonindex 4dfbf3d254..a0bcedcfc4 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -11,7 +11,6 @@"@earendil-works/pi-agent-core": ["./packages/agent/src/index.ts"],"@earendil-works/pi-agent-core/*": ["./packages/agent/src/*"],"@earendil-works/pi-coding-agent": ["./packages/coding-agent/src/index.ts"],- "@earendil-works/pi-coding-agent/hooks": ["./packages/coding-agent/src/core/hooks/index.ts"],"@earendil-works/pi-coding-agent/*": ["./packages/coding-agent/src/*"],"typebox": ["./node_modules/typebox"],"@earendil-works/pi-tui": ["./packages/tui/src/index.ts"],