@x-magpie/core
v0.5.0
Published
Shared magpie gateway client: catalog fetch with ETag, tolerant row parsing, protocol and config normalization.
Readme
@x-magpie/core
magpie 网关的共享客户端,供 @x-magpie/{dsh,pi,opencode} 使用。零运行时依赖。
fetchCatalog(root, { apiKey?, etag?, timeoutMs?, signal?, fetchImpl? })—GET {root}/v1/models,Bearer 认证、ETag/304 条件请求、data/models双键兼容、用户可读错误。parseRow(row)/parseCatalog(rows)— 容错解析为宿主中立的NormalizedModel(缺字段落空,宿主各自决定 fallback)。推理档位同时给出两种形状:levels(宿主固定档位名 → 线上 effort)与efforts(网关列出的全部 effort,由弱到强,含ultra与厂商自有词)。resolveGateway({ gatewayUrl?, apiKey?, api? })— 显式配置 →MAGPIE_GATEWAY_URL/_KEY/_APIenv → 默认值(http://127.0.0.1:3425、openai-responses)。baseUrlFor(root, api)/gatewayRootOf(url)— 协议归一(OpenAI 方言走/v1,anthropic-messages 走根)。applyOverrides(model, override)— 按模型覆盖,null删字段。isLoopback(url)— 本机网关判定(离线豁免用)。EFFORT_ORDER— effort 的强弱顺序(none→ultra),efforts按它排序。
