mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-12 04:01:20 +00:00
Single RemoteError with a merge-extensible, domain-prefixed code map; owners throw at the failure point; streams surface marked failures; clients consume ctx.remote directly with isRemoteFailure as the only discrimination point and construct no failure instances.
22 lines
891 B
TypeScript
22 lines
891 B
TypeScript
/**
|
|
* Contract-layer helpers: transport-error folding and response unwrapping.
|
|
* (The assistant block classifier half of the legacy spec lives in
|
|
* runtime/tests — the classifier moved there.)
|
|
*/
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
import { RpcId, resultOf, transportError } from '../src/client/api.ts'
|
|
|
|
describe('transportError', () => {
|
|
it('folds an Error to internal keeping the message, and stringifies non-Errors', () => {
|
|
expect(transportError(new Error('线断了'))).toEqual({ ok: false, error: { code: 'gateway/internal', message: '线断了', details: {} } })
|
|
expect(transportError('raw string')).toMatchObject({ ok: false, error: { message: 'raw string' } })
|
|
})
|
|
})
|
|
|
|
describe('resultOf', () => {
|
|
it('unwraps the result slot', () => {
|
|
expect(resultOf({ rpcId: RpcId('r'), result: { ok: true, value: 7 } })).toEqual({ ok: true, value: 7 })
|
|
})
|
|
})
|