feat(models): bridge Chat Completions and Responses through Claude runtime
This commit is contained in:
1 parent
8fcfb69408
commit
d773961168
21 files changed
+1346
-68
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { modelBridgeHistoryDirectory } from '../src/main/model-bridge/paths'
|
||||
import assert from 'node:assert/strict'
|
||||
import { testTerminalHostPlugin } from './test-terminal-host-plugin'
|
||||
import { mkdir, mkdtemp, readFile, readdir, rm } from 'node:fs/promises'
|
||||
import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
@@ -8,6 +9,7 @@ import { build } from 'esbuild'
|
||||
import type { ChatMessage, SessionMeta, ToolCallRecord } from '../src/shared/types'
|
||||
|
||||
interface SessionStoreApi {
|
||||
deleteSession(sessionId: string): Promise<void>
|
||||
listSessions(): Promise<SessionMeta[]>
|
||||
createSession(title?: string): Promise<SessionMeta>
|
||||
appendMessage(sessionId: string, message: ChatMessage): Promise<void>
|
||||
@@ -265,6 +267,16 @@ async function main(): Promise<void> {
|
||||
assert.deepEqual(afterRecovery, inMemory,
|
||||
'session:messages should remain consistent after the write queue recovers')
|
||||
|
||||
const deletedHistory = modelBridgeHistoryDirectory(state.userData, recovered.id)
|
||||
const retainedHistory = modelBridgeHistoryDirectory(state.userData, targetSession.id)
|
||||
await mkdir(deletedHistory, { recursive: true })
|
||||
await mkdir(retainedHistory, { recursive: true })
|
||||
await writeFile(join(deletedHistory, 'route.json'), '{}')
|
||||
await writeFile(join(retainedHistory, 'route.json'), '{}')
|
||||
await coldModule.sessions.deleteSession(recovered.id)
|
||||
await assert.rejects(readFile(join(deletedHistory, 'route.json')), /ENOENT/)
|
||||
assert.equal(await readFile(join(retainedHistory, 'route.json'), 'utf8'), '{}', 'deleting one session preserves another bridge history')
|
||||
assert.ok(!modelBridgeHistoryDirectory(state.userData, '../escape').includes('..'), 'session identifiers are hashed, not path segments')
|
||||
console.log('session-store-regression: all checks passed')
|
||||
} finally {
|
||||
if (previous === undefined) delete globals[STATE_KEY]
|
||||
|
||||
Reference in new issue
Block a user