mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-01 12:21:25 +00:00
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
import {
|
|
createBedrockNoCacheWrapper,
|
|
isAnthropicBedrockModel,
|
|
} from "openclaw/plugin-sdk/provider-stream";
|
|
import {
|
|
mergeImplicitBedrockProvider,
|
|
resolveBedrockConfigApiKey,
|
|
resolveImplicitBedrockProvider,
|
|
} from "./api.js";
|
|
|
|
const PROVIDER_ID = "amazon-bedrock";
|
|
const CLAUDE_46_MODEL_RE = /claude-(?:opus|sonnet)-4(?:\.|-)6(?:$|[-.])/i;
|
|
|
|
export default definePluginEntry({
|
|
id: PROVIDER_ID,
|
|
name: "Amazon Bedrock Provider",
|
|
description: "Bundled Amazon Bedrock provider policy plugin",
|
|
register(api) {
|
|
api.registerProvider({
|
|
id: PROVIDER_ID,
|
|
label: "Amazon Bedrock",
|
|
docsPath: "/providers/models",
|
|
auth: [],
|
|
catalog: {
|
|
order: "simple",
|
|
run: async (ctx) => {
|
|
const implicit = await resolveImplicitBedrockProvider({
|
|
config: ctx.config,
|
|
env: ctx.env,
|
|
});
|
|
if (!implicit) {
|
|
return null;
|
|
}
|
|
return {
|
|
provider: mergeImplicitBedrockProvider({
|
|
existing: ctx.config.models?.providers?.[PROVIDER_ID],
|
|
implicit,
|
|
}),
|
|
};
|
|
},
|
|
},
|
|
resolveConfigApiKey: ({ env }) => resolveBedrockConfigApiKey(env),
|
|
wrapStreamFn: ({ modelId, streamFn }) =>
|
|
isAnthropicBedrockModel(modelId) ? streamFn : createBedrockNoCacheWrapper(streamFn),
|
|
resolveDefaultThinkingLevel: ({ modelId }) =>
|
|
CLAUDE_46_MODEL_RE.test(modelId.trim()) ? "adaptive" : undefined,
|
|
});
|
|
},
|
|
});
|