- 品牌替换:OpenCode/opencode → AirCoding/aircoding(16+ 文件) - Logo ASCII art:修复 left/right 行数不匹配导致的启动崩溃 - 启动诊断:添加 OPENCODE_PRINT_TIMING 计时探针 - dev 模式默认 --pure 跳过外部插件加载 - AGENTS.md 模板:追加 AirCoding 多 Agent 专项段落 - architect prompt + plugin:强化 AGENTS.md 产出验证
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import { Schema } from "effect"
|
|
import { LLMError, ProviderErrorEvent } from "./schema"
|
|
|
|
const patterns = [
|
|
/prompt is too long/i,
|
|
/input is too long for requested model/i,
|
|
/exceeds the context window/i,
|
|
/input token count.*exceeds the maximum/i,
|
|
/maximum prompt length is \d+/i,
|
|
/reduce the length of the messages/i,
|
|
/maximum context length is \d+ tokens/i,
|
|
/exceeds the limit of \d+/i,
|
|
/exceeds the available context size/i,
|
|
/greater than the context length/i,
|
|
/context window exceeds limit/i,
|
|
/exceeded model token limit/i,
|
|
/context[_ ]length[_ ]exceeded/i,
|
|
/request entity too large/i,
|
|
/context length is only \d+ tokens/i,
|
|
/input length.*exceeds.*context length/i,
|
|
/prompt too long; exceeded (?:max )?context length/i,
|
|
/too large for model with \d+ maximum context length/i,
|
|
/model_context_window_exceeded/i,
|
|
]
|
|
|
|
export const isContextOverflow = (message: string) =>
|
|
patterns.some((pattern) => pattern.test(message)) || /^4(00|13)\s*(status code)?\s*\(no body\)/i.test(message)
|
|
|
|
export const isContextOverflowFailure = (failure: unknown) =>
|
|
failure instanceof LLMError
|
|
? failure.reason._tag === "InvalidRequest" && failure.reason.classification === "context-overflow"
|
|
: Schema.is(ProviderErrorEvent)(failure) && failure.classification === "context-overflow"
|