Files
openclaw/extensions/amazon-bedrock-mantle/index.test.ts
wirjo dbac5fa258 feat(bedrock): add Bedrock Mantle (OpenAI-compatible) provider (#61296)
* feat(bedrock): add Bedrock Mantle (OpenAI-compatible) provider

New amazon-bedrock-mantle extension that provides auto-discovery and
authentication for Amazon Bedrock Mantle endpoints.

Mantle (bedrock-mantle.<region>.api.aws) is Amazon Bedrock's OpenAI-
compatible API surface, separate from the existing bedrock-runtime
(ConverseStream) endpoint. It has its own model catalog including
models not available via ConverseStream (e.g. openai.gpt-oss-120b,
mistral.devstral-2-123b).

Extension structure:
- discovery.ts: Model discovery via GET /v1/models (OpenAI format),
  bearer token resolution, implicit provider configuration
- register.sync.runtime.ts: Provider registration with catalog,
  error classification (rate limits, context overflow)
- openclaw.plugin.json: Plugin manifest, enabledByDefault

Auth support:
- Long-lived Bedrock API key (AWS_BEARER_TOKEN_BEDROCK env var)
  created from the AWS Console → used directly as Bearer token
- Pre-generated SigV4-derived tokens (via aws-bedrock-token-generator)
  set in AWS_BEARER_TOKEN_BEDROCK → works transparently

Provider config (auto-resolved when AWS_BEARER_TOKEN_BEDROCK is set):
  api: "openai-completions"
  baseUrl: "https://bedrock-mantle.<region>.api.aws/v1"
  auth: "api-key" (bearer token)

Available in 12 regions: us-east-1, us-east-2, us-west-2,
ap-northeast-1, ap-south-1, ap-southeast-3, eu-central-1,
eu-west-1, eu-west-2, eu-south-1, eu-north-1, sa-east-1

Tests: 15 passing (13 discovery + 2 plugin registration)

* chore(bedrock): clarify mantle bearer auth scope

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-04-05 12:53:54 +01:00

25 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-registration.js";
import bedrockMantlePlugin from "./index.js";
describe("amazon-bedrock-mantle provider plugin", () => {
it("registers with correct provider ID and label", async () => {
const provider = await registerSingleProviderPlugin(bedrockMantlePlugin);
expect(provider.id).toBe("amazon-bedrock-mantle");
expect(provider.label).toBe("Amazon Bedrock Mantle (OpenAI-compatible)");
});
it("classifies rate limit errors for failover", async () => {
const provider = await registerSingleProviderPlugin(bedrockMantlePlugin);
expect(
provider.classifyFailoverReason?.({ errorMessage: "rate_limit exceeded" } as never),
).toBe("rate_limit");
expect(
provider.classifyFailoverReason?.({ errorMessage: "429 Too Many Requests" } as never),
).toBe("rate_limit");
expect(
provider.classifyFailoverReason?.({ errorMessage: "some other error" } as never),
).toBeUndefined();
});
});