You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(dev): positional prompt arg for invoking dev server (#707)
* feat(dev): add positional prompt arg, remove --invoke flag
Replace `agentcore dev --invoke "Hello"` with `agentcore dev "Hello"`.
The dev command now accepts an optional positional [prompt] argument
that invokes a running dev server directly. The --invoke/-i flag is
removed entirely — this is a breaking change for scripts using it.
Rejected: keep --invoke as deprecated alias | adds UX confusion with two ways to do the same thing
Confidence: high
Scope-risk: narrow
* feat(dev): auto-start dev server on invoke
When running `agentcore dev "Hello"`, the CLI now automatically starts
a dev server if none is running, invokes it, and shuts it down after.
If a server is already running (via --logs or TUI), it reuses it.
- Export waitForServerReady from dev operations barrel
- Probe target port before invoking; auto-start if nothing listening
- Use Promise.race to bail early if server crashes during startup
- Silent startup (no "Starting dev server..." output)
- Helpful error when outside project with no server running
- Update tests, docs, and command descriptions
Constraint: Must not add latency when server is already running
Rejected: Always require separate terminal for dev server | poor UX parity with agentcore invoke
Confidence: high
Scope-risk: narrow
* fix(dev): prevent orphaned servers and handle empty prompt
Fixes found during bugbash of auto-start feature:
- Register process.on('exit') handler to kill auto-started server,
ensuring cleanup even when invoke helpers call process.exit(1)
- Initialize resolveServerExit with safe default to prevent
potential undefined call if Promise executor changes
- Add unref() to SIGKILL timer in DevServer.kill() so Node.js
exits promptly instead of hanging 2 seconds
- Use !== undefined check for prompt so empty string "" enters
invoke path instead of falling through to interactive TUI
Constraint: process.on('exit') handlers are synchronous; cannot await server shutdown
Rejected: Modify invoke helpers to throw instead of process.exit | too many callers to change
Confidence: high
Scope-risk: narrow
Not-tested: rapid consecutive invocations (port TIME_WAIT race)
* fix(dev): detect non-agentcore servers on target port
After the TCP port probe finds something listening, do a lightweight
HTTP GET to the endpoint. If the response is HTML (text/html), the
server is not an agentcore dev server — show a clear error instead
of sending a POST and dumping raw HTML as the error message.
Constraint: Cannot add a /health endpoint without modifying all Python agent templates
Rejected: HEAD request probe | some servers return different headers for HEAD vs GET
Confidence: high
Scope-risk: narrow
* fix(dev): reliable server cleanup on SIGINT and non-HTTP port detection
- Spawn child processes with detached:true and kill the entire process
group (-pid) to clean up uvicorn workers and other grandchild
processes on shutdown
- Fix SIGKILL fallback that never fired: child.killed is set when the
signal is sent, not when the process exits. Use child.exitCode to
check actual termination.
- Add explicit SIGINT handler in auto-start invoke path so Ctrl+C
kills the server before Node exits
- Improve port identity probe: detect non-HTTP processes (e.g., raw
TCP listeners) by treating probe failures as port conflicts instead
of silently falling through
- Guard kill() in finally block with try-catch and remove exit listener
to prevent leaks
Constraint: process.kill(-pid) requires detached:true so child is its own process group leader
Rejected: child.killed for exit check | set on signal send, not on actual termination
Rejected: process.exit(130) in SIGINT handler | kills Node before child cleanup completes
Confidence: high
Scope-risk: moderate
Not-tested: SIGINT during waitForServerReady phase (before invoke starts)
* revert(dev): remove dev-server.ts spawn/kill changes
Reverts the detached:true, process group kill, and exitCode changes
from dev-server.ts. These affected all dev server modes (TUI, --logs,
auto-start) but were only needed for an edge case in auto-start SIGINT
cleanup. Too much blast radius for the benefit.
The command.tsx fixes (port probe, SIGINT handler, exit listener
cleanup) remain — they are scoped to the invoke path only.
* fix(dev): simplify invoke to require running server, improve error messages
Remove auto-start logic from the invoke path. Users must now start the
dev server in a separate terminal with `agentcore dev --logs` before
invoking with `agentcore dev "prompt"`.
Improve connection error detection by adding isConnectionRefused() helper
that checks ConnectionError name, cause chain, and common fetch failure
messages instead of only checking err.message for ECONNREFUSED.
Constraint: Node fetch wraps ECONNREFUSED in TypeError cause chain
Rejected: Auto-start server on invoke | orphaned processes, complexity
Confidence: high
Scope-risk: narrow
0 commit comments