@aws/agentcore 1.0.0-rc.1 → 1.0.0-rc.4
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/LICENSE +175 -0
- package/README.md +93 -985
- package/dist/assets/agent-inspector/index.js.asset +1 -1
- package/dist/assets/cdk/README.md +42 -19
- package/dist/assets/cdk/bin/cdk.ts +22 -173
- package/dist/assets/cdk/lib/cdk-stack.ts +18 -80
- package/dist/assets/cdk/package.json +3 -10
- package/dist/assets/cdk/tsconfig.json +1 -1
- package/dist/assets/evaluators/python-lambda/README.md +5 -1
- package/dist/assets/templates/a2a-python-strands/pyproject.toml +1 -1
- package/dist/assets/templates/agent-python-langchain/README.md +5 -4
- package/dist/assets/templates/agent-python-langchain/main.py +7 -11
- package/dist/assets/templates/agent-python-strands/README.md +16 -2
- package/dist/assets/templates/agent-python-strands/main.py +40 -81
- package/dist/assets/templates/agent-python-strands/memory/session.py +1 -5
- package/dist/assets/templates/agent-python-strands/model/load.py +4 -4
- package/dist/assets/templates/agent-python-strands/parse.py +41 -0
- package/dist/assets/templates/agent-typescript-strands/README.md +23 -2
- package/dist/assets/templates/agent-typescript-strands/main.ts +4 -13
- package/dist/assets/templates/agent-typescript-strands/memory/memory.ts +1 -12
- package/dist/assets/templates/agent-typescript-strands/package.json.template +0 -1
- package/dist/assets/templates/agui-python-strands/README.md +1 -1
- package/dist/assets/templates/agui-python-strands/pyproject.toml +1 -1
- package/dist/assets/templates/export-harness-python/model/load.py +3 -3
- package/dist/assets/templates/harness/harness.yaml +225 -0
- package/dist/main.js +728 -220
- package/package.json +13 -6
- package/dist/assets/cdk/.prettierrc +0 -8
- package/dist/assets/cdk/jest.config.js +0 -9
- package/dist/assets/cdk/npmignore.template +0 -6
- package/dist/assets/cdk/test/cdk.test.ts +0 -120
- package/dist/assets/evaluators/autoevals-lambda/README.md +0 -23
- package/dist/assets/evaluators/autoevals-lambda/execution-role-policy.json +0 -15
- package/dist/assets/evaluators/autoevals-lambda/lambda_function.py +0 -37
- package/dist/assets/evaluators/autoevals-lambda/pyproject.toml +0 -23
- package/dist/assets/evaluators/deepeval-lambda/README.md +0 -23
- package/dist/assets/evaluators/deepeval-lambda/execution-role-policy.json +0 -15
- package/dist/assets/evaluators/deepeval-lambda/lambda_function.py +0 -29
- package/dist/assets/evaluators/deepeval-lambda/pyproject.toml +0 -22
- package/dist/assets/templates/agent-typescript-strands/mcp_client/client.ts +0 -11
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# AgentCore CLI
|
|
2
2
|
|
|
3
3
|
`agentcore` is a command-line tool and interactive terminal UI (TUI) for managing
|
|
4
|
-
**[AWS Bedrock AgentCore](https://aws.amazon.com/bedrock/agentcore/)
|
|
4
|
+
**[AWS Bedrock AgentCore](https://aws.amazon.com/bedrock/agentcore/)**. AgentCore is Amazon's
|
|
5
5
|
platform for building and running production AI agents.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**[Amazon Bedrock AgentCore documentation](https://docs.aws.amazon.com/bedrock-agentcore/)**
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
It gives you two ways to work, from the same package:
|
|
10
|
+
|
|
11
|
+
- **A scriptable CLI** — composed of flag-driven commands with JSON output (`--json`) for
|
|
12
|
+
coding agents, scripts, CI, and automation.
|
|
13
|
+
- **An interactive TUI** — guided workflows for creating projects, browsing
|
|
14
|
+
resources, and chatting with agents.
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
agentcore # launch the interactive TUI
|
|
@@ -20,1019 +20,127 @@ agentcore harness list --json # scriptable, machine-readable output
|
|
|
20
20
|
|
|
21
21
|
## What problem does it solve?
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
responses. `agentcore` wraps all of that behind one ergonomic tool.
|
|
27
|
-
|
|
28
|
-
## Command surface
|
|
29
|
-
|
|
30
|
-
Commands with operation flags run headlessly. Bare Harness, Runtime, Memory,
|
|
31
|
-
Identity, and Gateway branches and leaves open their interactive flows, as does
|
|
32
|
-
a bare `project create` in a terminal (any flag, `--json`, or a non-TTY stays
|
|
33
|
-
headless). A bare `project status` opens a Linked Resources view that groups
|
|
34
|
-
the project's resources by agent and forwards to each deployed resource's
|
|
35
|
-
detail page. The harness hub (`harness get`) ends with the same kind of Linked
|
|
36
|
-
Resources tree for the Runtime, Memory, Gateway, Browser, Code Interpreter and
|
|
37
|
-
credential providers wired to that harness, each opening in its own region.
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
agentcore # interactive TUI
|
|
41
|
-
├── harness # manage agentcore harnesses
|
|
42
|
-
│ ├── create # create a harness (auto-provisions a role if none given)
|
|
43
|
-
│ ├── get # fetch a harness by id
|
|
44
|
-
│ ├── list # list harnesses (server-side paginated)
|
|
45
|
-
│ ├── update # update a harness
|
|
46
|
-
│ ├── delete # delete a harness
|
|
47
|
-
│ ├── invoke # chat with / prompt a harness (streams the reply)
|
|
48
|
-
│ ├── exec # run a shell command in a harness runtime
|
|
49
|
-
│ ├── version
|
|
50
|
-
│ │ ├── list # list a harness's versions
|
|
51
|
-
│ │ └── get # get a specific version
|
|
52
|
-
│ └── endpoint
|
|
53
|
-
│ ├── create
|
|
54
|
-
│ ├── get
|
|
55
|
-
│ ├── list
|
|
56
|
-
│ ├── update
|
|
57
|
-
│ └── delete
|
|
58
|
-
├── identity # manage AgentCore Identity resources
|
|
59
|
-
│ ├── api-key-credential-provider
|
|
60
|
-
│ │ ├── create # create an API key credential provider
|
|
61
|
-
│ │ ├── get # get an API key credential provider
|
|
62
|
-
│ │ ├── list # list API key credential providers
|
|
63
|
-
│ │ ├── update # update an API key credential provider
|
|
64
|
-
│ │ └── delete # delete an API key credential provider
|
|
65
|
-
│ └── oauth2-credential-provider
|
|
66
|
-
│ ├── create # create an OAuth2 credential provider
|
|
67
|
-
│ ├── get # get an OAuth2 credential provider
|
|
68
|
-
│ ├── list # list OAuth2 credential providers
|
|
69
|
-
│ ├── update # update an OAuth2 credential provider
|
|
70
|
-
│ └── delete # delete an OAuth2 credential provider
|
|
71
|
-
├── runtime # inspect deployed AgentCore Runtimes
|
|
72
|
-
│ ├── get # fetch a Runtime by id
|
|
73
|
-
│ ├── list # list Runtimes (server-side paginated)
|
|
74
|
-
│ ├── invoke # invoke a Runtime headlessly or in a persistent console
|
|
75
|
-
│ ├── shell # open a persistent interactive terminal in a Runtime
|
|
76
|
-
│ ├── logs # follow a Runtime's logs live, or search a time window
|
|
77
|
-
│ ├── traces
|
|
78
|
-
│ │ ├── list # list a Runtime's recent traces
|
|
79
|
-
│ │ └── get # download a trace's log records to a JSON file
|
|
80
|
-
│ ├── version
|
|
81
|
-
│ │ ├── get # get a specific Runtime version
|
|
82
|
-
│ │ └── list # list a Runtime's versions
|
|
83
|
-
│ └── endpoint
|
|
84
|
-
│ ├── get # get a Runtime endpoint by qualifier
|
|
85
|
-
│ └── list # list a Runtime's endpoints
|
|
86
|
-
├── memory # inspect AgentCore Memories
|
|
87
|
-
│ ├── get # fetch a Memory by id
|
|
88
|
-
│ ├── list # list Memories (server-side paginated)
|
|
89
|
-
│ ├── event
|
|
90
|
-
│ │ ├── get # get an Event from a Memory session
|
|
91
|
-
│ │ └── list # list Events from a Memory session
|
|
92
|
-
│ └── record
|
|
93
|
-
│ ├── get # get a long-term Memory record
|
|
94
|
-
│ └── list # list long-term Memory records
|
|
95
|
-
├── gateway # manage AgentCore Gateways
|
|
96
|
-
│ ├── get # get a Gateway by id
|
|
97
|
-
│ ├── list # list Gateways (server-side paginated)
|
|
98
|
-
│ ├── invoke # invoke a Gateway headlessly or in a persistent console
|
|
99
|
-
│ ├── target
|
|
100
|
-
│ │ ├── get # get a Target under a Gateway
|
|
101
|
-
│ │ └── list # list Targets under a Gateway
|
|
102
|
-
│ ├── connector
|
|
103
|
-
│ │ ├── get # get a connector-backed Target
|
|
104
|
-
│ │ └── list # list connector-backed Targets
|
|
105
|
-
│ ├── rule
|
|
106
|
-
│ │ ├── get # get a Rule under a Gateway
|
|
107
|
-
│ │ └── list # list Rules under a Gateway
|
|
108
|
-
│ └── policy
|
|
109
|
-
│ └── generate # generate Cedar for a Gateway from a prompt (TUI when run bare)
|
|
110
|
-
├── eval # evaluate and optimize AgentCore agents
|
|
111
|
-
│ └── evaluator # manage AgentCore evaluators
|
|
112
|
-
│ ├── llm-as-a-judge # LLM-as-a-Judge evaluators
|
|
113
|
-
│ │ ├── create # create (instructions + rating scale + model)
|
|
114
|
-
│ │ └── update # update (merged over the existing config)
|
|
115
|
-
│ ├── code-based # code-based (Lambda-backed) evaluators
|
|
116
|
-
│ │ ├── create # create (Lambda ARN + optional timeout)
|
|
117
|
-
│ │ └── update # update (merged over the existing config)
|
|
118
|
-
│ ├── get # get an evaluator by id (type-agnostic)
|
|
119
|
-
│ ├── list # list evaluators (server-side paginated)
|
|
120
|
-
│ └── delete # delete an evaluator by id
|
|
121
|
-
├── project # manage an AgentCore project (scaffold → deploy)
|
|
122
|
-
│ ├── create # create a project: a managed harness by default,
|
|
123
|
-
│ │ # or scaffolded runtime code via --template;
|
|
124
|
-
│ │ # bare `project create` opens an interactive wizard
|
|
125
|
-
│ ├── add # add a resource to the project (runtime, harness, memory, …)
|
|
126
|
-
│ ├── export
|
|
127
|
-
│ │ └── harness # convert a harness into an editable Strands runtime agent
|
|
128
|
-
│ ├── remove # remove a resource from the project spec (spec-level;
|
|
129
|
-
│ │ # code under app/ is kept). Resource types: harness,
|
|
130
|
-
│ │ # runtime, credential, config-bundle, online-eval,
|
|
131
|
-
│ │ # online-insight, memory, gateway, gateway-target,
|
|
132
|
-
│ │ # gateway-connector, policy-engine, policy,
|
|
133
|
-
│ │ # payment-manager, payment-connector — or `all`, which
|
|
134
|
-
│ │ # empties every resource collection (y/N prompt; --yes
|
|
135
|
-
│ │ # skips it for non-interactive use)
|
|
136
|
-
│ ├── dev # run the project locally
|
|
137
|
-
│ ├── deploy # deploy to AWS (auto-provisions the default target)
|
|
138
|
-
│ ├── invoke # invoke a deployed project resource
|
|
139
|
-
│ │ ├── runtime # use the existing Runtime invoke experience
|
|
140
|
-
│ │ └── harness # use the existing Harness invoke experience
|
|
141
|
-
│ ├── status # inspect deployed project resources (TUI when run bare)
|
|
142
|
-
│ └── build # synthesize the project's CloudFormation templates
|
|
143
|
-
└── config # read/write global config values
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
`project export harness` "ejects" a harness to code you own: it renders a
|
|
147
|
-
Python Strands agent under `app/<target-agent-name>/` mapping the harness spec
|
|
148
|
-
(model, system prompt, tools, skills, memory, execution limits), registers the
|
|
149
|
-
new runtime in `agentcore.json` (the harness entry stays), and writes an
|
|
150
|
-
`EXPORT_NOTES.md` in the agent directory listing anything that could not be
|
|
151
|
-
mapped mechanically. Pass `--name <harness>` for an in-project harness or
|
|
152
|
-
`--arn <harnessArn>` to fetch a deployed one (the fetch uses the region
|
|
153
|
-
embedded in the ARN); `--target-agent-name` overrides the default
|
|
154
|
-
`<harnessName>Agent`. The exported agent is always a `CodeZip` runtime: it
|
|
155
|
-
declares its own dependencies, so it needs no image build. If the harness used a
|
|
156
|
-
pre-built container image or a custom Dockerfile, that is reported in
|
|
157
|
-
`EXPORT_NOTES.md` rather than rebuilt. Path-based skills are not supported,
|
|
158
|
-
since the exported agent has no container filesystem to read them from.
|
|
23
|
+
Using the AgentCore APIs directly means making calls across several services,
|
|
24
|
+
setting up execution roles, and handling streamed responses. `agentcore` handles
|
|
25
|
+
those details so you can create, deploy, and invoke agents from your terminal.
|
|
159
26
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
| Flag | Purpose |
|
|
163
|
-
| ---------------- | -------------------------------------------------------------------- |
|
|
164
|
-
| `--region` | AWS region (falls back to `AWS_REGION`, then the shared AWS config). |
|
|
165
|
-
| `--json` | Emit machine-readable JSON instead of launching the TUI. |
|
|
166
|
-
| `--debug` | Debug logging. |
|
|
167
|
-
| `--endpoint-url` | Override the service endpoint URL (e.g. for testing against a stub). |
|
|
27
|
+
## Quick Start
|
|
168
28
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
Run `agentcore project invoke` from inside a project to choose a deployed
|
|
172
|
-
Runtime or Harness interactively. Headless invocation keeps each resource's
|
|
173
|
-
existing input contract:
|
|
29
|
+
Create a managed Harness project, deploy it, and send a prompt:
|
|
174
30
|
|
|
175
31
|
```bash
|
|
176
|
-
agentcore project invoke runtime \
|
|
177
|
-
--name checkout \
|
|
178
|
-
--payload '{"prompt":"Check order 123."}' \
|
|
179
|
-
--content-type application/json
|
|
180
|
-
|
|
181
|
-
agentcore project invoke harness \
|
|
182
|
-
--name support \
|
|
183
|
-
--prompt "Help with my account."
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
Use `--target` to select a deployment target. When a project declares exactly
|
|
187
|
-
one resource of the requested type, `--name` may be omitted.
|
|
188
|
-
|
|
189
|
-
### Examples
|
|
190
|
-
|
|
191
|
-
```bash
|
|
192
|
-
# Create a project. The default is a harness project: a managed agent
|
|
193
|
-
# configured by spec, no model-loop code to maintain. Passing only --name
|
|
194
|
-
# scaffolds the default harness.
|
|
195
32
|
agentcore project create --name MyAssistant
|
|
196
|
-
cd MyAssistant
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
# creation path.
|
|
200
|
-
agentcore harness invoke --id <id from the deploy outputs> --prompt "hello"
|
|
201
|
-
|
|
202
|
-
# Scaffold runtime code instead by selecting a template. Templates that support
|
|
203
|
-
# a model provider (agent-python-strands) accept --model-provider/--api-key;
|
|
204
|
-
# add the -container suffix for a container build, or use `empty` for a project
|
|
205
|
-
# with no runtime.
|
|
206
|
-
agentcore project create --name MyAgent --template agent-python-strands
|
|
207
|
-
# The same Strands agent built as a container image, with a Dockerfile.
|
|
208
|
-
agentcore project create --name MyAgent --template agent-python-strands-container
|
|
209
|
-
# A LangChain agent on Bedrock, built with create_agent.
|
|
210
|
-
agentcore project create --name MyAgent --template agent-python-langchain
|
|
211
|
-
|
|
212
|
-
# Translate an existing Amazon Bedrock Agent version into editable runtime code
|
|
213
|
-
# with `project add runtime --type import` from inside a project. The selected
|
|
214
|
-
# alias identifies the immutable source version; generated code invokes models
|
|
215
|
-
# and translated tools directly rather than proxying the alias. Use --framework
|
|
216
|
-
# strands (default) or langgraph. The alias must point at a prepared version,
|
|
217
|
-
# not the mutable DRAFT that the built-in test alias (TSTALIASID) routes to.
|
|
218
|
-
# Anything that could not be translated is listed in the generated IMPORT_NOTES.md.
|
|
219
|
-
agentcore project add runtime --name MyImportedAgent --type import \
|
|
220
|
-
--agent-id A1B2C3D4E5 --agent-alias-id XYZ123ABC4 --region us-east-1 \
|
|
221
|
-
--framework strands
|
|
33
|
+
cd MyAssistant
|
|
34
|
+
agentcore project deploy
|
|
35
|
+
agentcore project invoke harness --prompt "Hey, what can you do for me?"
|
|
222
36
|
```
|
|
223
37
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
agentcore harness create \
|
|
227
|
-
--name my-agent \
|
|
228
|
-
--system-prompt "You are a helpful assistant." \
|
|
229
|
-
--model '{"bedrockModelConfig":{"modelId":"us.anthropic.claude-sonnet-4-5-20250929-v1:0"}}' \
|
|
230
|
-
--json
|
|
231
|
-
|
|
232
|
-
# List and inspect
|
|
233
|
-
agentcore harness list --json
|
|
234
|
-
agentcore harness get --id <harnessId> --json
|
|
235
|
-
|
|
236
|
-
# One-shot prompt (streams, then prints the full transcript as JSON)
|
|
237
|
-
agentcore harness invoke --id <harnessId> --prompt "Summarize this repo." --json
|
|
238
|
-
|
|
239
|
-
# Interactive chat (no --prompt): opens the TUI chat at that harness/session
|
|
240
|
-
agentcore harness invoke --id <harnessId>
|
|
241
|
-
agentcore harness invoke --id <harnessId> --session-id <session> --qualifier PROD
|
|
242
|
-
|
|
243
|
-
# Run a shell command inside the agent runtime
|
|
244
|
-
agentcore harness exec --id <harnessId> --command "ls -la" --json
|
|
245
|
-
|
|
246
|
-
# Inspect deployed Runtimes without project configuration or deployment
|
|
247
|
-
agentcore runtime get --id <runtimeId>
|
|
248
|
-
agentcore runtime list --max-results 20
|
|
249
|
-
agentcore runtime version get --id <runtimeId> --version <version>
|
|
250
|
-
agentcore runtime version list --id <runtimeId> --max-results 20
|
|
251
|
-
agentcore runtime endpoint get --id <runtimeId> --qualifier DEFAULT
|
|
252
|
-
agentcore runtime endpoint list --id <runtimeId> --max-results 20
|
|
253
|
-
|
|
254
|
-
# Follow a Runtime's logs live (Ctrl+C to stop); inside a project --id is optional
|
|
255
|
-
agentcore runtime logs --id <runtimeId>
|
|
256
|
-
agentcore runtime logs --id <runtimeId> --level error --query "database"
|
|
257
|
-
|
|
258
|
-
# Search a past window instead (--since/--until switch to search mode)
|
|
259
|
-
agentcore runtime logs --id <runtimeId> --since 1h --limit 100
|
|
260
|
-
agentcore runtime logs --id <runtimeId> --since 2026-08-30T12:00:00Z --until now --json
|
|
261
|
-
|
|
262
|
-
# List recent traces (they take 2-3 minutes to appear), then download one
|
|
263
|
-
agentcore runtime traces list --id <runtimeId> --since 30m
|
|
264
|
-
agentcore runtime traces get <traceId> --id <runtimeId> --output trace.json
|
|
265
|
-
|
|
266
|
-
# Inspect AgentCore Memories without project configuration or deployment
|
|
267
|
-
agentcore memory get --id <memoryId>
|
|
268
|
-
agentcore memory get --id <memoryId> --view without_decryption
|
|
269
|
-
agentcore memory list --max-results 20
|
|
270
|
-
agentcore memory event get --id <memoryId> --actor-id <actorId> --session-id <sessionId> --event-id <eventId>
|
|
271
|
-
agentcore memory event list --id <memoryId> --actor-id <actorId> --session-id <sessionId> --max-results 20
|
|
272
|
-
agentcore memory record get --id <memoryId> --record-id <recordId>
|
|
273
|
-
agentcore memory record list --id <memoryId> --namespace <namespace> --max-results 20
|
|
274
|
-
|
|
275
|
-
# Inspect Gateway resources without project configuration or deployment
|
|
276
|
-
agentcore gateway get --id <gatewayId>
|
|
277
|
-
agentcore gateway list --max-results 20
|
|
278
|
-
agentcore gateway invoke --id <gatewayId> --payload file://request.json
|
|
279
|
-
agentcore gateway invoke --id <gatewayId> # open the persistent JSON console
|
|
280
|
-
agentcore gateway target get --gateway-id <gatewayId> --target-id <targetId>
|
|
281
|
-
agentcore gateway target list --gateway-id <gatewayId> --max-results 20
|
|
282
|
-
agentcore gateway connector get --gateway-id <gatewayId> --id <targetId>
|
|
283
|
-
agentcore gateway connector list --gateway-id <gatewayId> --max-results 20
|
|
284
|
-
agentcore gateway rule get --gateway-id <gatewayId> --rule-id <ruleId>
|
|
285
|
-
agentcore gateway rule list --gateway-id <gatewayId> --max-results 20
|
|
286
|
-
agentcore gateway policy generate --gateway-id <gatewayId> --prompt "forbid IAM callers from every tool"
|
|
287
|
-
agentcore gateway policy generate --gateway-id <gatewayArn> --prompt file://policy.txt --json
|
|
288
|
-
# Pipe the generated Cedar into a project (run inside the project)
|
|
289
|
-
agentcore gateway policy generate --gateway-id <gatewayId> --prompt "..." \
|
|
290
|
-
| agentcore project add policy --engine Guardrails --name Generated --statement -
|
|
291
|
-
|
|
292
|
-
# Manage API key credential providers
|
|
293
|
-
agentcore identity api-key-credential-provider create --name my-provider --api-key <key>
|
|
294
|
-
agentcore identity api-key-credential-provider get --name my-provider
|
|
295
|
-
agentcore identity api-key-credential-provider list --max-results 10
|
|
296
|
-
agentcore identity api-key-credential-provider update --name my-provider --api-key <new-key>
|
|
297
|
-
agentcore identity api-key-credential-provider delete --name my-provider
|
|
298
|
-
|
|
299
|
-
# Manage OAuth2 credential providers (guided Custom OAuth2, or --provider-configuration for other vendors)
|
|
300
|
-
agentcore identity oauth2-credential-provider create \
|
|
301
|
-
--name my-oauth-provider \
|
|
302
|
-
--vendor CustomOauth2 \
|
|
303
|
-
--client-id <client-id> \
|
|
304
|
-
--discovery-url https://issuer.example.com/.well-known/openid-configuration \
|
|
305
|
-
--client-secret -
|
|
306
|
-
agentcore identity oauth2-credential-provider get --name my-oauth-provider
|
|
307
|
-
agentcore identity oauth2-credential-provider list --max-results 10
|
|
308
|
-
agentcore identity oauth2-credential-provider delete --name my-oauth-provider
|
|
309
|
-
|
|
310
|
-
# Manage evaluators
|
|
311
|
-
# Create an LLM-as-a-Judge evaluator with a rating-scale preset.
|
|
312
|
-
agentcore eval evaluator llm-as-a-judge create \
|
|
313
|
-
--name order-support-quality \
|
|
314
|
-
--level SESSION \
|
|
315
|
-
--model us.anthropic.claude-sonnet-4-5-20250929-v1:0 \
|
|
316
|
-
--instructions "Judge from {context} whether the order-support agent answered correctly." \
|
|
317
|
-
--rating-scale 1-5-quality \
|
|
318
|
-
--json
|
|
319
|
-
|
|
320
|
-
# Create a code-based (Lambda-backed) evaluator; timeout defaults to the service value.
|
|
321
|
-
agentcore eval evaluator code-based create \
|
|
322
|
-
--name refund-policy-compliance \
|
|
323
|
-
--level SESSION \
|
|
324
|
-
--lambda-arn arn:aws:lambda:us-west-2:123456789012:function:refund-policy \
|
|
325
|
-
--json
|
|
326
|
-
|
|
327
|
-
# Get, list, delete.
|
|
328
|
-
agentcore eval evaluator get --id <evaluatorId> --json
|
|
329
|
-
agentcore eval evaluator list --max-results 20 --json
|
|
330
|
-
agentcore eval evaluator delete --id <evaluatorId> --json
|
|
331
|
-
|
|
332
|
-
# Remove resources from a project's spec (run inside the project)
|
|
333
|
-
agentcore project remove memory --name recall
|
|
334
|
-
agentcore project remove credential --name svc-key # also deletes its .env.local entries
|
|
335
|
-
agentcore project remove gateway-target --gateway tools --name search
|
|
336
|
-
agentcore project remove all # y/N prompt; empties every collection
|
|
337
|
-
agentcore project remove all --yes # non-interactive
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
Source-aware values: any field flag documented as such accepts the value inline,
|
|
341
|
-
`file://<path>` to read it from a file, or `-` to read it from stdin (the AWS CLI
|
|
342
|
-
`file://` convention). A command reads stdin from at most one flag. For example,
|
|
343
|
-
`--instructions file://order-quality.txt` or `--instructions -`.
|
|
344
|
-
|
|
345
|
-
### Invoke a Gateway
|
|
346
|
-
|
|
347
|
-
Gateway Invoke is a project-independent HTTP request command with headless and
|
|
348
|
-
interactive modes. It gets the Gateway by ID, uses the returned HTTPS origin,
|
|
349
|
-
selects authentication from the Gateway's authorizer, and preserves the request
|
|
350
|
-
and response bodies.
|
|
38
|
+
To start with code you own instead, create a Runtime project from a template.
|
|
39
|
+
Run this alternative from outside an existing project:
|
|
351
40
|
|
|
352
41
|
```bash
|
|
353
|
-
|
|
354
|
-
agentcore gateway invoke \
|
|
355
|
-
--id <gatewayId> \
|
|
356
|
-
--payload '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"agentcore-cli","version":"1"}}}' \
|
|
357
|
-
--accept 'application/json, text/event-stream' \
|
|
358
|
-
--mcp-protocol-version 2025-03-26
|
|
359
|
-
|
|
360
|
-
# HTTP target: --path is relative to the Gateway origin.
|
|
361
|
-
agentcore gateway invoke \
|
|
362
|
-
--id <gatewayId> \
|
|
363
|
-
--path support-agent/invocations \
|
|
364
|
-
--payload file://request.json \
|
|
365
|
-
--session-id <runtimeSessionId>
|
|
366
|
-
|
|
367
|
-
# Inference target.
|
|
368
|
-
agentcore gateway invoke \
|
|
369
|
-
--id <gatewayId> \
|
|
370
|
-
--path inference/v1/messages \
|
|
371
|
-
--payload file://message.json \
|
|
372
|
-
--json
|
|
373
|
-
|
|
374
|
-
# GET requests do not accept a payload.
|
|
375
|
-
agentcore gateway invoke \
|
|
376
|
-
--id <gatewayId> \
|
|
377
|
-
--method GET \
|
|
378
|
-
--path inference/v1/models
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
`--path` replaces the path in the returned Gateway URL while retaining its
|
|
382
|
-
origin. It must remain relative to the selected Gateway and may include a query
|
|
383
|
-
string. Omitting it uses the returned `gatewayUrl` exactly. Supported methods
|
|
384
|
-
are `GET`, `POST` (the default), and `DELETE`. POST requires `--payload`; DELETE
|
|
385
|
-
may include one. Payloads accept inline bytes, `file://<path>`, or `-` for stdin.
|
|
386
|
-
|
|
387
|
-
Authentication follows `GetGateway.authorizerType`: `AWS_IAM` and
|
|
388
|
-
`AUTHENTICATE_ONLY` requests use SigV4, `CUSTOM_JWT` requires `--bearer-token`,
|
|
389
|
-
and `NONE` uses unsigned HTTPS. Bearer tokens accept inline, `file://`, or stdin
|
|
390
|
-
sources; payload and token cannot both read stdin.
|
|
391
|
-
|
|
392
|
-
Raw responses stream exact bytes to stdout. `--output-file` streams those bytes
|
|
393
|
-
to disk, while `--json` buffers one envelope containing status, selected session
|
|
394
|
-
and request metadata, body encoding, and body. Binary or unknown output requires
|
|
395
|
-
`--output-file` or `--json` when stdout is a terminal. Response metadata goes to
|
|
396
|
-
stderr in raw and file modes. Redirects are returned without being followed.
|
|
397
|
-
Non-2xx response bodies use the selected output mode before the command exits
|
|
398
|
-
with a failure status.
|
|
399
|
-
|
|
400
|
-
Without `--payload`, Gateway Invoke opens a persistent POST JSON console. Bare
|
|
401
|
-
invoke opens the Gateway picker, while `--id` opens the selected Gateway
|
|
402
|
-
directly. `--path`, `--session-id`, MCP session flags, `--header`, and
|
|
403
|
-
`--bearer-token` seed the console. Interactive bearer tokens may be inline or
|
|
404
|
-
`file://` sources, but not stdin. Explicit headless-only flags such as
|
|
405
|
-
`--method`, `--accept`, `--content-type`, `--output-file`, or `--json` keep the
|
|
406
|
-
command headless.
|
|
407
|
-
|
|
408
|
-
The console generates and displays a Runtime session ID, adopts returned Runtime
|
|
409
|
-
and MCP sessions, and streams textual responses as they arrive. An empty path
|
|
410
|
-
uses the exact `gatewayUrl`; `Ctrl+P` edits the raw Gateway-relative path and
|
|
411
|
-
`Ctrl+T` switches Gateways. Switching Gateways clears request context, while
|
|
412
|
-
changing paths preserves the draft and Gateway authentication but starts fresh
|
|
413
|
-
sessions.
|
|
414
|
-
|
|
415
|
-
| Shortcut | Action |
|
|
416
|
-
| ------------- | -------------------------------------------- |
|
|
417
|
-
| `Enter` | Send the JSON request |
|
|
418
|
-
| `Shift+Enter` | Insert a newline |
|
|
419
|
-
| `Ctrl+P` | Edit the Gateway-relative path |
|
|
420
|
-
| `Ctrl+T` | Change Gateway |
|
|
421
|
-
| `Ctrl+V` | Toggle raw and pretty completed JSON |
|
|
422
|
-
| `Esc` | Interrupt an active request or navigate back |
|
|
423
|
-
| `↑`/`↓` | Scroll response history |
|
|
424
|
-
|
|
425
|
-
Gateway Invoke V1 has no request-type selector, target/path discovery,
|
|
426
|
-
tool/model discovery command, authentication editor, or protocol-specific
|
|
427
|
-
payload builder. Callers provide the Gateway-relative route and protocol payload
|
|
428
|
-
directly. GET and DELETE remain available through headless invoke.
|
|
429
|
-
|
|
430
|
-
### Invoke a Runtime
|
|
431
|
-
|
|
432
|
-
Headless invocation accepts inline, file, or stdin payload bytes:
|
|
433
|
-
|
|
434
|
-
```bash
|
|
435
|
-
# Inline
|
|
436
|
-
agentcore runtime invoke \
|
|
437
|
-
--id <runtimeId> \
|
|
438
|
-
--payload '{"action":"status"}' \
|
|
439
|
-
--content-type application/json \
|
|
440
|
-
--accept text/event-stream
|
|
441
|
-
|
|
442
|
-
# File
|
|
443
|
-
agentcore runtime invoke --id <runtimeId> --payload file://request.json
|
|
444
|
-
|
|
445
|
-
# stdin
|
|
446
|
-
cat request.json | agentcore runtime invoke --id <runtimeId> --payload -
|
|
447
|
-
```
|
|
448
|
-
|
|
449
|
-
CUSTOM_JWT Runtimes require `--bearer-token`. The token accepts the same inline,
|
|
450
|
-
`file://`, or stdin sources as the payload; payload and token cannot both read
|
|
451
|
-
stdin.
|
|
452
|
-
|
|
453
|
-
```bash
|
|
454
|
-
agentcore runtime invoke \
|
|
455
|
-
--id <runtimeId> \
|
|
456
|
-
--payload file://request.json \
|
|
457
|
-
--bearer-token file://$HOME/.config/agentcore/runtime-token
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
For MCP Runtimes, initialize first, then pass the returned Runtime and MCP
|
|
461
|
-
session IDs to later methods. MCP requests accept both JSON and SSE responses.
|
|
462
|
-
|
|
463
|
-
```bash
|
|
464
|
-
agentcore runtime invoke \
|
|
465
|
-
--id <runtimeId> \
|
|
466
|
-
--payload '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"agentcore-cli","version":"1"}}}' \
|
|
467
|
-
--accept 'application/json, text/event-stream' \
|
|
468
|
-
--mcp-protocol-version 2025-03-26 \
|
|
469
|
-
--mcp-method initialize
|
|
470
|
-
|
|
471
|
-
agentcore runtime invoke \
|
|
472
|
-
--id <runtimeId> \
|
|
473
|
-
--payload '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' \
|
|
474
|
-
--accept 'application/json, text/event-stream' \
|
|
475
|
-
--session-id <returnedRuntimeSessionId> \
|
|
476
|
-
--mcp-session-id <returnedMcpSessionId> \
|
|
477
|
-
--mcp-protocol-version 2025-03-26 \
|
|
478
|
-
--mcp-method tools/list
|
|
479
|
-
```
|
|
480
|
-
|
|
481
|
-
Raw stdout always streams exact response bytes as they arrive, regardless of
|
|
482
|
-
content type. `--output-file` streams the same bytes directly to disk. Binary or
|
|
483
|
-
unknown responses require `--output-file` or `--json` when stdout is a terminal.
|
|
484
|
-
Response metadata is written to stderr.
|
|
485
|
-
|
|
486
|
-
`--json` buffers the complete response, including streaming representations, and
|
|
487
|
-
emits one metadata envelope without interpreting the customer body. If a raw or
|
|
488
|
-
file response fails, bytes already written remain available and the stderr
|
|
489
|
-
summary reports `complete=false`. A failed JSON response emits no partial
|
|
490
|
-
envelope.
|
|
491
|
-
|
|
492
|
-
```bash
|
|
493
|
-
agentcore runtime invoke \
|
|
494
|
-
--id <runtimeId> \
|
|
495
|
-
--payload file://request.bin \
|
|
496
|
-
--content-type application/octet-stream \
|
|
497
|
-
--accept application/octet-stream \
|
|
498
|
-
--output-file response.bin
|
|
499
|
-
|
|
500
|
-
agentcore runtime invoke --id <runtimeId> --payload '{"action":"status"}' --json
|
|
501
|
-
# {"statusCode":200,"contentType":"application/json","bodyEncoding":"utf8","body":"{\"ok\":true}","complete":true}
|
|
502
|
-
```
|
|
503
|
-
|
|
504
|
-
Without `--payload`, Runtime Invoke opens a persistent JSON console for repeated
|
|
505
|
-
requests. The console sends inline `application/json` payloads and renders each
|
|
506
|
-
response according to its returned content type. Bare invoke opens the Runtime
|
|
507
|
-
and endpoint pickers; `--id` skips the Runtime picker, and `--id` plus
|
|
508
|
-
`--qualifier` opens the console directly. `--session-id` resumes that Runtime
|
|
509
|
-
session in the console. `--user-id`, `--header`, and `--bearer-token` seed
|
|
510
|
-
request context that persists across sends and endpoint changes within that
|
|
511
|
-
Runtime. The console never displays their values, and switching Runtimes clears
|
|
512
|
-
them. Interactive bearer tokens may be inline or `file://` sources, but not
|
|
513
|
-
stdin.
|
|
514
|
-
|
|
515
|
-
| Shortcut | Action |
|
|
516
|
-
| ------------- | -------------------------------------------- |
|
|
517
|
-
| `Enter` | Send the JSON request |
|
|
518
|
-
| `Shift+Enter` | Insert a newline |
|
|
519
|
-
| `Ctrl+T` | Change Runtime or endpoint |
|
|
520
|
-
| `Ctrl+V` | Toggle raw and pretty completed JSON |
|
|
521
|
-
| `Esc` | Interrupt an active request or navigate back |
|
|
522
|
-
| `↑`/`↓` | Scroll response history |
|
|
523
|
-
|
|
524
|
-
Runtime Invoke accepts Runtime IDs from the current account only. It does not
|
|
525
|
-
accept ARNs, `--version`, `--interactive`, cross-account targets, or custom
|
|
526
|
-
request paths. All requests use the Runtime `/invocations` route, including MCP
|
|
527
|
-
Runtimes.
|
|
528
|
-
|
|
529
|
-
### Open a Runtime shell
|
|
530
|
-
|
|
531
|
-
Runtime Shell opens a persistent interactive terminal in a Runtime session.
|
|
532
|
-
Bare shell opens the Runtime and endpoint pickers. `--id` skips the Runtime
|
|
533
|
-
picker, and `--id` plus `--qualifier` connects directly.
|
|
534
|
-
|
|
535
|
-
```bash
|
|
536
|
-
agentcore runtime shell
|
|
537
|
-
agentcore runtime shell --id <runtimeId>
|
|
538
|
-
agentcore runtime shell --id <runtimeId> --qualifier DEFAULT
|
|
539
|
-
```
|
|
540
|
-
|
|
541
|
-
Use `--session-id` to open the shell in a specific Runtime session/VM:
|
|
542
|
-
|
|
543
|
-
```bash
|
|
544
|
-
agentcore runtime shell \
|
|
545
|
-
--id <runtimeId> \
|
|
546
|
-
--qualifier DEFAULT \
|
|
547
|
-
--session-id <runtimeSessionId>
|
|
42
|
+
agentcore project create --name MyAgent --template agent-python-strands
|
|
548
43
|
```
|
|
549
44
|
|
|
550
|
-
|
|
551
|
-
inline or `file://` sources, but not stdin.
|
|
552
|
-
|
|
553
|
-
The shell forwards terminal input byte-for-byte, including `Ctrl+C`, `Ctrl+D`,
|
|
554
|
-
escape sequences, and full-screen terminal applications. Terminal resize events
|
|
555
|
-
update the remote PTY. Running `exit` or sending `Ctrl+D` terminates the remote
|
|
556
|
-
shell.
|
|
45
|
+
## Command Surface
|
|
557
46
|
|
|
558
|
-
|
|
559
|
-
|
|
47
|
+
`project` commands manage local project specifications and their deployments.
|
|
48
|
+
Resource commands operate on deployed resources without requiring a local project.
|
|
560
49
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
agentcore runtime version list
|
|
575
|
-
agentcore runtime endpoint list
|
|
576
|
-
agentcore memory
|
|
577
|
-
agentcore memory list
|
|
578
|
-
agentcore memory get
|
|
579
|
-
agentcore memory event
|
|
580
|
-
agentcore memory record
|
|
581
|
-
```
|
|
582
|
-
|
|
583
|
-
The Identity TUI is read-only: bare `identity` branches and the `get`/`list`
|
|
584
|
-
leaves open interactive menus and detail views. Mutations (`create`, `update`,
|
|
585
|
-
`delete`) remain available through the CLI and are omitted from the TUI menus.
|
|
586
|
-
|
|
587
|
-
```bash
|
|
588
|
-
agentcore identity
|
|
589
|
-
agentcore identity api-key-credential-provider list
|
|
590
|
-
agentcore identity api-key-credential-provider get
|
|
591
|
-
agentcore identity oauth2-credential-provider list
|
|
592
|
-
agentcore identity oauth2-credential-provider get
|
|
593
|
-
```
|
|
50
|
+
| Command | Purpose |
|
|
51
|
+
| ---------- | ----------------------------------------------------------------------------- |
|
|
52
|
+
| `project` | Create, develop, build, deploy, invoke, and inspect a project |
|
|
53
|
+
| `harness` | Manage Harnesses, versions, and endpoints; invoke and inspect them |
|
|
54
|
+
| `identity` | Manage credential providers |
|
|
55
|
+
| `runtime` | Inspect, invoke, and open a shell in deployed Runtimes |
|
|
56
|
+
| `memory` | Inspect Memories, actors, sessions, events, and records |
|
|
57
|
+
| `gateway` | Inspect and invoke Gateways, inspect targets and rules, and generate policies |
|
|
58
|
+
| `payment` | Inspect payment managers, connectors, sessions, instruments, and balances |
|
|
59
|
+
| `eval` | Evaluate agents, manage datasets and configurations, and run experiments |
|
|
60
|
+
| `feedback` | Submit feedback |
|
|
61
|
+
| `config` | Read and write global CLI settings |
|
|
62
|
+
| `update` | Check for and install CLI updates |
|
|
594
63
|
|
|
595
|
-
|
|
596
|
-
branches and their `get`/`list` leaves open command menus and scoped selection
|
|
597
|
-
flows. Connector is presented as a separate resource experience while using
|
|
598
|
-
Gateway Target operations internally.
|
|
64
|
+
Use `--help` for subcommands and flags, or browse the [command reference](command.md):
|
|
599
65
|
|
|
600
66
|
```bash
|
|
601
|
-
agentcore
|
|
602
|
-
agentcore
|
|
603
|
-
agentcore
|
|
604
|
-
agentcore gateway target list
|
|
605
|
-
agentcore gateway target get
|
|
606
|
-
agentcore gateway connector list
|
|
607
|
-
agentcore gateway connector get
|
|
608
|
-
agentcore gateway rule list
|
|
609
|
-
agentcore gateway rule get
|
|
67
|
+
agentcore --help
|
|
68
|
+
agentcore project --help
|
|
69
|
+
agentcore runtime invoke --help
|
|
610
70
|
```
|
|
611
71
|
|
|
612
|
-
|
|
72
|
+
Supported bare commands open their interactive flows in a terminal. Operation
|
|
73
|
+
flags select headless behavior for most commands, but invoke commands can use
|
|
74
|
+
selectors such as `--id` and `--session-id` to seed an interactive console.
|
|
75
|
+
Run `agentcore project create` for guided setup. To create a default project
|
|
76
|
+
without the wizard, run `agentcore project create --name MyAssistant`.
|
|
613
77
|
|
|
614
|
-
|
|
78
|
+
Global flags (declared at the root, available on every command):
|
|
615
79
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
80
|
+
| Flag | Purpose |
|
|
81
|
+
| ---------- | ------------------------------------------------------------------------------------------- |
|
|
82
|
+
| `--region` | AWS region: flag, `AWS_REGION`, `AWS_DEFAULT_REGION`, active AWS profile, then `us-east-1`. |
|
|
83
|
+
| `--json` | Emit machine-readable JSON instead of launching the TUI. |
|
|
84
|
+
| `--debug` | Debug logging. |
|
|
619
85
|
|
|
620
|
-
|
|
86
|
+
Run `agentcore --version` to check the installed CLI version.
|
|
621
87
|
|
|
622
|
-
|
|
623
|
-
┌───────────────────────────┐
|
|
624
|
-
argv ─────────────▶ │ Router / Handler tree │ src/router, src/handlers
|
|
625
|
-
│ (flags, args, middleware)│
|
|
626
|
-
└────────────┬──────────────┘
|
|
627
|
-
│
|
|
628
|
-
flags/args ? │ bare command ?
|
|
629
|
-
│ │ │
|
|
630
|
-
▼ ▼
|
|
631
|
-
┌─────────────────┐ ┌───────────────────┐
|
|
632
|
-
│ headless handler│ │ Ink/React TUI │ src/tui, src/components
|
|
633
|
-
│ → JSON output │ │ (same handlers) │
|
|
634
|
-
└────────┬────────┘ └────────┬──────────┘
|
|
635
|
-
│ │
|
|
636
|
-
└──────────┬─────────────┘
|
|
637
|
-
▼
|
|
638
|
-
┌───────────────────────┐
|
|
639
|
-
│ Core (CoreClient) │ src/core
|
|
640
|
-
│ feature sub-clients │
|
|
641
|
-
└──────────┬────────────┘
|
|
642
|
-
▼
|
|
643
|
-
AWS SDK: Bedrock AgentCore (control + data) + IAM
|
|
644
|
-
```
|
|
88
|
+
## Extending the CDK app
|
|
645
89
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
90
|
+
`agentcore/cdk/` has two source files. `bin/cdk.ts` reads the project once
|
|
91
|
+
(`readAgentCoreProject`), makes one stack per deployment target
|
|
92
|
+
(`resolveTargetStacks`) and turns `agentcore.json` into the application's props
|
|
93
|
+
(`transformAgentCoreJson`). All three come from `@aws/agentcore-cdk`, so that
|
|
94
|
+
logic is updated through the library rather than changes to your CDK app.
|
|
649
95
|
|
|
650
|
-
|
|
96
|
+
`lib/cdk-stack.ts` instantiates one `AgentCoreApplication`. This is the file you
|
|
97
|
+
edit to add your own resources. Runtimes and harnesses implement `iam.IGrantable`,
|
|
98
|
+
so you can pass them to a resource's CDK grant methods to give your agents access.
|
|
99
|
+
Use `addEnvironmentVariable` to pass resource names, ARNs, or endpoints to your agent.
|
|
651
100
|
|
|
652
|
-
|
|
653
|
-
**`Router`** (`src/router/`). A `Router` is itself a mountable branch node, so
|
|
654
|
-
routers nest to form the command tree (`agentcore` → `harness` → `get`). Every
|
|
655
|
-
command — branch or leaf — is a `Handler`:
|
|
656
|
-
|
|
657
|
-
- **Branch nodes** (routers) host subcommands and may declare group-level
|
|
658
|
-
("global") flags and middleware that apply to everything beneath them. A
|
|
659
|
-
branch can also register a **default handler** (`router.default(...)`) that
|
|
660
|
-
runs when the branch is invoked with no subcommand (e.g. bare `agentcore` or
|
|
661
|
-
`agentcore harness` — this is how the TUI launches).
|
|
662
|
-
- **Leaf nodes** (built with `createHandler(...)`) do the work. They declare
|
|
663
|
-
their own flags/arguments (validated and coerced via zod schemas) and receive
|
|
664
|
-
a typed object in `handle(ctx, flags, args)`.
|
|
665
|
-
|
|
666
|
-
Every node — branch or leaf — satisfies the `Handler` interface:
|
|
101
|
+
This example gives the generated runtime named `agent` access to a table:
|
|
667
102
|
|
|
668
103
|
```ts
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
arguments(): Argument[];
|
|
674
|
-
// At runtime `handle` receives the validated, coerced flags object. The precise
|
|
675
|
-
// shape is supplied to authors via createHandler's generic; the interface keeps
|
|
676
|
-
// it erased so middleware can forward it uniformly.
|
|
677
|
-
handle: (ctx: Context, flags: any, args: any) => Promise<void>;
|
|
678
|
-
children(): Handler[];
|
|
679
|
-
}
|
|
680
|
-
```
|
|
681
|
-
|
|
682
|
-
Under the hood the tree is compiled into a [Commander](https://github.com/tj/commander.js)
|
|
683
|
-
command tree (`src/router/router.tsx`), so `--help`, argument parsing, and error
|
|
684
|
-
handling come from a battle-tested parser while the authoring API stays small.
|
|
685
|
-
|
|
686
|
-
Cross-cutting values flow through a typed **`Context`**. Group-level flags
|
|
687
|
-
(`globalFlag(...)`) double as context keys, so a flag declared high in the tree
|
|
688
|
-
is read type-safely by any descendant via `ctx.value(key)` / `ctx.require(key)`.
|
|
104
|
+
import { AgentCoreApplication, type AgentCoreApplicationProps } from "@aws/agentcore-cdk";
|
|
105
|
+
import { Stack, type StackProps } from "aws-cdk-lib";
|
|
106
|
+
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
|
|
107
|
+
import { Construct } from "constructs";
|
|
689
108
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
// value returns the value previously stored under `key`, or undefined if absent.
|
|
693
|
-
value<V>(key: ContextKey<V>): V | undefined;
|
|
694
|
-
// require returns the value stored under `key`, throwing if it is absent.
|
|
695
|
-
require<V>(key: ContextKey<V>): V;
|
|
696
|
-
// withValue returns a new Context that carries `key`/`value` on top of this one.
|
|
697
|
-
withValue<V>(key: ContextKey<V>, value: V): Context;
|
|
109
|
+
export interface AgentCoreStackProps extends StackProps {
|
|
110
|
+
application: AgentCoreApplicationProps;
|
|
698
111
|
}
|
|
699
|
-
```
|
|
700
112
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
region once at the root and pins it on the context for every command below. A
|
|
704
|
-
middleware is just a function that wraps one `Handler` in another:
|
|
113
|
+
export class AgentCoreStack extends Stack {
|
|
114
|
+
public readonly application: AgentCoreApplication;
|
|
705
115
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
### Putting it all together
|
|
711
|
-
|
|
712
|
-
A minimal, self-contained example — a router with one piece of middleware and a
|
|
713
|
-
`greet` leaf handler:
|
|
714
|
-
|
|
715
|
-
```ts
|
|
716
|
-
import z from "zod";
|
|
717
|
-
import { Router, createHandler, flag, globalFlag, type Middleware } from "./router";
|
|
718
|
-
|
|
719
|
-
// A group-level flag that doubles as a typed context key.
|
|
720
|
-
const LoudKey = globalFlag("loud", "shout the greeting", z.boolean().default(false));
|
|
721
|
-
|
|
722
|
-
// Middleware wraps every handler beneath where it's mounted. Here it just logs.
|
|
723
|
-
const withLogging = (): Middleware => (h) => ({
|
|
724
|
-
name: () => h.name(),
|
|
725
|
-
description: () => h.description(),
|
|
726
|
-
flags: () => h.flags(),
|
|
727
|
-
arguments: () => h.arguments(),
|
|
728
|
-
children: () => h.children(),
|
|
729
|
-
handle: async (ctx, flags, args) => {
|
|
730
|
-
console.error(`> running ${h.name()}`);
|
|
731
|
-
await h.handle(ctx, flags, args);
|
|
732
|
-
},
|
|
733
|
-
});
|
|
734
|
-
|
|
735
|
-
// A leaf handler. `flags` is precisely typed from the zod schemas, and the
|
|
736
|
-
// group-level LoudKey is read back off the context.
|
|
737
|
-
const greet = createHandler({
|
|
738
|
-
name: "greet",
|
|
739
|
-
description: "greet someone",
|
|
740
|
-
flags: [flag("name", "who to greet", z.string().default("world"))] as const,
|
|
741
|
-
handle: async (ctx, flags) => {
|
|
742
|
-
const message = `hello, ${flags.name}!`;
|
|
743
|
-
console.log(ctx.value(LoudKey) ? message.toUpperCase() : message);
|
|
744
|
-
},
|
|
745
|
-
});
|
|
746
|
-
|
|
747
|
-
// Wire it together: flags + middleware live on the router, handlers mount under it.
|
|
748
|
-
const app = new Router("demo", "a tiny demo CLI")
|
|
749
|
-
.groupFlags(LoudKey)
|
|
750
|
-
.use(withLogging())
|
|
751
|
-
.handler(greet);
|
|
752
|
-
|
|
753
|
-
await app.route(process.argv);
|
|
754
|
-
```
|
|
755
|
-
|
|
756
|
-
```bash
|
|
757
|
-
demo greet --name Ada # hello, Ada!
|
|
758
|
-
demo greet --name Ada --loud # HELLO, ADA!
|
|
759
|
-
```
|
|
760
|
-
|
|
761
|
-
## Adding a new handler
|
|
762
|
-
|
|
763
|
-
Each command lives in its own directory with a consistent file layout. Using
|
|
764
|
-
`harness` as the model:
|
|
765
|
-
|
|
766
|
-
```
|
|
767
|
-
src/handlers/harness/
|
|
768
|
-
├── index.tsx # createHarnessHandler(core): builds the Router/Handler, wires
|
|
769
|
-
│ # subcommands, middleware, flags, and the default handler
|
|
770
|
-
├── screen.tsx # the Ink/React screen(s) rendered for this command in the TUI
|
|
771
|
-
├── types.tsx # the interface(s) this command consumes from Core (see below)
|
|
772
|
-
├── get/ # a subcommand, same layout recursively
|
|
773
|
-
│ ├── index.tsx
|
|
774
|
-
│ └── screen.tsx
|
|
775
|
-
└── list/
|
|
776
|
-
├── index.tsx
|
|
777
|
-
└── screen.tsx
|
|
778
|
-
```
|
|
779
|
-
|
|
780
|
-
Conventions:
|
|
781
|
-
|
|
782
|
-
- **`index.tsx`** exports a `create<Name>Handler(core)` factory returning a
|
|
783
|
-
`Handler`/`Router`. Dependencies (the `Core` client) are passed in, never
|
|
784
|
-
imported as singletons. Re-export the command's `screen.tsx` from here.
|
|
785
|
-
- **`screen.tsx`** exports the React component(s) for the TUI. Screens receive
|
|
786
|
-
`ScreenProps` (`{ ctx, core }`) threaded down from `Root`, and drive data
|
|
787
|
-
fetching with react-query against `core`.
|
|
788
|
-
- **`types.tsx`** defines the interface(s) this command needs from Core.
|
|
789
|
-
- Shared helpers live in a sibling `utils.tsx` (e.g. `coreOptsFromCtx(ctx)`
|
|
790
|
-
builds the standard `CoreOptions` from context values).
|
|
791
|
-
- Shared components live in `src/components/`: anything rendered by more than
|
|
792
|
-
one screen belongs there (e.g. `Layout`, `RouterScreen`, `HarnessPicker`),
|
|
793
|
-
with the vendored InkUI primitives under `src/components/ui/`. A handler
|
|
794
|
-
directory contains only the screens for its own command.
|
|
795
|
-
|
|
796
|
-
Mount the new handler by adding `root.handler(create<Name>Handler(core))` in
|
|
797
|
-
`src/handlers/index.tsx` (or on the appropriate parent router).
|
|
798
|
-
|
|
799
|
-
## Core and dependency inversion
|
|
800
|
-
|
|
801
|
-
Business logic and all I/O (AWS SDK calls, etc.) live in **`src/core/`**, behind
|
|
802
|
-
a `CoreClient` that exposes feature-scoped sub-clients (e.g. `core.harness`).
|
|
803
|
-
`CoreClient` owns the underlying AWS clients — the Bedrock AgentCore
|
|
804
|
-
**control** plane (CRUD, versions, endpoints), the **data** plane (invoke, exec
|
|
805
|
-
streaming), **IAM** (default execution roles) — caching one per config.
|
|
806
|
-
|
|
807
|
-
The important rule: **interfaces are defined by their consumers, not by Core.**
|
|
808
|
-
The `CoreHarnessClient` interface lives in `src/handlers/harness/types.tsx` —
|
|
809
|
-
next to the handler that uses it — and `src/core/harness.tsx` provides the
|
|
810
|
-
implementation. Handlers depend on the interface they declare; Core depends on
|
|
811
|
-
nothing about the handlers. This is **dependency inversion**: the
|
|
812
|
-
high-level policy (handlers) owns the abstraction, and the low-level detail
|
|
813
|
-
(Core/SDK) conforms to it.
|
|
814
|
-
|
|
815
|
-
Construction is also inverted. `CoreClient` doesn't build SDK clients directly;
|
|
816
|
-
it takes **factory functions** (`(config) => new BedrockAgentCore...Client(...)`)
|
|
817
|
-
injected at the app edge in `src/index.ts`. That keeps the SDK swappable —
|
|
818
|
-
crucial for the testing strategy below.
|
|
819
|
-
|
|
820
|
-
## The TUI
|
|
821
|
-
|
|
822
|
-
The interactive UI is built with [Ink](https://github.com/vadimdemedes/ink)
|
|
823
|
-
(React for the terminal). `renderTui` mounts the `Root` component
|
|
824
|
-
(`src/components/Root.tsx`) — a MemoryRouter over the app's route table plus a
|
|
825
|
-
react-query client — seeded at the command's path. Because routes map to the
|
|
826
|
-
same handler paths as the CLI, deep-linking works: `harness invoke --id X` opens
|
|
827
|
-
the chat screen at that harness. Ink reads and writes through the injected IO
|
|
828
|
-
streams, so the TUI is fully testable without a real terminal.
|
|
829
|
-
|
|
830
|
-
## Testing
|
|
831
|
-
|
|
832
|
-
Tests sit next to the code they cover as `<file>.test.tsx` (e.g.
|
|
833
|
-
`src/router/router.test.ts`), run with `bun test`. Shared test infrastructure
|
|
834
|
-
lives in `src/testing/`.
|
|
835
|
-
|
|
836
|
-
The guiding principle is **test behavior, not implementation**: a good test lets
|
|
837
|
-
a maintainer refactor freely and only fails when observable behavior changes.
|
|
838
|
-
This is possible because the app injects every dependency at its edges, so a
|
|
839
|
-
test can build the whole CLI with test doubles at the boundary and drive a real
|
|
840
|
-
command flow — argument parsing, middleware, handler, Core, and (for the TUI)
|
|
841
|
-
rendering — as a single unit, asserting on the output a user would see.
|
|
842
|
-
|
|
843
|
-
We aim for **90% line coverage** (`bun test --coverage`).
|
|
844
|
-
|
|
845
|
-
### Injected IO
|
|
846
|
-
|
|
847
|
-
Nothing in the app reaches for `process.stdout`/`console.*` directly. An `AppIO`
|
|
848
|
-
(`{ stdin, stdout, stderr }`, defined in `src/handlers/types.tsx`) is passed to
|
|
849
|
-
`createRootHandler(core, io)` at the edge (`src/index.ts` passes the real process
|
|
850
|
-
streams) and threaded down to the TUI renderer and handlers. JSON output flows
|
|
851
|
-
through the context: a `withJsonRenderer` middleware pins a `JsonRenderer` wired
|
|
852
|
-
to the configured stdout, and leaf handlers emit via
|
|
853
|
-
`ctx.require(JsonRendererKey).renderJson(...)`. In tests, `testIO()` supplies an
|
|
854
|
-
in-memory `AppIO` with `stdout()`/`stderr()` accessors, so a command's output is
|
|
855
|
-
captured with no global patching.
|
|
856
|
-
|
|
857
|
-
### Golden files and record mode
|
|
858
|
-
|
|
859
|
-
Handler tests run the real `CoreClient` over fixture-backed SDK clients and
|
|
860
|
-
compare rendered output against committed **golden files**. The record/replay
|
|
861
|
-
seam sits at the SDK `.send()` boundary (the same seam `src/index.ts` wires the
|
|
862
|
-
real clients into), so replayed tests still exercise the real `CoreClient`,
|
|
863
|
-
`HarnessClient`, and option translation — only the network call is swapped out.
|
|
864
|
-
|
|
865
|
-
Two modes, selected by the `RECORD` env var:
|
|
866
|
-
|
|
867
|
-
```bash
|
|
868
|
-
RECORD=1 bun test # hit the live AWS APIs and (re)write fixtures + golden files
|
|
869
|
-
bun test # replay the saved fixtures; never touch the network
|
|
870
|
-
```
|
|
871
|
-
|
|
872
|
-
Recording lets the suite be fast, deterministic, and runnable offline/in CI.
|
|
873
|
-
Refresh the fixtures by re-running in record mode when the APIs or expected
|
|
874
|
-
output change. Fixtures are Date-safe (Dates round-trip via a tagged encoding)
|
|
875
|
-
and strip volatile transport metadata (`$metadata`, request IDs) so they stay
|
|
876
|
-
stable. Golden files are excluded from Prettier (`.prettierignore`) — they are
|
|
877
|
-
byte-for-byte recordings, not source to reformat.
|
|
878
|
-
|
|
879
|
-
See [this talk](https://www.youtube.com/watch?v=yszygk1cpEc&t=1s) for background
|
|
880
|
-
on the pattern.
|
|
881
|
-
|
|
882
|
-
### TUI tests
|
|
883
|
-
|
|
884
|
-
Screens are tested with
|
|
885
|
-
[`ink-testing-library`](https://github.com/vadimdemedes/ink-testing-library) via
|
|
886
|
-
the `renderScreen(path, { core })` helper (`src/testing/renderScreen.tsx`). It
|
|
887
|
-
mounts the real `Root` (MemoryRouter + the app's route table + react-query)
|
|
888
|
-
seeded at a command path — exactly how the CLI mounts a screen — so routing,
|
|
889
|
-
route params, data fetching, key input, and rendering are all exercised
|
|
890
|
-
together. Data comes from a `TestCoreClient` (a hand-controllable `Core` that
|
|
891
|
-
returns canned responses, forces errors, and records calls). Assertions read the
|
|
892
|
-
rendered frame (`waitForText`, `lastFrame`) and key presses drive navigation
|
|
893
|
-
between screens (`press`, `write`).
|
|
894
|
-
|
|
895
|
-
## Repository layout
|
|
896
|
-
|
|
897
|
-
```
|
|
898
|
-
src/
|
|
899
|
-
index.ts # app entry: wires real SDK factories + process IO into the root handler
|
|
900
|
-
router/ # the Router/Handler framework (compiles to Commander)
|
|
901
|
-
handlers/ # the command tree; one directory per command (index/screen/types)
|
|
902
|
-
core/ # CoreClient + feature sub-clients; all AWS SDK I/O lives here
|
|
903
|
-
middleware/ # cross-cutting middleware (withRegion, withJsonRenderer, ...)
|
|
904
|
-
tui/ # Ink renderer entry (renderTui / renderTuiAt) + JSON renderer
|
|
905
|
-
components/ # shared TUI components; ui/ holds vendored InkUI primitives
|
|
906
|
-
testing/ # test doubles + helpers (testIO, renderScreen, fixtures, golden IO)
|
|
907
|
-
runnable/ # top-level run/exit-code wrapper
|
|
908
|
-
```
|
|
909
|
-
|
|
910
|
-
---
|
|
911
|
-
|
|
912
|
-
# Development
|
|
913
|
-
|
|
914
|
-
Install [Bun](https://bun.com).
|
|
915
|
-
|
|
916
|
-
```bash
|
|
917
|
-
brew install oven-sh/bun/bun
|
|
918
|
-
```
|
|
919
|
-
|
|
920
|
-
Install dependencies:
|
|
921
|
-
|
|
922
|
-
```bash
|
|
923
|
-
bun install
|
|
924
|
-
```
|
|
925
|
-
|
|
926
|
-
Run from source:
|
|
927
|
-
|
|
928
|
-
```bash
|
|
929
|
-
bun run start
|
|
930
|
-
```
|
|
931
|
-
|
|
932
|
-
Run tests:
|
|
933
|
-
|
|
934
|
-
```bash
|
|
935
|
-
bun test
|
|
936
|
-
```
|
|
937
|
-
|
|
938
|
-
## Run Locally
|
|
939
|
-
|
|
940
|
-
Build, then symlink the `agentcore` command globally so it works from any directory:
|
|
941
|
-
|
|
942
|
-
```bash
|
|
943
|
-
bun run build
|
|
944
|
-
npm link
|
|
945
|
-
```
|
|
946
|
-
|
|
947
|
-
Re-run `bun run build` after changes; the linked command picks it up. Remove with:
|
|
948
|
-
|
|
949
|
-
```bash
|
|
950
|
-
npm unlink -g @aws/agentcore
|
|
951
|
-
```
|
|
952
|
-
|
|
953
|
-
To test the exact published artifact instead:
|
|
954
|
-
|
|
955
|
-
```bash
|
|
956
|
-
npm pack # builds via prepublishOnly, creates the .tgz
|
|
957
|
-
npm i -g ./aws-agentcore-0.28.1.tgz
|
|
958
|
-
```
|
|
959
|
-
|
|
960
|
-
## Windows notes
|
|
961
|
-
|
|
962
|
-
- **`agentcore.ps1 cannot be loaded because running scripts is disabled`**: the
|
|
963
|
-
npm shim is a PowerShell script and Windows Server defaults to a `Restricted`
|
|
964
|
-
execution policy. Run `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned`
|
|
965
|
-
once, or call `agentcore.cmd`. The compiled `.exe` has no shim.
|
|
966
|
-
- **The CLI looks frozen in a PowerShell window**: legacy conhost pauses all
|
|
967
|
-
output while text is selected (the title bar shows `Select`). Press `Esc`.
|
|
968
|
-
Windows Terminal does not do this.
|
|
969
|
-
- **`project create` refuses a long path**: Windows caps paths at 260 characters
|
|
970
|
-
unless `LongPathsEnabled` is set, and the CDK app's `node_modules` needs about
|
|
971
|
-
100 of them. Create the project higher in the tree or enable long paths.
|
|
972
|
-
|
|
973
|
-
# Build
|
|
974
|
-
|
|
975
|
-
Run `make` to verify bun is installed, build the Node bundle, and compile all native binaries:
|
|
976
|
-
|
|
977
|
-
```bash
|
|
978
|
-
make # check-bun -> build -> compile (all platforms)
|
|
979
|
-
make bundle # node bundle only (dist/index.js)
|
|
980
|
-
make compile # native binaries only (dist/bin/)
|
|
981
|
-
make clean # remove dist/
|
|
982
|
-
```
|
|
983
|
-
|
|
984
|
-
`make` errors out early if bun is not installed.
|
|
985
|
-
|
|
986
|
-
Bundle the CLI into `dist/` for distribution. The bundle targets Node.js and is the artifact published to npm (via the `bin` entry):
|
|
987
|
-
|
|
988
|
-
```bash
|
|
989
|
-
make bundle
|
|
990
|
-
```
|
|
116
|
+
constructor(scope: Construct, id: string, props: AgentCoreStackProps) {
|
|
117
|
+
super(scope, id, props);
|
|
118
|
+
this.application = new AgentCoreApplication(this, "Application", props.application);
|
|
991
119
|
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
Compile standalone executables (Bun runtime embedded; no Node/Bun required to run) for all platforms into `dist/bin/`:
|
|
1001
|
-
|
|
1002
|
-
```bash
|
|
1003
|
-
make compile
|
|
120
|
+
const orders = new dynamodb.Table(this, "Orders", {
|
|
121
|
+
partitionKey: { name: "pk", type: dynamodb.AttributeType.STRING },
|
|
122
|
+
});
|
|
123
|
+
const agent = this.application.runtime("agent");
|
|
124
|
+
orders.grantReadWriteData(agent);
|
|
125
|
+
agent.addEnvironmentVariable("ORDERS_TABLE", orders.tableName);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
1004
128
|
```
|
|
1005
129
|
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
| Script | Output |
|
|
1009
|
-
| ----------------------- | ----------------------------- |
|
|
1010
|
-
| `compile:darwin-x64` | `agentcore-darwin-x64` |
|
|
1011
|
-
| `compile:darwin-arm64` | `agentcore-darwin-arm64` |
|
|
1012
|
-
| `compile:linux-x64` | `agentcore-linux-x64` |
|
|
1013
|
-
| `compile:linux-arm64` | `agentcore-linux-arm64` |
|
|
1014
|
-
| `compile:windows-x64` | `agentcore-windows-x64.exe` |
|
|
1015
|
-
| `compile:windows-arm64` | `agentcore-windows-arm64.exe` |
|
|
1016
|
-
|
|
1017
|
-
Each binary is ~60–95MB (embedded runtime).
|
|
130
|
+
For a Harness, use `this.application.harness("<name>")` instead.
|
|
1018
131
|
|
|
1019
|
-
|
|
132
|
+
Run `agentcore project deploy` to apply your changes. The names passed to
|
|
133
|
+
`runtime()` or `harness()` must match the names in your project.
|
|
1020
134
|
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
bun run format # write changes
|
|
1025
|
-
bun run format:check # check only
|
|
1026
|
-
```
|
|
135
|
+
If you use an existing execution role through `executionRoleArn`, CDK cannot
|
|
136
|
+
change its permissions. You'll need to add the required permissions to that role
|
|
137
|
+
yourself.
|
|
1027
138
|
|
|
1028
|
-
|
|
139
|
+
Note that `agentcore project status` reports only the resources `agentcore.json`
|
|
140
|
+
declares, not the ones you add in the stack.
|
|
1029
141
|
|
|
1030
|
-
|
|
142
|
+
## Documentation
|
|
1031
143
|
|
|
1032
|
-
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
data-plane operations, browser profiles, and the other AgentCore resources.
|
|
1036
|
-
- **Implement `config`.** The `config` command is currently a stub — it should
|
|
1037
|
-
read/write real global settings (telemetry, log level, ...) through an
|
|
1038
|
-
injected config accessor.
|
|
144
|
+
- [Amazon Bedrock AgentCore documentation](https://docs.aws.amazon.com/bedrock-agentcore/): service guides and API references.
|
|
145
|
+
- [Harness project configuration](docs/harness-project-configuration.md): Harness YAML, prompts, tools, skills, and environment settings.
|
|
146
|
+
- [Contributing](CONTRIBUTING.md): development, builds, architecture, and testing.
|