UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

52 lines • 3.02 kB
import type { ExtensionAPI } from "../../types.ts"; import type { ResolvedMcpServer } from "./config-schema.ts"; import type { McpConnectionEntry } from "./service-types.ts"; export declare const MCP_STARTUP_RACE_MS = 250; export declare const MCP_STARTUP_TIMEOUT_ENV = "SENPI_MCP_STARTUP_TIMEOUT_MS"; /** * How long a consumer that must OBSERVE the attach waits for the connects this * race backgrounded. Each connect is itself bounded by the server's * `connectTimeoutMs` (15s default), so this is the earlier point at which the * user's turn stops waiting and the server's catalog lands on a later turn. */ export declare const MCP_ATTACH_SETTLE_TIMEOUT_MS = 5000; /** * Resolve the startup-race window (ms) a server's attach connect is bounded by. * Precedence: the `SENPI_MCP_STARTUP_TIMEOUT_MS` env override (a global escape * hatch) beats the per-server `startupTimeoutMs`, which beats the default. A * non-numeric or negative env value is ignored; `0` is honored and makes the * startup window non-blocking (connect is backgrounded immediately). */ export declare function resolveMcpStartupTimeoutMs(configured?: number): number; export type McpStartupRaceResult = "settled" | "timeout"; export type McpToolRegistrar = Pick<ExtensionAPI, "getActiveTools" | "setActiveTools" | "registerTool">; interface RaceMcpStartupConnectOptions { readonly entry: McpConnectionEntry; readonly pi: McpToolRegistrar | undefined; readonly registerDirectTools: (pi: McpToolRegistrar) => Promise<void>; readonly serverConfig: ResolvedMcpServer["config"]; readonly shouldRefreshTools: () => boolean; readonly deadlineMs?: number; readonly onDeferred: (settled: Promise<void>) => void; } /** * Completion signal for the connects `raceMcpStartupConnect` backgrounds. * session_start deliberately returns before a slow connect finishes; anything * that assembles session state from the catalog - the first turn's system * prompt build - awaits this instead of assuming the attach already landed. */ export declare class McpDeferredAttach { #private; track(settled: Promise<void>): void; wait(timeoutMs: number): Promise<McpStartupRaceResult>; clear(): void; } export declare function raceMcpStartupConnect(options: RaceMcpStartupConnectOptions): Promise<void>; export declare function connectAndRefreshMcpCatalog(entry: McpConnectionEntry, serverConfig: ResolvedMcpServer["config"]): Promise<void>; /** Reconcile the grant before health recovery without attempting a transport connection. */ export declare function prepareMcpAuthentication(entry: McpConnectionEntry): Promise<boolean>; export declare function ignoreStartupNeedsAuth(entry: McpConnectionEntry, connect: Promise<void>): Promise<void>; export declare function waitForMcpStartupRace(connect: Promise<void>, deadlineMs?: number): Promise<McpStartupRaceResult>; export declare function shouldRaceMcpStartup(lifecycle: "lazy" | "eager" | "keep-alive"): boolean; export {}; //# sourceMappingURL=startup-race.d.ts.map