- 品牌替换:OpenCode/opencode → AirCoding/aircoding(16+ 文件) - Logo ASCII art:修复 left/right 行数不匹配导致的启动崩溃 - 启动诊断:添加 OPENCODE_PRINT_TIMING 计时探针 - dev 模式默认 --pure 跳过外部插件加载 - AGENTS.md 模板:追加 AirCoding 多 Agent 专项段落 - architect prompt + plugin:强化 AGENTS.md 产出验证
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import { describe, expect } from "bun:test"
|
|
import { Effect } from "effect"
|
|
import { LLM } from "../../src"
|
|
import { LLMClient } from "../../src/route"
|
|
import * as OpenRouter from "../../src/providers/openrouter"
|
|
import { it } from "../lib/effect"
|
|
|
|
describe("OpenRouter", () => {
|
|
it.effect("prepares OpenRouter models through the OpenAI-compatible Chat route", () =>
|
|
Effect.gen(function* () {
|
|
const model = OpenRouter.configure({ apiKey: "test-key" }).model("openai/gpt-4o-mini")
|
|
|
|
expect(model).toMatchObject({
|
|
id: "openai/gpt-4o-mini",
|
|
provider: "openrouter",
|
|
route: { id: "openrouter" },
|
|
})
|
|
expect(model.route.endpoint.baseURL).toBe("https://openrouter.ai/api/v1")
|
|
|
|
const prepared = yield* LLMClient.prepare(LLM.request({ model, prompt: "Say hello." }))
|
|
|
|
expect(prepared.route).toBe("openrouter")
|
|
expect(prepared.body).toMatchObject({
|
|
model: "openai/gpt-4o-mini",
|
|
messages: [{ role: "user", content: "Say hello." }],
|
|
stream: true,
|
|
})
|
|
}),
|
|
)
|
|
|
|
it.effect("applies OpenRouter payload options from the model helper", () =>
|
|
Effect.gen(function* () {
|
|
const prepared = yield* LLMClient.prepare(
|
|
LLM.request({
|
|
model: OpenRouter.configure({
|
|
apiKey: "test-key",
|
|
providerOptions: {
|
|
openrouter: {
|
|
usage: true,
|
|
reasoning: { effort: "high" },
|
|
promptCacheKey: "session_123",
|
|
},
|
|
},
|
|
}).model("anthropic/claude-3.7-sonnet:thinking"),
|
|
prompt: "Think briefly.",
|
|
}),
|
|
)
|
|
|
|
expect(prepared.body).toMatchObject({
|
|
usage: { include: true },
|
|
reasoning: { effort: "high" },
|
|
prompt_cache_key: "session_123",
|
|
})
|
|
}),
|
|
)
|
|
})
|