mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
pi-ai 0.80 restructured its entrypoints: the static catalog reads now live on /providers/all as getBuiltinModels/getBuiltinProviders (keyed by the catalog-only BuiltinProvider type, replacing KnownProvider at those call sites), and the global streamSimple moved to /compat. The config schema gains the new 'max' reasoning level.
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
const streamSimple = vi.hoisted(() => vi.fn())
|
|
|
|
// The 0.81 SDK moved `streamSimple` to the compat entry; the adapter imports it
|
|
// from there, so the mock must target the same specifier.
|
|
vi.mock('@earendil-works/pi-ai/compat', async (importOriginal) => {
|
|
const actual = await importOriginal<typeof import('@earendil-works/pi-ai/compat')>()
|
|
return { ...actual, streamSimple }
|
|
})
|
|
|
|
import { PiAiAdapter } from '../src/adapter.ts'
|
|
|
|
afterEach(() => { streamSimple.mockReset() })
|
|
|
|
describe('pi-ai SDK retry boundary', () => {
|
|
it('pins one SDK attempt even when the installed provider currently defaults to zero retries', async () => {
|
|
const failure = new Error('mock SDK boundary')
|
|
streamSimple.mockReturnValue({
|
|
async * [Symbol.asyncIterator](): AsyncGenerator<never> {
|
|
throw failure
|
|
},
|
|
})
|
|
const adapter = new PiAiAdapter({ profiles: [{ provider: 'openai', apiKey: 'test-key' }] })
|
|
const drain = async (): Promise<void> => {
|
|
for await (const _chunk of adapter.stream({
|
|
provider: 'openai',
|
|
model: 'gpt-4.1',
|
|
messages: [],
|
|
})) { /* drain */ }
|
|
}
|
|
|
|
await expect(drain()).rejects.toBe(failure)
|
|
expect(streamSimple).toHaveBeenCalledOnce()
|
|
expect(streamSimple.mock.calls[0]?.[2]).toMatchObject({ maxRetries: 0 })
|
|
})
|
|
})
|