feat(ts#strands-agent,py#strands-agent): add CLI invoke target#537
Open
nx-plugin-for-aws wants to merge 11 commits intomainfrom
Open
feat(ts#strands-agent,py#strands-agent): add CLI invoke target#537nx-plugin-for-aws wants to merge 11 commits intomainfrom
nx-plugin-for-aws wants to merge 11 commits intomainfrom
Conversation
Add an interactive CLI for chatting with strands agents directly from the terminal. The generators now vend a minimal cli file and an invoke Nx target for both TypeScript and Python agents. - TS: uses the vended tRPC client with readline for interactive chat - Python: adds a new httpx-based client with SigV4 auth support and a simple CLI using input() - Local mode (default): connects to localhost on the assigned port - Remote mode: set RUNTIME_CONFIG_APP_ID env var to resolve agent ARN from AppConfig and invoke via IAM-authenticated AgentCore transport - Streams responses back to the terminal in real time Closes #479
Contributor
|
📚 Documentation translations have been updated and committed (4e905e4) to this PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #537 +/- ##
==========================================
- Coverage 90.65% 89.67% -0.99%
==========================================
Files 90 92 +2
Lines 3126 3127 +1
Branches 672 680 +8
==========================================
- Hits 2834 2804 -30
- Misses 122 152 +30
- Partials 170 171 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ith agent-connection Major refactoring of the CLI invoke feature: - Move tRPC client (WebSocketTrpcClient, AgentCoreTrpcClient) to agent-connection shared project core - Add shared CLI chat utility (runCliChat) to agent-connection core - Both TS and Python generators now call ensureTypeScriptAgentConnectionProject - CLI scripts are now always TypeScript, generated at scripts/<agent>/cli.ts - TS agent client.ts imports from :scope/agent-connection instead of local file - Python agent CLI uses OpenAPI-generated TypeScript client for type safety - Adds openapi target (generate spec from FastAPI) - Adds generate:<agent>-client target (open-api#ts-client) - Generated client files are gitignored - Remove Python client.py and cli.py templates (no longer needed) - Remove agent-core-trpc-client.ts from agent template (moved to agent-connection) - Update dungeon adventure tutorial to use CLI instead of curl/acurl - Update TS and Python strands agent guide documentation Closes #479
Contributor
|
📚 Documentation translations have been updated and committed (f1a550e) to this PR. |
The ensureTypeScriptAgentConnectionProject function now adds all dependencies needed by the core modules (MCP client, tRPC client, CLI utils) so that the agent-connection project compiles correctly when created by any generator, not just the MCP connection generator.
The AgentCoreTrpcClient template moved from ts/strands-agent/files/app/ to utils/agent-connection/files/core/. Update the e2e virtual module import to match.
…nnection, add auth Move app-specific agent clients into agent-connection project. Add auth support (IAM/Cognito) with --accessToken CLI parameter. Use /exit and /quit commands. Update dungeon adventure tutorial with CLI customization step. Fix docs to use NxCommands for deployed invocation. Closes #479
Contributor
|
📚 Documentation translations have been updated and committed (1c894ee) to this PR. |
added 2 commits
April 2, 2026 07:21
TS agent CLI uses agent's own client.ts. Python agent client factory returns config object to avoid importing generated .gen.ts files during TypeScript compilation. Closes #479
…utput Use single quotes and IAM auth (default) in the old template to match the prettier-formatted output from the generator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reason for this change
Closes #479
Users need a simple way to test their strands agents (both locally and deployed) without writing custom scripts. Currently there's no out-of-the-box way to interactively chat with an agent from the terminal.
Description of changes
Adds a
<agent-name>-invokeNx target and supporting CLI files to both the TypeScript and Python strands agent generators.TypeScript:
cli.tstemplate — uses the vended tRPC client with Node.jsreadline/promisesfor interactive terminal chatonDatacallbacks)WebSocketTrpcClient.createtows://localhost:<port>/wsRUNTIME_CONFIG_APP_IDenv var is set, resolves agent ARN from AppConfig and usesAgentCoreTrpcClient.withIamAuthPython:
client.pytemplate — httpx-based client withlocal()andwith_iam_auth()factory methods, including inline SigV4 auth for AgentCorecli.pytemplate — simple interactive CLI using the vended client andinput()/invocationsendpointhttpx==0.28.1as a direct dependency (pinned version)Both languages:
PORTenv varserve-local— user starts the agent separately (or invokes a deployed agent)Description of how you validated changes
httpxdependency additionIssue # (if applicable)
Closes #479.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license