mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-26 02:04:37 +08:00
MCP server checks the gate at startup and exits before opening stdio if the data directory requires a newer runtime. Desktop HTTP API maps DataDirCompatibilityError (including wrapped causes) to a 409 response so the renderer can surface a clear upgrade prompt. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
24 lines
966 B
TypeScript
24 lines
966 B
TypeScript
import assert from 'node:assert/strict'
|
|
import test from 'node:test'
|
|
import { DataDirCompatibilityError } from '@openchatlab/node-runtime/src/data-dir-compat'
|
|
import { ApiErrorCode, apiErrorFromUnknown } from './errors'
|
|
|
|
test('apiErrorFromUnknown maps wrapped data directory compatibility errors to 409', () => {
|
|
const cause = new DataDirCompatibilityError(
|
|
'DATA_DIR_REQUIRES_NEWER_RUNTIME',
|
|
'ChatLab data directory requires runtime version 0.25.1 or newer; current version is 0.25.0.',
|
|
{
|
|
userDataDir: '/tmp/chatlab-data',
|
|
metaPath: '/tmp/chatlab-data/.chatlab-meta.json',
|
|
currentVersion: '0.25.0',
|
|
minRuntimeVersion: '0.25.1',
|
|
}
|
|
)
|
|
|
|
const apiError = apiErrorFromUnknown(new Error('Desktop startup formatted message', { cause }))
|
|
|
|
assert.equal(apiError?.code, ApiErrorCode.DATA_DIR_INCOMPATIBLE)
|
|
assert.equal(apiError?.statusCode, 409)
|
|
assert.match(apiError?.message ?? '', /requires runtime version 0\.25\.1/)
|
|
})
|