@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
83 lines • 4.36 kB
TypeScript
/**
* Main entry point for the coding agent CLI.
*
* This file handles CLI argument parsing and translates them into
* createAgentSession() options. The SDK does the heavy lifting.
*/
import { type Args } from "./cli/args.ts";
import { createStartupLoadingIndicator } from "./cli/startup-loading-indicator.ts";
import { type ToolRuntimeKind } from "./cli/tool-runtime.ts";
import { type AgentSessionRuntimeDiagnostic } from "./core/agent-session-services.ts";
import { AuthStorage } from "./core/auth-storage.ts";
import type { InlineExtension } from "./core/extensions/types.ts";
import { ModelRuntime } from "./core/model-runtime.ts";
import { type AppMode } from "./core/project-trust.ts";
import { SessionManager } from "./core/session-manager.ts";
import { SettingsManager } from "./core/settings-manager.ts";
import type { PreparableRuntimeFactory } from "./modes/rpc/host-warm.ts";
/**
* Auth problems for a run's diagnostics. Each credential notice appears once per process; with
* `persistSeen` (a run a person reads) it is also recorded as seen, so later runs stay quiet until
* the problem changes (senpi#3486).
*/
export declare function collectAuthDiagnostics(authStorage: AuthStorage, context: string, options: {
persistSeen: boolean;
}): AgentSessionRuntimeDiagnostic[];
/** The TUI shows auth problems at startup; credential notices are marked seen once shown (senpi#3486). */
export declare function interactiveAuthNotices(authStorage: AuthStorage): {
messages: string[];
markSeen: () => void;
};
export declare function collectExtensionLoadDiagnostics(errors: readonly {
path: string;
error: string;
}[]): AgentSessionRuntimeDiagnostic[];
/**
* Interactive launches auto-title by default. RPC clients can opt in through
* `auto_title_sessions`; every other non-interactive app mode opts in with
* `--auto-title-sessions`. A per-session `open_session.auto_title`, when present,
* replaces that host-wide decision for that session only. Sessions resumed with
* existing context messages are never retitled, whatever the mode, capability,
* flag, or per-session override.
*/
export declare function resolveAutoTitleSessions(appMode: AppMode, parsed: Args, hasContextMessages: boolean, clientCapabilities?: readonly string[], sessionAutoTitle?: boolean): boolean;
/**
* Prompt user for yes/no confirmation.
* Resolves false on stdin EOF (Ctrl+D, closed pipe): without the close handler a
* readline question never settles once the input stream ends, hanging the process.
*/
export declare function promptConfirm(message: string): Promise<boolean>;
export declare function createSessionManager(parsed: Args, cwd: string, sessionDir: string | undefined, settingsManager: SettingsManager, appMode: AppMode): Promise<SessionManager>;
export interface MainOptions {
extensionFactories?: InlineExtension[];
}
/**
* Supply grok-night as a non-persistent fallback until a user explicitly chooses
* a theme. Existing settings are always returned first.
*/
export declare function applyGrokNeoThemeFallback(settingsManager: SettingsManager): void;
export interface CliRuntimeConfiguration {
parsed: Args;
cwd: string;
agentDir: string;
appMode: AppMode;
/** Resolved `--tool-runtime` (flag, then env); absent means `in-process`. A worker isolate never re-reads env. */
toolRuntime?: ToolRuntimeKind;
}
/** Fixed launch data is cloneable; UI callbacks and extension factories stay in their isolate. */
export declare function createCliRuntimeFactory(configuration: CliRuntimeConfiguration, local?: {
extensionFactories?: InlineExtension[];
startupSettingsManager?: SettingsManager;
startupLoadingIndicator?: ReturnType<typeof createStartupLoadingIndicator>;
/**
* One model runtime for every session this factory creates. A shared host's
* sessions all live in one agent dir, so they would each build an identical
* runtime - ~100 ms of loop CPU per open that, concurrent, every open pays
* N times over (senpi#1844). Provider registration is keyed by id and
* merges, so replaying each session's extension providers into one runtime
* is idempotent.
*/
modelRuntime?: ModelRuntime;
}): PreparableRuntimeFactory;
export declare function main(args: string[], options?: MainOptions): Promise<void>;
//# sourceMappingURL=main.d.ts.map