Add amika send and amika sessions commands - #320
Open
jdc123 wants to merge 2 commits into
Open
Conversation
Add a top-level `send` command that drives the remote agent-sessions API: it sends a message to a coding agent, creating a sandbox behind the scenes when the chat has none, or continuing an existing chat (`--session-id`) or routing into a specific sandbox (`--sandbox`). The agent is picked by `--agent`, else the org default, else `claude`. The message comes from a positional arg or stdin; the call is synchronous and prints the reply (with `session_id`/created-sandbox notes on stderr so stdout stays the pure response, or a single JSON object under `--output json`). Add a `sessions` group (`list`, `show <id>`) to browse the durable chats those sends create, backed by the new `GET /agent-sessions` endpoints. Extend the API client with `SendAgentSession`, `ListAgentSessions`, and `GetAgentSession` (plus their request/response mirror types). `SendAgentSession` uses the 10-minute timeout the synchronous agent-send path already uses. Tested: httptest coverage of the three client methods (request shape, response parsing, nullable fields, id path-escaping) and command-level tests for registration, flags, message-required, and `--output` validation.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
The agent-sessions endpoint now offers a streaming transport (`POST /agent-sessions/stream`), so `amika send` no longer has to block on the whole reply before showing anything. - `apiclient.SendAgentSessionStream` POSTs to the stream endpoint with `Accept: text/event-stream`, forwards `status` and `delta` frames to handler callbacks as they arrive, and returns the terminal `done` frame — the same `AgentSessionSendResponse` the buffered call returns. A mid-stream `error` frame (or a stream that ends without `done`) becomes an error; auth/validation failures arrive as a JSON error before the stream opens and are surfaced like the buffered path. - `amika send` streams by default when stdout is a terminal and buffers when piped (so a captured pipe stays the single final response) or when `--output json` is set (which must stay one valid object). `--stream` / `--stream=false` overrides the default. Sandbox lifecycle progress and the session id go to stderr; only the agent's text goes to stdout, matching the buffered path.
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.
What
Adds the CLI half of the agent-sessions feature: a one-shot
amika sendand asessionsbrowser, driving the new remoteagent-sessionsAPI.amika send [message]— send a message to a coding agent. With neither--session-idnor--sandbox, a sandbox is created behind the scenes and a new chat starts; the returnedsession_idcontinues it next time. Agent from--agent(claude|codex), else the org default, else claude. Message from a positional arg or stdin. Synchronous — prints the reply. Flags:--agent,--session-id,--sandbox,--new-session,--repo. In text modesession_id/created-sandbox notes go to stderr so stdout stays the pure response;--output jsonemits theAgentSessionSendResponseverbatim.amika sessions list/amika sessions show <id>— browse the durable chats those sends create (backed byGET /agent-sessions).SendAgentSession,ListAgentSessions,GetAgentSession+ mirror types.SendAgentSessionuses the same 10-minute timeout as the existing synchronous agent-send.Server dependency
Requires the
agent-sessionsendpoint in amika-mono (gofixpoint/amika-mono#866). The client structs are hand-maintained mirrors of that API's OpenAPI schema, matching how the rest ofapiclientworks.Testing
httptestcoverage of the three client methods: request method/path/body, full response parsing, nullablesandbox_id/agent,[]-not-nulllist, and id path-escaping.send/sessionsregistration + flags, message-required, and--outputvalidation.make fmtcheck vet lintandgo test ./internal/apiclient/... ./cmd/amika/...pass; the CLI builds (make build-cli).Streaming (update)
amika sendnow streams the reply in real time via the newPOST /agent-sessions/streamSSE endpoint (amika-mono#915), instead ofblocking on the whole message.
SendAgentSessionStream(req, handlers)POSTs withAccept: text/event-stream, forwardsstatus(sandbox lifecycle) anddelta(agent text) frames to callbacks as they arrive, and returns theterminal
doneframe — the sameAgentSessionSendResponsethe bufferedSendAgentSessionreturns. A mid-streamerrorframe, or a stream thatends without
done, becomes an error; auth/validation failures arrive as aJSON error before the stream opens and are surfaced like the buffered path.
amika send --stream: streams by default when stdout is a terminal;buffers when stdout is piped (so a captured pipe stays the single final
response, not the concatenated deltas) and always for
--output json(whichmust stay one valid object).
--stream/--stream=falseforces eithermode. Sandbox progress +
session_idgo to stderr; only agent text goes tostdout, matching the buffered path. Buffered
SendAgentSessionis unchanged.The
--session-idreturned by either mode continues the chat as before.Testing (streaming)
httptestSSE coverage ofSendAgentSessionStream: in-orderstatus/deltadispatch +
doneparsing (andAccept/method/path), anerrorframe → error,a stream with no
done→ error, and a pre-stream 4xx → error.sendcommand test now also asserts the--streamflag is registered.