@aws/agentcore 0.9.1 → 1.0.0-preview.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/dist/agent-inspector/index.css +1 -1
- package/dist/agent-inspector/index.js +90 -72
- package/dist/assets/README.md +56 -31
- package/dist/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +1781 -259
- package/dist/assets/__tests__/__snapshots__/dockerfile-render.test.ts.snap +77 -0
- package/dist/assets/__tests__/dockerfile-render.test.ts +24 -0
- package/dist/assets/agents/AGENTS.md +84 -55
- package/dist/assets/cdk/bin/cdk.ts +40 -0
- package/dist/assets/cdk/cdk.json +1 -1
- package/dist/assets/cdk/lib/cdk-stack.ts +59 -2
- package/dist/assets/container/python/Dockerfile +4 -0
- package/dist/assets/evaluators/python-lambda/execution-role-policy.json +1 -1
- package/dist/assets/harness/invoke.py.template +74 -0
- package/dist/assets/python/a2a/googleadk/base/main.py +65 -3
- package/dist/assets/python/a2a/langchain_langgraph/base/main.py +64 -1
- package/dist/assets/python/a2a/strands/base/main.py +65 -2
- package/dist/assets/python/agui/googleadk/base/README.md +30 -0
- package/dist/assets/python/agui/googleadk/base/gitignore.template +41 -0
- package/dist/assets/python/agui/googleadk/base/main.py +31 -0
- package/dist/assets/python/agui/googleadk/base/model/__init__.py +1 -0
- package/dist/assets/python/agui/googleadk/base/model/load.py +41 -0
- package/dist/assets/python/agui/googleadk/base/pyproject.toml +24 -0
- package/dist/assets/python/agui/langchain_langgraph/base/README.md +22 -0
- package/dist/assets/python/agui/langchain_langgraph/base/gitignore.template +41 -0
- package/dist/assets/python/agui/langchain_langgraph/base/main.py +74 -0
- package/dist/assets/python/agui/langchain_langgraph/base/model/__init__.py +1 -0
- package/dist/assets/python/agui/langchain_langgraph/base/model/load.py +123 -0
- package/dist/assets/python/agui/langchain_langgraph/base/pyproject.toml +30 -0
- package/dist/assets/python/agui/strands/base/README.md +22 -0
- package/dist/assets/python/agui/strands/base/gitignore.template +41 -0
- package/dist/assets/python/agui/strands/base/main.py +43 -0
- package/dist/assets/python/agui/strands/base/model/__init__.py +1 -0
- package/dist/assets/python/agui/strands/base/model/load.py +123 -0
- package/dist/assets/python/agui/strands/base/pyproject.toml +27 -0
- package/dist/assets/python/agui/strands/capabilities/memory/__init__.py +1 -0
- package/dist/assets/python/agui/strands/capabilities/memory/session.py +38 -0
- package/dist/assets/python/http/autogen/base/main.py +61 -1
- package/dist/assets/python/http/googleadk/base/main.py +62 -2
- package/dist/assets/python/http/langchain_langgraph/base/main.py +61 -1
- package/dist/assets/python/http/openaiagents/base/main.py +70 -4
- package/dist/assets/python/http/strands/base/main.py +64 -6
- package/dist/cli/index.mjs +415 -377
- package/dist/lib/constants.d.ts +1 -0
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +3 -1
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/errors/config.d.ts.map +1 -1
- package/dist/lib/errors/config.js +5 -2
- package/dist/lib/errors/config.js.map +1 -1
- package/dist/lib/schemas/io/config-io.d.ts +9 -1
- package/dist/lib/schemas/io/config-io.d.ts.map +1 -1
- package/dist/lib/schemas/io/config-io.js +14 -0
- package/dist/lib/schemas/io/config-io.js.map +1 -1
- package/dist/lib/schemas/io/path-resolver.d.ts +12 -0
- package/dist/lib/schemas/io/path-resolver.d.ts.map +1 -1
- package/dist/lib/schemas/io/path-resolver.js +18 -0
- package/dist/lib/schemas/io/path-resolver.js.map +1 -1
- package/dist/schema/constants.d.ts +1 -0
- package/dist/schema/constants.d.ts.map +1 -1
- package/dist/schema/constants.js +8 -1
- package/dist/schema/constants.js.map +1 -1
- package/dist/schema/schemas/agent-env.d.ts +20 -0
- package/dist/schema/schemas/agent-env.d.ts.map +1 -1
- package/dist/schema/schemas/agent-env.js +17 -2
- package/dist/schema/schemas/agent-env.js.map +1 -1
- package/dist/schema/schemas/agentcore-project.d.ts +17 -0
- package/dist/schema/schemas/agentcore-project.d.ts.map +1 -1
- package/dist/schema/schemas/agentcore-project.js +18 -1
- package/dist/schema/schemas/agentcore-project.js.map +1 -1
- package/dist/schema/schemas/aws-targets.d.ts +3 -0
- package/dist/schema/schemas/aws-targets.d.ts.map +1 -1
- package/dist/schema/schemas/aws-targets.js +1 -0
- package/dist/schema/schemas/aws-targets.js.map +1 -1
- package/dist/schema/schemas/deployed-state.d.ts +50 -0
- package/dist/schema/schemas/deployed-state.d.ts.map +1 -1
- package/dist/schema/schemas/deployed-state.js +15 -1
- package/dist/schema/schemas/deployed-state.js.map +1 -1
- package/dist/schema/schemas/primitives/harness.d.ts +287 -0
- package/dist/schema/schemas/primitives/harness.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/harness.js +237 -0
- package/dist/schema/schemas/primitives/harness.js.map +1 -0
- package/dist/schema/schemas/primitives/index.d.ts +2 -0
- package/dist/schema/schemas/primitives/index.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/index.js +14 -1
- package/dist/schema/schemas/primitives/index.js.map +1 -1
- package/package.json +2 -2
- package/scripts/bump-version.ts +7 -80
- package/scripts/bundle.mjs +57 -3
- package/dist/agent-inspector/index.js.map +0 -1
|
@@ -9,6 +9,9 @@ from mcp_client.client import get_streamable_http_mcp_client
|
|
|
9
9
|
{{#if hasMemory}}
|
|
10
10
|
from memory.session import get_memory_session_manager
|
|
11
11
|
{{/if}}
|
|
12
|
+
{{#if sessionStorageMountPath}}
|
|
13
|
+
import os
|
|
14
|
+
{{/if}}
|
|
12
15
|
|
|
13
16
|
app = BedrockAgentCoreApp()
|
|
14
17
|
log = app.logger
|
|
@@ -30,11 +33,70 @@ def add_numbers(a: int, b: int) -> int:
|
|
|
30
33
|
return a+b
|
|
31
34
|
tools.append(add_numbers)
|
|
32
35
|
|
|
36
|
+
{{#if sessionStorageMountPath}}
|
|
37
|
+
SESSION_STORAGE_PATH = "{{sessionStorageMountPath}}"
|
|
38
|
+
|
|
39
|
+
def _safe_resolve(path: str) -> str:
|
|
40
|
+
"""Resolve path safely within the storage boundary."""
|
|
41
|
+
resolved = os.path.realpath(os.path.join(SESSION_STORAGE_PATH, path.lstrip("/")))
|
|
42
|
+
if not resolved.startswith(os.path.realpath(SESSION_STORAGE_PATH)):
|
|
43
|
+
raise ValueError(f"Path '{path}' is outside the storage boundary")
|
|
44
|
+
return resolved
|
|
45
|
+
|
|
46
|
+
@tool
|
|
47
|
+
def file_read(path: str) -> str:
|
|
48
|
+
"""Read a file from persistent storage. The path is relative to the storage root."""
|
|
49
|
+
try:
|
|
50
|
+
full_path = _safe_resolve(path)
|
|
51
|
+
with open(full_path) as f:
|
|
52
|
+
return f.read()
|
|
53
|
+
except ValueError as e:
|
|
54
|
+
return str(e)
|
|
55
|
+
except OSError as e:
|
|
56
|
+
return f"Error reading '{path}': {e.strerror}"
|
|
57
|
+
|
|
58
|
+
@tool
|
|
59
|
+
def file_write(path: str, content: str) -> str:
|
|
60
|
+
"""Write content to a file in persistent storage. The path is relative to the storage root."""
|
|
61
|
+
try:
|
|
62
|
+
full_path = _safe_resolve(path)
|
|
63
|
+
parent = os.path.dirname(full_path)
|
|
64
|
+
if parent:
|
|
65
|
+
os.makedirs(parent, exist_ok=True)
|
|
66
|
+
with open(full_path, "w") as f:
|
|
67
|
+
f.write(content)
|
|
68
|
+
return f"Written to {path}"
|
|
69
|
+
except ValueError as e:
|
|
70
|
+
return str(e)
|
|
71
|
+
except OSError as e:
|
|
72
|
+
return f"Error writing '{path}': {e.strerror}"
|
|
73
|
+
|
|
74
|
+
@tool
|
|
75
|
+
def list_files(directory: str = "") -> str:
|
|
76
|
+
"""List files in persistent storage. The directory is relative to the storage root."""
|
|
77
|
+
try:
|
|
78
|
+
target = _safe_resolve(directory)
|
|
79
|
+
entries = os.listdir(target)
|
|
80
|
+
return "\n".join(entries) if entries else "(empty directory)"
|
|
81
|
+
except ValueError as e:
|
|
82
|
+
return str(e)
|
|
83
|
+
except OSError as e:
|
|
84
|
+
return f"Error listing '{directory}': {e.strerror}"
|
|
85
|
+
|
|
86
|
+
tools.extend([file_read, file_write, list_files])
|
|
87
|
+
{{/if}}
|
|
88
|
+
|
|
33
89
|
# Add MCP client to tools if available
|
|
34
90
|
for mcp_client in mcp_clients:
|
|
35
91
|
if mcp_client:
|
|
36
92
|
tools.append(mcp_client)
|
|
37
93
|
|
|
94
|
+
SYSTEM_PROMPT = """
|
|
95
|
+
You are a helpful assistant. Use tools when appropriate.
|
|
96
|
+
{{#if sessionStorageMountPath}}
|
|
97
|
+
You have persistent storage at {{sessionStorageMountPath}}. Use file tools to read and write files. Data persists across sessions.
|
|
98
|
+
{{/if}}
|
|
99
|
+
"""
|
|
38
100
|
|
|
39
101
|
{{#if hasMemory}}
|
|
40
102
|
def agent_factory():
|
|
@@ -46,9 +108,7 @@ def agent_factory():
|
|
|
46
108
|
cache[key] = Agent(
|
|
47
109
|
model=load_model(),
|
|
48
110
|
session_manager=get_memory_session_manager(session_id, user_id),
|
|
49
|
-
system_prompt=
|
|
50
|
-
You are a helpful assistant. Use tools when appropriate.
|
|
51
|
-
""",
|
|
111
|
+
system_prompt=SYSTEM_PROMPT,
|
|
52
112
|
tools=tools
|
|
53
113
|
)
|
|
54
114
|
return cache[key]
|
|
@@ -62,9 +122,7 @@ def get_or_create_agent():
|
|
|
62
122
|
if _agent is None:
|
|
63
123
|
_agent = Agent(
|
|
64
124
|
model=load_model(),
|
|
65
|
-
system_prompt=
|
|
66
|
-
You are a helpful assistant. Use tools when appropriate.
|
|
67
|
-
""",
|
|
125
|
+
system_prompt=SYSTEM_PROMPT,
|
|
68
126
|
tools=tools
|
|
69
127
|
)
|
|
70
128
|
return _agent
|