Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/assets/templates/a2a-python-strands/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ requires-python = ">=3.10"
dependencies = [
"a2a-sdk[all] ~= 0.3.0",
"aws-opentelemetry-distro ~= 0.18.0",
"bedrock-agentcore[a2a] ~= 1.9.1",
"bedrock-agentcore[a2a,strands-agents] >= 1.18.1, < 2.0.0",
"botocore[crt] ~= 1.43.0",
"strands-agents ~= 1.15.0",
"strands-agents >= 1.15.0, < 2.0.0",
]

[tool.hatch.build.targets.wheel]
Expand Down
2 changes: 1 addition & 1 deletion src/assets/templates/agent-python-minimal/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"aws-opentelemetry-distro ~= 0.18.0",
"bedrock-agentcore ~= 1.9.1",
"bedrock-agentcore >= 1.18.1, < 2.0.0",
"botocore[crt] ~= 1.43.0",
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM public.ecr.aws/docker/library/python:3.12-slim-trixie

RUN apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir uv

ARG UV_DEFAULT_INDEX
Expand All @@ -8,6 +10,7 @@ ARG UV_INDEX
WORKDIR /app

ENV UV_SYSTEM_PYTHON=1 \
UV_NO_CACHE=1 \
UV_COMPILE_BYTECODE=1 \
UV_NO_PROGRESS=1 \
PYTHONUNBUFFERED=1 \
Expand All @@ -22,7 +25,7 @@ COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev --no-install-project

COPY --chown=bedrock_agentcore:bedrock_agentcore . .
RUN uv sync --frozen --no-dev
RUN uv sync --frozen --no-dev && /usr/local/bin/python -m pip uninstall -y uv

USER bedrock_agentcore

