Skip to content

feat(ts#strands-agent,py#strands-agent): add CLI invoke target#537

Open
nx-plugin-for-aws wants to merge 11 commits intomainfrom
feat/strands-agent-cli-invoke
Open

feat(ts#strands-agent,py#strands-agent): add CLI invoke target#537
nx-plugin-for-aws wants to merge 11 commits intomainfrom
feat/strands-agent-cli-invoke

Conversation

@nx-plugin-for-aws
Copy link
Copy Markdown
Collaborator

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>-invoke Nx target and supporting CLI files to both the TypeScript and Python strands agent generators.

TypeScript:

  • New cli.ts template — uses the vended tRPC client with Node.js readline/promises for interactive terminal chat
  • Streams agent responses via tRPC WebSocket subscription (onData callbacks)
  • Local mode: connects via WebSocketTrpcClient.create to ws://localhost:<port>/ws
  • Remote mode: when RUNTIME_CONFIG_APP_ID env var is set, resolves agent ARN from AppConfig and uses AgentCoreTrpcClient.withIamAuth

Python:

  • New client.py template — httpx-based client with local() and with_iam_auth() factory methods, including inline SigV4 auth for AgentCore
  • New cli.py template — simple interactive CLI using the vended client and input()
  • Streams JSONL response chunks from the FastAPI /invocations endpoint
  • Added httpx==0.28.1 as a direct dependency (pinned version)

Both languages:

  • Invoke target uses the assigned local dev port via PORT env var
  • No dependency on serve-local — user starts the agent separately (or invokes a deployed agent)
  • Documentation updated for both TS and Python strands agent guides

Description of how you validated changes

  • All 1604 unit tests pass (80 test files)
  • Updated snapshots for new files and httpx dependency addition
  • Build compiles successfully
  • Lint passes with no new errors

Issue # (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

nx-plugin-for-aws and others added 2 commits April 1, 2026 07:52
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
@github-actions
Copy link
Copy Markdown
Contributor

📚 Documentation translations have been updated and committed (4e905e4) to this PR.

docs/src/content/docs/es/guides/py-strands-agent.mdx
docs/src/content/docs/es/guides/ts-strands-agent.mdx
docs/src/content/docs/fr/guides/py-strands-agent.mdx
docs/src/content/docs/fr/guides/ts-strands-agent.mdx
docs/src/content/docs/it/guides/py-strands-agent.mdx
docs/src/content/docs/it/guides/ts-strands-agent.mdx
docs/src/content/docs/jp/guides/py-strands-agent.mdx
docs/src/content/docs/jp/guides/ts-strands-agent.mdx
docs/src/content/docs/ko/guides/py-strands-agent.mdx
docs/src/content/docs/ko/guides/ts-strands-agent.mdx
docs/src/content/docs/pt/guides/py-strands-agent.mdx
docs/src/content/docs/pt/guides/ts-strands-agent.mdx
docs/src/content/docs/vi/guides/py-strands-agent.mdx
docs/src/content/docs/vi/guides/ts-strands-agent.mdx
docs/src/content/docs/zh/guides/py-strands-agent.mdx
docs/src/content/docs/zh/guides/ts-strands-agent.mdx

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 94.11765% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.67%. Comparing base (5144d06) to head (b66a442).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...ckages/nx-plugin/src/py/strands-agent/generator.ts 90.90% 0 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

nx-plugin-for-aws and others added 2 commits April 1, 2026 14:56
…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
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

📚 Documentation translations have been updated and committed (f1a550e) to this PR.

docs/src/content/docs/es/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/es/guides/py-strands-agent.mdx
docs/src/content/docs/es/guides/ts-strands-agent.mdx
docs/src/content/docs/fr/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/fr/guides/py-strands-agent.mdx
docs/src/content/docs/fr/guides/ts-strands-agent.mdx
docs/src/content/docs/it/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/it/guides/py-strands-agent.mdx
docs/src/content/docs/it/guides/ts-strands-agent.mdx
docs/src/content/docs/jp/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/jp/guides/py-strands-agent.mdx
docs/src/content/docs/jp/guides/ts-strands-agent.mdx
docs/src/content/docs/ko/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/ko/guides/py-strands-agent.mdx
docs/src/content/docs/ko/guides/ts-strands-agent.mdx
docs/src/content/docs/pt/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/pt/guides/py-strands-agent.mdx
docs/src/content/docs/pt/guides/ts-strands-agent.mdx
docs/src/content/docs/vi/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/vi/guides/py-strands-agent.mdx
docs/src/content/docs/vi/guides/ts-strands-agent.mdx
docs/src/content/docs/zh/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/zh/guides/py-strands-agent.mdx
docs/src/content/docs/zh/guides/ts-strands-agent.mdx

nx-plugin-for-aws and others added 4 commits April 1, 2026 15:44
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
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

📚 Documentation translations have been updated and committed (1c894ee) to this PR.

docs/src/content/docs/es/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/es/guides/py-strands-agent.mdx
docs/src/content/docs/es/guides/ts-strands-agent.mdx
docs/src/content/docs/fr/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/fr/guides/py-strands-agent.mdx
docs/src/content/docs/fr/guides/ts-strands-agent.mdx
docs/src/content/docs/it/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/it/guides/py-strands-agent.mdx
docs/src/content/docs/it/guides/ts-strands-agent.mdx
docs/src/content/docs/jp/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/jp/guides/py-strands-agent.mdx
docs/src/content/docs/jp/guides/ts-strands-agent.mdx
docs/src/content/docs/ko/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/ko/guides/py-strands-agent.mdx
docs/src/content/docs/ko/guides/ts-strands-agent.mdx
docs/src/content/docs/pt/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/pt/guides/py-strands-agent.mdx
docs/src/content/docs/pt/guides/ts-strands-agent.mdx
docs/src/content/docs/vi/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/vi/guides/py-strands-agent.mdx
docs/src/content/docs/vi/guides/ts-strands-agent.mdx
docs/src/content/docs/zh/get_started/tutorials/dungeon-game/3.mdx
docs/src/content/docs/zh/guides/py-strands-agent.mdx
docs/src/content/docs/zh/guides/ts-strands-agent.mdx

nx-plugin-for-aws 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(ts#strands-agent/py#strands-agent): cli invoke target

2 participants