my harness for niri
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 44 lines 1.5 kB view raw
1import assert from "node:assert/strict" 2import test from "node:test" 3import type OpenAI from "openai" 4import { isTransientTransportError, sanitizeMessages, shouldFallback } from "./util.js" 5 6type AssistantMessageWithReasoning = OpenAI.Chat.ChatCompletionAssistantMessageParam & { 7 reasoning_content?: string 8} 9 10test("sanitizeMessages backfills empty reasoning_content for assistant history", () => { 11 const messages = sanitizeMessages([ 12 { 13 role: "assistant", 14 content: "plain reply", 15 refusal: null, 16 }, 17 { 18 role: "assistant", 19 content: "reply with reasoning", 20 refusal: null, 21 reasoning_content: "thinking...", 22 } as AssistantMessageWithReasoning, 23 ]) 24 25 const assistant = messages[0] as (typeof messages)[number] & { reasoning_content?: string } 26 assert.equal(assistant.role, "assistant") 27 assert.equal(assistant.reasoning_content, "") 28}) 29 30test("terminated fetch errors are treated as retryable transport failures", () => { 31 const err = new TypeError("terminated") 32 33 assert.equal(isTransientTransportError(err), true) 34 assert.equal(shouldFallback(err), true) 35}) 36 37test("nested undici errors are treated as retryable transport failures", () => { 38 const cause = new Error("other side closed") 39 const nested = new TypeError("fetch failed") as TypeError & { cause?: unknown } 40 nested.cause = cause 41 42 assert.equal(isTransientTransportError(nested), true) 43 assert.equal(shouldFallback(nested), true) 44})