bedrock-agentcore-starter-toolkit 0.1.12__py3-none-any.whl → 0.1.13__py3-none-any.whl
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.
Potentially problematic release.
This version of bedrock-agentcore-starter-toolkit might be problematic. Click here for more details.
- bedrock_agentcore_starter_toolkit/cli/import_agent/agent_info.py +6 -1
- bedrock_agentcore_starter_toolkit/cli/runtime/commands.py +86 -1
- bedrock_agentcore_starter_toolkit/cli/runtime/configuration_manager.py +53 -0
- bedrock_agentcore_starter_toolkit/operations/memory/__init__.py +1 -0
- bedrock_agentcore_starter_toolkit/operations/memory/constants.py +98 -0
- bedrock_agentcore_starter_toolkit/operations/memory/manager.py +890 -0
- bedrock_agentcore_starter_toolkit/operations/memory/models/DictWrapper.py +51 -0
- bedrock_agentcore_starter_toolkit/operations/memory/models/Memory.py +17 -0
- bedrock_agentcore_starter_toolkit/operations/memory/models/MemoryStrategy.py +17 -0
- bedrock_agentcore_starter_toolkit/operations/memory/models/MemorySummary.py +17 -0
- bedrock_agentcore_starter_toolkit/operations/runtime/configure.py +4 -0
- bedrock_agentcore_starter_toolkit/operations/runtime/create_role.py +3 -2
- bedrock_agentcore_starter_toolkit/operations/runtime/invoke.py +8 -2
- bedrock_agentcore_starter_toolkit/operations/runtime/launch.py +1 -0
- bedrock_agentcore_starter_toolkit/services/codebuild.py +17 -6
- bedrock_agentcore_starter_toolkit/services/runtime.py +71 -5
- bedrock_agentcore_starter_toolkit/utils/runtime/schema.py +1 -0
- bedrock_agentcore_starter_toolkit/utils/runtime/templates/Dockerfile.j2 +25 -11
- {bedrock_agentcore_starter_toolkit-0.1.12.dist-info → bedrock_agentcore_starter_toolkit-0.1.13.dist-info}/METADATA +3 -4
- {bedrock_agentcore_starter_toolkit-0.1.12.dist-info → bedrock_agentcore_starter_toolkit-0.1.13.dist-info}/RECORD +24 -17
- {bedrock_agentcore_starter_toolkit-0.1.12.dist-info → bedrock_agentcore_starter_toolkit-0.1.13.dist-info}/WHEEL +0 -0
- {bedrock_agentcore_starter_toolkit-0.1.12.dist-info → bedrock_agentcore_starter_toolkit-0.1.13.dist-info}/entry_points.txt +0 -0
- {bedrock_agentcore_starter_toolkit-0.1.12.dist-info → bedrock_agentcore_starter_toolkit-0.1.13.dist-info}/licenses/LICENSE.txt +0 -0
- {bedrock_agentcore_starter_toolkit-0.1.12.dist-info → bedrock_agentcore_starter_toolkit-0.1.13.dist-info}/licenses/NOTICE.txt +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Base wrapper class for dictionary-like data structures."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DictWrapper:
|
|
7
|
+
"""A wrapper class that provides both attribute and dictionary-style access to data."""
|
|
8
|
+
|
|
9
|
+
def __init__(self, data: Dict[str, Any]):
|
|
10
|
+
"""Initialize the wrapper with dictionary data.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
data: Dictionary data to wrap. If None, initializes with empty dict.
|
|
14
|
+
"""
|
|
15
|
+
self._data = data if data is not None else {}
|
|
16
|
+
|
|
17
|
+
def __getattr__(self, name: str) -> Any:
|
|
18
|
+
"""Provides direct access to data fields as attributes."""
|
|
19
|
+
return self._data.get(name)
|
|
20
|
+
|
|
21
|
+
def __getitem__(self, key: str) -> Any:
|
|
22
|
+
"""Provides dictionary-style access to data fields."""
|
|
23
|
+
return self._data[key]
|
|
24
|
+
|
|
25
|
+
def get(self, key: str, default: Any = None) -> Any:
|
|
26
|
+
"""Provides dict.get() style access to data fields."""
|
|
27
|
+
return self._data.get(key, default)
|
|
28
|
+
|
|
29
|
+
def __contains__(self, key: str) -> bool:
|
|
30
|
+
"""Support 'in' operator for checking if key exists."""
|
|
31
|
+
return key in self._data
|
|
32
|
+
|
|
33
|
+
def keys(self):
|
|
34
|
+
"""Return keys from the underlying dictionary."""
|
|
35
|
+
return self._data.keys()
|
|
36
|
+
|
|
37
|
+
def values(self):
|
|
38
|
+
"""Return values from the underlying dictionary."""
|
|
39
|
+
return self._data.values()
|
|
40
|
+
|
|
41
|
+
def items(self):
|
|
42
|
+
"""Return items from the underlying dictionary."""
|
|
43
|
+
return self._data.items()
|
|
44
|
+
|
|
45
|
+
def __dir__(self):
|
|
46
|
+
"""Enable tab completion and introspection of available attributes."""
|
|
47
|
+
return list(self._data.keys()) + ["get"]
|
|
48
|
+
|
|
49
|
+
def __repr__(self):
|
|
50
|
+
"""Return string representation of the underlying data."""
|
|
51
|
+
return self._data.__repr__()
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Memory model class for AgentCore Memory resources."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict
|
|
4
|
+
|
|
5
|
+
from .DictWrapper import DictWrapper
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Memory(DictWrapper):
|
|
9
|
+
"""A class representing a memory resource."""
|
|
10
|
+
|
|
11
|
+
def __init__(self, memory: Dict[str, Any]):
|
|
12
|
+
"""Initialize Memory with memory data.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
memory: Dictionary containing memory resource data.
|
|
16
|
+
"""
|
|
17
|
+
super().__init__(memory)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Memory strategy model class for AgentCore Memory resources."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict
|
|
4
|
+
|
|
5
|
+
from .DictWrapper import DictWrapper
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class MemoryStrategy(DictWrapper):
|
|
9
|
+
"""A class representing a memory strategy."""
|
|
10
|
+
|
|
11
|
+
def __init__(self, memory_strategy: Dict[str, Any]):
|
|
12
|
+
"""Initialize MemoryStrategy with strategy data.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
memory_strategy: Dictionary containing memory strategy data.
|
|
16
|
+
"""
|
|
17
|
+
super().__init__(memory_strategy)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Memory summary model class for AgentCore Memory resources."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict
|
|
4
|
+
|
|
5
|
+
from .DictWrapper import DictWrapper
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class MemorySummary(DictWrapper):
|
|
9
|
+
"""A class representing a memory summary."""
|
|
10
|
+
|
|
11
|
+
def __init__(self, memory_summary: Dict[str, Any]):
|
|
12
|
+
"""Initialize MemorySummary with summary data.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
memory_summary: Dictionary containing memory summary data.
|
|
16
|
+
"""
|
|
17
|
+
super().__init__(memory_summary)
|
|
@@ -32,6 +32,7 @@ def configure_bedrock_agentcore(
|
|
|
32
32
|
enable_observability: bool = True,
|
|
33
33
|
requirements_file: Optional[str] = None,
|
|
34
34
|
authorizer_configuration: Optional[Dict[str, Any]] = None,
|
|
35
|
+
request_header_configuration: Optional[Dict[str, Any]] = None,
|
|
35
36
|
verbose: bool = False,
|
|
36
37
|
region: Optional[str] = None,
|
|
37
38
|
protocol: Optional[str] = None,
|
|
@@ -49,6 +50,7 @@ def configure_bedrock_agentcore(
|
|
|
49
50
|
enable_observability: Whether to enable observability
|
|
50
51
|
requirements_file: Path to requirements file
|
|
51
52
|
authorizer_configuration: JWT authorizer configuration dictionary
|
|
53
|
+
request_header_configuration: Request header configuration dictionary
|
|
52
54
|
verbose: Whether to provide verbose output during configuration
|
|
53
55
|
region: AWS region for deployment
|
|
54
56
|
protocol: agent server protocol, must be either HTTP or MCP
|
|
@@ -173,6 +175,7 @@ def configure_bedrock_agentcore(
|
|
|
173
175
|
ecr_repo_display = ecr_repository if ecr_repository else "Auto-create" if ecr_auto_create_value else "N/A"
|
|
174
176
|
log.debug(" ECR repository: %s", ecr_repo_display)
|
|
175
177
|
log.debug(" Enable observability: %s", enable_observability)
|
|
178
|
+
log.debug(" Request header configuration: %s", request_header_configuration)
|
|
176
179
|
|
|
177
180
|
# Create new agent configuration
|
|
178
181
|
config = BedrockAgentCoreAgentSchema(
|
|
@@ -193,6 +196,7 @@ def configure_bedrock_agentcore(
|
|
|
193
196
|
),
|
|
194
197
|
bedrock_agentcore=BedrockAgentCoreDeploymentInfo(),
|
|
195
198
|
authorizer_configuration=authorizer_configuration,
|
|
199
|
+
request_header_configuration=request_header_configuration,
|
|
196
200
|
)
|
|
197
201
|
|
|
198
202
|
# Use simplified config merging
|
|
@@ -375,8 +375,9 @@ def get_or_create_codebuild_execution_role(
|
|
|
375
375
|
},
|
|
376
376
|
{
|
|
377
377
|
"Effect": "Allow",
|
|
378
|
-
"Action": ["s3:GetObject"],
|
|
379
|
-
"Resource": f"arn:aws:s3:::{source_bucket_name}/*",
|
|
378
|
+
"Action": ["s3:GetObject", "s3:PutObject", "s3:ListBucket"],
|
|
379
|
+
"Resource": [f"arn:aws:s3:::{source_bucket_name}", f"arn:aws:s3:::{source_bucket_name}/*"],
|
|
380
|
+
"Condition": {"StringEquals": {"s3:ResourceAccount": account_id}},
|
|
380
381
|
},
|
|
381
382
|
],
|
|
382
383
|
}
|
|
@@ -23,6 +23,7 @@ def invoke_bedrock_agentcore(
|
|
|
23
23
|
bearer_token: Optional[str] = None,
|
|
24
24
|
user_id: Optional[str] = None,
|
|
25
25
|
local_mode: Optional[bool] = False,
|
|
26
|
+
custom_headers: Optional[dict] = None,
|
|
26
27
|
) -> InvokeResult:
|
|
27
28
|
"""Invoke deployed Bedrock AgentCore endpoint."""
|
|
28
29
|
# Load project configuration
|
|
@@ -68,7 +69,7 @@ def invoke_bedrock_agentcore(
|
|
|
68
69
|
|
|
69
70
|
# TODO: store and read port config of local running container
|
|
70
71
|
client = LocalBedrockAgentCoreClient("http://127.0.0.1:8080")
|
|
71
|
-
response = client.invoke_endpoint(session_id, payload_str, workload_access_token)
|
|
72
|
+
response = client.invoke_endpoint(session_id, payload_str, workload_access_token, custom_headers)
|
|
72
73
|
|
|
73
74
|
else:
|
|
74
75
|
if not agent_arn:
|
|
@@ -88,12 +89,17 @@ def invoke_bedrock_agentcore(
|
|
|
88
89
|
payload=payload_str,
|
|
89
90
|
session_id=session_id,
|
|
90
91
|
bearer_token=bearer_token,
|
|
92
|
+
custom_headers=custom_headers,
|
|
91
93
|
)
|
|
92
94
|
else:
|
|
93
95
|
# Use existing boto3 client
|
|
94
96
|
bedrock_agentcore_client = BedrockAgentCoreClient(region)
|
|
95
97
|
response = bedrock_agentcore_client.invoke_endpoint(
|
|
96
|
-
agent_arn=agent_arn,
|
|
98
|
+
agent_arn=agent_arn,
|
|
99
|
+
payload=payload_str,
|
|
100
|
+
session_id=session_id,
|
|
101
|
+
user_id=user_id,
|
|
102
|
+
custom_headers=custom_headers,
|
|
97
103
|
)
|
|
98
104
|
|
|
99
105
|
return InvokeResult(
|
|
@@ -171,6 +171,7 @@ def _deploy_to_bedrock_agentcore(
|
|
|
171
171
|
execution_role_arn=agent_config.aws.execution_role,
|
|
172
172
|
network_config=network_config,
|
|
173
173
|
authorizer_config=agent_config.get_authorizer_configuration(),
|
|
174
|
+
request_header_config=agent_config.request_header_configuration,
|
|
174
175
|
protocol_config=protocol_config,
|
|
175
176
|
env_vars=env_vars,
|
|
176
177
|
auto_update_on_conflict=auto_update_on_conflict,
|
|
@@ -26,6 +26,7 @@ class CodeBuildService:
|
|
|
26
26
|
self.iam_client = session.client("iam")
|
|
27
27
|
self.logger = logging.getLogger(__name__)
|
|
28
28
|
self.source_bucket = None
|
|
29
|
+
self.account_id = session.client("sts").get_caller_identity()["Account"]
|
|
29
30
|
|
|
30
31
|
def get_source_bucket_name(self, account_id: str) -> str:
|
|
31
32
|
"""Get S3 bucket name for CodeBuild sources."""
|
|
@@ -37,10 +38,18 @@ class CodeBuildService:
|
|
|
37
38
|
bucket_name = self.get_source_bucket_name(account_id)
|
|
38
39
|
|
|
39
40
|
try:
|
|
40
|
-
self.s3_client.head_bucket(Bucket=bucket_name)
|
|
41
|
+
self.s3_client.head_bucket(Bucket=bucket_name, ExpectedBucketOwner=account_id)
|
|
41
42
|
self.logger.debug("Using existing S3 bucket: %s", bucket_name)
|
|
42
|
-
except ClientError:
|
|
43
|
-
|
|
43
|
+
except ClientError as e:
|
|
44
|
+
if e.response["Error"]["Code"] == "403":
|
|
45
|
+
self.logger.error("Unable to access bucket %s due to permission constraints", bucket_name)
|
|
46
|
+
raise RuntimeError(
|
|
47
|
+
f"Access Error: Unable to access S3 bucket '{bucket_name}' due to permission constraints. "
|
|
48
|
+
f"The bucket may exist but you don't have sufficient permissions, or it could be "
|
|
49
|
+
f"owned by another account."
|
|
50
|
+
) from e
|
|
51
|
+
|
|
52
|
+
# Create bucket (no ExpectedBucketOwner needed for create_bucket)
|
|
44
53
|
region = self.session.region_name
|
|
45
54
|
if region == "us-east-1":
|
|
46
55
|
self.s3_client.create_bucket(Bucket=bucket_name)
|
|
@@ -49,9 +58,9 @@ class CodeBuildService:
|
|
|
49
58
|
Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": region}
|
|
50
59
|
)
|
|
51
60
|
|
|
52
|
-
# Set lifecycle to cleanup old builds
|
|
53
61
|
self.s3_client.put_bucket_lifecycle_configuration(
|
|
54
62
|
Bucket=bucket_name,
|
|
63
|
+
ExpectedBucketOwner=account_id,
|
|
55
64
|
LifecycleConfiguration={
|
|
56
65
|
"Rules": [{"ID": "DeleteOldBuilds", "Status": "Enabled", "Filter": {}, "Expiration": {"Days": 7}}]
|
|
57
66
|
},
|
|
@@ -63,7 +72,7 @@ class CodeBuildService:
|
|
|
63
72
|
|
|
64
73
|
def upload_source(self, agent_name: str) -> str:
|
|
65
74
|
"""Upload current directory to S3, respecting .dockerignore patterns."""
|
|
66
|
-
account_id = self.
|
|
75
|
+
account_id = self.account_id
|
|
67
76
|
bucket_name = self.ensure_source_bucket(account_id)
|
|
68
77
|
self.source_bucket = bucket_name
|
|
69
78
|
|
|
@@ -101,7 +110,9 @@ class CodeBuildService:
|
|
|
101
110
|
# Create agent-organized S3 key: agentname/source.zip (fixed naming for cache consistency)
|
|
102
111
|
s3_key = f"{agent_name}/source.zip"
|
|
103
112
|
|
|
104
|
-
self.s3_client.upload_file(
|
|
113
|
+
self.s3_client.upload_file(
|
|
114
|
+
temp_zip.name, bucket_name, s3_key, ExtraArgs={"ExpectedBucketOwner": account_id}
|
|
115
|
+
)
|
|
105
116
|
|
|
106
117
|
self.logger.info("Uploaded source to S3: %s", s3_key)
|
|
107
118
|
return f"s3://{bucket_name}/{s3_key}"
|
|
@@ -122,6 +122,7 @@ class BedrockAgentCoreClient:
|
|
|
122
122
|
execution_role_arn: str,
|
|
123
123
|
network_config: Optional[Dict] = None,
|
|
124
124
|
authorizer_config: Optional[Dict] = None,
|
|
125
|
+
request_header_config: Optional[Dict] = None,
|
|
125
126
|
protocol_config: Optional[Dict] = None,
|
|
126
127
|
env_vars: Optional[Dict] = None,
|
|
127
128
|
auto_update_on_conflict: bool = False,
|
|
@@ -142,6 +143,9 @@ class BedrockAgentCoreClient:
|
|
|
142
143
|
if authorizer_config is not None:
|
|
143
144
|
params["authorizerConfiguration"] = authorizer_config
|
|
144
145
|
|
|
146
|
+
if request_header_config is not None:
|
|
147
|
+
params["requestHeaderConfiguration"] = request_header_config
|
|
148
|
+
|
|
145
149
|
if protocol_config is not None:
|
|
146
150
|
params["protocolConfiguration"] = protocol_config
|
|
147
151
|
|
|
@@ -196,6 +200,7 @@ class BedrockAgentCoreClient:
|
|
|
196
200
|
execution_role_arn,
|
|
197
201
|
network_config,
|
|
198
202
|
authorizer_config,
|
|
203
|
+
request_header_config,
|
|
199
204
|
protocol_config,
|
|
200
205
|
env_vars,
|
|
201
206
|
)
|
|
@@ -216,6 +221,7 @@ class BedrockAgentCoreClient:
|
|
|
216
221
|
execution_role_arn: str,
|
|
217
222
|
network_config: Optional[Dict] = None,
|
|
218
223
|
authorizer_config: Optional[Dict] = None,
|
|
224
|
+
request_header_config: Optional[Dict] = None,
|
|
219
225
|
protocol_config: Optional[Dict] = None,
|
|
220
226
|
env_vars: Optional[Dict] = None,
|
|
221
227
|
) -> Dict[str, str]:
|
|
@@ -235,6 +241,9 @@ class BedrockAgentCoreClient:
|
|
|
235
241
|
if authorizer_config is not None:
|
|
236
242
|
params["authorizerConfiguration"] = authorizer_config
|
|
237
243
|
|
|
244
|
+
if request_header_config is not None:
|
|
245
|
+
params["requestHeaderConfiguration"] = request_header_config
|
|
246
|
+
|
|
238
247
|
if protocol_config is not None:
|
|
239
248
|
params["protocolConfiguration"] = protocol_config
|
|
240
249
|
|
|
@@ -297,6 +306,7 @@ class BedrockAgentCoreClient:
|
|
|
297
306
|
execution_role_arn: str,
|
|
298
307
|
network_config: Optional[Dict] = None,
|
|
299
308
|
authorizer_config: Optional[Dict] = None,
|
|
309
|
+
request_header_config: Optional[Dict] = None,
|
|
300
310
|
protocol_config: Optional[Dict] = None,
|
|
301
311
|
env_vars: Optional[Dict] = None,
|
|
302
312
|
auto_update_on_conflict: bool = False,
|
|
@@ -304,7 +314,14 @@ class BedrockAgentCoreClient:
|
|
|
304
314
|
"""Create or update agent."""
|
|
305
315
|
if agent_id:
|
|
306
316
|
return self.update_agent(
|
|
307
|
-
agent_id,
|
|
317
|
+
agent_id,
|
|
318
|
+
image_uri,
|
|
319
|
+
execution_role_arn,
|
|
320
|
+
network_config,
|
|
321
|
+
authorizer_config,
|
|
322
|
+
request_header_config,
|
|
323
|
+
protocol_config,
|
|
324
|
+
env_vars,
|
|
308
325
|
)
|
|
309
326
|
return self.create_agent(
|
|
310
327
|
agent_name,
|
|
@@ -312,6 +329,7 @@ class BedrockAgentCoreClient:
|
|
|
312
329
|
execution_role_arn,
|
|
313
330
|
network_config,
|
|
314
331
|
authorizer_config,
|
|
332
|
+
request_header_config,
|
|
315
333
|
protocol_config,
|
|
316
334
|
env_vars,
|
|
317
335
|
auto_update_on_conflict,
|
|
@@ -416,8 +434,21 @@ class BedrockAgentCoreClient:
|
|
|
416
434
|
session_id: str,
|
|
417
435
|
endpoint_name: str = "DEFAULT",
|
|
418
436
|
user_id: Optional[str] = None,
|
|
437
|
+
custom_headers: Optional[dict] = None,
|
|
419
438
|
) -> Dict:
|
|
420
|
-
"""Invoke agent endpoint.
|
|
439
|
+
"""Invoke agent endpoint.
|
|
440
|
+
|
|
441
|
+
Args:
|
|
442
|
+
agent_arn: Agent ARN to invoke
|
|
443
|
+
payload: Payload to send as string
|
|
444
|
+
session_id: Session ID for the request
|
|
445
|
+
endpoint_name: Endpoint name, defaults to "DEFAULT"
|
|
446
|
+
user_id: Optional user ID for authorization
|
|
447
|
+
custom_headers: Optional custom headers to include in the request
|
|
448
|
+
|
|
449
|
+
Returns:
|
|
450
|
+
Response from the agent endpoint
|
|
451
|
+
"""
|
|
421
452
|
req = {
|
|
422
453
|
"agentRuntimeArn": agent_arn,
|
|
423
454
|
"qualifier": endpoint_name,
|
|
@@ -428,8 +459,27 @@ class BedrockAgentCoreClient:
|
|
|
428
459
|
if user_id:
|
|
429
460
|
req["runtimeUserId"] = user_id
|
|
430
461
|
|
|
431
|
-
|
|
432
|
-
|
|
462
|
+
# Handle custom headers using boto3 event system
|
|
463
|
+
handler_id = None
|
|
464
|
+
if custom_headers:
|
|
465
|
+
# Register a single event handler for all custom headers
|
|
466
|
+
def add_all_headers(request, **kwargs):
|
|
467
|
+
for header_name, header_value in custom_headers.items():
|
|
468
|
+
request.headers.add_header(header_name, header_value)
|
|
469
|
+
|
|
470
|
+
handler_id = self.dataplane_client.meta.events.register_first(
|
|
471
|
+
"before-sign.bedrock-agentcore.InvokeAgentRuntime", add_all_headers
|
|
472
|
+
)
|
|
473
|
+
|
|
474
|
+
try:
|
|
475
|
+
response = self.dataplane_client.invoke_agent_runtime(**req)
|
|
476
|
+
return _handle_aws_response(response)
|
|
477
|
+
finally:
|
|
478
|
+
# Always clean up event handler
|
|
479
|
+
if handler_id is not None:
|
|
480
|
+
self.dataplane_client.meta.events.unregister(
|
|
481
|
+
"before-sign.bedrock-agentcore.InvokeAgentRuntime", handler_id
|
|
482
|
+
)
|
|
433
483
|
|
|
434
484
|
|
|
435
485
|
class HttpBedrockAgentCoreClient:
|
|
@@ -455,6 +505,7 @@ class HttpBedrockAgentCoreClient:
|
|
|
455
505
|
session_id: str,
|
|
456
506
|
bearer_token: Optional[str],
|
|
457
507
|
endpoint_name: str = "DEFAULT",
|
|
508
|
+
custom_headers: Optional[dict] = None,
|
|
458
509
|
) -> Dict:
|
|
459
510
|
"""Invoke agent endpoint using HTTP request with bearer token.
|
|
460
511
|
|
|
@@ -464,6 +515,7 @@ class HttpBedrockAgentCoreClient:
|
|
|
464
515
|
session_id: Session ID for the request
|
|
465
516
|
bearer_token: Bearer token for authentication
|
|
466
517
|
endpoint_name: Endpoint name, defaults to "DEFAULT"
|
|
518
|
+
custom_headers: Optional custom headers to include in the request
|
|
467
519
|
|
|
468
520
|
Returns:
|
|
469
521
|
Response from the agent endpoint
|
|
@@ -480,6 +532,10 @@ class HttpBedrockAgentCoreClient:
|
|
|
480
532
|
"X-Amzn-Bedrock-AgentCore-Runtime-Session-Id": session_id,
|
|
481
533
|
}
|
|
482
534
|
|
|
535
|
+
# Merge custom headers if provided
|
|
536
|
+
if custom_headers:
|
|
537
|
+
headers.update(custom_headers)
|
|
538
|
+
|
|
483
539
|
# Parse the payload string back to JSON object to send properly
|
|
484
540
|
# This ensures consistent payload structure between boto3 and HTTP clients
|
|
485
541
|
try:
|
|
@@ -513,7 +569,13 @@ class LocalBedrockAgentCoreClient:
|
|
|
513
569
|
self.endpoint = endpoint
|
|
514
570
|
self.logger = logging.getLogger("bedrock_agentcore.http_local")
|
|
515
571
|
|
|
516
|
-
def invoke_endpoint(
|
|
572
|
+
def invoke_endpoint(
|
|
573
|
+
self,
|
|
574
|
+
session_id: str,
|
|
575
|
+
payload: str,
|
|
576
|
+
workload_access_token: str,
|
|
577
|
+
custom_headers: Optional[dict] = None,
|
|
578
|
+
):
|
|
517
579
|
"""Invoke the endpoint with the given parameters."""
|
|
518
580
|
from bedrock_agentcore.runtime.models import ACCESS_TOKEN_HEADER, SESSION_HEADER
|
|
519
581
|
|
|
@@ -525,6 +587,10 @@ class LocalBedrockAgentCoreClient:
|
|
|
525
587
|
SESSION_HEADER: session_id,
|
|
526
588
|
}
|
|
527
589
|
|
|
590
|
+
# Merge custom headers if provided
|
|
591
|
+
if custom_headers:
|
|
592
|
+
headers.update(custom_headers)
|
|
593
|
+
|
|
528
594
|
try:
|
|
529
595
|
body = json.loads(payload) if isinstance(payload, str) else payload
|
|
530
596
|
except json.JSONDecodeError:
|
|
@@ -81,6 +81,7 @@ class BedrockAgentCoreAgentSchema(BaseModel):
|
|
|
81
81
|
bedrock_agentcore: BedrockAgentCoreDeploymentInfo = Field(default_factory=BedrockAgentCoreDeploymentInfo)
|
|
82
82
|
codebuild: CodeBuildConfig = Field(default_factory=CodeBuildConfig)
|
|
83
83
|
authorizer_configuration: Optional[dict] = Field(default=None, description="JWT authorizer configuration")
|
|
84
|
+
request_header_configuration: Optional[dict] = Field(default=None, description="Request header configuration")
|
|
84
85
|
oauth_configuration: Optional[dict] = Field(default=None, description="Oauth configuration")
|
|
85
86
|
|
|
86
87
|
def get_authorizer_configuration(self) -> Optional[dict]:
|
|
@@ -1,29 +1,43 @@
|
|
|
1
1
|
FROM ghcr.io/astral-sh/uv:python{{ python_version }}-bookworm-slim
|
|
2
|
+
WORKDIR /app
|
|
2
3
|
|
|
3
|
-
#
|
|
4
|
-
ENV UV_SYSTEM_PYTHON=1 UV_COMPILE_BYTECODE=1
|
|
5
|
-
{% if aws_region %} AWS_REGION={{ aws_region }} AWS_DEFAULT_REGION={{ aws_region }} \
|
|
6
|
-
{% endif %} DOCKER_CONTAINER=1
|
|
4
|
+
# Configure UV for container environment
|
|
5
|
+
ENV UV_SYSTEM_PYTHON=1 UV_COMPILE_BYTECODE=1
|
|
7
6
|
|
|
8
7
|
{% if dependencies_file %}
|
|
9
8
|
{% if dependencies_install_path %}
|
|
10
9
|
COPY {{ dependencies_install_path }} {{ dependencies_install_path }}
|
|
10
|
+
# Install from pyproject.toml directory
|
|
11
|
+
RUN uv pip install {{ dependencies_install_path }}
|
|
11
12
|
{% else %}
|
|
12
13
|
COPY {{ dependencies_file }} {{ dependencies_file }}
|
|
14
|
+
# Install from requirements file
|
|
15
|
+
RUN uv pip install -r {{ dependencies_file }}
|
|
13
16
|
{% endif %}
|
|
14
17
|
{% endif %}
|
|
15
18
|
|
|
16
|
-
{% if
|
|
17
|
-
RUN
|
|
18
|
-
|
|
19
|
+
{% if observability_enabled %}
|
|
20
|
+
RUN uv pip install aws-opentelemetry-distro>=0.10.1
|
|
21
|
+
{% endif %}
|
|
22
|
+
|
|
23
|
+
# Set AWS region environment variable
|
|
24
|
+
{% if aws_region %}
|
|
25
|
+
ENV AWS_REGION={{ aws_region }}
|
|
26
|
+
ENV AWS_DEFAULT_REGION={{ aws_region }}
|
|
19
27
|
{% endif %}
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
# Signal that this is running in Docker for host binding logic
|
|
30
|
+
ENV DOCKER_CONTAINER=1
|
|
22
31
|
|
|
23
|
-
#
|
|
24
|
-
|
|
32
|
+
# Create non-root user
|
|
33
|
+
RUN useradd -m -u 1000 bedrock_agentcore
|
|
34
|
+
USER bedrock_agentcore
|
|
35
|
+
|
|
36
|
+
EXPOSE 8080
|
|
37
|
+
EXPOSE 8000
|
|
38
|
+
|
|
39
|
+
# Copy entire project (respecting .dockerignore)
|
|
25
40
|
COPY . .
|
|
26
|
-
{% endif %}
|
|
27
41
|
|
|
28
42
|
# Use the full module path
|
|
29
43
|
{% if observability_enabled %}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bedrock-agentcore-starter-toolkit
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.13
|
|
4
4
|
Summary: A starter toolkit for using Bedrock AgentCore
|
|
5
5
|
Project-URL: Homepage, https://github.com/aws/bedrock-agentcore-starter-toolkit
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/aws/bedrock-agentcore-starter-toolkit/issues
|
|
@@ -23,8 +23,8 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
23
23
|
Requires-Python: >=3.10
|
|
24
24
|
Requires-Dist: autopep8>=2.3.2
|
|
25
25
|
Requires-Dist: bedrock-agentcore>=0.1.4
|
|
26
|
-
Requires-Dist: boto3>=1.
|
|
27
|
-
Requires-Dist: botocore>=1.
|
|
26
|
+
Requires-Dist: boto3>=1.40.35
|
|
27
|
+
Requires-Dist: botocore>=1.40.35
|
|
28
28
|
Requires-Dist: docstring-parser<1.0,>=0.15
|
|
29
29
|
Requires-Dist: httpx>=0.28.1
|
|
30
30
|
Requires-Dist: jinja2>=3.1.6
|
|
@@ -38,7 +38,6 @@ Requires-Dist: questionary>=2.1.0
|
|
|
38
38
|
Requires-Dist: requests>=2.25.0
|
|
39
39
|
Requires-Dist: rich>=13.0.0
|
|
40
40
|
Requires-Dist: ruamel-yaml>=0.18.14
|
|
41
|
-
Requires-Dist: strands-agents>=1.7.1
|
|
42
41
|
Requires-Dist: toml>=0.10.2
|
|
43
42
|
Requires-Dist: typer>=0.16.0
|
|
44
43
|
Requires-Dist: typing-extensions<5.0.0,>=4.13.2
|
|
@@ -6,11 +6,11 @@ bedrock_agentcore_starter_toolkit/cli/gateway/__init__.py,sha256=8IZ0kSe6Kz5s2j-
|
|
|
6
6
|
bedrock_agentcore_starter_toolkit/cli/gateway/commands.py,sha256=3DuXCvqXlmHU2cmjGzDruyc2Fkrpgoi158myj0vc3nA,3265
|
|
7
7
|
bedrock_agentcore_starter_toolkit/cli/import_agent/README.md,sha256=e7WJz4dagYU2HrGmgSr6Skk7gl_Um8pGKlGKCSAF9rk,2291
|
|
8
8
|
bedrock_agentcore_starter_toolkit/cli/import_agent/__init__.py,sha256=tyM3dXM3Tce3me6roMG4N3nsrfpj3jgCJne5fbobvmI,54
|
|
9
|
-
bedrock_agentcore_starter_toolkit/cli/import_agent/agent_info.py,sha256=
|
|
9
|
+
bedrock_agentcore_starter_toolkit/cli/import_agent/agent_info.py,sha256=CcPXbKNnI9fc7NyFmZBjB3PkB0wAz2Q_kBGoUVcnngA,9736
|
|
10
10
|
bedrock_agentcore_starter_toolkit/cli/import_agent/commands.py,sha256=vpA66fGwKf6cxBelT3Yb_Af5Ow3AMquGLIDe-tBLjmc,22419
|
|
11
11
|
bedrock_agentcore_starter_toolkit/cli/runtime/__init__.py,sha256=0zKPPoYThoDIr3DZhIQJavq5nVTKRsgcE1s9--wx118,60
|
|
12
|
-
bedrock_agentcore_starter_toolkit/cli/runtime/commands.py,sha256=
|
|
13
|
-
bedrock_agentcore_starter_toolkit/cli/runtime/configuration_manager.py,sha256=
|
|
12
|
+
bedrock_agentcore_starter_toolkit/cli/runtime/commands.py,sha256=pqX5E29eF8syiu1guxJJpWsYXPa273CxgvG9gv0gJR4,49138
|
|
13
|
+
bedrock_agentcore_starter_toolkit/cli/runtime/configuration_manager.py,sha256=ye0Dr-Hf6LUyJGU0TAFFXIDmBru0rqmAxSl389IIKkk,8875
|
|
14
14
|
bedrock_agentcore_starter_toolkit/notebook/__init__.py,sha256=wH1ZzIVKsKT_P0qX2kIIoyVxeHj8K40odfR1YI3McHw,129
|
|
15
15
|
bedrock_agentcore_starter_toolkit/notebook/runtime/__init__.py,sha256=DoGfB_uGFLANJVE9rSZtTH3ymw76WBWmD9vORvBIdXs,66
|
|
16
16
|
bedrock_agentcore_starter_toolkit/notebook/runtime/bedrock_agentcore.py,sha256=UvG-X9Ny_z4VhMG8BNTy-OaZMFU4VIQ8QIHz2lm7Dyo,15328
|
|
@@ -21,18 +21,25 @@ bedrock_agentcore_starter_toolkit/operations/gateway/constants.py,sha256=0_4J6BN
|
|
|
21
21
|
bedrock_agentcore_starter_toolkit/operations/gateway/create_lambda.py,sha256=MQsBJfUj26zBh7LqYWLoekHuvbAHIJE8qcXwrmJOhM0,2875
|
|
22
22
|
bedrock_agentcore_starter_toolkit/operations/gateway/create_role.py,sha256=Oma9s6K4T9EFgwPAUDungDL9fGa3W0LsHBknIXUmSpI,4474
|
|
23
23
|
bedrock_agentcore_starter_toolkit/operations/gateway/exceptions.py,sha256=WjsrE7lT2708CJniM_ISMzkfNX4IUteGgvOxleD9JZY,272
|
|
24
|
+
bedrock_agentcore_starter_toolkit/operations/memory/__init__.py,sha256=PAj25QAlnlvjaQIgfIpfxXXVXu5BTOXy-xDMDh6_HIc,59
|
|
25
|
+
bedrock_agentcore_starter_toolkit/operations/memory/constants.py,sha256=E7jBvcXAHXoj9jOlpkN1bpoUqMsb-Ji-NQie6P1eIoQ,3583
|
|
26
|
+
bedrock_agentcore_starter_toolkit/operations/memory/manager.py,sha256=OJG3uOhRH9LuXlAL317nL8FbhOr1uiboxXgagyBzj7A,35708
|
|
27
|
+
bedrock_agentcore_starter_toolkit/operations/memory/models/DictWrapper.py,sha256=GtPnR2NoZ9BXZX4fFYupG97T-YEet2NrBFlaDZIS-gM,1693
|
|
28
|
+
bedrock_agentcore_starter_toolkit/operations/memory/models/Memory.py,sha256=As1b9al57zlYWUAHcwIuHjL-6QAsfH_zhxD8xU9gh3I,424
|
|
29
|
+
bedrock_agentcore_starter_toolkit/operations/memory/models/MemoryStrategy.py,sha256=CnVfWqrSWefSxK5Oh1jllZRr1_JTnUvROLuuqTVVlWM,478
|
|
30
|
+
bedrock_agentcore_starter_toolkit/operations/memory/models/MemorySummary.py,sha256=H5Itj_R3XKaUHJk4_8N_ViAfwkI-9wDhBrmOQq570Sw,469
|
|
24
31
|
bedrock_agentcore_starter_toolkit/operations/runtime/__init__.py,sha256=0jRUuwSoqh4R_WqzfP4XAXngrgyFK5uH8JGXUVars6Y,793
|
|
25
|
-
bedrock_agentcore_starter_toolkit/operations/runtime/configure.py,sha256=
|
|
26
|
-
bedrock_agentcore_starter_toolkit/operations/runtime/create_role.py,sha256=
|
|
32
|
+
bedrock_agentcore_starter_toolkit/operations/runtime/configure.py,sha256=MUCd_pJaGnA1BhYn7KRjP6D4xWBz0g8fjkwxA0ZkE_8,9354
|
|
33
|
+
bedrock_agentcore_starter_toolkit/operations/runtime/create_role.py,sha256=1-b_wBvkOXNh-HJsxATwHfXQqj0dpdETds0FNSTY0BE,16116
|
|
27
34
|
bedrock_agentcore_starter_toolkit/operations/runtime/destroy.py,sha256=XuQQ_fBetQxanIZQx5MMvKYQGbaUHqU9JwJXZOeraco,23541
|
|
28
|
-
bedrock_agentcore_starter_toolkit/operations/runtime/invoke.py,sha256=
|
|
29
|
-
bedrock_agentcore_starter_toolkit/operations/runtime/launch.py,sha256=
|
|
35
|
+
bedrock_agentcore_starter_toolkit/operations/runtime/invoke.py,sha256=QduqWCu4Buszcg50IKCkNHxbUMERf4CXb3bX4YP_9Ew,4764
|
|
36
|
+
bedrock_agentcore_starter_toolkit/operations/runtime/launch.py,sha256=o5SEVCIFKJKcGrcraKMyuLL9-4dBY0LoLsTyIVWk3ZI,20009
|
|
30
37
|
bedrock_agentcore_starter_toolkit/operations/runtime/models.py,sha256=iSpD6Zc-FyS4Fu_oRzXzre4N9uYuzBMDkvZZx4MhBGE,4220
|
|
31
38
|
bedrock_agentcore_starter_toolkit/operations/runtime/status.py,sha256=tpOtzAq1S3z_7baxR_WOT8Avo3MtWKGpelVOOfb-uMA,2516
|
|
32
39
|
bedrock_agentcore_starter_toolkit/services/__init__.py,sha256=s7QtYYFCCX2ff0gZHUdDxCDI3zhUq0fPsjevZbF9xdA,66
|
|
33
|
-
bedrock_agentcore_starter_toolkit/services/codebuild.py,sha256
|
|
40
|
+
bedrock_agentcore_starter_toolkit/services/codebuild.py,sha256=-ys84zixz2Y4g3kATnITrQ5cjREU_aZjjgMc3D_giFU,14311
|
|
34
41
|
bedrock_agentcore_starter_toolkit/services/ecr.py,sha256=nW9wIZcXI6amZeLVSmM9F6awVBQP1-zrFXTozSNEDjo,2805
|
|
35
|
-
bedrock_agentcore_starter_toolkit/services/runtime.py,sha256=
|
|
42
|
+
bedrock_agentcore_starter_toolkit/services/runtime.py,sha256=NmjsGfOfdUr-ySFB6hDd9YjIFJsdRied-yVCQhbcOdI,22365
|
|
36
43
|
bedrock_agentcore_starter_toolkit/services/xray.py,sha256=CRlcfVXpghVy7PvZqLUC4rp49Sw5DQ98rUU61HAluRM,6363
|
|
37
44
|
bedrock_agentcore_starter_toolkit/services/import_agent/__init__.py,sha256=ig-xanZqA3oJdRTucYz9xF9_2yi31ADRVIKFsnIw_l4,68
|
|
38
45
|
bedrock_agentcore_starter_toolkit/services/import_agent/utils.py,sha256=yCnzqv3S8sbQi6ArTz3MeR4ggRcojbAgMbBb7KAf0sA,16077
|
|
@@ -51,14 +58,14 @@ bedrock_agentcore_starter_toolkit/utils/runtime/container.py,sha256=wGJLxwT2mhTG
|
|
|
51
58
|
bedrock_agentcore_starter_toolkit/utils/runtime/entrypoint.py,sha256=d-XjEwvQOdpRHvBGLdIBCs1fgUwNwB0EL_WkcdQXwXQ,5893
|
|
52
59
|
bedrock_agentcore_starter_toolkit/utils/runtime/logs.py,sha256=ZZ9PD4QO0BSms5KphhUb3-6-IPTkmwkY-Zn2AWM9Aew,1601
|
|
53
60
|
bedrock_agentcore_starter_toolkit/utils/runtime/policy_template.py,sha256=CgER7YXPh0BpR6JcTcumDL_k8bhmfLSEok1sf09-31I,2054
|
|
54
|
-
bedrock_agentcore_starter_toolkit/utils/runtime/schema.py,sha256=
|
|
55
|
-
bedrock_agentcore_starter_toolkit/utils/runtime/templates/Dockerfile.j2,sha256=
|
|
61
|
+
bedrock_agentcore_starter_toolkit/utils/runtime/schema.py,sha256=KqNlF8_va5GuOVoUWMN2lT5QenJwgqG_3i_mQ-FPHJw,6533
|
|
62
|
+
bedrock_agentcore_starter_toolkit/utils/runtime/templates/Dockerfile.j2,sha256=0KmVBMP3ZeCrt7dQ5cR8WTvI8ZVt_SFgHYRxn6DYMfA,1261
|
|
56
63
|
bedrock_agentcore_starter_toolkit/utils/runtime/templates/dockerignore.template,sha256=b_70sBi0MwkTuA9TqxPqFcWK7TcmpaXBJ6M2Ipox65Q,691
|
|
57
64
|
bedrock_agentcore_starter_toolkit/utils/runtime/templates/execution_role_policy.json.j2,sha256=-0AXT46IYVQr4fwueXTQ0FVXcCshZFNx7-2mViR34Co,4941
|
|
58
65
|
bedrock_agentcore_starter_toolkit/utils/runtime/templates/execution_role_trust_policy.json.j2,sha256=PPJF6Ofq70W5DUE0NlbmnZjw5RkgepPgkskxEgEG28o,473
|
|
59
|
-
bedrock_agentcore_starter_toolkit-0.1.
|
|
60
|
-
bedrock_agentcore_starter_toolkit-0.1.
|
|
61
|
-
bedrock_agentcore_starter_toolkit-0.1.
|
|
62
|
-
bedrock_agentcore_starter_toolkit-0.1.
|
|
63
|
-
bedrock_agentcore_starter_toolkit-0.1.
|
|
64
|
-
bedrock_agentcore_starter_toolkit-0.1.
|
|
66
|
+
bedrock_agentcore_starter_toolkit-0.1.13.dist-info/METADATA,sha256=SFM1-1WtcP0J8YTi9HZk0l3a5kacFIuw5I5EkTkFP9M,9999
|
|
67
|
+
bedrock_agentcore_starter_toolkit-0.1.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
68
|
+
bedrock_agentcore_starter_toolkit-0.1.13.dist-info/entry_points.txt,sha256=Tf94DkUf2Tp8P7p8MEXLxre7A7Pp_XNukteiz0wHnk8,77
|
|
69
|
+
bedrock_agentcore_starter_toolkit-0.1.13.dist-info/licenses/LICENSE.txt,sha256=nNPOMinitYdtfbhdQgsPgz1UowBznU6QVN3Xs0pSTKU,10768
|
|
70
|
+
bedrock_agentcore_starter_toolkit-0.1.13.dist-info/licenses/NOTICE.txt,sha256=rkBsg8DbKqfIoQbveqX9foR4uJPUVAokbkr02pRPilE,8674
|
|
71
|
+
bedrock_agentcore_starter_toolkit-0.1.13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|