@link-assistant/agent 0.8.17 → 0.8.18
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/package.json +1 -1
- package/src/index.js +7 -2
- package/src/provider/provider.ts +18 -1
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -68,11 +68,16 @@ process.on('uncaughtException', (error) => {
|
|
|
68
68
|
|
|
69
69
|
process.on('unhandledRejection', (reason, _promise) => {
|
|
70
70
|
hasError = true;
|
|
71
|
-
|
|
71
|
+
const errorOutput = {
|
|
72
72
|
errorType: 'UnhandledRejection',
|
|
73
73
|
message: reason?.message || String(reason),
|
|
74
74
|
stack: reason?.stack,
|
|
75
|
-
}
|
|
75
|
+
};
|
|
76
|
+
// If the error has a data property with a suggestion (e.g., ProviderModelNotFoundError), add it as a hint
|
|
77
|
+
if (reason?.data?.suggestion) {
|
|
78
|
+
errorOutput.hint = reason.data.suggestion;
|
|
79
|
+
}
|
|
80
|
+
outputError(errorOutput);
|
|
76
81
|
process.exit(1);
|
|
77
82
|
});
|
|
78
83
|
|
package/src/provider/provider.ts
CHANGED
|
@@ -909,7 +909,23 @@ export namespace Provider {
|
|
|
909
909
|
log.info(() => ({ message: 'getModel', providerID, modelID }));
|
|
910
910
|
|
|
911
911
|
const provider = s.providers[providerID];
|
|
912
|
-
if (!provider)
|
|
912
|
+
if (!provider) {
|
|
913
|
+
// Check if this model ID might exist in another provider (e.g., OpenRouter)
|
|
914
|
+
// This helps users who use formats like "z-ai/glm-4.7" instead of "openrouter/z-ai/glm-4.7"
|
|
915
|
+
const fullModelKey = `${providerID}/${modelID}`;
|
|
916
|
+
let suggestion: string | undefined;
|
|
917
|
+
|
|
918
|
+
for (const [knownProviderID, knownProvider] of Object.entries(
|
|
919
|
+
s.providers
|
|
920
|
+
)) {
|
|
921
|
+
if (knownProvider.info.models[fullModelKey]) {
|
|
922
|
+
suggestion = `Did you mean: ${knownProviderID}/${fullModelKey}?`;
|
|
923
|
+
break;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
throw new ModelNotFoundError({ providerID, modelID, suggestion });
|
|
928
|
+
}
|
|
913
929
|
|
|
914
930
|
// For synthetic providers (like link-assistant/echo and link-assistant/cache), skip SDK loading
|
|
915
931
|
// These providers have a custom getModel function that creates the model directly
|
|
@@ -1077,6 +1093,7 @@ export namespace Provider {
|
|
|
1077
1093
|
z.object({
|
|
1078
1094
|
providerID: z.string(),
|
|
1079
1095
|
modelID: z.string(),
|
|
1096
|
+
suggestion: z.string().optional(),
|
|
1080
1097
|
})
|
|
1081
1098
|
);
|
|
1082
1099
|
|