@aws/agentcore 1.0.0-preview.10 → 1.0.0-preview.12
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 +83 -78
- package/dist/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +452 -146
- package/dist/assets/__tests__/__snapshots__/dockerfile-render.test.ts.snap +2 -2
- package/dist/assets/cdk/bin/cdk.ts +4 -0
- package/dist/assets/cdk/lib/cdk-stack.ts +2 -0
- package/dist/assets/cdk/package.json +1 -1
- package/dist/assets/container/python/Dockerfile +1 -1
- package/dist/assets/python/a2a/googleadk/base/main.py +24 -16
- package/dist/assets/python/a2a/googleadk/base/pyproject.toml +1 -1
- package/dist/assets/python/a2a/langchain_langgraph/base/main.py +24 -16
- package/dist/assets/python/a2a/langchain_langgraph/base/pyproject.toml +1 -0
- package/dist/assets/python/a2a/strands/base/main.py +23 -17
- package/dist/assets/python/agui/googleadk/base/main.py +62 -2
- package/dist/assets/python/agui/googleadk/base/pyproject.toml +1 -1
- package/dist/assets/python/agui/langchain_langgraph/base/main.py +56 -0
- package/dist/assets/python/agui/langchain_langgraph/base/pyproject.toml +1 -0
- package/dist/assets/python/agui/strands/base/main.py +63 -1
- package/dist/assets/python/http/autogen/base/main.py +27 -19
- package/dist/assets/python/http/googleadk/base/main.py +24 -16
- package/dist/assets/python/http/googleadk/base/pyproject.toml +1 -0
- package/dist/assets/python/http/langchain_langgraph/base/main.py +24 -16
- package/dist/assets/python/http/langchain_langgraph/base/pyproject.toml +1 -0
- package/dist/assets/python/http/openaiagents/base/main.py +24 -16
- package/dist/assets/python/http/strands/base/main.py +23 -17
- package/dist/assets/python/mcp/standalone/base/main.py +58 -0
- package/dist/cli/index.mjs +707 -634
- package/dist/lib/errors/types.d.ts +9 -0
- package/dist/lib/errors/types.d.ts.map +1 -1
- package/dist/lib/errors/types.js +19 -1
- package/dist/lib/errors/types.js.map +1 -1
- package/dist/lib/errors/zod.js +1 -1
- package/dist/lib/errors/zod.js.map +1 -1
- package/dist/lib/packaging/helpers.d.ts.map +1 -1
- package/dist/lib/packaging/helpers.js +6 -10
- package/dist/lib/packaging/helpers.js.map +1 -1
- package/dist/lib/result.d.ts +21 -4
- package/dist/lib/result.d.ts.map +1 -1
- package/dist/lib/result.js +19 -0
- package/dist/lib/result.js.map +1 -1
- package/dist/lib/schemas/io/global-config.d.ts +28 -21
- package/dist/lib/schemas/io/global-config.d.ts.map +1 -1
- package/dist/lib/schemas/io/global-config.js +57 -28
- package/dist/lib/schemas/io/global-config.js.map +1 -1
- package/dist/lib/utils/index.d.ts +1 -1
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/dist/lib/utils/index.js +2 -1
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/lib/utils/zod.d.ts +16 -0
- package/dist/lib/utils/zod.d.ts.map +1 -1
- package/dist/lib/utils/zod.js +45 -0
- package/dist/lib/utils/zod.js.map +1 -1
- package/dist/schema/schemas/agent-env.d.ts +50 -4
- package/dist/schema/schemas/agent-env.d.ts.map +1 -1
- package/dist/schema/schemas/agent-env.js +102 -4
- package/dist/schema/schemas/agent-env.js.map +1 -1
- package/dist/schema/schemas/agentcore-project.d.ts +12 -2
- package/dist/schema/schemas/agentcore-project.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/harness.d.ts +8 -0
- package/dist/schema/schemas/primitives/harness.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/harness.js +23 -0
- package/dist/schema/schemas/primitives/harness.js.map +1 -1
- package/npm-shrinkwrap.json +281 -366
- package/package.json +12 -7
- package/scripts/bump-version.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
3
|
exports[`Dockerfile enableOtel rendering > renders opentelemetry-instrument CMD when enableOtel is true > Dockerfile-enableOtel-true 1`] = `
|
|
4
|
-
"FROM public.ecr.aws/docker/library/python:3.12-slim-
|
|
4
|
+
"FROM public.ecr.aws/docker/library/python:3.12-slim-trixie
|
|
5
5
|
|
|
6
6
|
RUN pip install --no-cache-dir uv
|
|
7
7
|
|
|
@@ -41,7 +41,7 @@ CMD ["opentelemetry-instrument", "python", "-m", "main"]
|
|
|
41
41
|
`;
|
|
42
42
|
|
|
43
43
|
exports[`Dockerfile enableOtel rendering > renders plain python CMD when enableOtel is false > Dockerfile-enableOtel-false 1`] = `
|
|
44
|
-
"FROM public.ecr.aws/docker/library/python:3.12-slim-
|
|
44
|
+
"FROM public.ecr.aws/docker/library/python:3.12-slim-trixie
|
|
45
45
|
|
|
46
46
|
RUN pip install --no-cache-dir uv
|
|
47
47
|
|
|
@@ -66,6 +66,8 @@ async function main() {
|
|
|
66
66
|
codeLocation?: string;
|
|
67
67
|
tools?: { type: string; name: string }[];
|
|
68
68
|
apiKeyArn?: string;
|
|
69
|
+
efsAccessPoints?: { accessPointArn: string; mountPath: string }[];
|
|
70
|
+
s3AccessPoints?: { accessPointArn: string; mountPath: string }[];
|
|
69
71
|
}[] = [];
|
|
70
72
|
for (const entry of specAny.harnesses ?? []) {
|
|
71
73
|
const harnessDir = path.resolve(projectRoot, entry.path);
|
|
@@ -82,6 +84,8 @@ async function main() {
|
|
|
82
84
|
codeLocation: harnessSpec.dockerfile ? harnessDir : undefined,
|
|
83
85
|
tools: harnessSpec.tools,
|
|
84
86
|
apiKeyArn: harnessSpec.model?.apiKeyArn,
|
|
87
|
+
efsAccessPoints: harnessSpec.efsAccessPoints,
|
|
88
|
+
s3AccessPoints: harnessSpec.s3AccessPoints,
|
|
85
89
|
});
|
|
86
90
|
} catch (err) {
|
|
87
91
|
throw new Error(
|
|
@@ -17,6 +17,8 @@ export interface HarnessConfig {
|
|
|
17
17
|
codeLocation?: string;
|
|
18
18
|
tools?: { type: string; name: string }[];
|
|
19
19
|
apiKeyArn?: string;
|
|
20
|
+
efsAccessPoints?: { accessPointArn: string; mountPath: string }[];
|
|
21
|
+
s3AccessPoints?: { accessPointArn: string; mountPath: string }[];
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export interface AgentCoreStackProps extends StackProps {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
{{#if needsOs}}
|
|
1
2
|
import os
|
|
3
|
+
{{/if}}
|
|
2
4
|
from google.adk.agents import Agent
|
|
3
5
|
from google.adk.a2a.executor.a2a_agent_executor import A2aAgentExecutor
|
|
4
6
|
from google.adk.runners import Runner
|
|
@@ -17,18 +19,21 @@ def add_numbers(a: int, b: int) -> int:
|
|
|
17
19
|
|
|
18
20
|
tools = [add_numbers]
|
|
19
21
|
|
|
20
|
-
{{#if
|
|
21
|
-
|
|
22
|
+
{{#if needsOs}}
|
|
23
|
+
_MOUNT_PATHS = [
|
|
24
|
+
{{#if sessionStorageMountPath}}"{{sessionStorageMountPath}}",{{/if}}
|
|
25
|
+
{{#each efsMounts}}"{{mountPath}}",{{/each}}
|
|
26
|
+
{{#each s3Mounts}}"{{mountPath}}",{{/each}}
|
|
27
|
+
]
|
|
22
28
|
|
|
23
29
|
def _safe_resolve(path: str) -> str:
|
|
24
|
-
|
|
25
|
-
resolved
|
|
26
|
-
|
|
27
|
-
raise ValueError(f"Path '{path}' is outside the storage boundary")
|
|
30
|
+
resolved = os.path.realpath(path)
|
|
31
|
+
if not any(resolved == os.path.realpath(m) or resolved.startswith(os.path.realpath(m) + os.sep) for m in _MOUNT_PATHS):
|
|
32
|
+
raise ValueError(f"Path '{path}' is not within any configured mount ({', '.join(_MOUNT_PATHS)})")
|
|
28
33
|
return resolved
|
|
29
34
|
|
|
30
35
|
def file_read(path: str) -> str:
|
|
31
|
-
"""Read a file from
|
|
36
|
+
"""Read a file from a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
32
37
|
try:
|
|
33
38
|
full_path = _safe_resolve(path)
|
|
34
39
|
with open(full_path) as f:
|
|
@@ -39,7 +44,7 @@ def file_read(path: str) -> str:
|
|
|
39
44
|
return f"Error reading '{path}': {e.strerror}"
|
|
40
45
|
|
|
41
46
|
def file_write(path: str, content: str) -> str:
|
|
42
|
-
"""Write
|
|
47
|
+
"""Write a file to a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
43
48
|
try:
|
|
44
49
|
full_path = _safe_resolve(path)
|
|
45
50
|
parent = os.path.dirname(full_path)
|
|
@@ -53,25 +58,28 @@ def file_write(path: str, content: str) -> str:
|
|
|
53
58
|
except OSError as e:
|
|
54
59
|
return f"Error writing '{path}': {e.strerror}"
|
|
55
60
|
|
|
56
|
-
def list_files(
|
|
57
|
-
"""List files in
|
|
61
|
+
def list_files(path: str) -> str:
|
|
62
|
+
"""List files in a mounted filesystem directory. Use the absolute path (e.g. /mnt/tools)."""
|
|
58
63
|
try:
|
|
59
|
-
|
|
60
|
-
entries = os.listdir(
|
|
64
|
+
full_path = _safe_resolve(path)
|
|
65
|
+
entries = os.listdir(full_path)
|
|
61
66
|
return "\n".join(entries) if entries else "(empty directory)"
|
|
62
67
|
except ValueError as e:
|
|
63
68
|
return str(e)
|
|
64
69
|
except OSError as e:
|
|
65
|
-
return f"Error listing '{
|
|
70
|
+
return f"Error listing '{path}': {e.strerror}"
|
|
66
71
|
|
|
67
72
|
tools.extend([file_read, file_write, list_files])
|
|
68
73
|
{{/if}}
|
|
69
74
|
|
|
70
75
|
AGENT_INSTRUCTION = """
|
|
71
76
|
You are a helpful assistant. Use tools when appropriate.
|
|
72
|
-
{{#if
|
|
73
|
-
You have
|
|
74
|
-
{{
|
|
77
|
+
{{#if needsOs}}
|
|
78
|
+
You have access to the following mounted filesystems. Use file_read, file_write, and list_files with full absolute paths:
|
|
79
|
+
{{#if sessionStorageMountPath}}- {{sessionStorageMountPath}}: ephemeral session storage (lost when session ends)
|
|
80
|
+
{{/if}}{{#each efsMounts}}- {{mountPath}}: EFS persistent storage (persists across sessions and agent restarts)
|
|
81
|
+
{{/each}}{{#each s3Mounts}}- {{mountPath}}: S3 Files persistent storage (durable, backed by S3)
|
|
82
|
+
{{/each}}{{/if}}
|
|
75
83
|
"""
|
|
76
84
|
|
|
77
85
|
agent = Agent(
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
{{#if needsOs}}
|
|
1
2
|
import os
|
|
3
|
+
{{/if}}
|
|
2
4
|
from langchain_core.tools import tool
|
|
3
5
|
from langgraph.prebuilt import create_react_agent
|
|
4
6
|
from opentelemetry.instrumentation.langchain import LangchainInstrumentor
|
|
@@ -21,19 +23,22 @@ def add_numbers(a: int, b: int) -> int:
|
|
|
21
23
|
|
|
22
24
|
tools = [add_numbers]
|
|
23
25
|
|
|
24
|
-
{{#if
|
|
25
|
-
|
|
26
|
+
{{#if needsOs}}
|
|
27
|
+
_MOUNT_PATHS = [
|
|
28
|
+
{{#if sessionStorageMountPath}}"{{sessionStorageMountPath}}",{{/if}}
|
|
29
|
+
{{#each efsMounts}}"{{mountPath}}",{{/each}}
|
|
30
|
+
{{#each s3Mounts}}"{{mountPath}}",{{/each}}
|
|
31
|
+
]
|
|
26
32
|
|
|
27
33
|
def _safe_resolve(path: str) -> str:
|
|
28
|
-
|
|
29
|
-
resolved
|
|
30
|
-
|
|
31
|
-
raise ValueError(f"Path '{path}' is outside the storage boundary")
|
|
34
|
+
resolved = os.path.realpath(path)
|
|
35
|
+
if not any(resolved == os.path.realpath(m) or resolved.startswith(os.path.realpath(m) + os.sep) for m in _MOUNT_PATHS):
|
|
36
|
+
raise ValueError(f"Path '{path}' is not within any configured mount ({', '.join(_MOUNT_PATHS)})")
|
|
32
37
|
return resolved
|
|
33
38
|
|
|
34
39
|
@tool
|
|
35
40
|
def file_read(path: str) -> str:
|
|
36
|
-
"""Read a file from
|
|
41
|
+
"""Read a file from a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
37
42
|
try:
|
|
38
43
|
full_path = _safe_resolve(path)
|
|
39
44
|
with open(full_path) as f:
|
|
@@ -45,7 +50,7 @@ def file_read(path: str) -> str:
|
|
|
45
50
|
|
|
46
51
|
@tool
|
|
47
52
|
def file_write(path: str, content: str) -> str:
|
|
48
|
-
"""Write
|
|
53
|
+
"""Write a file to a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
49
54
|
try:
|
|
50
55
|
full_path = _safe_resolve(path)
|
|
51
56
|
parent = os.path.dirname(full_path)
|
|
@@ -60,25 +65,28 @@ def file_write(path: str, content: str) -> str:
|
|
|
60
65
|
return f"Error writing '{path}': {e.strerror}"
|
|
61
66
|
|
|
62
67
|
@tool
|
|
63
|
-
def list_files(
|
|
64
|
-
"""List files in
|
|
68
|
+
def list_files(path: str) -> str:
|
|
69
|
+
"""List files in a mounted filesystem directory. Use the absolute path (e.g. /mnt/tools)."""
|
|
65
70
|
try:
|
|
66
|
-
|
|
67
|
-
entries = os.listdir(
|
|
71
|
+
full_path = _safe_resolve(path)
|
|
72
|
+
entries = os.listdir(full_path)
|
|
68
73
|
return "\n".join(entries) if entries else "(empty directory)"
|
|
69
74
|
except ValueError as e:
|
|
70
75
|
return str(e)
|
|
71
76
|
except OSError as e:
|
|
72
|
-
return f"Error listing '{
|
|
77
|
+
return f"Error listing '{path}': {e.strerror}"
|
|
73
78
|
|
|
74
79
|
tools.extend([file_read, file_write, list_files])
|
|
75
80
|
{{/if}}
|
|
76
81
|
|
|
77
82
|
SYSTEM_PROMPT = """
|
|
78
83
|
You are a helpful assistant. Use tools when appropriate.
|
|
79
|
-
{{#if
|
|
80
|
-
You have
|
|
81
|
-
{{
|
|
84
|
+
{{#if needsOs}}
|
|
85
|
+
You have access to the following mounted filesystems. Use file_read, file_write, and list_files with full absolute paths:
|
|
86
|
+
{{#if sessionStorageMountPath}}- {{sessionStorageMountPath}}: ephemeral session storage (lost when session ends)
|
|
87
|
+
{{/if}}{{#each efsMounts}}- {{mountPath}}: EFS persistent storage (persists across sessions and agent restarts)
|
|
88
|
+
{{/each}}{{#each s3Mounts}}- {{mountPath}}: S3 Files persistent storage (durable, backed by S3)
|
|
89
|
+
{{/each}}{{/if}}
|
|
82
90
|
"""
|
|
83
91
|
|
|
84
92
|
model = load_model()
|
|
@@ -13,6 +13,7 @@ dependencies = [
|
|
|
13
13
|
{{#if (eq modelProvider "Anthropic")}}"langchain-anthropic >= 0.3.0",
|
|
14
14
|
{{/if}}{{#if (eq modelProvider "Bedrock")}}"langchain-aws >= 0.2.0",
|
|
15
15
|
{{/if}}{{#if (eq modelProvider "Gemini")}}"langchain-google-genai >= 2.0.0",
|
|
16
|
+
"google-genai >= 1.0.0, < 2.0.0",
|
|
16
17
|
{{/if}}{{#if (eq modelProvider "OpenAI")}}"langchain-openai >= 0.2.0",
|
|
17
18
|
{{/if}}"aws-opentelemetry-distro",
|
|
18
19
|
"opentelemetry-instrumentation-langchain >= 0.59.0",
|
|
@@ -5,7 +5,7 @@ from model.load import load_model
|
|
|
5
5
|
{{#if hasMemory}}
|
|
6
6
|
from memory.session import get_memory_session_manager
|
|
7
7
|
{{/if}}
|
|
8
|
-
{{#if
|
|
8
|
+
{{#if needsOs}}
|
|
9
9
|
import os
|
|
10
10
|
{{/if}}
|
|
11
11
|
|
|
@@ -18,19 +18,22 @@ def add_numbers(a: int, b: int) -> int:
|
|
|
18
18
|
|
|
19
19
|
tools = [add_numbers]
|
|
20
20
|
|
|
21
|
-
{{#if
|
|
22
|
-
|
|
21
|
+
{{#if needsOs}}
|
|
22
|
+
_MOUNT_PATHS = [
|
|
23
|
+
{{#if sessionStorageMountPath}}"{{sessionStorageMountPath}}",{{/if}}
|
|
24
|
+
{{#each efsMounts}}"{{mountPath}}",{{/each}}
|
|
25
|
+
{{#each s3Mounts}}"{{mountPath}}",{{/each}}
|
|
26
|
+
]
|
|
23
27
|
|
|
24
28
|
def _safe_resolve(path: str) -> str:
|
|
25
|
-
|
|
26
|
-
resolved
|
|
27
|
-
|
|
28
|
-
raise ValueError(f"Path '{path}' is outside the storage boundary")
|
|
29
|
+
resolved = os.path.realpath(path)
|
|
30
|
+
if not any(resolved == os.path.realpath(m) or resolved.startswith(os.path.realpath(m) + os.sep) for m in _MOUNT_PATHS):
|
|
31
|
+
raise ValueError(f"Path '{path}' is not within any configured mount ({', '.join(_MOUNT_PATHS)})")
|
|
29
32
|
return resolved
|
|
30
33
|
|
|
31
34
|
@tool
|
|
32
35
|
def file_read(path: str) -> str:
|
|
33
|
-
"""Read a file from
|
|
36
|
+
"""Read a file from a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
34
37
|
try:
|
|
35
38
|
full_path = _safe_resolve(path)
|
|
36
39
|
with open(full_path) as f:
|
|
@@ -42,7 +45,7 @@ def file_read(path: str) -> str:
|
|
|
42
45
|
|
|
43
46
|
@tool
|
|
44
47
|
def file_write(path: str, content: str) -> str:
|
|
45
|
-
"""Write
|
|
48
|
+
"""Write a file to a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
46
49
|
try:
|
|
47
50
|
full_path = _safe_resolve(path)
|
|
48
51
|
parent = os.path.dirname(full_path)
|
|
@@ -57,25 +60,28 @@ def file_write(path: str, content: str) -> str:
|
|
|
57
60
|
return f"Error writing '{path}': {e.strerror}"
|
|
58
61
|
|
|
59
62
|
@tool
|
|
60
|
-
def list_files(
|
|
61
|
-
"""List files in
|
|
63
|
+
def list_files(path: str) -> str:
|
|
64
|
+
"""List files in a mounted filesystem directory. Use the absolute path (e.g. /mnt/tools)."""
|
|
62
65
|
try:
|
|
63
|
-
|
|
64
|
-
entries = os.listdir(
|
|
66
|
+
full_path = _safe_resolve(path)
|
|
67
|
+
entries = os.listdir(full_path)
|
|
65
68
|
return "\n".join(entries) if entries else "(empty directory)"
|
|
66
69
|
except ValueError as e:
|
|
67
70
|
return str(e)
|
|
68
71
|
except OSError as e:
|
|
69
|
-
return f"Error listing '{
|
|
72
|
+
return f"Error listing '{path}': {e.strerror}"
|
|
70
73
|
|
|
71
74
|
tools.extend([file_read, file_write, list_files])
|
|
72
75
|
{{/if}}
|
|
73
76
|
|
|
74
77
|
SYSTEM_PROMPT = """
|
|
75
78
|
You are a helpful assistant. Use tools when appropriate.
|
|
76
|
-
{{#if
|
|
77
|
-
You have
|
|
78
|
-
{{
|
|
79
|
+
{{#if needsOs}}
|
|
80
|
+
You have access to the following mounted filesystems. Use file_read, file_write, and list_files with full absolute paths:
|
|
81
|
+
{{#if sessionStorageMountPath}}- {{sessionStorageMountPath}}: ephemeral session storage (lost when session ends)
|
|
82
|
+
{{/if}}{{#each efsMounts}}- {{mountPath}}: EFS persistent storage (persists across sessions and agent restarts)
|
|
83
|
+
{{/each}}{{#each s3Mounts}}- {{mountPath}}: S3 Files persistent storage (durable, backed by S3)
|
|
84
|
+
{{/each}}{{/if}}
|
|
79
85
|
"""
|
|
80
86
|
|
|
81
87
|
{{#if hasMemory}}
|
|
@@ -1,16 +1,76 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import uvicorn
|
|
3
3
|
from google.adk.agents import LlmAgent
|
|
4
|
+
from google.adk.tools import FunctionTool
|
|
4
5
|
from ag_ui_adk import ADKAgent, AGUIToolset, create_adk_app
|
|
5
6
|
from model.load import load_model
|
|
6
7
|
|
|
7
8
|
load_model()
|
|
8
9
|
|
|
10
|
+
{{#if needsOs}}
|
|
11
|
+
_MOUNT_PATHS = [
|
|
12
|
+
{{#if sessionStorageMountPath}}"{{sessionStorageMountPath}}",{{/if}}
|
|
13
|
+
{{#each efsMounts}}"{{mountPath}}",{{/each}}
|
|
14
|
+
{{#each s3Mounts}}"{{mountPath}}",{{/each}}
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
def _safe_resolve(path: str) -> str:
|
|
18
|
+
resolved = os.path.realpath(path)
|
|
19
|
+
if not any(resolved == os.path.realpath(m) or resolved.startswith(os.path.realpath(m) + os.sep) for m in _MOUNT_PATHS):
|
|
20
|
+
raise ValueError(f"Path '{path}' is not within any configured mount ({', '.join(_MOUNT_PATHS)})")
|
|
21
|
+
return resolved
|
|
22
|
+
|
|
23
|
+
def file_read(path: str) -> str:
|
|
24
|
+
"""Read a file from a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
25
|
+
try:
|
|
26
|
+
full_path = _safe_resolve(path)
|
|
27
|
+
with open(full_path) as f:
|
|
28
|
+
return f.read()
|
|
29
|
+
except ValueError as e:
|
|
30
|
+
return str(e)
|
|
31
|
+
except OSError as e:
|
|
32
|
+
return f"Error reading '{path}': {e.strerror}"
|
|
33
|
+
|
|
34
|
+
def file_write(path: str, content: str) -> str:
|
|
35
|
+
"""Write a file to a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
36
|
+
try:
|
|
37
|
+
full_path = _safe_resolve(path)
|
|
38
|
+
parent = os.path.dirname(full_path)
|
|
39
|
+
if parent:
|
|
40
|
+
os.makedirs(parent, exist_ok=True)
|
|
41
|
+
with open(full_path, "w") as f:
|
|
42
|
+
f.write(content)
|
|
43
|
+
return f"Written to {path}"
|
|
44
|
+
except ValueError as e:
|
|
45
|
+
return str(e)
|
|
46
|
+
except OSError as e:
|
|
47
|
+
return f"Error writing '{path}': {e.strerror}"
|
|
48
|
+
|
|
49
|
+
def list_files(path: str) -> str:
|
|
50
|
+
"""List files in a mounted filesystem directory. Use the absolute path (e.g. /mnt/tools)."""
|
|
51
|
+
try:
|
|
52
|
+
full_path = _safe_resolve(path)
|
|
53
|
+
entries = os.listdir(full_path)
|
|
54
|
+
return "\n".join(entries) if entries else "(empty directory)"
|
|
55
|
+
except ValueError as e:
|
|
56
|
+
return str(e)
|
|
57
|
+
except OSError as e:
|
|
58
|
+
return f"Error listing '{path}': {e.strerror}"
|
|
59
|
+
|
|
60
|
+
_fs_tools = [FunctionTool(file_read), FunctionTool(file_write), FunctionTool(list_files)]
|
|
61
|
+
{{/if}}
|
|
62
|
+
|
|
9
63
|
agent = LlmAgent(
|
|
10
64
|
name="{{ name }}",
|
|
11
65
|
model="gemini-2.5-flash",
|
|
12
|
-
instruction="You are a helpful assistant.
|
|
13
|
-
|
|
66
|
+
instruction="""You are a helpful assistant.
|
|
67
|
+
{{#if needsOs}}
|
|
68
|
+
You have access to the following mounted filesystems. Use file_read, file_write, and list_files with full absolute paths:
|
|
69
|
+
{{#if sessionStorageMountPath}}- {{sessionStorageMountPath}}: ephemeral session storage (lost when session ends)
|
|
70
|
+
{{/if}}{{#each efsMounts}}- {{mountPath}}: EFS persistent storage (persists across sessions and agent restarts)
|
|
71
|
+
{{/each}}{{#each s3Mounts}}- {{mountPath}}: S3 Files persistent storage (durable, backed by S3)
|
|
72
|
+
{{/each}}{{/if}}""",
|
|
73
|
+
tools=[AGUIToolset(), {{#if needsOs}}*_fs_tools{{/if}}],
|
|
14
74
|
)
|
|
15
75
|
|
|
16
76
|
adk_agent = ADKAgent(
|
|
@@ -14,7 +14,7 @@ dependencies = [
|
|
|
14
14
|
"bedrock-agentcore >= 1.0.3",
|
|
15
15
|
"fastapi >= 0.115.12",
|
|
16
16
|
"google-adk >= 1.16.0, < 2.0.0",
|
|
17
|
-
"google-genai >= 1.0.0",
|
|
17
|
+
"google-genai >= 1.0.0, < 2.0.0",
|
|
18
18
|
"opentelemetry-distro",
|
|
19
19
|
"opentelemetry-exporter-otlp",
|
|
20
20
|
"uvicorn >= 0.34.3",
|
|
@@ -25,6 +25,62 @@ def add_numbers(a: int, b: int) -> int:
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
backend_tools = [add_numbers]
|
|
28
|
+
|
|
29
|
+
{{#if needsOs}}
|
|
30
|
+
_MOUNT_PATHS = [
|
|
31
|
+
{{#if sessionStorageMountPath}}"{{sessionStorageMountPath}}",{{/if}}
|
|
32
|
+
{{#each efsMounts}}"{{mountPath}}",{{/each}}
|
|
33
|
+
{{#each s3Mounts}}"{{mountPath}}",{{/each}}
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
def _safe_resolve(path: str) -> str:
|
|
37
|
+
resolved = os.path.realpath(path)
|
|
38
|
+
if not any(resolved == os.path.realpath(m) or resolved.startswith(os.path.realpath(m) + os.sep) for m in _MOUNT_PATHS):
|
|
39
|
+
raise ValueError(f"Path '{path}' is not within any configured mount ({', '.join(_MOUNT_PATHS)})")
|
|
40
|
+
return resolved
|
|
41
|
+
|
|
42
|
+
@tool
|
|
43
|
+
def file_read(path: str) -> str:
|
|
44
|
+
"""Read a file from a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
45
|
+
try:
|
|
46
|
+
full_path = _safe_resolve(path)
|
|
47
|
+
with open(full_path) as f:
|
|
48
|
+
return f.read()
|
|
49
|
+
except ValueError as e:
|
|
50
|
+
return str(e)
|
|
51
|
+
except OSError as e:
|
|
52
|
+
return f"Error reading '{path}': {e.strerror}"
|
|
53
|
+
|
|
54
|
+
@tool
|
|
55
|
+
def file_write(path: str, content: str) -> str:
|
|
56
|
+
"""Write a file to a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
57
|
+
try:
|
|
58
|
+
full_path = _safe_resolve(path)
|
|
59
|
+
parent = os.path.dirname(full_path)
|
|
60
|
+
if parent:
|
|
61
|
+
os.makedirs(parent, exist_ok=True)
|
|
62
|
+
with open(full_path, "w") as f:
|
|
63
|
+
f.write(content)
|
|
64
|
+
return f"Written to {path}"
|
|
65
|
+
except ValueError as e:
|
|
66
|
+
return str(e)
|
|
67
|
+
except OSError as e:
|
|
68
|
+
return f"Error writing '{path}': {e.strerror}"
|
|
69
|
+
|
|
70
|
+
@tool
|
|
71
|
+
def list_files(path: str) -> str:
|
|
72
|
+
"""List files in a mounted filesystem directory. Use the absolute path (e.g. /mnt/tools)."""
|
|
73
|
+
try:
|
|
74
|
+
full_path = _safe_resolve(path)
|
|
75
|
+
entries = os.listdir(full_path)
|
|
76
|
+
return "\n".join(entries) if entries else "(empty directory)"
|
|
77
|
+
except ValueError as e:
|
|
78
|
+
return str(e)
|
|
79
|
+
except OSError as e:
|
|
80
|
+
return f"Error listing '{path}': {e.strerror}"
|
|
81
|
+
|
|
82
|
+
backend_tools.extend([file_read, file_write, list_files])
|
|
83
|
+
{{/if}}
|
|
28
84
|
model = load_model()
|
|
29
85
|
|
|
30
86
|
|
|
@@ -14,6 +14,7 @@ dependencies = [
|
|
|
14
14
|
{{#if (eq modelProvider "Anthropic")}}"langchain-anthropic >= 0.3.0",
|
|
15
15
|
{{/if}}{{#if (eq modelProvider "Bedrock")}}"langchain-aws >= 0.2.0",
|
|
16
16
|
{{/if}}{{#if (eq modelProvider "Gemini")}}"langchain-google-genai >= 2.0.0",
|
|
17
|
+
"google-genai >= 1.0.0, < 2.0.0",
|
|
17
18
|
{{/if}}{{#if (eq modelProvider "OpenAI")}}"langchain-openai >= 0.2.0",
|
|
18
19
|
{{/if}}"aws-opentelemetry-distro",
|
|
19
20
|
"opentelemetry-instrumentation-langchain >= 0.59.0",
|
|
@@ -21,9 +21,71 @@ def add_numbers(a: int, b: int) -> int:
|
|
|
21
21
|
|
|
22
22
|
tools = [add_numbers]
|
|
23
23
|
|
|
24
|
+
{{#if needsOs}}
|
|
25
|
+
_MOUNT_PATHS = [
|
|
26
|
+
{{#if sessionStorageMountPath}}"{{sessionStorageMountPath}}",{{/if}}
|
|
27
|
+
{{#each efsMounts}}"{{mountPath}}",{{/each}}
|
|
28
|
+
{{#each s3Mounts}}"{{mountPath}}",{{/each}}
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
def _safe_resolve(path: str) -> str:
|
|
32
|
+
resolved = os.path.realpath(path)
|
|
33
|
+
if not any(resolved == os.path.realpath(m) or resolved.startswith(os.path.realpath(m) + os.sep) for m in _MOUNT_PATHS):
|
|
34
|
+
raise ValueError(f"Path '{path}' is not within any configured mount ({', '.join(_MOUNT_PATHS)})")
|
|
35
|
+
return resolved
|
|
36
|
+
|
|
37
|
+
@tool
|
|
38
|
+
def file_read(path: str) -> str:
|
|
39
|
+
"""Read a file from a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
40
|
+
try:
|
|
41
|
+
full_path = _safe_resolve(path)
|
|
42
|
+
with open(full_path) as f:
|
|
43
|
+
return f.read()
|
|
44
|
+
except ValueError as e:
|
|
45
|
+
return str(e)
|
|
46
|
+
except OSError as e:
|
|
47
|
+
return f"Error reading '{path}': {e.strerror}"
|
|
48
|
+
|
|
49
|
+
@tool
|
|
50
|
+
def file_write(path: str, content: str) -> str:
|
|
51
|
+
"""Write a file to a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
52
|
+
try:
|
|
53
|
+
full_path = _safe_resolve(path)
|
|
54
|
+
parent = os.path.dirname(full_path)
|
|
55
|
+
if parent:
|
|
56
|
+
os.makedirs(parent, exist_ok=True)
|
|
57
|
+
with open(full_path, "w") as f:
|
|
58
|
+
f.write(content)
|
|
59
|
+
return f"Written to {path}"
|
|
60
|
+
except ValueError as e:
|
|
61
|
+
return str(e)
|
|
62
|
+
except OSError as e:
|
|
63
|
+
return f"Error writing '{path}': {e.strerror}"
|
|
64
|
+
|
|
65
|
+
@tool
|
|
66
|
+
def list_files(path: str) -> str:
|
|
67
|
+
"""List files in a mounted filesystem directory. Use the absolute path (e.g. /mnt/tools)."""
|
|
68
|
+
try:
|
|
69
|
+
full_path = _safe_resolve(path)
|
|
70
|
+
entries = os.listdir(full_path)
|
|
71
|
+
return "\n".join(entries) if entries else "(empty directory)"
|
|
72
|
+
except ValueError as e:
|
|
73
|
+
return str(e)
|
|
74
|
+
except OSError as e:
|
|
75
|
+
return f"Error listing '{path}': {e.strerror}"
|
|
76
|
+
|
|
77
|
+
tools.extend([file_read, file_write, list_files])
|
|
78
|
+
{{/if}}
|
|
79
|
+
|
|
24
80
|
agent = Agent(
|
|
25
81
|
model=load_model(),
|
|
26
|
-
system_prompt="You are a helpful assistant. Use tools when appropriate.
|
|
82
|
+
system_prompt="""You are a helpful assistant. Use tools when appropriate.
|
|
83
|
+
{{#if needsOs}}
|
|
84
|
+
You have access to the following mounted filesystems. Use file_read, file_write, and list_files with full absolute paths:
|
|
85
|
+
{{#if sessionStorageMountPath}}- {{sessionStorageMountPath}}: ephemeral session storage (lost when session ends)
|
|
86
|
+
{{/if}}{{#each efsMounts}}- {{mountPath}}: EFS persistent storage (persists across sessions and agent restarts)
|
|
87
|
+
{{/each}}{{#each s3Mounts}}- {{mountPath}}: S3 Files persistent storage (durable, backed by S3)
|
|
88
|
+
{{/each}}{{/if}}""",
|
|
27
89
|
tools=tools,
|
|
28
90
|
)
|
|
29
91
|
|