@actagent/amazon-bedrock-mantle-provider 2026.6.2
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/README.md +11 -0
- package/actagent.plugin.json +36 -0
- package/api.ts +16 -0
- package/discovery.test.ts +683 -0
- package/discovery.ts +436 -0
- package/index.test.ts +88 -0
- package/index.ts +15 -0
- package/mantle-anthropic.runtime.test.ts +123 -0
- package/mantle-anthropic.runtime.ts +134 -0
- package/npm-shrinkwrap.json +805 -0
- package/package.json +38 -0
- package/register.sync.runtime.ts +82 -0
- package/tsconfig.json +16 -0
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@actagent/amazon-bedrock-mantle-provider",
|
|
3
|
+
"version": "2026.6.2",
|
|
4
|
+
"description": "ACTAgent Amazon Bedrock Mantle provider plugin for OpenAI-compatible model routing.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/actagent/actagent"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@anthropic-ai/sdk": "0.100.1",
|
|
12
|
+
"@aws/bedrock-token-generator": "1.1.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@actagent/plugin-sdk": "workspace:*"
|
|
16
|
+
},
|
|
17
|
+
"actagent": {
|
|
18
|
+
"extensions": [
|
|
19
|
+
"./index.ts"
|
|
20
|
+
],
|
|
21
|
+
"install": {
|
|
22
|
+
"npmSpec": "@actagent/amazon-bedrock-mantle-provider",
|
|
23
|
+
"defaultChoice": "npm",
|
|
24
|
+
"minHostVersion": ">=2026.5.12-beta.1"
|
|
25
|
+
},
|
|
26
|
+
"compat": {
|
|
27
|
+
"pluginApi": ">=2026.6.2"
|
|
28
|
+
},
|
|
29
|
+
"build": {
|
|
30
|
+
"actagentVersion": "2026.6.2",
|
|
31
|
+
"bundledDist": false
|
|
32
|
+
},
|
|
33
|
+
"release": {
|
|
34
|
+
"publishToACTAgentHub": true,
|
|
35
|
+
"publishToNpm": true
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synchronous Amazon Bedrock Mantle provider registration. It wires discovery,
|
|
3
|
+
* runtime bearer-token preparation, stream wrappers, and failover classifiers.
|
|
4
|
+
*/
|
|
5
|
+
import type { ACTAgentConfig } from "actagent/plugin-sdk/config-contracts";
|
|
6
|
+
import { resolvePluginConfigObject } from "actagent/plugin-sdk/plugin-config-runtime";
|
|
7
|
+
import type { ACTAgentPluginApi } from "actagent/plugin-sdk/plugin-entry";
|
|
8
|
+
import {
|
|
9
|
+
mergeImplicitMantleProvider,
|
|
10
|
+
resolveImplicitMantleProvider,
|
|
11
|
+
resolveMantleBearerToken,
|
|
12
|
+
resolveMantleRuntimeBearerToken,
|
|
13
|
+
} from "./discovery.js";
|
|
14
|
+
import { createMantleAnthropicStreamFn } from "./mantle-anthropic.runtime.js";
|
|
15
|
+
|
|
16
|
+
type BedrockMantlePluginConfig = {
|
|
17
|
+
discovery?: {
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Register the Amazon Bedrock Mantle provider with ACTAgent. */
|
|
23
|
+
export function registerBedrockMantlePlugin(api: ACTAgentPluginApi): void {
|
|
24
|
+
const providerId = "amazon-bedrock-mantle";
|
|
25
|
+
const startupPluginConfig = (api.pluginConfig ?? {}) as BedrockMantlePluginConfig;
|
|
26
|
+
|
|
27
|
+
function resolveCurrentPluginConfig(
|
|
28
|
+
config: ACTAgentConfig | undefined,
|
|
29
|
+
): BedrockMantlePluginConfig | undefined {
|
|
30
|
+
const runtimePluginConfig = resolvePluginConfigObject(config, providerId);
|
|
31
|
+
return (
|
|
32
|
+
(runtimePluginConfig as BedrockMantlePluginConfig | undefined) ??
|
|
33
|
+
(config ? undefined : startupPluginConfig)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
api.registerProvider({
|
|
38
|
+
id: providerId,
|
|
39
|
+
label: "Amazon Bedrock Mantle (OpenAI-compatible)",
|
|
40
|
+
docsPath: "/providers/bedrock-mantle",
|
|
41
|
+
auth: [],
|
|
42
|
+
catalog: {
|
|
43
|
+
order: "simple",
|
|
44
|
+
run: async (ctx) => {
|
|
45
|
+
const currentPluginConfig = resolveCurrentPluginConfig(ctx.config);
|
|
46
|
+
const implicit = await resolveImplicitMantleProvider({
|
|
47
|
+
env: ctx.env,
|
|
48
|
+
pluginConfig: currentPluginConfig,
|
|
49
|
+
});
|
|
50
|
+
if (!implicit) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
provider: mergeImplicitMantleProvider({
|
|
55
|
+
existing: ctx.config.models?.providers?.[providerId],
|
|
56
|
+
implicit,
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
resolveConfigApiKey: ({ env }) =>
|
|
62
|
+
resolveMantleBearerToken(env) ? "env:AWS_BEARER_TOKEN_BEDROCK" : undefined,
|
|
63
|
+
prepareRuntimeAuth: async ({ apiKey, env }) =>
|
|
64
|
+
await resolveMantleRuntimeBearerToken({
|
|
65
|
+
apiKey,
|
|
66
|
+
env,
|
|
67
|
+
}),
|
|
68
|
+
createStreamFn: ({ model }) =>
|
|
69
|
+
model.api === "anthropic-messages" ? createMantleAnthropicStreamFn() : undefined,
|
|
70
|
+
matchesContextOverflowError: ({ errorMessage }) =>
|
|
71
|
+
/context_length_exceeded|max.*tokens.*exceeded/i.test(errorMessage),
|
|
72
|
+
classifyFailoverReason: ({ errorMessage }) => {
|
|
73
|
+
if (/rate_limit|too many requests|429/i.test(errorMessage)) {
|
|
74
|
+
return "rate_limit";
|
|
75
|
+
}
|
|
76
|
+
if (/overloaded|503|service.*unavailable/i.test(errorMessage)) {
|
|
77
|
+
return "overloaded";
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.package-boundary.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "."
|
|
5
|
+
},
|
|
6
|
+
"include": ["./*.ts", "./src/**/*.ts"],
|
|
7
|
+
"exclude": [
|
|
8
|
+
"./**/*.test.ts",
|
|
9
|
+
"./dist/**",
|
|
10
|
+
"./node_modules/**",
|
|
11
|
+
"./src/test-support/**",
|
|
12
|
+
"./src/**/*test-helpers.ts",
|
|
13
|
+
"./src/**/*test-harness.ts",
|
|
14
|
+
"./src/**/*test-support.ts"
|
|
15
|
+
]
|
|
16
|
+
}
|