{
diff --git a/chat/src/components/MessageList.tsx b/chat/src/components/message-list.tsx
similarity index 98%
rename from chat/src/components/MessageList.tsx
rename to chat/src/components/message-list.tsx
index b01c476..75c6ade 100644
--- a/chat/src/components/MessageList.tsx
+++ b/chat/src/components/message-list.tsx
@@ -120,7 +120,7 @@ export default function MessageList({ messages }: MessageListProps) {
} ${message.id === undefined ? "animate-pulse" : ""}`}
>
diff --git a/cmd/server/server.go b/cmd/server/server.go
index 7feadf1..58d0964 100644
--- a/cmd/server/server.go
+++ b/cmd/server/server.go
@@ -23,6 +23,8 @@ var (
port int
printOpenAPI bool
chatBasePath string
+ termWidth uint16
+ termHeight uint16
)
type AgentType = msgfmt.AgentType
@@ -78,11 +80,24 @@ func runServer(ctx context.Context, logger *slog.Logger, argsToPass []string) er
if err != nil {
return xerrors.Errorf("failed to parse agent type: %w", err)
}
+
+ if termWidth < 10 {
+ return xerrors.Errorf("term width must be at least 10")
+ }
+ if termHeight < 10 {
+ return xerrors.Errorf("term height must be at least 10")
+ }
+
var process *termexec.Process
if printOpenAPI {
process = nil
} else {
- process, err = httpapi.SetupProcess(ctx, agent, argsToPass[1:]...)
+ process, err = httpapi.SetupProcess(ctx, httpapi.SetupProcessConfig{
+ Program: agent,
+ ProgramArgs: argsToPass[1:],
+ TerminalWidth: termWidth,
+ TerminalHeight: termHeight,
+ })
if err != nil {
return xerrors.Errorf("failed to setup process: %w", err)
}
@@ -139,4 +154,6 @@ func init() {
ServerCmd.Flags().IntVarP(&port, "port", "p", 3284, "Port to run the server on")
ServerCmd.Flags().BoolVarP(&printOpenAPI, "print-openapi", "P", false, "Print the OpenAPI schema to stdout and exit")
ServerCmd.Flags().StringVarP(&chatBasePath, "chat-base-path", "c", "/chat", "Base path for assets and routes used in the static files of the chat interface")
+ ServerCmd.Flags().Uint16VarP(&termWidth, "term-width", "W", 80, "Width of the emulated terminal")
+ ServerCmd.Flags().Uint16VarP(&termHeight, "term-height", "H", 1000, "Height of the emulated terminal")
}
diff --git a/lib/httpapi/events.go b/lib/httpapi/events.go
index ccca17d..1e6281d 100644
--- a/lib/httpapi/events.go
+++ b/lib/httpapi/events.go
@@ -39,7 +39,7 @@ func (a AgentStatus) Schema(r huma.Registry) *huma.Schema {
type MessageUpdateBody struct {
Id int `json:"id" doc:"Unique identifier for the message. This identifier also represents the order of the message in the conversation history."`
Role st.ConversationRole `json:"role" doc:"Role of the message author"`
- Message string `json:"message" doc:"Message content. The message is formatted as it appears in the agent's terminal session, meaning it consists of lines of text with 80 characters per line."`
+ Message string `json:"message" doc:"Message content. The message is formatted as it appears in the agent's terminal session, meaning that, by default, it consists of lines of text with 80 characters per line."`
Time time.Time `json:"time" doc:"Timestamp of the message"`
}
diff --git a/lib/httpapi/models.go b/lib/httpapi/models.go
index 6e33dfd..8f969f9 100644
--- a/lib/httpapi/models.go
+++ b/lib/httpapi/models.go
@@ -27,7 +27,7 @@ func (m MessageType) Schema(r huma.Registry) *huma.Schema {
// Message represents a message
type Message struct {
Id int `json:"id" doc:"Unique identifier for the message. This identifier also represents the order of the message in the conversation history."`
- Content string `json:"content" example:"Hello world" doc:"Message content. The message is formatted as it appears in the agent's terminal session, meaning it consists of lines of text with 80 characters per line."`
+ Content string `json:"content" example:"Hello world" doc:"Message content. The message is formatted as it appears in the agent's terminal session, meaning that, by default, it consists of lines of text with 80 characters per line."`
Role st.ConversationRole `json:"role" doc:"Role of the message author"`
Time time.Time `json:"time" doc:"Timestamp of the message"`
}
diff --git a/lib/httpapi/setup.go b/lib/httpapi/setup.go
index 298a800..8328991 100644
--- a/lib/httpapi/setup.go
+++ b/lib/httpapi/setup.go
@@ -13,16 +13,23 @@ import (
"github.com/coder/agentapi/lib/termexec"
)
-func SetupProcess(ctx context.Context, program string, programArgs ...string) (*termexec.Process, error) {
+type SetupProcessConfig struct {
+ Program string
+ ProgramArgs []string
+ TerminalWidth uint16
+ TerminalHeight uint16
+}
+
+func SetupProcess(ctx context.Context, config SetupProcessConfig) (*termexec.Process, error) {
logger := logctx.From(ctx)
- logger.Info(fmt.Sprintf("Running: %s %s", program, strings.Join(programArgs, " ")))
+ logger.Info(fmt.Sprintf("Running: %s %s", config.Program, strings.Join(config.ProgramArgs, " ")))
process, err := termexec.StartProcess(ctx, termexec.StartProcessConfig{
- Program: program,
- Args: programArgs,
- TerminalWidth: 80,
- TerminalHeight: 1000,
+ Program: config.Program,
+ Args: config.ProgramArgs,
+ TerminalWidth: config.TerminalWidth,
+ TerminalHeight: config.TerminalHeight,
})
if err != nil {
logger.Error(fmt.Sprintf("Error starting process: %v", err))
diff --git a/openapi.json b/openapi.json
index 79495e2..f4e2e88 100644
--- a/openapi.json
+++ b/openapi.json
@@ -108,7 +108,7 @@
"additionalProperties": false,
"properties": {
"content": {
- "description": "Message content. The message is formatted as it appears in the agent's terminal session, meaning it consists of lines of text with 80 characters per line.",
+ "description": "Message content. The message is formatted as it appears in the agent's terminal session, meaning that, by default, it consists of lines of text with 80 characters per line.",
"examples": [
"Hello world"
],
@@ -209,7 +209,7 @@
"type": "integer"
},
"message": {
- "description": "Message content. The message is formatted as it appears in the agent's terminal session, meaning it consists of lines of text with 80 characters per line.",
+ "description": "Message content. The message is formatted as it appears in the agent's terminal session, meaning that, by default, it consists of lines of text with 80 characters per line.",
"type": "string"
},
"role": {