MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / DaemonKimiWebApi

Class DaemonKimiWebApi

apps/kimi-web/src/api/daemon/client.ts:243–1378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241// ---------------------------------------------------------------------------
242
243export class DaemonKimiWebApi implements KimiWebApi {
244 private readonly http: DaemonHttpClient;
245 private readonly config: KimiApiConfig;
246
247 constructor(config: KimiApiConfig) {
248 this.config = config;
249 this.http = new DaemonHttpClient(config.serverHttpUrl, {
250 clientId: config.clientId,
251 clientName: config.clientName,
252 clientVersion: config.clientVersion,
253 clientUiMode: config.clientUiMode,
254 });
255 }
256
257 // -------------------------------------------------------------------------
258 // Health / Meta
259 // -------------------------------------------------------------------------
260
261 async getHealth(): Promise<{ status: 'ok'; uptimeSec: number }> {
262 // Real daemon returns { ok: true }; the older shape was { status, uptime_sec }.
263 const data = await this.http.get<Partial<WireHealth>>('/healthz');
264 return { status: 'ok', uptimeSec: data.uptime_sec ?? 0 };
265 }
266
267 async getMeta(): Promise<{
268 serverVersion: string;
269 serverId: string;
270 startedAt: string;
271 capabilities: Record<string, boolean>;
272 openInApps: string[];
273 }> {
274 const data = await this.http.get<WireMeta>('/meta');
275 return {
276 serverVersion: data.server_version,
277 serverId: data.server_id,
278 startedAt: data.started_at,
279 capabilities: data.capabilities,
280 openInApps: Array.isArray(data.open_in_apps) ? data.open_in_apps : [],
281 };
282 }
283
284 // -------------------------------------------------------------------------
285 // Sessions
286 // -------------------------------------------------------------------------
287
288 async listSessions(
289 input?: PageRequest & {
290 status?: AppSessionStatus;
291 workspaceId?: string;
292 includeArchive?: boolean;
293 excludeEmpty?: boolean;
294 },
295 ): Promise<Page<AppSession>> {
296 const query: Record<string, string | number | boolean | undefined> = {
297 before_id: input?.beforeId,
298 after_id: input?.afterId,
299 page_size: input?.pageSize,
300 status: input?.status ? toWireSessionStatus(input.status) : undefined,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected