mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 20:06:10 +00:00
fix(ai-vault): keep Kimi v2 epoch-ms session timestamps (#42712)
Kimi Code v2 writes state.json createdAt/updatedAt as epoch milliseconds, but the parser read them with extractString, leaving session timestamps null so session search --since dropped the session. Pass the raw values to updateTimeline, which already normalizes ISO strings and numbers. Refs #27918 Co-authored-by: szsip239 <88223778+szsip239@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { parseKimiSessionFile } from './session-scanner-kimi-parser'
|
||||
import { clearKimiSessionIndexCache } from './session-scanner-kimi-paths'
|
||||
|
||||
let tempDirs: string[] = []
|
||||
|
||||
afterEach(async () => {
|
||||
clearKimiSessionIndexCache()
|
||||
await Promise.all(tempDirs.map((dir) => rm(dir, { recursive: true, force: true })))
|
||||
tempDirs = []
|
||||
})
|
||||
|
||||
describe('parseKimiSessionFile', () => {
|
||||
it('reads Kimi Code v2 epoch-ms state timestamps', async () => {
|
||||
const home = await mkdtemp(join(tmpdir(), 'orca-kimi-parser-'))
|
||||
tempDirs.push(home)
|
||||
const sessionDir = join(home, 'sessions', 'wd_kimi-test', 'session_v2-epoch-ms')
|
||||
await mkdir(join(sessionDir, 'agents', 'main'), { recursive: true })
|
||||
const statePath = join(sessionDir, 'state.json')
|
||||
await writeFile(
|
||||
statePath,
|
||||
JSON.stringify({ version: 2, createdAt: 1791122400000, updatedAt: 1791122400500, agents: {} })
|
||||
)
|
||||
await writeFile(join(sessionDir, 'agents', 'main', 'wire.jsonl'), '')
|
||||
|
||||
const session = await parseKimiSessionFile(
|
||||
{ path: statePath, mtimeMs: 0, modifiedAt: new Date(0).toISOString() },
|
||||
'darwin'
|
||||
)
|
||||
|
||||
expect(session?.createdAt).toBe('2026-10-04T14:00:00.000Z')
|
||||
expect(session?.updatedAt).toBe('2026-10-04T14:00:00.500Z')
|
||||
})
|
||||
})
|
||||
@@ -72,8 +72,9 @@ export async function parseKimiSessionFile(
|
||||
|
||||
accumulator.title = normalizeTitleText(extractString(stateRecord.title) ?? '')
|
||||
accumulator.fallbackTitle = normalizeTitleText(extractString(stateRecord.lastPrompt) ?? '')
|
||||
updateTimeline(accumulator, extractString(stateRecord.createdAt))
|
||||
updateTimeline(accumulator, extractString(stateRecord.updatedAt))
|
||||
// Older Kimi state stores ISO strings; v2 state stores epoch milliseconds.
|
||||
updateTimeline(accumulator, stateRecord.createdAt)
|
||||
updateTimeline(accumulator, stateRecord.updatedAt)
|
||||
|
||||
await consumeKimiWireTranscript(
|
||||
accumulator,
|
||||
|
||||
Reference in New Issue
Block a user