@vheins/opencode-9router 0.4.3 → 0.4.4
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.
- package/dist/plugin.js +26 -2
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -47,7 +47,7 @@ async function discoverModels(baseURL) {
|
|
|
47
47
|
}
|
|
48
48
|
export const NineRouterPlugin = async ({ client }, options) => {
|
|
49
49
|
const { url: configuredBaseURL, isDefault } = resolveBaseURL(options);
|
|
50
|
-
|
|
50
|
+
let discovered = isDefault ? null : await discoverModels(configuredBaseURL);
|
|
51
51
|
if (!discovered && !isDefault && client?.app?.log) {
|
|
52
52
|
await client.app.log({
|
|
53
53
|
body: {
|
|
@@ -84,7 +84,31 @@ export const NineRouterPlugin = async ({ client }, options) => {
|
|
|
84
84
|
const auth = await getAuth();
|
|
85
85
|
if (auth && typeof auth === "object" && "baseURL" in auth) {
|
|
86
86
|
const userURL = normalizeBaseURL(String(auth.baseURL));
|
|
87
|
-
|
|
87
|
+
const apiURL = ensureAPIPath(userURL);
|
|
88
|
+
// Re-discover models with user-provided baseURL
|
|
89
|
+
const authDiscovered = await discoverModels(userURL);
|
|
90
|
+
if (authDiscovered) {
|
|
91
|
+
discovered = authDiscovered;
|
|
92
|
+
if (client?.app?.log) {
|
|
93
|
+
await client.app.log({
|
|
94
|
+
body: {
|
|
95
|
+
service: "9router-provider",
|
|
96
|
+
level: "info",
|
|
97
|
+
message: `Discovered ${Object.keys(authDiscovered).length} models from ${apiURL}`,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (client?.app?.log) {
|
|
103
|
+
await client.app.log({
|
|
104
|
+
body: {
|
|
105
|
+
service: "9router-provider",
|
|
106
|
+
level: "error",
|
|
107
|
+
message: `Failed to discover models from ${apiURL}. Check if 9Router is running and accessible.`,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return { baseURL: apiURL };
|
|
88
112
|
}
|
|
89
113
|
return {};
|
|
90
114
|
},
|