@aws/agentcore 1.0.0-preview.24 → 1.0.0-preview.25

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.
Files changed (27) hide show
  1. package/dist/assets/README.md +5 -0
  2. package/dist/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +115 -9
  3. package/dist/assets/__tests__/input-validation.test.ts +44 -0
  4. package/dist/assets/agents/AGENTS.md +2 -0
  5. package/dist/assets/evaluators/autoevals-lambda/execution-role-policy.json +15 -0
  6. package/dist/assets/evaluators/autoevals-lambda/lambda_function.py +37 -0
  7. package/dist/assets/evaluators/autoevals-lambda/pyproject.toml +22 -0
  8. package/dist/assets/evaluators/deepeval-lambda/execution-role-policy.json +15 -0
  9. package/dist/assets/evaluators/deepeval-lambda/lambda_function.py +29 -0
  10. package/dist/assets/evaluators/deepeval-lambda/pyproject.toml +19 -0
  11. package/dist/assets/python/http/autogen/base/README.md +5 -0
  12. package/dist/assets/python/http/autogen/base/main.py +2 -0
  13. package/dist/assets/python/http/googleadk/base/README.md +5 -0
  14. package/dist/assets/python/http/googleadk/base/main.py +2 -0
  15. package/dist/assets/python/http/langchain_langgraph/base/README.md +5 -0
  16. package/dist/assets/python/http/langchain_langgraph/base/main.py +4 -0
  17. package/dist/assets/python/http/openaiagents/base/README.md +5 -0
  18. package/dist/assets/python/http/openaiagents/base/main.py +2 -0
  19. package/dist/assets/python/http/strands/base/README.md +6 -0
  20. package/dist/assets/python/http/strands/base/main.py +40 -4
  21. package/dist/assets/typescript/http/strands/base/README.md +5 -0
  22. package/dist/assets/typescript/http/strands/base/main.ts +8 -3
  23. package/dist/assets/typescript/http/vercelai/base/README.md +5 -0
  24. package/dist/assets/typescript/http/vercelai/base/main.ts +8 -2
  25. package/dist/cli/index.mjs +421 -417
  26. package/npm-shrinkwrap.json +8 -8
  27. package/package.json +1 -1
@@ -13,6 +13,11 @@ defines an HTTP server that streams tokens from your chosen Agent framework SDK.
13
13
 
14
14
  `model/load.ts` instantiates your chosen model provider.
15
15
 
16
+ ## Input Validation
17
+
18
+ The generated Zod request schema keeps plain prompts typed as strings before forwarding them to Strands. Retain this
19
+ validation when extending the request shape, and pass only prompt text to the agent.
20
+
16
21
  ## Environment Variables
17
22
 
18
23
  | Variable | Required | Description |
@@ -34,6 +34,10 @@ const SYSTEM_PROMPT = `
34
34
  You are a helpful assistant. Use tools when appropriate.
35
35
  `;
36
36
 
37
+ const requestSchema = z.object({
38
+ prompt: z.string().default(''),
39
+ });
40
+
37
41
  {{#if hasMemory}}
38
42
  const agentCache = new Map<string, Agent>();
39
43
 
@@ -87,7 +91,8 @@ async function getOrCreateAgent(sessionId: string): Promise<Agent> {
87
91
 
88
92
  const app = new BedrockAgentCoreApp({
89
93
  invocationHandler: {
90
- async *process(payload: any, context: any) {
94
+ requestSchema,
95
+ async *process(payload, context) {
91
96
  {{#if hasMemory}}
92
97
  const sessionId = context?.sessionId ?? 'default-session';
93
98
  const actorId = getActorId(payload, context);
@@ -99,7 +104,7 @@ const app = new BedrockAgentCoreApp({
99
104
 
100
105
  {{#if hasMemory}}
101
106
  try {
102
- for await (const event of agent.stream(payload.prompt ?? '')) {
107
+ for await (const event of agent.stream(payload.prompt)) {
103
108
  if (
104
109
  event.type === 'modelStreamUpdateEvent' &&
105
110
  event.event?.type === 'modelContentBlockDeltaEvent' &&
@@ -123,7 +128,7 @@ const app = new BedrockAgentCoreApp({
123
128
  // e.g. Anthropic). Restoring on error keeps the session reusable.
124
129
  const snapshot = agent.takeSnapshot({ include: ['messages'] });
125
130
  try {
126
- for await (const event of agent.stream(payload.prompt ?? '')) {
131
+ for await (const event of agent.stream(payload.prompt)) {
127
132
  if (
128
133
  event.type === 'modelStreamUpdateEvent' &&
129
134
  event.event?.type === 'modelContentBlockDeltaEvent' &&
@@ -13,6 +13,11 @@ defines an HTTP app that streams tokens using the Vercel AI SDK's `streamText` A
13
13
 
14
14
  `model/load.ts` instantiates your chosen model provider.
15
15
 
16
+ ## Input Validation
17
+
18
+ The generated Zod request schema keeps plain prompts typed as strings before forwarding them to the agent framework.
19
+ Retain this validation when extending the request shape, and pass only prompt text to the agent.
20
+
16
21
  ## Environment Variables
17
22
 
18
23
  | Variable | Required | Description |
@@ -1,9 +1,14 @@
1
1
  import { BedrockAgentCoreApp } from 'bedrock-agentcore/runtime';
2
2
  import { streamText, type ModelMessage } from 'ai';
3
+ import { z } from 'zod';
3
4
  import { loadModel } from './model/load.js';
4
5
 
5
6
  const SYSTEM_PROMPT = `You are a helpful assistant.`;
6
7
 
8
+ const requestSchema = z.object({
9
+ prompt: z.string().default(''),
10
+ });
11
+
7
12
  const HISTORY_LIMIT = 128;
8
13
 
9
14
  // Keeps one message history per sessionId so each session remembers its own
@@ -32,10 +37,11 @@ function getHistory(sessionId: string): ModelMessage[] {
32
37
 
33
38
  const app = new BedrockAgentCoreApp({
34
39
  invocationHandler: {
35
- async *process(payload: any, context: any) {
40
+ requestSchema,
41
+ async *process(payload, context) {
36
42
  const sessionId = context?.sessionId ?? 'default-session';
37
43
  const history = getHistory(sessionId);
38
- const userMessage: ModelMessage = { role: 'user', content: payload.prompt ?? '' };
44
+ const userMessage: ModelMessage = { role: 'user', content: payload.prompt };
39
45
 
40
46
  const model = await loadModel();
41
47
  const result = streamText({