(
protected readonly rpcClient: CoreRPCClient,
options: KimiCoreOptions = {},
)
| 163 | private readonly experimentalFlags: FlagResolver; |
| 164 | |
| 165 | constructor( |
| 166 | protected readonly rpcClient: CoreRPCClient, |
| 167 | options: KimiCoreOptions = {}, |
| 168 | ) { |
| 169 | this.homeDir = resolveKimiHome(options.homeDir); |
| 170 | this.userHomeDir = homedir(); |
| 171 | this.configPath = resolveConfigPath({ |
| 172 | homeDir: this.homeDir, |
| 173 | configPath: options.configPath, |
| 174 | }); |
| 175 | this.runtimeOverride = options.runtime; |
| 176 | this.runtime = options.runtime; |
| 177 | this.kimiRequestHeaders = options.kimiRequestHeaders; |
| 178 | this.resolveOAuthTokenProvider = options.resolveOAuthTokenProvider; |
| 179 | this.skillDirs = options.skillDirs ?? []; |
| 180 | this.telemetry = options.telemetry ?? noopTelemetryClient; |
| 181 | this.appVersion = options.appVersion; |
| 182 | ensureKimiHome(this.homeDir); |
| 183 | // Schema errors degrade (invalid sections are dropped with warnings) so a |
| 184 | // typo cannot prevent startup, but a file that cannot be used at all — |
| 185 | // TOML syntax error, unreadable — fails fast: defaults-only would start |
| 186 | // the app looking logged out, which is worse than the parse error. |
| 187 | const loaded = loadRuntimeConfigSafe(this.configPath); |
| 188 | if (loaded.fileError !== undefined) { |
| 189 | throw loaded.fileError; |
| 190 | } |
| 191 | this.config = loaded.config; |
| 192 | this.configWarnings = [...loaded.fileWarnings, ...loaded.envWarnings]; |
| 193 | if (this.configWarnings.length > 0) { |
| 194 | log.warn('config load degraded', { warnings: this.configWarnings }); |
| 195 | } |
| 196 | this.experimentalFlags = new FlagResolver( |
| 197 | process.env, |
| 198 | FLAG_DEFINITIONS, |
| 199 | this.config.experimental, |
| 200 | ); |
| 201 | this.sessionStore = new SessionStore(this.homeDir); |
| 202 | this.plugins = new PluginManager({ kimiHomeDir: this.homeDir }); |
| 203 | // Capture the error rather than swallow it: mutators and explicit /plugins |
| 204 | // reads rethrow so the user sees what's wrong; createSession/resumeSession |
| 205 | // degrade silently (no plugin skills, no sessionStart injections) so the harness still |
| 206 | // starts. Reload clears the error on success. |
| 207 | this.pluginsReady = this.plugins.load().catch((error: unknown) => { |
| 208 | this.pluginsLoadError = error instanceof Error ? error : new Error(String(error)); |
| 209 | }); |
| 210 | log.info('experimental flags enabled', { flags: this.experimentalFlags.enabledIds() }); |
| 211 | |
| 212 | this.sdk = rpcClient(this); |
| 213 | } |
| 214 | |
| 215 | async createSession(input: CreateSessionPayload): Promise<SessionSummary> { |
| 216 | return this.createSessionWithOverrides(input, {}); |
nothing calls this directly
no test coverage detected