larkin 0.2.88 → 0.2.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -84,7 +84,7 @@ async function listProviderModels(baseUrl, apiKey, fetchImpl = fetch) {
|
|
|
84
84
|
}
|
|
85
85
|
catch (error) {
|
|
86
86
|
if (error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError"
|
|
87
|
-
|| /fetch failed|network|ETIMEDOUT|ECONNREFUSED/i.test(error.message))) {
|
|
87
|
+
|| /fetch failed|network|ETIMEDOUT|ECONNREFUSED|ConnectionRefused|Unable to connect/i.test(error.message))) {
|
|
88
88
|
return null;
|
|
89
89
|
}
|
|
90
90
|
throw error;
|
|
@@ -70,7 +70,7 @@ export async function listProviderModels(baseUrl, apiKey, fetchImpl = fetch) {
|
|
|
70
70
|
}
|
|
71
71
|
catch (error) {
|
|
72
72
|
if (error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError"
|
|
73
|
-
|| /fetch failed|network|ETIMEDOUT|ECONNREFUSED/i.test(error.message))) {
|
|
73
|
+
|| /fetch failed|network|ETIMEDOUT|ECONNREFUSED|ConnectionRefused|Unable to connect/i.test(error.message))) {
|
|
74
74
|
return null;
|
|
75
75
|
}
|
|
76
76
|
throw error;
|
|
@@ -600,7 +600,11 @@ export async function main() {
|
|
|
600
600
|
}
|
|
601
601
|
if (!setupApiKey)
|
|
602
602
|
throw new Error("builtin-pi 需要 --api-key;或改用 --runtime external-pi 使用已有 pi 登录");
|
|
603
|
-
|
|
603
|
+
// 自定义网关(--base-url)走 custom 预设:pi 会把 baseUrl 作为 provider 端点写入配置,
|
|
604
|
+
// 而不是用预设厂商目录(否则会打到预设默认地址,如 api.openai.com)。
|
|
605
|
+
const presetId = setupBaseUrl ? "custom" : (setupProvider ?? "custom");
|
|
606
|
+
if (presetId === "custom" && !setupModel)
|
|
607
|
+
throw new Error("custom base-url 需要 --model <模型名>");
|
|
604
608
|
const presetDef = PI_PROVIDER_PRESETS.find((p) => p.id === presetId);
|
|
605
609
|
if (!presetDef && !setupBaseUrl)
|
|
606
610
|
throw new Error(`未知 provider \`${presetId}\`;可选:${PI_PROVIDER_PRESETS.map((p) => p.id).join(" | ")} | custom`);
|
|
@@ -608,7 +612,8 @@ export async function main() {
|
|
|
608
612
|
distribution: "builtin",
|
|
609
613
|
preset: presetId,
|
|
610
614
|
model: setupModel ?? presetDef?.defaultModel ?? "",
|
|
611
|
-
|
|
615
|
+
// 显式 --base-url 优先于预设默认值(自定义网关场景,如 opencode)。
|
|
616
|
+
...(setupBaseUrl ? { baseUrl: validatePiBaseUrl(setupBaseUrl) } : presetDef ? { baseUrl: presetDef.baseUrl } : {}),
|
|
612
617
|
};
|
|
613
618
|
if (setupModel && raw.baseUrl) {
|
|
614
619
|
// Owner 决策:模型名必须来自 provider 的权威可用列表,输错即报错,不做运行时猜测。
|