serverless-bedrock-agentcore-plugin 0.2.0 → 0.3.0
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 +100 -71
- package/package.json +1 -1
- package/src/compilers/gateway.js +13 -4
- package/src/compilers/memory.js +1 -0
- package/src/index.js +1 -1
- package/src/validators/schema.js +19 -27
package/README.md
CHANGED
|
@@ -45,15 +45,15 @@ agents:
|
|
|
45
45
|
myAgent:
|
|
46
46
|
type: runtime
|
|
47
47
|
description: My AI agent
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
protocol:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
artifact:
|
|
49
|
+
docker:
|
|
50
|
+
path: .
|
|
51
|
+
file: Dockerfile
|
|
52
|
+
repository: my-agent
|
|
53
|
+
protocol: HTTP
|
|
54
|
+
network:
|
|
55
|
+
networkMode: PUBLIC
|
|
56
|
+
# Omit 'authorizer' for no authentication
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
## Resource Types
|
|
@@ -67,15 +67,20 @@ agents:
|
|
|
67
67
|
myAgent:
|
|
68
68
|
type: runtime
|
|
69
69
|
description: My AI agent
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
protocol:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
artifact:
|
|
71
|
+
docker:
|
|
72
|
+
path: .
|
|
73
|
+
file: Dockerfile
|
|
74
|
+
repository: my-agent
|
|
75
|
+
protocol: HTTP # HTTP, MCP, or A2A
|
|
76
|
+
network:
|
|
77
|
+
networkMode: PUBLIC # PUBLIC or VPC
|
|
78
|
+
# Optional: JWT authorization (omit for no auth)
|
|
79
|
+
authorizer:
|
|
80
|
+
customJwtAuthorizer:
|
|
81
|
+
discoveryUrl: https://cognito-idp.us-east-1.amazonaws.com/us-east-1_xxx/.well-known/openid-configuration
|
|
82
|
+
allowedAudience:
|
|
83
|
+
- my-client-id
|
|
79
84
|
# Optional: Pass specific headers to the runtime
|
|
80
85
|
requestHeaders:
|
|
81
86
|
allowlist:
|
|
@@ -84,18 +89,26 @@ agents:
|
|
|
84
89
|
- Authorization
|
|
85
90
|
```
|
|
86
91
|
|
|
87
|
-
| Property
|
|
88
|
-
|
|
|
89
|
-
| `type`
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
92
|
+
| Property | Required | Description |
|
|
93
|
+
| ------------------------------------------------ | -------- | ---------------------------------------- |
|
|
94
|
+
| `type` | Yes | `runtime` |
|
|
95
|
+
| `artifact.docker.path` | Yes\* | Docker build context path |
|
|
96
|
+
| `artifact.docker.file` | No | Dockerfile name (default: Dockerfile) |
|
|
97
|
+
| `artifact.docker.repository` | No | ECR repository name |
|
|
98
|
+
| `artifact.containerImage` | Yes\* | Pre-built container image URI |
|
|
99
|
+
| `protocol` | No | `HTTP`, `MCP`, or `A2A` |
|
|
100
|
+
| `network.networkMode` | No | `PUBLIC` or `VPC` |
|
|
101
|
+
| `authorizer.customJwtAuthorizer` | No | JWT authorizer config (omit for no auth) |
|
|
102
|
+
| `authorizer.customJwtAuthorizer.discoveryUrl` | Yes\*\* | OIDC discovery URL |
|
|
103
|
+
| `authorizer.customJwtAuthorizer.allowedAudience` | No | Array of allowed audience values |
|
|
104
|
+
| `authorizer.customJwtAuthorizer.allowedClients` | No | Array of allowed client IDs |
|
|
105
|
+
| `requestHeaders.allowlist` | No | Headers to pass to runtime (max 20) |
|
|
106
|
+
| `description` | No | Runtime description |
|
|
107
|
+
| `roleArn` | No | Custom IAM role ARN |
|
|
108
|
+
|
|
109
|
+
\*Either `artifact.docker` or `artifact.containerImage` is required
|
|
110
|
+
|
|
111
|
+
\*\*Required when using `customJwtAuthorizer`
|
|
99
112
|
|
|
100
113
|
### Memory
|
|
101
114
|
|
|
@@ -111,25 +124,18 @@ agents:
|
|
|
111
124
|
# Semantic search strategy
|
|
112
125
|
- SemanticMemoryStrategy:
|
|
113
126
|
Name: ConversationSearch
|
|
114
|
-
Type: SEMANTIC
|
|
115
127
|
Namespaces:
|
|
116
128
|
- /conversations/{sessionId}
|
|
117
|
-
SemanticMemoryConfiguration:
|
|
118
|
-
ModelId: amazon.titan-embed-text-v2:0
|
|
119
|
-
SimilarityThreshold: 0.75
|
|
120
129
|
|
|
121
130
|
# Summarization strategy
|
|
122
131
|
- SummaryMemoryStrategy:
|
|
123
132
|
Name: SessionSummary
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
SummaryModelId: anthropic.claude-3-haiku-20240307-v1:0
|
|
127
|
-
MaxMessages: 100
|
|
133
|
+
Namespaces:
|
|
134
|
+
- /sessions/{sessionId}
|
|
128
135
|
|
|
129
136
|
# User preference strategy
|
|
130
137
|
- UserPreferenceMemoryStrategy:
|
|
131
138
|
Name: UserPrefs
|
|
132
|
-
Type: USER_PREFERENCE
|
|
133
139
|
Namespaces:
|
|
134
140
|
- /users/{userId}/preferences
|
|
135
141
|
```
|
|
@@ -150,12 +156,8 @@ agents:
|
|
|
150
156
|
```yaml
|
|
151
157
|
- SemanticMemoryStrategy:
|
|
152
158
|
Name: Search
|
|
153
|
-
Type: SEMANTIC
|
|
154
159
|
Namespaces:
|
|
155
160
|
- /sessions/{sessionId}
|
|
156
|
-
SemanticMemoryConfiguration:
|
|
157
|
-
ModelId: amazon.titan-embed-text-v2:0
|
|
158
|
-
SimilarityThreshold: 0.75
|
|
159
161
|
```
|
|
160
162
|
|
|
161
163
|
**SummaryMemoryStrategy** - Summarize long conversations:
|
|
@@ -163,10 +165,8 @@ agents:
|
|
|
163
165
|
```yaml
|
|
164
166
|
- SummaryMemoryStrategy:
|
|
165
167
|
Name: Summary
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
SummaryModelId: anthropic.claude-3-haiku-20240307-v1:0
|
|
169
|
-
MaxMessages: 100
|
|
168
|
+
Namespaces:
|
|
169
|
+
- /sessions/{sessionId}
|
|
170
170
|
```
|
|
171
171
|
|
|
172
172
|
**UserPreferenceMemoryStrategy** - Track user preferences:
|
|
@@ -174,7 +174,6 @@ agents:
|
|
|
174
174
|
```yaml
|
|
175
175
|
- UserPreferenceMemoryStrategy:
|
|
176
176
|
Name: Preferences
|
|
177
|
-
Type: USER_PREFERENCE
|
|
178
177
|
Namespaces:
|
|
179
178
|
- /users/{userId}
|
|
180
179
|
```
|
|
@@ -184,8 +183,7 @@ agents:
|
|
|
184
183
|
```yaml
|
|
185
184
|
- CustomMemoryStrategy:
|
|
186
185
|
Name: Custom
|
|
187
|
-
|
|
188
|
-
CustomConfiguration:
|
|
186
|
+
Configuration:
|
|
189
187
|
key: value
|
|
190
188
|
```
|
|
191
189
|
|
|
@@ -265,33 +263,65 @@ Integrate external APIs as agent tools.
|
|
|
265
263
|
|
|
266
264
|
```yaml
|
|
267
265
|
agents:
|
|
268
|
-
|
|
266
|
+
# Gateway without authentication
|
|
267
|
+
publicGateway:
|
|
269
268
|
type: gateway
|
|
270
|
-
description:
|
|
271
|
-
|
|
269
|
+
description: Public API gateway
|
|
270
|
+
authorizerType: NONE
|
|
272
271
|
targets:
|
|
273
|
-
|
|
274
|
-
type:
|
|
275
|
-
|
|
272
|
+
- name: WeatherAPI
|
|
273
|
+
type: lambda
|
|
274
|
+
description: Get weather data
|
|
275
|
+
functionArn:
|
|
276
276
|
Fn::GetAtt:
|
|
277
277
|
- WeatherFunction
|
|
278
278
|
- Arn
|
|
279
|
-
|
|
280
|
-
|
|
279
|
+
|
|
280
|
+
# Gateway with JWT authentication
|
|
281
|
+
secureGateway:
|
|
282
|
+
type: gateway
|
|
283
|
+
description: Secure API gateway with JWT auth
|
|
284
|
+
authorizerType: CUSTOM_JWT
|
|
285
|
+
authorizerConfiguration:
|
|
286
|
+
customJwtAuthorizer:
|
|
287
|
+
discoveryUrl: https://cognito-idp.us-east-1.amazonaws.com/us-east-1_xxx/.well-known/openid-configuration
|
|
288
|
+
allowedAudience:
|
|
289
|
+
- my-client-id
|
|
290
|
+
allowedClients:
|
|
291
|
+
- my-app-client
|
|
292
|
+
targets:
|
|
293
|
+
- name: SecureAPI
|
|
294
|
+
type: lambda
|
|
295
|
+
functionArn:
|
|
296
|
+
Fn::GetAtt:
|
|
297
|
+
- SecureFunction
|
|
298
|
+
- Arn
|
|
281
299
|
```
|
|
282
300
|
|
|
283
|
-
| Property
|
|
284
|
-
|
|
|
285
|
-
| `type`
|
|
286
|
-
| `
|
|
287
|
-
| `
|
|
288
|
-
| `
|
|
289
|
-
| `
|
|
301
|
+
| Property | Required | Description |
|
|
302
|
+
| ------------------------------------------------------------- | -------- | ------------------------------------------------------------------ |
|
|
303
|
+
| `type` | Yes | `gateway` |
|
|
304
|
+
| `authorizerType` | No | `NONE`, `AWS_IAM`, or `CUSTOM_JWT` (default: `AWS_IAM`) |
|
|
305
|
+
| `authorizerConfiguration.customJwtAuthorizer` | No\* | JWT authorizer config (required when `authorizerType: CUSTOM_JWT`) |
|
|
306
|
+
| `authorizerConfiguration.customJwtAuthorizer.discoveryUrl` | Yes\*\* | OIDC discovery URL |
|
|
307
|
+
| `authorizerConfiguration.customJwtAuthorizer.allowedAudience` | No | Array of allowed audience values |
|
|
308
|
+
| `authorizerConfiguration.customJwtAuthorizer.allowedClients` | No | Array of allowed client IDs |
|
|
309
|
+
| `protocolType` | No | `MCP` (default: `MCP`) |
|
|
310
|
+
| `targets` | No | Gateway targets (Lambda functions) |
|
|
311
|
+
| `description` | No | Gateway description |
|
|
312
|
+
| `roleArn` | No | Custom IAM role ARN |
|
|
313
|
+
|
|
314
|
+
\*Required when `authorizerType` is `CUSTOM_JWT`
|
|
315
|
+
|
|
316
|
+
\*\*Required when using `customJwtAuthorizer`
|
|
290
317
|
|
|
291
318
|
## Commands
|
|
292
319
|
|
|
293
320
|
```bash
|
|
294
321
|
sls agentcore info # Show defined resources
|
|
322
|
+
sls agentcore build # Build Docker images
|
|
323
|
+
sls agentcore invoke # Invoke a deployed agent
|
|
324
|
+
sls agentcore logs # Fetch logs for a runtime
|
|
295
325
|
sls package # Generate CloudFormation
|
|
296
326
|
sls deploy # Deploy to AWS
|
|
297
327
|
sls remove # Remove deployed resources
|
|
@@ -305,7 +335,7 @@ The `examples/` directory contains complete working examples:
|
|
|
305
335
|
|
|
306
336
|
A comprehensive example showing all resource types working together:
|
|
307
337
|
|
|
308
|
-
- Runtime with Docker
|
|
338
|
+
- Runtime with Docker artifact
|
|
309
339
|
- Memory with multiple strategies
|
|
310
340
|
- Browser for web interactions
|
|
311
341
|
- CodeInterpreter for code execution
|
|
@@ -456,8 +486,8 @@ The memory strategy format has changed to a typed union structure. The legacy fo
|
|
|
456
486
|
strategies:
|
|
457
487
|
- type: semantic
|
|
458
488
|
name: Search
|
|
459
|
-
|
|
460
|
-
|
|
489
|
+
namespaces:
|
|
490
|
+
- /sessions/{sessionId}
|
|
461
491
|
```
|
|
462
492
|
|
|
463
493
|
**New format:**
|
|
@@ -466,9 +496,8 @@ strategies:
|
|
|
466
496
|
strategies:
|
|
467
497
|
- SemanticMemoryStrategy:
|
|
468
498
|
Name: Search
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
ModelId: amazon.titan-embed-text-v2:0
|
|
499
|
+
Namespaces:
|
|
500
|
+
- /sessions/{sessionId}
|
|
472
501
|
```
|
|
473
502
|
|
|
474
503
|
## License
|
package/package.json
CHANGED
package/src/compilers/gateway.js
CHANGED
|
@@ -4,19 +4,28 @@ const { getLogicalId } = require('../utils/naming');
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Build authorizer configuration for the gateway
|
|
7
|
+
* Only used when authorizerType is CUSTOM_JWT
|
|
7
8
|
*
|
|
8
9
|
* @param {Object} authConfig - The authorizer configuration from serverless.yml
|
|
9
10
|
* @returns {Object|null} CloudFormation authorizer configuration or null
|
|
10
11
|
*/
|
|
11
12
|
function buildGatewayAuthorizerConfiguration(authConfig) {
|
|
12
|
-
if (!authConfig) {
|
|
13
|
+
if (!authConfig || !authConfig.customJwtAuthorizer) {
|
|
13
14
|
return null;
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
const jwtConfig = authConfig.customJwtAuthorizer;
|
|
18
|
+
|
|
19
|
+
if (!jwtConfig.discoveryUrl) {
|
|
20
|
+
throw new Error('Gateway CustomJWTAuthorizer requires discoveryUrl');
|
|
21
|
+
}
|
|
22
|
+
|
|
16
23
|
return {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
CustomJWTAuthorizer: {
|
|
25
|
+
DiscoveryUrl: jwtConfig.discoveryUrl,
|
|
26
|
+
...(jwtConfig.allowedAudience && { AllowedAudience: jwtConfig.allowedAudience }),
|
|
27
|
+
...(jwtConfig.allowedClients && { AllowedClients: jwtConfig.allowedClients }),
|
|
28
|
+
},
|
|
20
29
|
};
|
|
21
30
|
}
|
|
22
31
|
|
package/src/compilers/memory.js
CHANGED
|
@@ -109,6 +109,7 @@ function buildMemoryStrategies(strategies) {
|
|
|
109
109
|
if (isLegacyFormat(strategy)) {
|
|
110
110
|
// Emit deprecation warning once per deployment
|
|
111
111
|
if (!deprecationWarningShown) {
|
|
112
|
+
// eslint-disable-next-line no-console -- Intentional user-facing deprecation warning
|
|
112
113
|
console.warn(
|
|
113
114
|
'\x1b[33m%s\x1b[0m', // Yellow color
|
|
114
115
|
'DEPRECATION WARNING: Memory strategy format has changed to typed union structure. ' +
|
package/src/index.js
CHANGED
|
@@ -309,7 +309,7 @@ class ServerlessBedrockAgentCore {
|
|
|
309
309
|
* Validate gateway configuration
|
|
310
310
|
*/
|
|
311
311
|
validateGateway(name, config) {
|
|
312
|
-
const validAuthTypes = ['AWS_IAM', 'CUSTOM_JWT'];
|
|
312
|
+
const validAuthTypes = ['NONE', 'AWS_IAM', 'CUSTOM_JWT'];
|
|
313
313
|
if (config.authorizerType && !validAuthTypes.includes(config.authorizerType)) {
|
|
314
314
|
throw new this.serverless.classes.Error(
|
|
315
315
|
`Gateway '${name}' has invalid authorizerType '${config.authorizerType}'. Valid types: ${validAuthTypes.join(', ')}`
|
package/src/validators/schema.js
CHANGED
|
@@ -126,28 +126,17 @@ function defineAgentsSchema(serverless) {
|
|
|
126
126
|
type: 'array',
|
|
127
127
|
items: {
|
|
128
128
|
type: 'object',
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
},
|
|
134
|
-
name: { type: 'string' },
|
|
135
|
-
namespaces: {
|
|
136
|
-
type: 'array',
|
|
137
|
-
items: { type: 'string' },
|
|
138
|
-
},
|
|
139
|
-
configuration: {
|
|
140
|
-
type: 'object',
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
required: ['type', 'name'],
|
|
129
|
+
// Supports both legacy format and new typed union format
|
|
130
|
+
// Legacy: { type: 'semantic', name: 'Search', ... }
|
|
131
|
+
// New: { SemanticMemoryStrategy: { Name: 'Search', ... } }
|
|
132
|
+
additionalProperties: true,
|
|
144
133
|
},
|
|
145
134
|
},
|
|
146
135
|
|
|
147
136
|
// Gateway-specific properties
|
|
148
137
|
authorizerType: {
|
|
149
138
|
type: 'string',
|
|
150
|
-
enum: ['AWS_IAM', 'CUSTOM_JWT'],
|
|
139
|
+
enum: ['NONE', 'AWS_IAM', 'CUSTOM_JWT'],
|
|
151
140
|
},
|
|
152
141
|
protocolType: {
|
|
153
142
|
type: 'string',
|
|
@@ -156,17 +145,20 @@ function defineAgentsSchema(serverless) {
|
|
|
156
145
|
authorizerConfiguration: {
|
|
157
146
|
type: 'object',
|
|
158
147
|
properties: {
|
|
159
|
-
|
|
160
|
-
type: '
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
148
|
+
customJwtAuthorizer: {
|
|
149
|
+
type: 'object',
|
|
150
|
+
properties: {
|
|
151
|
+
discoveryUrl: { type: 'string' },
|
|
152
|
+
allowedAudience: {
|
|
153
|
+
type: 'array',
|
|
154
|
+
items: { type: 'string' },
|
|
155
|
+
},
|
|
156
|
+
allowedClients: {
|
|
157
|
+
type: 'array',
|
|
158
|
+
items: { type: 'string' },
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
required: ['discoveryUrl'],
|
|
170
162
|
},
|
|
171
163
|
},
|
|
172
164
|
},
|