|
23 | 23 | port int
|
24 | 24 | printOpenAPI bool
|
25 | 25 | chatBasePath string
|
| 26 | + termWidth uint16 |
| 27 | + termHeight uint16 |
26 | 28 | )
|
27 | 29 |
|
28 | 30 | type AgentType = msgfmt.AgentType
|
@@ -78,11 +80,24 @@ func runServer(ctx context.Context, logger *slog.Logger, argsToPass []string) er
|
78 | 80 | if err != nil {
|
79 | 81 | return xerrors.Errorf("failed to parse agent type: %w", err)
|
80 | 82 | }
|
| 83 | + |
| 84 | + if termWidth < 10 { |
| 85 | + return xerrors.Errorf("term width must be at least 10") |
| 86 | + } |
| 87 | + if termHeight < 10 { |
| 88 | + return xerrors.Errorf("term height must be at least 10") |
| 89 | + } |
| 90 | + |
81 | 91 | var process *termexec.Process
|
82 | 92 | if printOpenAPI {
|
83 | 93 | process = nil
|
84 | 94 | } else {
|
85 |
| - process, err = httpapi.SetupProcess(ctx, agent, argsToPass[1:]...) |
| 95 | + process, err = httpapi.SetupProcess(ctx, httpapi.SetupProcessConfig{ |
| 96 | + Program: agent, |
| 97 | + ProgramArgs: argsToPass[1:], |
| 98 | + TerminalWidth: termWidth, |
| 99 | + TerminalHeight: termHeight, |
| 100 | + }) |
86 | 101 | if err != nil {
|
87 | 102 | return xerrors.Errorf("failed to setup process: %w", err)
|
88 | 103 | }
|
@@ -139,4 +154,6 @@ func init() {
|
139 | 154 | ServerCmd.Flags().IntVarP(&port, "port", "p", 3284, "Port to run the server on")
|
140 | 155 | ServerCmd.Flags().BoolVarP(&printOpenAPI, "print-openapi", "P", false, "Print the OpenAPI schema to stdout and exit")
|
141 | 156 | ServerCmd.Flags().StringVarP(&chatBasePath, "chat-base-path", "c", "/chat", "Base path for assets and routes used in the static files of the chat interface")
|
| 157 | + ServerCmd.Flags().Uint16VarP(&termWidth, "term-width", "W", 80, "Width of the emulated terminal") |
| 158 | + ServerCmd.Flags().Uint16VarP(&termHeight, "term-height", "H", 1000, "Height of the emulated terminal") |
142 | 159 | }
|
0 commit comments