diff --git a/README.md b/README.md index 3f45478..6bfb02a 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ agentapi server -- goose ``` > [!NOTE] -> When using Codex, Gemini or CursorCLI, always specify the agent type explicitly (eg: `agentapi server --type=codex -- codex`), or message formatting may break. +> When using Codex, Gemini, Amp or CursorCLI, always specify the agent type explicitly (eg: `agentapi server --type=codex -- codex`), or message formatting may break. An OpenAPI schema is available in [openapi.json](openapi.json). diff --git a/chat/src/components/message-list.tsx b/chat/src/components/message-list.tsx index 75c6ade..d675a85 100644 --- a/chat/src/components/message-list.tsx +++ b/chat/src/components/message-list.tsx @@ -127,7 +127,7 @@ export default function MessageList({ messages }: MessageListProps) { {message.role !== "user" && message.content === "" ? ( ) : ( - message.content.trim() + message.content.trimEnd() )} diff --git a/cmd/server/server.go b/cmd/server/server.go index acdbc54..33c294e 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -94,6 +94,7 @@ func runServer(ctx context.Context, logger *slog.Logger, argsToPass []string) er ProgramArgs: argsToPass[1:], TerminalWidth: termWidth, TerminalHeight: termHeight, + AgentType: agentType, }) if err != nil { return xerrors.Errorf("failed to setup process: %w", err) diff --git a/lib/httpapi/setup.go b/lib/httpapi/setup.go index 8328991..1620304 100644 --- a/lib/httpapi/setup.go +++ b/lib/httpapi/setup.go @@ -10,6 +10,7 @@ import ( "time" "github.com/coder/agentapi/lib/logctx" + mf "github.com/coder/agentapi/lib/msgfmt" "github.com/coder/agentapi/lib/termexec" ) @@ -18,6 +19,7 @@ type SetupProcessConfig struct { ProgramArgs []string TerminalWidth uint16 TerminalHeight uint16 + AgentType mf.AgentType } func SetupProcess(ctx context.Context, config SetupProcessConfig) (*termexec.Process, error) { @@ -36,6 +38,14 @@ func SetupProcess(ctx context.Context, config SetupProcessConfig) (*termexec.Pro os.Exit(1) } + // Hack for sourcegraph amp to stop the animation. + if config.AgentType == mf.AgentTypeAmp { + _, err = process.Write([]byte(" \b")) + if err != nil { + return nil, err + } + } + // Handle SIGINT (Ctrl+C) and send it to the process signalCh := make(chan os.Signal, 1) signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM)