




















@@ -7,9 +7,7 @@ import type { PluginRuntime } from "../../src/plugins/runtime/types.js";
77import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-registration.js";
88import amazonBedrockPlugin from "./index.js";
9910-type InferenceProfileResult =
11-| { models?: Array<{ modelArn?: string }> }
12-| Error;
10+type InferenceProfileResult = { models?: Array<{ modelArn?: string }> } | Error;
13111412const inferenceProfileResults: InferenceProfileResult[] = [];
1513const bedrockClientConfigs: Array<Record<string, unknown>> = [];
@@ -376,10 +374,11 @@ describe("amazon-bedrock provider plugin", () => {
376374streamFn: spyStreamFn,
377375} as never);
378376379-const result = wrapped?.(modelDescriptor, { messages: [] } as never, options) as unknown as Record<
380-string,
381-unknown
382->;
377+const result = wrapped?.(
378+modelDescriptor,
379+{ messages: [] } as never,
380+options,
381+) as unknown as Record<string, unknown>;
383382384383if (typeof result?.onPayload === "function") {
385384await (
@@ -393,9 +392,7 @@ describe("amazon-bedrock provider plugin", () => {
393392const provider = await registerWithConfig(undefined);
394393const payload: Record<string, unknown> = {
395394system: [{ text: "You are helpful." }],
396-messages: [
397-{ role: "user", content: [{ text: "Hello" }] },
398-],
395+messages: [{ role: "user", content: [{ text: "Hello" }] }],
399396};
400397401398await callWrappedStreamWithPayload(
@@ -410,7 +407,10 @@ describe("amazon-bedrock provider plugin", () => {
410407expect(system).toHaveLength(2);
411408expect(system[1]).toEqual({ cachePoint: { type: "default" } });
412409413-const messages = payload.messages as Array<{ role: string; content: Array<Record<string, unknown>> }>;
410+const messages = payload.messages as Array<{
411+role: string;
412+content: Array<Record<string, unknown>>;
413+}>;
414414const lastUserContent = messages[0].content;
415415expect(lastUserContent).toHaveLength(2);
416416expect(lastUserContent[1]).toEqual({ cachePoint: { type: "default" } });
@@ -420,9 +420,7 @@ describe("amazon-bedrock provider plugin", () => {
420420const provider = await registerWithConfig(undefined);
421421const payload: Record<string, unknown> = {
422422system: [{ text: "You are helpful." }],
423-messages: [
424-{ role: "user", content: [{ text: "Hello" }] },
425-],
423+messages: [{ role: "user", content: [{ text: "Hello" }] }],
426424};
427425428426await callWrappedStreamWithPayload(
@@ -441,9 +439,7 @@ describe("amazon-bedrock provider plugin", () => {
441439const provider = await registerWithConfig(undefined);
442440const payload: Record<string, unknown> = {
443441system: [{ text: "You are helpful." }],
444-messages: [
445-{ role: "user", content: [{ text: "Hello" }] },
446-],
442+messages: [{ role: "user", content: [{ text: "Hello" }] }],
447443};
448444449445await callWrappedStreamWithPayload(
@@ -478,17 +474,18 @@ describe("amazon-bedrock provider plugin", () => {
478474const system = payload.system as Array<Record<string, unknown>>;
479475expect(system).toHaveLength(2);
480476481-const messages = payload.messages as Array<{ role: string; content: Array<Record<string, unknown>> }>;
477+const messages = payload.messages as Array<{
478+role: string;
479+content: Array<Record<string, unknown>>;
480+}>;
482481expect(messages[0].content).toHaveLength(2);
483482});
484483485484it("does not inject cache points for regular Anthropic model IDs (pi-ai handles them)", async () => {
486485const provider = await registerWithConfig(undefined);
487486const payload: Record<string, unknown> = {
488487system: [{ text: "You are helpful." }],
489-messages: [
490-{ role: "user", content: [{ text: "Hello" }] },
491-],
488+messages: [{ role: "user", content: [{ text: "Hello" }] }],
492489};
493490494491// Regular model IDs contain "claude" so pi-ai handles caching natively.
@@ -517,9 +514,7 @@ describe("amazon-bedrock provider plugin", () => {
517514const oldClaudeModel = "anthropic.claude-3-opus-20240229-v1:0";
518515const payload: Record<string, unknown> = {
519516system: [{ text: "You are helpful." }],
520-messages: [
521-{ role: "user", content: [{ text: "Hello" }] },
522-],
517+messages: [{ role: "user", content: [{ text: "Hello" }] }],
523518};
524519525520// Claude 3 Opus is not in pi-ai's supportsPromptCaching list, but it's
@@ -546,9 +541,7 @@ describe("amazon-bedrock provider plugin", () => {
546541const provider = await registerWithConfig(undefined);
547542const payload: Record<string, unknown> = {
548543system: [{ text: "You are helpful." }],
549-messages: [
550-{ role: "user", content: [{ text: "Hello" }] },
551-],
544+messages: [{ role: "user", content: [{ text: "Hello" }] }],
552545};
553546554547await callWrappedStreamWithPayload(
@@ -584,7 +577,10 @@ describe("amazon-bedrock provider plugin", () => {
584577payload,
585578);
586579587-const messages = payload.messages as Array<{ role: string; content: Array<Record<string, unknown>> }>;
580+const messages = payload.messages as Array<{
581+role: string;
582+content: Array<Record<string, unknown>>;
583+}>;
588584// First user message should NOT have a cache point
589585expect(messages[0].content).toHaveLength(1);
590586// Assistant message untouched
@@ -661,17 +657,14 @@ describe("amazon-bedrock provider plugin", () => {
661657it("retries opaque profile lookup after a transient failure instead of caching the fallback", async () => {
662658const modelId =
663659"arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/z27qyso459dc";
664-inferenceProfileResults.push(
665-new Error("throttled"),
666-{
667-models: [
668-{
669-modelArn:
670-"arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-sonnet-4-6-20250514-v1:0",
671-},
672-],
673-},
674-);
660+inferenceProfileResults.push(new Error("throttled"), {
661+models: [
662+{
663+modelArn:
664+"arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-sonnet-4-6-20250514-v1:0",
665+},
666+],
667+});
675668const provider = await registerWithConfig(undefined);
676669const firstPayload: Record<string, unknown> = {
677670system: [{ text: "You are helpful." }],
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。