bedrock-agentcore-starter-toolkit 0.1.11__py3-none-any.whl → 0.1.12__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/runtime/commands.py +15 -3
- bedrock_agentcore_starter_toolkit/cli/runtime/configuration_manager.py +15 -1
- bedrock_agentcore_starter_toolkit/operations/gateway/client.py +139 -0
- {bedrock_agentcore_starter_toolkit-0.1.11.dist-info → bedrock_agentcore_starter_toolkit-0.1.12.dist-info}/METADATA +17 -1
- {bedrock_agentcore_starter_toolkit-0.1.11.dist-info → bedrock_agentcore_starter_toolkit-0.1.12.dist-info}/RECORD +9 -9
- {bedrock_agentcore_starter_toolkit-0.1.11.dist-info → bedrock_agentcore_starter_toolkit-0.1.12.dist-info}/WHEEL +0 -0
- {bedrock_agentcore_starter_toolkit-0.1.11.dist-info → bedrock_agentcore_starter_toolkit-0.1.12.dist-info}/entry_points.txt +0 -0
- {bedrock_agentcore_starter_toolkit-0.1.11.dist-info → bedrock_agentcore_starter_toolkit-0.1.12.dist-info}/licenses/LICENSE.txt +0 -0
- {bedrock_agentcore_starter_toolkit-0.1.11.dist-info → bedrock_agentcore_starter_toolkit-0.1.12.dist-info}/licenses/NOTICE.txt +0 -0
|
@@ -68,7 +68,7 @@ def _prompt_for_requirements_file(prompt_text: str, default: str = "") -> Option
|
|
|
68
68
|
return None
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
def _handle_requirements_file_display(requirements_file: Optional[str]) -> Optional[str]:
|
|
71
|
+
def _handle_requirements_file_display(requirements_file: Optional[str], non_interactive: bool = False) -> Optional[str]:
|
|
72
72
|
"""Handle requirements file with display logic for CLI."""
|
|
73
73
|
from ...utils.runtime.entrypoint import detect_dependencies
|
|
74
74
|
|
|
@@ -76,6 +76,15 @@ def _handle_requirements_file_display(requirements_file: Optional[str]) -> Optio
|
|
|
76
76
|
# User provided file - validate and show confirmation
|
|
77
77
|
return _validate_requirements_file(requirements_file)
|
|
78
78
|
|
|
79
|
+
if non_interactive:
|
|
80
|
+
# Auto-detection for non-interactive mode
|
|
81
|
+
deps = detect_dependencies(Path.cwd())
|
|
82
|
+
if deps.found:
|
|
83
|
+
_print_success(f"Using detected file: [dim]{deps.file}[/dim]")
|
|
84
|
+
return None # Use detected file
|
|
85
|
+
else:
|
|
86
|
+
_handle_error("No requirements file specified and none found automatically")
|
|
87
|
+
|
|
79
88
|
# Auto-detection with interactive prompt
|
|
80
89
|
deps = detect_dependencies(Path.cwd())
|
|
81
90
|
|
|
@@ -170,6 +179,9 @@ def configure(
|
|
|
170
179
|
verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable verbose output"),
|
|
171
180
|
region: Optional[str] = typer.Option(None, "--region", "-r"),
|
|
172
181
|
protocol: Optional[str] = typer.Option(None, "--protocol", "-p", help="Server protocol (HTTP or MCP)"),
|
|
182
|
+
non_interactive: bool = typer.Option(
|
|
183
|
+
False, "--non-interactive", "-ni", help="Skip prompts; use defaults unless overridden"
|
|
184
|
+
),
|
|
173
185
|
):
|
|
174
186
|
"""Configure a Bedrock AgentCore agent. The agent name defaults to your Python file name."""
|
|
175
187
|
if ctx.invoked_subcommand is not None:
|
|
@@ -196,7 +208,7 @@ def configure(
|
|
|
196
208
|
|
|
197
209
|
# Create configuration manager for clean, elegant prompting
|
|
198
210
|
config_path = Path.cwd() / ".bedrock_agentcore.yaml"
|
|
199
|
-
config_manager = ConfigurationManager(config_path)
|
|
211
|
+
config_manager = ConfigurationManager(config_path, non_interactive)
|
|
200
212
|
|
|
201
213
|
# Interactive prompts for missing values - clean and elegant
|
|
202
214
|
if not execution_role:
|
|
@@ -217,7 +229,7 @@ def configure(
|
|
|
217
229
|
_print_success(f"Using existing ECR repository: [dim]{ecr_repository}[/dim]")
|
|
218
230
|
|
|
219
231
|
# Handle dependency file selection with simplified logic
|
|
220
|
-
final_requirements_file = _handle_requirements_file_display(requirements_file)
|
|
232
|
+
final_requirements_file = _handle_requirements_file_display(requirements_file, non_interactive)
|
|
221
233
|
|
|
222
234
|
# Handle OAuth authorization configuration
|
|
223
235
|
oauth_config = None
|
|
@@ -10,19 +10,25 @@ from ..common import _handle_error, _print_success, _prompt_with_default, consol
|
|
|
10
10
|
class ConfigurationManager:
|
|
11
11
|
"""Manages interactive configuration prompts with existing configuration defaults."""
|
|
12
12
|
|
|
13
|
-
def __init__(self, config_path: Path):
|
|
13
|
+
def __init__(self, config_path: Path, non_interactive: bool = False):
|
|
14
14
|
"""Initialize the ConfigPrompt with a configuration path.
|
|
15
15
|
|
|
16
16
|
Args:
|
|
17
17
|
config_path: Path to the configuration file
|
|
18
|
+
non_interactive: If True, use defaults without prompting
|
|
18
19
|
"""
|
|
19
20
|
from ...utils.runtime.config import load_config_if_exists
|
|
20
21
|
|
|
21
22
|
project_config = load_config_if_exists(config_path)
|
|
22
23
|
self.existing_config = project_config.get_agent_config() if project_config else None
|
|
24
|
+
self.non_interactive = non_interactive
|
|
23
25
|
|
|
24
26
|
def prompt_execution_role(self) -> Optional[str]:
|
|
25
27
|
"""Prompt for execution role. Returns role name/ARN or None for auto-creation."""
|
|
28
|
+
if self.non_interactive:
|
|
29
|
+
_print_success("Will auto-create execution role")
|
|
30
|
+
return None
|
|
31
|
+
|
|
26
32
|
console.print("\n🔐 [cyan]Execution Role[/cyan]")
|
|
27
33
|
console.print(
|
|
28
34
|
"[dim]Press Enter to auto-create execution role, or provide execution role ARN/name to use existing[/dim]"
|
|
@@ -43,6 +49,10 @@ class ConfigurationManager:
|
|
|
43
49
|
|
|
44
50
|
def prompt_ecr_repository(self) -> tuple[Optional[str], bool]:
|
|
45
51
|
"""Prompt for ECR repository. Returns (repository, auto_create_flag)."""
|
|
52
|
+
if self.non_interactive:
|
|
53
|
+
_print_success("Will auto-create ECR repository")
|
|
54
|
+
return None, True
|
|
55
|
+
|
|
46
56
|
console.print("\n🏗️ [cyan]ECR Repository[/cyan]")
|
|
47
57
|
console.print(
|
|
48
58
|
"[dim]Press Enter to auto-create ECR repository, or provide ECR Repository URI to use existing[/dim]"
|
|
@@ -63,6 +73,10 @@ class ConfigurationManager:
|
|
|
63
73
|
|
|
64
74
|
def prompt_oauth_config(self) -> Optional[dict]:
|
|
65
75
|
"""Prompt for OAuth configuration. Returns OAuth config dict or None."""
|
|
76
|
+
if self.non_interactive:
|
|
77
|
+
_print_success("Using default IAM authorization")
|
|
78
|
+
return None
|
|
79
|
+
|
|
66
80
|
console.print("\n🔐 [cyan]Authorization Configuration[/cyan]")
|
|
67
81
|
console.print("[dim]By default, Bedrock AgentCore uses IAM authorization.[/dim]")
|
|
68
82
|
|
|
@@ -176,6 +176,145 @@ class GatewayClient:
|
|
|
176
176
|
self.logger.info("\n✅Target is ready")
|
|
177
177
|
return target
|
|
178
178
|
|
|
179
|
+
def fix_iam_permissions(self, gateway: dict) -> None:
|
|
180
|
+
"""Fix IAM role trust policy for the gateway.
|
|
181
|
+
|
|
182
|
+
:param gateway: the gateway dict containing roleArn
|
|
183
|
+
"""
|
|
184
|
+
# Check for None gateway
|
|
185
|
+
if gateway is None:
|
|
186
|
+
return
|
|
187
|
+
|
|
188
|
+
# Check for missing roleArn
|
|
189
|
+
role_arn = gateway.get("roleArn")
|
|
190
|
+
if not role_arn:
|
|
191
|
+
return
|
|
192
|
+
|
|
193
|
+
sts = boto3.client("sts")
|
|
194
|
+
iam = boto3.client("iam")
|
|
195
|
+
|
|
196
|
+
account_id = sts.get_caller_identity()["Account"]
|
|
197
|
+
role_name = role_arn.split("/")[-1]
|
|
198
|
+
|
|
199
|
+
# Update trust policy
|
|
200
|
+
trust_policy = {
|
|
201
|
+
"Version": "2012-10-17",
|
|
202
|
+
"Statement": [
|
|
203
|
+
{
|
|
204
|
+
"Effect": "Allow",
|
|
205
|
+
"Principal": {"Service": "bedrock-agentcore.amazonaws.com"},
|
|
206
|
+
"Action": "sts:AssumeRole",
|
|
207
|
+
"Condition": {
|
|
208
|
+
"StringEquals": {"aws:SourceAccount": account_id},
|
|
209
|
+
"ArnLike": {"aws:SourceArn": f"arn:aws:bedrock-agentcore:{self.region}:{account_id}:*"},
|
|
210
|
+
},
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
try:
|
|
216
|
+
iam.update_assume_role_policy(RoleName=role_name, PolicyDocument=json.dumps(trust_policy))
|
|
217
|
+
|
|
218
|
+
# Add Lambda permissions
|
|
219
|
+
iam.put_role_policy(
|
|
220
|
+
RoleName=role_name,
|
|
221
|
+
PolicyName="LambdaInvokePolicy",
|
|
222
|
+
PolicyDocument=json.dumps(
|
|
223
|
+
{
|
|
224
|
+
"Version": "2012-10-17",
|
|
225
|
+
"Statement": [
|
|
226
|
+
{
|
|
227
|
+
"Effect": "Allow",
|
|
228
|
+
"Action": ["lambda:InvokeFunction"],
|
|
229
|
+
"Resource": (
|
|
230
|
+
f"arn:aws:lambda:{self.region}:{account_id}:function:AgentCoreLambdaTestFunction"
|
|
231
|
+
),
|
|
232
|
+
}
|
|
233
|
+
],
|
|
234
|
+
}
|
|
235
|
+
),
|
|
236
|
+
)
|
|
237
|
+
self.logger.info("✓ Fixed IAM permissions for Gateway")
|
|
238
|
+
except Exception as e:
|
|
239
|
+
self.logger.warning("⚠️ IAM role update failed: %s. Continuing with best effort.", str(e))
|
|
240
|
+
|
|
241
|
+
def cleanup_gateway(self, gateway_id: str, client_info: Optional[Dict] = None) -> None:
|
|
242
|
+
"""Remove all resources associated with a gateway.
|
|
243
|
+
|
|
244
|
+
:param gateway_id: the ID of the gateway to clean up
|
|
245
|
+
:param client_info: optional Cognito client info for cleanup
|
|
246
|
+
"""
|
|
247
|
+
self.logger.info("🧹 Cleaning up Gateway resources...")
|
|
248
|
+
|
|
249
|
+
gateway_client = self.client
|
|
250
|
+
|
|
251
|
+
# Step 1: List and delete all targets
|
|
252
|
+
self.logger.info(" • Finding targets for gateway: %s", gateway_id)
|
|
253
|
+
|
|
254
|
+
try:
|
|
255
|
+
response = gateway_client.list_gateway_targets(gatewayIdentifier=gateway_id)
|
|
256
|
+
# API returns targets in 'items' field
|
|
257
|
+
targets = response.get("items", [])
|
|
258
|
+
self.logger.info(" Found %s targets to delete", len(targets))
|
|
259
|
+
|
|
260
|
+
for target in targets:
|
|
261
|
+
target_id = target["targetId"]
|
|
262
|
+
self.logger.info(" • Deleting target: %s", target_id)
|
|
263
|
+
try:
|
|
264
|
+
gateway_client.delete_gateway_target(gatewayIdentifier=gateway_id, targetId=target_id)
|
|
265
|
+
self.logger.info(" ✓ Target deletion initiated: %s", target_id)
|
|
266
|
+
# Wait for deletion to complete
|
|
267
|
+
time.sleep(5)
|
|
268
|
+
except Exception as e:
|
|
269
|
+
self.logger.warning(" ⚠️ Error deleting target %s: %s", target_id, str(e))
|
|
270
|
+
|
|
271
|
+
# Verify all targets are deleted
|
|
272
|
+
self.logger.info(" • Verifying targets deletion...")
|
|
273
|
+
time.sleep(5) # Additional wait
|
|
274
|
+
verify_response = gateway_client.list_gateway_targets(gatewayIdentifier=gateway_id)
|
|
275
|
+
remaining_targets = verify_response.get("items", [])
|
|
276
|
+
if remaining_targets:
|
|
277
|
+
self.logger.warning(" ⚠️ %s targets still remain", len(remaining_targets))
|
|
278
|
+
else:
|
|
279
|
+
self.logger.info(" ✓ All targets deleted")
|
|
280
|
+
|
|
281
|
+
except Exception as e:
|
|
282
|
+
self.logger.warning(" ⚠️ Error managing targets: %s", str(e))
|
|
283
|
+
|
|
284
|
+
# Step 2: Delete the gateway
|
|
285
|
+
try:
|
|
286
|
+
self.logger.info(" • Deleting gateway: %s", gateway_id)
|
|
287
|
+
gateway_client.delete_gateway(gatewayIdentifier=gateway_id)
|
|
288
|
+
self.logger.info(" ✓ Gateway deleted: %s", gateway_id)
|
|
289
|
+
except Exception as e:
|
|
290
|
+
self.logger.warning(" ⚠️ Error deleting gateway: %s", str(e))
|
|
291
|
+
|
|
292
|
+
# Step 3: Delete Cognito resources if provided
|
|
293
|
+
if client_info and "user_pool_id" in client_info:
|
|
294
|
+
cognito = boto3.client("cognito-idp", region_name=self.region)
|
|
295
|
+
user_pool_id = client_info["user_pool_id"]
|
|
296
|
+
|
|
297
|
+
# Delete domain first
|
|
298
|
+
if "domain_prefix" in client_info:
|
|
299
|
+
domain_prefix = client_info["domain_prefix"]
|
|
300
|
+
self.logger.info(" • Deleting Cognito domain: %s", domain_prefix)
|
|
301
|
+
try:
|
|
302
|
+
cognito.delete_user_pool_domain(UserPoolId=user_pool_id, Domain=domain_prefix)
|
|
303
|
+
self.logger.info(" ✓ Cognito domain deleted")
|
|
304
|
+
time.sleep(5) # Wait for domain deletion
|
|
305
|
+
except Exception as e:
|
|
306
|
+
self.logger.warning(" ⚠️ Error deleting Cognito domain: %s", str(e))
|
|
307
|
+
|
|
308
|
+
# Now delete the user pool
|
|
309
|
+
self.logger.info(" • Deleting Cognito user pool: %s", user_pool_id)
|
|
310
|
+
try:
|
|
311
|
+
cognito.delete_user_pool(UserPoolId=user_pool_id)
|
|
312
|
+
self.logger.info(" ✓ Cognito user pool deleted")
|
|
313
|
+
except Exception as e:
|
|
314
|
+
self.logger.warning(" ⚠️ Error deleting Cognito user pool: %s", str(e))
|
|
315
|
+
|
|
316
|
+
self.logger.info("✅ Cleanup complete")
|
|
317
|
+
|
|
179
318
|
def __handle_lambda_target_creation(self, role_arn: str) -> Dict[str, Any]:
|
|
180
319
|
"""Create a test lambda.
|
|
181
320
|
|
|
@@ -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.12
|
|
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
|
|
@@ -126,6 +126,22 @@ AgentCore Import-Agent enables seamless migration of existing Amazon Bedrock Age
|
|
|
126
126
|
|
|
127
127
|
Bedrock AgentCore is currently in public preview.
|
|
128
128
|
|
|
129
|
+
## Installation
|
|
130
|
+
|
|
131
|
+
### Quick Start
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Install uv if you haven't already
|
|
135
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
136
|
+
|
|
137
|
+
# Install using uv (recommended)
|
|
138
|
+
uv pip install bedrock-agentcore-starter-toolkit
|
|
139
|
+
|
|
140
|
+
# Or alternatively with pip
|
|
141
|
+
pip install bedrock-agentcore-starter-toolkit
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
|
|
129
145
|
## 📝 License & Contributing
|
|
130
146
|
|
|
131
147
|
- **License:** Apache 2.0 - see [LICENSE.txt](LICENSE.txt)
|
|
@@ -9,14 +9,14 @@ bedrock_agentcore_starter_toolkit/cli/import_agent/__init__.py,sha256=tyM3dXM3Tc
|
|
|
9
9
|
bedrock_agentcore_starter_toolkit/cli/import_agent/agent_info.py,sha256=V0fZEbV76_H3gmkA17yscyJ8UdcMAquzNqENQ9DXdHA,9477
|
|
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=nBRT37Ydbhq5rnJdXidjFdHLCKJtk_ifSvIjPTsYdnU,45860
|
|
13
|
+
bedrock_agentcore_starter_toolkit/cli/runtime/configuration_manager.py,sha256=eu-PnhT0YoOSMbSfpaF0aFVp4LtTDAekdUrRzfq-bVM,6321
|
|
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
|
|
17
17
|
bedrock_agentcore_starter_toolkit/operations/__init__.py,sha256=L7sCNjfZviiVVoh2f3NEs2sbjNqFkmIRI3ZPYMMWMz0,51
|
|
18
18
|
bedrock_agentcore_starter_toolkit/operations/gateway/__init__.py,sha256=5Qo1GeN-DghNp9g0coFUs7WpUJDboJoidOVs-5Co7fo,233
|
|
19
|
-
bedrock_agentcore_starter_toolkit/operations/gateway/client.py,sha256=
|
|
19
|
+
bedrock_agentcore_starter_toolkit/operations/gateway/client.py,sha256=A4pBxe66TKVpwVQb4GWfC5LCVvwPo0kdRqXnSgONf6w,26063
|
|
20
20
|
bedrock_agentcore_starter_toolkit/operations/gateway/constants.py,sha256=0_4J6BN4VAE4-XTQhPTEACkhilRrFqu_iKiuHSm2pYk,4610
|
|
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
|
|
@@ -56,9 +56,9 @@ bedrock_agentcore_starter_toolkit/utils/runtime/templates/Dockerfile.j2,sha256=X
|
|
|
56
56
|
bedrock_agentcore_starter_toolkit/utils/runtime/templates/dockerignore.template,sha256=b_70sBi0MwkTuA9TqxPqFcWK7TcmpaXBJ6M2Ipox65Q,691
|
|
57
57
|
bedrock_agentcore_starter_toolkit/utils/runtime/templates/execution_role_policy.json.j2,sha256=-0AXT46IYVQr4fwueXTQ0FVXcCshZFNx7-2mViR34Co,4941
|
|
58
58
|
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.
|
|
59
|
+
bedrock_agentcore_starter_toolkit-0.1.12.dist-info/METADATA,sha256=_UcEnnN8XVm3sucpUYlbSjFjlehTsyFh9HTa-K-bsFw,10034
|
|
60
|
+
bedrock_agentcore_starter_toolkit-0.1.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
61
|
+
bedrock_agentcore_starter_toolkit-0.1.12.dist-info/entry_points.txt,sha256=Tf94DkUf2Tp8P7p8MEXLxre7A7Pp_XNukteiz0wHnk8,77
|
|
62
|
+
bedrock_agentcore_starter_toolkit-0.1.12.dist-info/licenses/LICENSE.txt,sha256=nNPOMinitYdtfbhdQgsPgz1UowBznU6QVN3Xs0pSTKU,10768
|
|
63
|
+
bedrock_agentcore_starter_toolkit-0.1.12.dist-info/licenses/NOTICE.txt,sha256=rkBsg8DbKqfIoQbveqX9foR4uJPUVAokbkr02pRPilE,8674
|
|
64
|
+
bedrock_agentcore_starter_toolkit-0.1.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|