Download packages/node-sdk/examples/t8-race-create.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/node-sdk/examples/t8-race-create.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/node-sdk/examples/t8-race-create.ts
-
curl -L -o t8-race-create.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/node-sdk/examples/t8-race-create.ts
1.03 kB
| // T8.4 driver: create session with explicit id, twice concurrently in same process. | |
| import { createKimiHarness, type KimiHarness } from '@moonshot-ai/kimi-code-sdk'; | |
| const workDir = process.argv[2]!; | |
| const homeDir = process.argv[3]!; | |
| const sessionId = process.argv[4]!; | |
| const identity: any = { productName: 'kimi-code-cli', version: '0.0.1-test', platform: 'kimi_code_cli' }; | |
| const harnessA = createKimiHarness({ identity, homeDir }); | |
| const harnessB = createKimiHarness({ identity, homeDir }); | |
| async function run(label: string, h: KimiHarness): Promise<void> { | |
| try { | |
| const s = await h.createSession({ workDir, id: sessionId, model: 'kimi-code/kimi-for-coding' }); | |
| console.log(JSON.stringify({ label, ok: true, id: s.id, dir: s.summary?.sessionDir })); | |
| } catch (error: any) { | |
| console.log(JSON.stringify({ label, ok: false, msg: String(error.message ?? error), code: error.code ?? error.cause?.code })); | |
| } finally { | |
| await h.close(); | |
| } | |
| } | |
| await Promise.all([run('A', harnessA), run('B', harnessB)]); | |