Expand Down
12 changes: 6 additions & 6 deletions src/assets/templates/agent-python-strands/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"aws-opentelemetry-distro ~= 0.18.0",
"bedrock-agentcore ~= 1.9.1",
"bedrock-agentcore[strands-agents] >= 1.18.1, < 2.0.0",
"botocore[crt] ~= 1.43.0",
{{#if (eq modelProvider "Anthropic")}}"strands-agents[anthropic] ~= 1.15.0",
{{else}}{{#if (eq modelProvider "OpenAI")}}"strands-agents[openai] ~= 1.15.0",
{{else}}{{#if (eq modelProvider "Gemini")}}"strands-agents[gemini] ~= 1.15.0",
{{else}}{{#if (eq modelProvider "LiteLLM")}}"strands-agents[litellm] ~= 1.15.0",
{{else}}"strands-agents ~= 1.15.0",
{{#if (eq modelProvider "Anthropic")}}"strands-agents[anthropic] >= 1.15.0, < 2.0.0",
{{else}}{{#if (eq modelProvider "OpenAI")}}"strands-agents[openai] >= 1.15.0, < 2.0.0",
{{else}}{{#if (eq modelProvider "Gemini")}}"strands-agents[gemini] >= 1.15.0, < 2.0.0",
{{else}}{{#if (eq modelProvider "LiteLLM")}}"strands-agents[litellm] >= 1.15.0, < 2.0.0",
{{else}}"strands-agents >= 1.15.0, < 2.0.0",
{{/if}}{{/if}}{{/if}}{{/if}}
]

Expand Down
4 changes: 2 additions & 2 deletions src/assets/templates/agui-python-strands/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ dependencies = [
"ag-ui-strands >= 0.3.0, < 0.4.0",
"ag-ui-protocol >= 0.1.19, < 0.2.0",
"aws-opentelemetry-distro ~= 0.18.0",
"bedrock-agentcore ~= 1.9.1",
"bedrock-agentcore[strands-agents] >= 1.18.1, < 2.0.0",
"botocore[crt] ~= 1.43.0",
"strands-agents ~= 1.15.0",
"strands-agents >= 1.15.0, < 2.0.0",
"uvicorn >= 0.34.3, < 1.0.0",
]

Expand Down
6 changes: 3 additions & 3 deletions src/assets/templates/export-harness-python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"aws-opentelemetry-distro ~= 0.18.0",
"bedrock-agentcore ~= 1.9.1",
"bedrock-agentcore[strands-agents] >= 1.18.1, < 2.0.0",
"botocore[crt] ~= 1.43.0",
"mcp >= 1.23.0, < 2.0.0",
"mcp >= 1.28.1, < 2.0.0",
{{#if bedrockMantle}}"aws-bedrock-token-generator >= 1.1.0, < 2.0.0",
{{/if}}"strands-agents{{#if strandsExtras}}[{{strandsExtras}}]{{/if}} ~= 1.54.0",
{{/if}}"strands-agents{{#if strandsExtras}}[{{strandsExtras}}]{{/if}} >= 1.54.0, < 2.0.0",

]

Expand Down
2 changes: 1 addition & 1 deletion src/assets/templates/mcp-python-fastmcp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"aws-opentelemetry-distro ~= 0.18.0",
"mcp ~= 1.24.0",
"mcp >= 1.28.1, < 2.0.0",
]

[tool.hatch.build.targets.wheel]
Expand Down
18 changes: 14 additions & 4 deletions src/core/project/manager.export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ function exportInput(overrides: Partial<ExportHarnessInput> = {}): ExportHarness
}

describe("FsProjectManager.exportHarness rendered tree", () => {
test("an exported harness permits the framework version selected by the SDK integration", async () => {
const { manager: subject } = manager();
const project = await projectWithHarness(subject);

const result = await drain(subject.exportHarness(project, exportInput()));

const pyproject = await Bun.file(join(result.agentPath, "pyproject.toml")).text();
expect(pyproject).toContain('"strands-agents >= 1.54.0, < 2.0.0"');
});

test("loads only the MCP tools allowedTools selects", async () => {
const { manager: subject } = manager();
const project = await projectWithHarness(subject, {
Expand Down Expand Up @@ -238,7 +248,7 @@ describe("FsProjectManager.exportHarness rendered tree", () => {
expect(loadModel).toContain('params["temperature"] = 0.2');
expect(loadModel).toContain('params["top_p"] = 0.8');
const pyproject = await Bun.file(join(result.agentPath, "pyproject.toml")).text();
expect(pyproject).toContain('"strands-agents[openai] ~= 1.54.0"');
expect(pyproject).toContain('"strands-agents[openai] >= 1.54.0, < 2.0.0"');
expect(pyproject).not.toContain('"openai ~= 1.0.0"');
});

Expand All @@ -265,7 +275,7 @@ describe("FsProjectManager.exportHarness rendered tree", () => {
expect(loadModel).toContain('params["top_p"] = 0.9');
expect(loadModel).toContain('params["top_k"] = 20');
expect(await Bun.file(join(result.agentPath, "pyproject.toml")).text()).toContain(
'"strands-agents[gemini] ~= 1.54.0"',
'"strands-agents[gemini] >= 1.54.0, < 2.0.0"',
);
});

Expand All @@ -290,7 +300,7 @@ describe("FsProjectManager.exportHarness rendered tree", () => {
expect(loadModel).toContain('params["top_p"] = 0.7');
expect(loadModel).toContain('json.loads("{\\"max_retries\\":2}")');
expect(await Bun.file(join(result.agentPath, "pyproject.toml")).text()).toContain(
'"strands-agents[litellm] ~= 1.54.0"',
'"strands-agents[litellm] >= 1.54.0, < 2.0.0"',
);
});

Expand All @@ -310,7 +320,7 @@ describe("FsProjectManager.exportHarness rendered tree", () => {
expect(main).toContain("from strands import AgentSkills");
expect(main).toContain('SlidingWindowConversationManager(**{"window_size":12}, per_turn=True)');
expect(await Bun.file(join(result.agentPath, "pyproject.toml")).text()).toContain(
'"strands-agents ~= 1.54.0"',
'"strands-agents >= 1.54.0, < 2.0.0"',
);
});

Expand Down
44 changes: 44 additions & 0 deletions src/core/project/templates/pythonSecurity.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { expect, test } from "bun:test";
import { FsAssetSource } from "../source";
import { HandlebarsTemplateRenderer } from "./renderer";

const source = new FsAssetSource();
const renderer = new HandlebarsTemplateRenderer();

test.each([
["agent-python-minimal", ["bedrock-agentcore >= 1.18.1, < 2.0.0"]],
["agent-python-strands", ["bedrock-agentcore[strands-agents] >= 1.18.1, < 2.0.0"]],
["a2a-python-strands", ["bedrock-agentcore[a2a,strands-agents] >= 1.18.1, < 2.0.0"]],
["agui-python-strands", ["bedrock-agentcore[strands-agents] >= 1.18.1, < 2.0.0"]],
[
"export-harness-python",
["bedrock-agentcore[strands-agents] >= 1.18.1, < 2.0.0", "mcp >= 1.28.1, < 2.0.0"],
],
["mcp-python-fastmcp", ["mcp >= 1.28.1, < 2.0.0"]],
] as const)("%s retains patched Python dependency ranges", async (template, dependencies) => {
const pyproject = renderer.render(await source.read(`templates/${template}/pyproject.toml`), {
name: "test_agent",
modelProvider: "Bedrock",
});

expect(Bun.TOML.parse(pyproject)).toMatchObject({
project: { dependencies: expect.arrayContaining([...dependencies]) },
});
});

test("the Strands container updates OS packages and removes uv after installing dependencies", async () => {
const dockerfile = renderer.render(
await source.read("templates/agent-python-strands/Dockerfile.template"),
{ entrypoint: "main" },
);

expect(dockerfile).toMatch(
/RUN apt-get update && apt-get upgrade -y[\s\S]*USER bedrock_agentcore/,
);
expect(dockerfile).toMatch(
/UV_NO_CACHE=1[\s\S]*RUN uv sync --frozen --no-dev --no-install-project/,
);
expect(dockerfile).toMatch(
/RUN uv sync --frozen --no-dev && \/usr\/local\/bin\/python -m pip uninstall -y uv[\s\S]*USER bedrock_agentcore/,
);
});
Loading