Download packages/node-sdk/test/config.test.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/node-sdk/test/config.test.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/node-sdk/test/config.test.ts
-
curl -L -o config.test.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/node-sdk/test/config.test.ts
1.45 kB
| import { mkdtemp, rm } from 'node:fs/promises'; | |
| import { tmpdir } from 'node:os'; | |
| import { join } from 'node:path'; | |
| import { afterEach, describe, expect, it } from 'vitest'; | |
| import { createKimiConfigRpc } from '#/index'; | |
| const toPosix = (p: string): string => p.replaceAll('\\', '/'); | |
| const tempDirs: string[] = []; | |
| afterEach(async () => { | |
| for (const dir of tempDirs.splice(0)) { | |
| await rm(dir, { recursive: true, force: true }); | |
| } | |
| }); | |
| async function makeTempDir(): Promise<string> { | |
| const dir = await mkdtemp(join(tmpdir(), 'kimi-sdk-config-')); | |
| tempDirs.push(dir); | |
| return dir; | |
| } | |
| describe('SDK config TOML', () => { | |
| it('resolves config paths through the config RPC wrapper', async () => { | |
| const dir = await makeTempDir(); | |
| const rpc = createKimiConfigRpc(); | |
| await expect(rpc.resolveConfigPath({ homeDir: dir })).resolves.toBe(toPosix(join(dir, 'config.toml'))); | |
| }); | |
| it('returns structured validation issues through the config RPC wrapper', async () => { | |
| const rpc = createKimiConfigRpc(); | |
| await expect( | |
| rpc.validateConfigToml({ | |
| text: ` | |
| [providers.kimi] | |
| type = "kimi" | |
| [models.kimi] | |
| provider = "kimi" | |
| model = "kimi" | |
| max_context_size = "large" | |
| `, | |
| filePath: 'broken.toml', | |
| }), | |
| ).rejects.toMatchObject({ | |
| details: { | |
| validationIssues: [ | |
| { | |
| path: ['models', 'kimi', 'maxContextSize'], | |
| }, | |
| ], | |
| }, | |
| }); | |
| }); | |
| }); | |