Download packages/klient/test/helpers/engine.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/klient/test/helpers/engine.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/klient/test/helpers/engine.ts
-
curl -L -o engine.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/klient/test/helpers/engine.ts
1.17 kB
| /** | |
| * Shared engine bootstrap for klient integration tests. Mirrors what | |
| * kap-server does: `bootstrap()` plus the `ILogOptions` seed the | |
| * Session-scoped log writer needs (bare `bootstrap({ homeDir })` leaves | |
| * `logOptions` unregistered and any eager service depending on `ILogService` | |
| * fails to instantiate). | |
| */ | |
| import { mkdtemp } from 'node:fs/promises'; | |
| import { tmpdir } from 'node:os'; | |
| import { join } from 'node:path'; | |
| import { bootstrap, logSeed, resolveLoggingConfig } from '@moonshot-ai/agent-core-v2'; | |
| /** Shared host identity for klient test engines (bootstrap requires one). */ | |
| export const TEST_CLIENT_IDENTITY = { | |
| productName: 'klient-test', | |
| version: '0.0.0-test', | |
| platform: 'test', | |
| } as const; | |
| export interface TestEngine { | |
| readonly homeDir: string; | |
| readonly app: ReturnType<typeof bootstrap>['app']; | |
| } | |
| export async function makeEngine(prefix = 'klient-test-engine-'): Promise<TestEngine> { | |
| const homeDir = await mkdtemp(join(tmpdir(), prefix)); | |
| const { app } = bootstrap({ homeDir, clientIdentity: TEST_CLIENT_IDENTITY }, [ | |
| ...logSeed(resolveLoggingConfig({ homeDir, env: process.env })), | |
| ]); | |
| return { homeDir, app }; | |
| } | |