@aws/agentcore 0.3.0-preview.8.0 → 0.4.0
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/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +8 -337
- package/dist/assets/agents/AGENTS.md +1 -2
- package/dist/assets/cdk/test/cdk.test.ts +2 -1
- package/dist/assets/python/http/langchain_langgraph/base/main.py +4 -1
- package/dist/assets/python/http/langchain_langgraph/base/pyproject.toml +1 -2
- package/dist/cli/index.mjs +352 -337
- package/dist/lib/packaging/index.js +3 -3
- package/dist/lib/packaging/index.js.map +1 -1
- package/dist/lib/packaging/python.js +1 -1
- package/dist/lib/schemas/io/config-io.d.ts +11 -3
- package/dist/lib/schemas/io/config-io.d.ts.map +1 -1
- package/dist/lib/schemas/io/config-io.js +14 -3
- package/dist/lib/schemas/io/config-io.js.map +1 -1
- package/dist/lib/schemas/io/index.d.ts +1 -1
- package/dist/lib/schemas/io/index.d.ts.map +1 -1
- package/dist/lib/schemas/io/index.js +2 -1
- package/dist/lib/schemas/io/index.js.map +1 -1
- package/dist/schema/constants.d.ts +0 -1
- package/dist/schema/constants.d.ts.map +1 -1
- package/dist/schema/constants.js +2 -5
- package/dist/schema/constants.js.map +1 -1
- package/dist/schema/schemas/agent-env.d.ts +47 -7
- package/dist/schema/schemas/agent-env.d.ts.map +1 -1
- package/dist/schema/schemas/agent-env.js +50 -4
- package/dist/schema/schemas/agent-env.js.map +1 -1
- package/dist/schema/schemas/agentcore-project.d.ts +61 -27
- package/dist/schema/schemas/agentcore-project.d.ts.map +1 -1
- package/dist/schema/schemas/agentcore-project.js +24 -14
- package/dist/schema/schemas/agentcore-project.js.map +1 -1
- package/dist/schema/schemas/auth.d.ts +140 -0
- package/dist/schema/schemas/auth.d.ts.map +1 -0
- package/dist/schema/schemas/auth.js +114 -0
- package/dist/schema/schemas/auth.js.map +1 -0
- package/dist/schema/schemas/deployed-state.d.ts +4 -4
- package/dist/schema/schemas/deployed-state.js +3 -3
- package/dist/schema/schemas/deployed-state.js.map +1 -1
- package/dist/schema/schemas/index.d.ts +1 -0
- package/dist/schema/schemas/index.d.ts.map +1 -1
- package/dist/schema/schemas/index.js +1 -0
- package/dist/schema/schemas/index.js.map +1 -1
- package/dist/schema/schemas/mcp.d.ts +4 -107
- package/dist/schema/schemas/mcp.d.ts.map +1 -1
- package/dist/schema/schemas/mcp.js +9 -108
- package/dist/schema/schemas/mcp.js.map +1 -1
- package/dist/schema/schemas/primitives/index.d.ts +1 -1
- package/dist/schema/schemas/primitives/index.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/index.js +2 -1
- package/dist/schema/schemas/primitives/index.js.map +1 -1
- package/dist/schema/schemas/primitives/memory.d.ts +9 -0
- package/dist/schema/schemas/primitives/memory.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/memory.js +26 -3
- package/dist/schema/schemas/primitives/memory.js.map +1 -1
- package/dist/schema/schemas/primitives/online-eval-config.d.ts +0 -1
- package/dist/schema/schemas/primitives/online-eval-config.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/online-eval-config.js +0 -1
- package/dist/schema/schemas/primitives/online-eval-config.js.map +1 -1
- package/package.json +4 -1
- package/scripts/generate-schema.mjs +40 -0
- package/dist/assets/python/http/crewai/base/README.md +0 -39
- package/dist/assets/python/http/crewai/base/gitignore.template +0 -41
- package/dist/assets/python/http/crewai/base/main.py +0 -55
- package/dist/assets/python/http/crewai/base/model/__init__.py +0 -1
- package/dist/assets/python/http/crewai/base/model/load.py +0 -133
- package/dist/assets/python/http/crewai/base/pyproject.toml +0 -31
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MemoryStrategySchema = exports.MemoryStrategyNameSchema = exports.DEFAULT_STRATEGY_NAMESPACES = exports.MemoryStrategyTypeSchema = void 0;
|
|
3
|
+
exports.MemoryStrategySchema = exports.MemoryStrategyNameSchema = exports.DEFAULT_EPISODIC_REFLECTION_NAMESPACES = exports.DEFAULT_STRATEGY_NAMESPACES = exports.MemoryStrategyTypeSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
// ============================================================================
|
|
6
6
|
// Memory Strategy Types
|
|
@@ -11,9 +11,10 @@ const zod_1 = require("zod");
|
|
|
11
11
|
* - SEMANTIC → SemanticMemoryStrategy
|
|
12
12
|
* - SUMMARIZATION → SummaryMemoryStrategy (note: CloudFormation uses "Summary")
|
|
13
13
|
* - USER_PREFERENCE → UserPreferenceMemoryStrategy
|
|
14
|
+
* - EPISODIC → EpisodicMemoryStrategy
|
|
14
15
|
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-bedrockagentcore-memory-memorystrategy.html
|
|
15
16
|
*/
|
|
16
|
-
exports.MemoryStrategyTypeSchema = zod_1.z.enum(['SEMANTIC', 'SUMMARIZATION', 'USER_PREFERENCE']);
|
|
17
|
+
exports.MemoryStrategyTypeSchema = zod_1.z.enum(['SEMANTIC', 'SUMMARIZATION', 'USER_PREFERENCE', 'EPISODIC']);
|
|
17
18
|
/**
|
|
18
19
|
* Default namespaces for each memory strategy type.
|
|
19
20
|
* These match the patterns generated in CLI session.py templates.
|
|
@@ -22,7 +23,13 @@ exports.DEFAULT_STRATEGY_NAMESPACES = {
|
|
|
22
23
|
SEMANTIC: ['/users/{actorId}/facts'],
|
|
23
24
|
USER_PREFERENCE: ['/users/{actorId}/preferences'],
|
|
24
25
|
SUMMARIZATION: ['/summaries/{actorId}/{sessionId}'],
|
|
26
|
+
EPISODIC: ['/episodes/{actorId}/{sessionId}'],
|
|
25
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Default reflection namespaces for the EPISODIC strategy.
|
|
30
|
+
* The service requires reflection namespaces to be the same as or a prefix of episode namespaces.
|
|
31
|
+
*/
|
|
32
|
+
exports.DEFAULT_EPISODIC_REFLECTION_NAMESPACES = ['/episodes/{actorId}'];
|
|
26
33
|
/**
|
|
27
34
|
* Memory strategy name validation.
|
|
28
35
|
* Pattern: ^[a-zA-Z][a-zA-Z0-9_]{0,47}$
|
|
@@ -37,7 +44,8 @@ exports.MemoryStrategyNameSchema = zod_1.z
|
|
|
37
44
|
* Memory strategy configuration.
|
|
38
45
|
* Each memory can have multiple strategies with optional namespace scoping.
|
|
39
46
|
*/
|
|
40
|
-
exports.MemoryStrategySchema = zod_1.z
|
|
47
|
+
exports.MemoryStrategySchema = zod_1.z
|
|
48
|
+
.object({
|
|
41
49
|
/** Strategy type */
|
|
42
50
|
type: exports.MemoryStrategyTypeSchema,
|
|
43
51
|
/** Optional custom name for the strategy */
|
|
@@ -46,5 +54,20 @@ exports.MemoryStrategySchema = zod_1.z.object({
|
|
|
46
54
|
description: zod_1.z.string().optional(),
|
|
47
55
|
/** Optional namespaces for scoping memory access */
|
|
48
56
|
namespaces: zod_1.z.array(zod_1.z.string()).optional(),
|
|
57
|
+
/** Reflection namespaces for EPISODIC strategy. Required by the service for episodic strategies. */
|
|
58
|
+
reflectionNamespaces: zod_1.z.array(zod_1.z.string()).optional(),
|
|
59
|
+
})
|
|
60
|
+
.refine(strategy => strategy.type !== 'EPISODIC' ||
|
|
61
|
+
(strategy.reflectionNamespaces !== undefined && strategy.reflectionNamespaces.length > 0), {
|
|
62
|
+
message: 'EPISODIC strategy requires reflectionNamespaces',
|
|
63
|
+
path: ['reflectionNamespaces'],
|
|
64
|
+
})
|
|
65
|
+
.refine(strategy => {
|
|
66
|
+
if (strategy.type !== 'EPISODIC' || !strategy.reflectionNamespaces || !strategy.namespaces)
|
|
67
|
+
return true;
|
|
68
|
+
return strategy.reflectionNamespaces.every(ref => strategy.namespaces.some(ns => ns.startsWith(ref)));
|
|
69
|
+
}, {
|
|
70
|
+
message: 'Each reflectionNamespace must be a prefix of at least one namespace',
|
|
71
|
+
path: ['reflectionNamespaces'],
|
|
49
72
|
});
|
|
50
73
|
//# sourceMappingURL=memory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../../src/schema/schemas/primitives/memory.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../../src/schema/schemas/primitives/memory.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;;;;;;;GAQG;AACU,QAAA,wBAAwB,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;AAG7G;;;GAGG;AACU,QAAA,2BAA2B,GAAkD;IACxF,QAAQ,EAAE,CAAC,wBAAwB,CAAC;IACpC,eAAe,EAAE,CAAC,8BAA8B,CAAC;IACjD,aAAa,EAAE,CAAC,kCAAkC,CAAC;IACnD,QAAQ,EAAE,CAAC,iCAAiC,CAAC;CAC9C,CAAC;AAEF;;;GAGG;AACU,QAAA,sCAAsC,GAAa,CAAC,qBAAqB,CAAC,CAAC;AAExF;;;;GAIG;AACU,QAAA,wBAAwB,GAAG,OAAC;KACtC,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,EAAE,CAAC;KACP,KAAK,CACJ,8BAA8B,EAC9B,kGAAkG,CACnG,CAAC;AAEJ;;;GAGG;AACU,QAAA,oBAAoB,GAAG,OAAC;KAClC,MAAM,CAAC;IACN,oBAAoB;IACpB,IAAI,EAAE,gCAAwB;IAC9B,4CAA4C;IAC5C,IAAI,EAAE,gCAAwB,CAAC,QAAQ,EAAE;IACzC,2BAA2B;IAC3B,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,oDAAoD;IACpD,UAAU,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC1C,oGAAoG;IACpG,oBAAoB,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CACrD,CAAC;KACD,MAAM,CACL,QAAQ,CAAC,EAAE,CACT,QAAQ,CAAC,IAAI,KAAK,UAAU;IAC5B,CAAC,QAAQ,CAAC,oBAAoB,KAAK,SAAS,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,EAC3F;IACE,OAAO,EAAE,iDAAiD;IAC1D,IAAI,EAAE,CAAC,sBAAsB,CAAC;CAC/B,CACF;KACA,MAAM,CACL,QAAQ,CAAC,EAAE;IACT,IAAI,QAAQ,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,QAAQ,CAAC,oBAAoB,IAAI,CAAC,QAAQ,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IACxG,OAAO,QAAQ,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACzG,CAAC,EACD;IACE,OAAO,EAAE,qEAAqE;IAC9E,IAAI,EAAE,CAAC,sBAAsB,CAAC;CAC/B,CACF,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const OnlineEvalConfigNameSchema: z.ZodString;
|
|
3
3
|
export declare const OnlineEvalConfigSchema: z.ZodObject<{
|
|
4
|
-
type: z.ZodLiteral<"OnlineEvaluationConfig">;
|
|
5
4
|
name: z.ZodString;
|
|
6
5
|
agent: z.ZodString;
|
|
7
6
|
evaluators: z.ZodArray<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"online-eval-config.d.ts","sourceRoot":"","sources":["../../../../src/schema/schemas/primitives/online-eval-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,0BAA0B,aAOpC,CAAC;AAEJ,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"online-eval-config.d.ts","sourceRoot":"","sources":["../../../../src/schema/schemas/primitives/online-eval-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,0BAA0B,aAOpC,CAAC;AAEJ,eAAO,MAAM,sBAAsB;;;;;;;;iBAajC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -12,7 +12,6 @@ exports.OnlineEvalConfigNameSchema = zod_1.z
|
|
|
12
12
|
.max(48)
|
|
13
13
|
.regex(/^[a-zA-Z][a-zA-Z0-9_]{0,47}$/, 'Must begin with a letter and contain only alphanumeric characters and underscores (max 48 chars)');
|
|
14
14
|
exports.OnlineEvalConfigSchema = zod_1.z.object({
|
|
15
|
-
type: zod_1.z.literal('OnlineEvaluationConfig'),
|
|
16
15
|
name: exports.OnlineEvalConfigNameSchema,
|
|
17
16
|
/** Agent name to monitor (must match a project agent) */
|
|
18
17
|
agent: zod_1.z.string().min(1, 'Agent name is required'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"online-eval-config.js","sourceRoot":"","sources":["../../../../src/schema/schemas/primitives/online-eval-config.ts"],"names":[],"mappings":";;;AAAA,iCAAoC;AACpC,6BAAwB;AAExB,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAElE,QAAA,0BAA0B,GAAG,OAAC;KACxC,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC;KAC1B,GAAG,CAAC,EAAE,CAAC;KACP,KAAK,CACJ,8BAA8B,EAC9B,kGAAkG,CACnG,CAAC;AAES,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"online-eval-config.js","sourceRoot":"","sources":["../../../../src/schema/schemas/primitives/online-eval-config.ts"],"names":[],"mappings":";;;AAAA,iCAAoC;AACpC,6BAAwB;AAExB,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAElE,QAAA,0BAA0B,GAAG,OAAC;KACxC,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC;KAC1B,GAAG,CAAC,EAAE,CAAC;KACP,KAAK,CACJ,8BAA8B,EAC9B,kGAAkG,CACnG,CAAC;AAES,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,kCAA0B;IAChC,yDAAyD;IACzD,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC;IAClD,iEAAiE;IACjE,UAAU,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,oCAAoC,CAAC;IACnF,kDAAkD;IAClD,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAC3C,sDAAsD;IACtD,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IAC3C,4DAA4D;IAC5D,cAAc,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACtC,IAAI,EAAE,iBAAU,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws/agentcore",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "CLI for Amazon Bedrock AgentCore",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"scripts": {
|
|
47
47
|
"postinstall": "node scripts/check-old-cli.mjs",
|
|
48
48
|
"build": "npm run build:lib && npm run build:cli && npm run build:assets",
|
|
49
|
+
"build:schema": "node scripts/generate-schema.mjs && prettier --write schemas/",
|
|
49
50
|
"build:lib": "tsc -p tsconfig.build.json",
|
|
50
51
|
"build:cli": "node esbuild.config.mjs",
|
|
51
52
|
"build:assets": "node scripts/copy-assets.mjs",
|
|
@@ -95,6 +96,7 @@
|
|
|
95
96
|
"ink-spinner": "^5.0.0",
|
|
96
97
|
"js-yaml": "^4.1.1",
|
|
97
98
|
"react": "^19.2.3",
|
|
99
|
+
"yaml": "^2.8.3",
|
|
98
100
|
"zod": "^4.3.5"
|
|
99
101
|
},
|
|
100
102
|
"peerDependencies": {
|
|
@@ -102,6 +104,7 @@
|
|
|
102
104
|
"constructs": "^10.0.0"
|
|
103
105
|
},
|
|
104
106
|
"devDependencies": {
|
|
107
|
+
"@aws-sdk/client-cognito-identity-provider": "^3.1018.0",
|
|
105
108
|
"@eslint/js": "^9.39.2",
|
|
106
109
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
107
110
|
"@secretlint/secretlint-rule-preset-recommend": "^11.3.0",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates JSON Schema from the AgentCoreProjectSpec Zod schema.
|
|
3
|
+
* Runs against the compiled dist/ output — must be run after build:lib.
|
|
4
|
+
*/
|
|
5
|
+
import { mkdirSync, writeFileSync } from 'fs';
|
|
6
|
+
import { dirname, join } from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
const SCHEMA_VERSION = 'v1';
|
|
12
|
+
|
|
13
|
+
const outPath = join(__dirname, '..', 'schemas', `agentcore.schema.${SCHEMA_VERSION}.json`);
|
|
14
|
+
|
|
15
|
+
const z = await import('zod');
|
|
16
|
+
const { AgentCoreProjectSpecSchema } = await import('../dist/schema/schemas/agentcore-project.js');
|
|
17
|
+
|
|
18
|
+
const schema = z.toJSONSchema(AgentCoreProjectSpecSchema, { target: 'draft-07' });
|
|
19
|
+
|
|
20
|
+
// Fields with defaults should not be required — Zod's toJSONSchema marks them required anyway.
|
|
21
|
+
// Walk the entire schema tree so nested objects are fixed too.
|
|
22
|
+
function stripDefaultsFromRequired(node) {
|
|
23
|
+
if (typeof node !== 'object' || node === null) return;
|
|
24
|
+
if (Array.isArray(node)) {
|
|
25
|
+
node.forEach(stripDefaultsFromRequired);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (Array.isArray(node.required) && node.properties) {
|
|
29
|
+
node.required = node.required.filter(field => !('default' in (node.properties[field] ?? {})));
|
|
30
|
+
if (node.required.length === 0) delete node.required;
|
|
31
|
+
}
|
|
32
|
+
for (const value of Object.values(node)) {
|
|
33
|
+
stripDefaultsFromRequired(value);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
stripDefaultsFromRequired(schema);
|
|
37
|
+
|
|
38
|
+
mkdirSync(dirname(outPath), { recursive: true });
|
|
39
|
+
writeFileSync(outPath, JSON.stringify(schema, null, 2) + '\n');
|
|
40
|
+
console.log(`Schema written to ${outPath}`);
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
This is a project generated by the agentcore create CLI tool!
|
|
2
|
-
|
|
3
|
-
# Layout
|
|
4
|
-
|
|
5
|
-
The generated application code lives at the agent root directory. At the root, there is a `.gitignore` file, an
|
|
6
|
-
`agentcore/` folder which represents the configurations and state associated with this project. Other `agentcore`
|
|
7
|
-
commands like `deploy`, `dev`, and `invoke` rely on the configuration stored here.
|
|
8
|
-
|
|
9
|
-
## Agent Root
|
|
10
|
-
|
|
11
|
-
The main entrypoint to your app is defined in `main.py`. Using the AgentCore SDK `@app.entrypoint` decorator, this
|
|
12
|
-
file defines a Starlette ASGI app with the CrewAI framework running within.
|
|
13
|
-
|
|
14
|
-
`model/load.py` instantiates your chosen model provider.
|
|
15
|
-
|
|
16
|
-
## Environment Variables
|
|
17
|
-
|
|
18
|
-
| Variable | Required | Description |
|
|
19
|
-
| --- | --- | --- |
|
|
20
|
-
{{#if hasIdentity}}| `{{identityProviders.[0].envVarName}}` | Yes | {{modelProvider}} API key (local) or Identity provider name (deployed) |
|
|
21
|
-
{{/if}}| `LOCAL_DEV` | No | Set to `1` to use `.env.local` instead of AgentCore Identity |
|
|
22
|
-
|
|
23
|
-
# Developing locally
|
|
24
|
-
|
|
25
|
-
If installation was successful, a virtual environment is already created with dependencies installed.
|
|
26
|
-
|
|
27
|
-
Run `source .venv/bin/activate` before developing.
|
|
28
|
-
|
|
29
|
-
`agentcore dev` will start a local server on 0.0.0.0:8080.
|
|
30
|
-
|
|
31
|
-
In a new terminal, you can invoke that server with:
|
|
32
|
-
|
|
33
|
-
`agentcore invoke --dev "What can you do"`
|
|
34
|
-
|
|
35
|
-
# Deployment
|
|
36
|
-
|
|
37
|
-
After providing credentials, `agentcore deploy` will deploy your project into Amazon Bedrock AgentCore.
|
|
38
|
-
|
|
39
|
-
Use `agentcore invoke` to invoke your deployed agent.
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# Environment variables
|
|
2
|
-
.env
|
|
3
|
-
|
|
4
|
-
# Python
|
|
5
|
-
__pycache__/
|
|
6
|
-
*.py[cod]
|
|
7
|
-
*$py.class
|
|
8
|
-
*.so
|
|
9
|
-
.Python
|
|
10
|
-
build/
|
|
11
|
-
develop-eggs/
|
|
12
|
-
dist/
|
|
13
|
-
downloads/
|
|
14
|
-
eggs/
|
|
15
|
-
.eggs/
|
|
16
|
-
lib/
|
|
17
|
-
lib64/
|
|
18
|
-
parts/
|
|
19
|
-
sdist/
|
|
20
|
-
var/
|
|
21
|
-
wheels/
|
|
22
|
-
*.egg-info/
|
|
23
|
-
.installed.cfg
|
|
24
|
-
*.egg
|
|
25
|
-
|
|
26
|
-
# Virtual environments
|
|
27
|
-
.venv/
|
|
28
|
-
venv/
|
|
29
|
-
ENV/
|
|
30
|
-
env/
|
|
31
|
-
|
|
32
|
-
# IDE
|
|
33
|
-
.vscode/
|
|
34
|
-
.idea/
|
|
35
|
-
*.swp
|
|
36
|
-
*.swo
|
|
37
|
-
*~
|
|
38
|
-
|
|
39
|
-
# OS
|
|
40
|
-
.DS_Store
|
|
41
|
-
Thumbs.db
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
from crewai import Agent, Crew, Task, Process
|
|
2
|
-
from crewai.tools import tool
|
|
3
|
-
from bedrock_agentcore.runtime import BedrockAgentCoreApp
|
|
4
|
-
from model.load import load_model
|
|
5
|
-
|
|
6
|
-
app = BedrockAgentCoreApp()
|
|
7
|
-
log = app.logger
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# Define a simple function tool
|
|
11
|
-
@tool
|
|
12
|
-
def add_numbers(a: int, b: int) -> int:
|
|
13
|
-
"""Return the sum of two numbers"""
|
|
14
|
-
return a + b
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
# Define a collection of tools used by the model
|
|
18
|
-
tools = [add_numbers]
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@app.entrypoint
|
|
22
|
-
def invoke(payload, context):
|
|
23
|
-
log.info("Invoking Agent.....")
|
|
24
|
-
|
|
25
|
-
# Define the Agent with Tools
|
|
26
|
-
agent = Agent(
|
|
27
|
-
role="Question Answering Assistant",
|
|
28
|
-
goal="Answer the users questions",
|
|
29
|
-
backstory="Always eager to answer any questions",
|
|
30
|
-
llm=load_model(),
|
|
31
|
-
tools=tools,
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
# Define the Task
|
|
35
|
-
task = Task(
|
|
36
|
-
agent=agent,
|
|
37
|
-
description="Answer the users question: {prompt}",
|
|
38
|
-
expected_output="An answer to the users question",
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
# Create the Crew
|
|
42
|
-
crew = Crew(agents=[agent], tasks=[task], process=Process.sequential)
|
|
43
|
-
|
|
44
|
-
# Process the user prompt
|
|
45
|
-
prompt = payload.get("prompt", "What can you help me with?")
|
|
46
|
-
|
|
47
|
-
# Run the crew
|
|
48
|
-
result = crew.kickoff(inputs={"prompt": prompt})
|
|
49
|
-
|
|
50
|
-
# Return result
|
|
51
|
-
return {"result": result.raw}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if __name__ == "__main__":
|
|
55
|
-
app.run()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# Package marker
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
{{#if (eq modelProvider "Bedrock")}}
|
|
2
|
-
from crewai import LLM
|
|
3
|
-
|
|
4
|
-
# Uses global inference profile for Claude Sonnet 4.5
|
|
5
|
-
# https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html
|
|
6
|
-
MODEL_ID = "bedrock/global.anthropic.claude-sonnet-4-5-20250929-v1:0"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def load_model() -> LLM:
|
|
10
|
-
"""Get Bedrock model client using IAM credentials."""
|
|
11
|
-
return LLM(model=MODEL_ID)
|
|
12
|
-
{{/if}}
|
|
13
|
-
{{#if (eq modelProvider "Anthropic")}}
|
|
14
|
-
import os
|
|
15
|
-
from crewai import LLM
|
|
16
|
-
from bedrock_agentcore.identity.auth import requires_api_key
|
|
17
|
-
|
|
18
|
-
IDENTITY_PROVIDER_NAME = "{{identityProviders.[0].name}}"
|
|
19
|
-
IDENTITY_ENV_VAR = "{{identityProviders.[0].envVarName}}"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@requires_api_key(provider_name=IDENTITY_PROVIDER_NAME)
|
|
23
|
-
def _agentcore_identity_api_key_provider(api_key: str) -> str:
|
|
24
|
-
"""Fetch API key from AgentCore Identity."""
|
|
25
|
-
return api_key
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def _get_api_key() -> str:
|
|
29
|
-
"""
|
|
30
|
-
Uses AgentCore Identity for API key management in deployed environments.
|
|
31
|
-
For local development, run via 'agentcore dev' which loads agentcore/.env.
|
|
32
|
-
"""
|
|
33
|
-
if os.getenv("LOCAL_DEV") == "1":
|
|
34
|
-
api_key = os.getenv(IDENTITY_ENV_VAR)
|
|
35
|
-
if not api_key:
|
|
36
|
-
raise RuntimeError(
|
|
37
|
-
f"{IDENTITY_ENV_VAR} not found. Add {IDENTITY_ENV_VAR}=your-key to .env.local"
|
|
38
|
-
)
|
|
39
|
-
return api_key
|
|
40
|
-
return _agentcore_identity_api_key_provider()
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def load_model() -> LLM:
|
|
44
|
-
"""Get authenticated Anthropic model client."""
|
|
45
|
-
api_key = _get_api_key()
|
|
46
|
-
# CrewAI requires ANTHROPIC_API_KEY env var (ignores api_key parameter)
|
|
47
|
-
os.environ["ANTHROPIC_API_KEY"] = api_key
|
|
48
|
-
return LLM(
|
|
49
|
-
model="anthropic/claude-sonnet-4-5-20250929",
|
|
50
|
-
api_key=api_key,
|
|
51
|
-
max_tokens=4096
|
|
52
|
-
)
|
|
53
|
-
{{/if}}
|
|
54
|
-
{{#if (eq modelProvider "OpenAI")}}
|
|
55
|
-
import os
|
|
56
|
-
from crewai import LLM
|
|
57
|
-
from bedrock_agentcore.identity.auth import requires_api_key
|
|
58
|
-
|
|
59
|
-
IDENTITY_PROVIDER_NAME = "{{identityProviders.[0].name}}"
|
|
60
|
-
IDENTITY_ENV_VAR = "{{identityProviders.[0].envVarName}}"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
@requires_api_key(provider_name=IDENTITY_PROVIDER_NAME)
|
|
64
|
-
def _agentcore_identity_api_key_provider(api_key: str) -> str:
|
|
65
|
-
"""Fetch API key from AgentCore Identity."""
|
|
66
|
-
return api_key
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def _get_api_key() -> str:
|
|
70
|
-
"""
|
|
71
|
-
Uses AgentCore Identity for API key management in deployed environments.
|
|
72
|
-
For local development, run via 'agentcore dev' which loads agentcore/.env.
|
|
73
|
-
"""
|
|
74
|
-
if os.getenv("LOCAL_DEV") == "1":
|
|
75
|
-
api_key = os.getenv(IDENTITY_ENV_VAR)
|
|
76
|
-
if not api_key:
|
|
77
|
-
raise RuntimeError(
|
|
78
|
-
f"{IDENTITY_ENV_VAR} not found. Add {IDENTITY_ENV_VAR}=your-key to .env.local"
|
|
79
|
-
)
|
|
80
|
-
return api_key
|
|
81
|
-
return _agentcore_identity_api_key_provider()
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def load_model() -> LLM:
|
|
85
|
-
"""Get authenticated OpenAI model client."""
|
|
86
|
-
api_key = _get_api_key()
|
|
87
|
-
# CrewAI requires OPENAI_API_KEY env var (ignores api_key parameter)
|
|
88
|
-
os.environ["OPENAI_API_KEY"] = api_key
|
|
89
|
-
return LLM(
|
|
90
|
-
model="openai/gpt-4.1",
|
|
91
|
-
api_key=api_key
|
|
92
|
-
)
|
|
93
|
-
{{/if}}
|
|
94
|
-
{{#if (eq modelProvider "Gemini")}}
|
|
95
|
-
import os
|
|
96
|
-
from crewai import LLM
|
|
97
|
-
from bedrock_agentcore.identity.auth import requires_api_key
|
|
98
|
-
|
|
99
|
-
IDENTITY_PROVIDER_NAME = "{{identityProviders.[0].name}}"
|
|
100
|
-
IDENTITY_ENV_VAR = "{{identityProviders.[0].envVarName}}"
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
@requires_api_key(provider_name=IDENTITY_PROVIDER_NAME)
|
|
104
|
-
def _agentcore_identity_api_key_provider(api_key: str) -> str:
|
|
105
|
-
"""Fetch API key from AgentCore Identity."""
|
|
106
|
-
return api_key
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def _get_api_key() -> str:
|
|
110
|
-
"""
|
|
111
|
-
Uses AgentCore Identity for API key management in deployed environments.
|
|
112
|
-
For local development, run via 'agentcore dev' which loads agentcore/.env.
|
|
113
|
-
"""
|
|
114
|
-
if os.getenv("LOCAL_DEV") == "1":
|
|
115
|
-
api_key = os.getenv(IDENTITY_ENV_VAR)
|
|
116
|
-
if not api_key:
|
|
117
|
-
raise RuntimeError(
|
|
118
|
-
f"{IDENTITY_ENV_VAR} not found. Add {IDENTITY_ENV_VAR}=your-key to .env.local"
|
|
119
|
-
)
|
|
120
|
-
return api_key
|
|
121
|
-
return _agentcore_identity_api_key_provider()
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
def load_model() -> LLM:
|
|
125
|
-
"""Get authenticated Gemini model client."""
|
|
126
|
-
api_key = _get_api_key()
|
|
127
|
-
# CrewAI requires GEMINI_API_KEY env var (ignores api_key parameter)
|
|
128
|
-
os.environ["GEMINI_API_KEY"] = api_key
|
|
129
|
-
return LLM(
|
|
130
|
-
model="gemini/gemini-2.5-flash",
|
|
131
|
-
api_key=api_key
|
|
132
|
-
)
|
|
133
|
-
{{/if}}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["hatchling"]
|
|
3
|
-
build-backend = "hatchling.build"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "{{ name }}"
|
|
7
|
-
version = "0.1.0"
|
|
8
|
-
description = "AgentCore Runtime Application using CrewAI SDK"
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.11"
|
|
11
|
-
dependencies = [
|
|
12
|
-
"opentelemetry-distro",
|
|
13
|
-
"opentelemetry-exporter-otlp",
|
|
14
|
-
"bedrock-agentcore >= 1.0.3",
|
|
15
|
-
"botocore[crt] >= 1.35.0",
|
|
16
|
-
{{#if (eq modelProvider "Bedrock")}}
|
|
17
|
-
"crewai[tools,bedrock] >= 1.3.0",
|
|
18
|
-
{{/if}}
|
|
19
|
-
{{#if (eq modelProvider "Anthropic")}}
|
|
20
|
-
"crewai[tools,anthropic] >= 1.3.0",
|
|
21
|
-
{{/if}}
|
|
22
|
-
{{#if (eq modelProvider "OpenAI")}}
|
|
23
|
-
"crewai[tools,openai] >= 1.3.0",
|
|
24
|
-
{{/if}}
|
|
25
|
-
{{#if (eq modelProvider "Gemini")}}
|
|
26
|
-
"crewai[tools,google-genai] >= 1.3.0",
|
|
27
|
-
{{/if}}
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
[tool.hatch.build.targets.wheel]
|
|
31
|
-
packages = ["."]
|