mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 22:15:57 +08:00
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";
|
|
import {
|
|
mergeImplicitMantleProvider,
|
|
resolveImplicitMantleProvider,
|
|
resolveMantleBearerToken,
|
|
} from "./discovery.js";
|
|
|
|
export function registerBedrockMantlePlugin(api: OpenClawPluginApi): void {
|
|
const providerId = "amazon-bedrock-mantle";
|
|
|
|
api.registerProvider({
|
|
id: providerId,
|
|
label: "Amazon Bedrock Mantle (OpenAI-compatible)",
|
|
docsPath: "/providers/bedrock-mantle",
|
|
auth: [],
|
|
catalog: {
|
|
order: "simple",
|
|
run: async (ctx) => {
|
|
const implicit = await resolveImplicitMantleProvider({
|
|
env: ctx.env,
|
|
});
|
|
if (!implicit) {
|
|
return null;
|
|
}
|
|
return {
|
|
provider: mergeImplicitMantleProvider({
|
|
existing: ctx.config.models?.providers?.[providerId],
|
|
implicit,
|
|
}),
|
|
};
|
|
},
|
|
},
|
|
resolveConfigApiKey: ({ env }) =>
|
|
resolveMantleBearerToken(env) ? "AWS_BEARER_TOKEN_BEDROCK" : undefined,
|
|
matchesContextOverflowError: ({ errorMessage }) =>
|
|
/context_length_exceeded|max.*tokens.*exceeded/i.test(errorMessage),
|
|
classifyFailoverReason: ({ errorMessage }) => {
|
|
if (/rate_limit|too many requests|429/i.test(errorMessage)) {
|
|
return "rate_limit";
|
|
}
|
|
if (/overloaded|503/i.test(errorMessage)) {
|
|
return "overloaded";
|
|
}
|
|
return undefined;
|
|
},
|
|
});
|
|
}
|