chore: enforce erasable TypeScript syntax
This commit is contained in:
@@ -67,14 +67,25 @@ function extractUserMessageText(content: string | Array<{ type: string; text?: s
|
||||
export class AgentSessionRuntime {
|
||||
private rebindSession?: (session: AgentSession) => Promise<void>;
|
||||
private beforeSessionInvalidate?: () => void;
|
||||
private _session: AgentSession;
|
||||
private _services: AgentSessionServices;
|
||||
private readonly createRuntime: CreateAgentSessionRuntimeFactory;
|
||||
private _diagnostics: AgentSessionRuntimeDiagnostic[];
|
||||
private _modelFallbackMessage?: string;
|
||||
|
||||
constructor(
|
||||
private _session: AgentSession,
|
||||
private _services: AgentSessionServices,
|
||||
private readonly createRuntime: CreateAgentSessionRuntimeFactory,
|
||||
private _diagnostics: AgentSessionRuntimeDiagnostic[] = [],
|
||||
private _modelFallbackMessage?: string,
|
||||
) {}
|
||||
_session: AgentSession,
|
||||
_services: AgentSessionServices,
|
||||
createRuntime: CreateAgentSessionRuntimeFactory,
|
||||
_diagnostics: AgentSessionRuntimeDiagnostic[] = [],
|
||||
_modelFallbackMessage?: string,
|
||||
) {
|
||||
this._session = _session;
|
||||
this._services = _services;
|
||||
this.createRuntime = createRuntime;
|
||||
this._diagnostics = _diagnostics;
|
||||
this._modelFallbackMessage = _modelFallbackMessage;
|
||||
}
|
||||
|
||||
get services(): AgentSessionServices {
|
||||
return this._services;
|
||||
|
||||
@@ -50,7 +50,11 @@ export interface AuthStorageBackend {
|
||||
}
|
||||
|
||||
export class FileAuthStorageBackend implements AuthStorageBackend {
|
||||
constructor(private authPath: string = join(getAgentDir(), "auth.json")) {}
|
||||
private authPath: string;
|
||||
|
||||
constructor(authPath: string = join(getAgentDir(), "auth.json")) {
|
||||
this.authPath = authPath;
|
||||
}
|
||||
|
||||
private ensureParentDir(): void {
|
||||
const dir = dirname(this.authPath);
|
||||
@@ -194,8 +198,10 @@ export class AuthStorage {
|
||||
private fallbackResolver?: (provider: string) => string | undefined;
|
||||
private loadError: Error | null = null;
|
||||
private errors: Error[] = [];
|
||||
private storage: AuthStorageBackend;
|
||||
|
||||
private constructor(private storage: AuthStorageBackend) {
|
||||
private constructor(storage: AuthStorageBackend) {
|
||||
this.storage = storage;
|
||||
this.reload();
|
||||
}
|
||||
|
||||
|
||||
@@ -334,11 +334,12 @@ export class ModelRegistry {
|
||||
private modelRequestHeaders: Map<string, Record<string, string>> = new Map();
|
||||
private registeredProviders: Map<string, ProviderConfigInput> = new Map();
|
||||
private loadError: string | undefined = undefined;
|
||||
readonly authStorage: AuthStorage;
|
||||
private modelsJsonPath: string | undefined;
|
||||
|
||||
private constructor(
|
||||
readonly authStorage: AuthStorage,
|
||||
private modelsJsonPath: string | undefined,
|
||||
) {
|
||||
private constructor(authStorage: AuthStorage, modelsJsonPath: string | undefined) {
|
||||
this.authStorage = authStorage;
|
||||
this.modelsJsonPath = modelsJsonPath;
|
||||
this.loadModels();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,14 @@ import type { TUI } from "@earendil-works/pi-tui";
|
||||
export class CountdownTimer {
|
||||
private intervalId: ReturnType<typeof setInterval> | undefined;
|
||||
private remainingSeconds: number;
|
||||
private tui: TUI | undefined;
|
||||
private onTick: (seconds: number) => void;
|
||||
private onExpire: () => void;
|
||||
|
||||
constructor(
|
||||
timeoutMs: number,
|
||||
private tui: TUI | undefined,
|
||||
private onTick: (seconds: number) => void,
|
||||
private onExpire: () => void,
|
||||
) {
|
||||
constructor(timeoutMs: number, tui: TUI | undefined, onTick: (seconds: number) => void, onExpire: () => void) {
|
||||
this.tui = tui;
|
||||
this.onTick = onTick;
|
||||
this.onExpire = onExpire;
|
||||
this.remainingSeconds = Math.ceil(timeoutMs / 1000);
|
||||
this.onTick(this.remainingSeconds);
|
||||
|
||||
|
||||
@@ -32,11 +32,13 @@ function formatTokens(count: number): string {
|
||||
*/
|
||||
export class FooterComponent implements Component {
|
||||
private autoCompactEnabled = true;
|
||||
private session: AgentSession;
|
||||
private footerData: ReadonlyFooterDataProvider;
|
||||
|
||||
constructor(
|
||||
private session: AgentSession,
|
||||
private footerData: ReadonlyFooterDataProvider,
|
||||
) {}
|
||||
constructor(session: AgentSession, footerData: ReadonlyFooterDataProvider) {
|
||||
this.session = session;
|
||||
this.footerData = footerData;
|
||||
}
|
||||
|
||||
setSession(session: AgentSession): void {
|
||||
this.session = session;
|
||||
|
||||
@@ -15,6 +15,7 @@ export class LoginDialogComponent extends Container implements Focusable {
|
||||
private abortController = new AbortController();
|
||||
private inputResolver?: (value: string) => void;
|
||||
private inputRejecter?: (error: Error) => void;
|
||||
private onComplete: (success: boolean, message?: string) => void;
|
||||
|
||||
// Focusable implementation - propagate to input for IME cursor positioning
|
||||
private _focused = false;
|
||||
@@ -29,12 +30,13 @@ export class LoginDialogComponent extends Container implements Focusable {
|
||||
constructor(
|
||||
tui: TUI,
|
||||
providerId: string,
|
||||
private onComplete: (success: boolean, message?: string) => void,
|
||||
onComplete: (success: boolean, message?: string) => void,
|
||||
providerNameOverride?: string,
|
||||
titleOverride?: string,
|
||||
) {
|
||||
super();
|
||||
this.tui = tui;
|
||||
this.onComplete = onComplete;
|
||||
|
||||
const providerInfo = getOAuthProviders().find((p) => p.id === providerId);
|
||||
const providerName = providerNameOverride || providerInfo?.name || providerId;
|
||||
|
||||
@@ -1056,7 +1056,11 @@ class TreeList implements Component {
|
||||
|
||||
/** Component that displays the current search query */
|
||||
class SearchLine implements Component {
|
||||
constructor(private treeList: TreeList) {}
|
||||
private treeList: TreeList;
|
||||
|
||||
constructor(treeList: TreeList) {
|
||||
this.treeList = treeList;
|
||||
}
|
||||
|
||||
invalidate(): void {}
|
||||
|
||||
|
||||
@@ -147,14 +147,19 @@ function isExpandable(obj: unknown): obj is Expandable {
|
||||
}
|
||||
|
||||
class ExpandableText extends Text implements Expandable {
|
||||
private readonly getCollapsedText: () => string;
|
||||
private readonly getExpandedText: () => string;
|
||||
|
||||
constructor(
|
||||
private readonly getCollapsedText: () => string,
|
||||
private readonly getExpandedText: () => string,
|
||||
getCollapsedText: () => string,
|
||||
getExpandedText: () => string,
|
||||
expanded = false,
|
||||
paddingX = 0,
|
||||
paddingY = 0,
|
||||
) {
|
||||
super(expanded ? getExpandedText() : getCollapsedText(), paddingX, paddingY);
|
||||
this.getCollapsedText = getCollapsedText;
|
||||
this.getExpandedText = getExpandedText;
|
||||
}
|
||||
|
||||
setExpanded(expanded: boolean): void {
|
||||
@@ -334,6 +339,8 @@ export class InteractiveMode {
|
||||
// Custom header from extension (undefined = use built-in header)
|
||||
private customHeader: (Component & { dispose?(): void }) | undefined = undefined;
|
||||
|
||||
private options: InteractiveModeOptions;
|
||||
|
||||
// Convenience accessors
|
||||
private get session(): AgentSession {
|
||||
return this.runtimeHost.session;
|
||||
@@ -348,11 +355,9 @@ export class InteractiveMode {
|
||||
return this.session.settingsManager;
|
||||
}
|
||||
|
||||
constructor(
|
||||
runtimeHost: AgentSessionRuntime,
|
||||
private options: InteractiveModeOptions = {},
|
||||
) {
|
||||
constructor(runtimeHost: AgentSessionRuntime, options: InteractiveModeOptions = {}) {
|
||||
this.runtimeHost = runtimeHost;
|
||||
this.options = options;
|
||||
this.runtimeHost.setBeforeSessionInvalidate(() => {
|
||||
this.resetExtensionUI();
|
||||
});
|
||||
|
||||
@@ -59,8 +59,11 @@ export class RpcClient {
|
||||
new Map();
|
||||
private requestId = 0;
|
||||
private stderr = "";
|
||||
private options: RpcClientOptions;
|
||||
|
||||
constructor(private options: RpcClientOptions = {}) {}
|
||||
constructor(options: RpcClientOptions = {}) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the RPC agent process.
|
||||
|
||||
Reference in New Issue
Block a user