Skip to content

Commit 9e874f3

Browse files
committed
feat: update support for codex
1 parent a8c8cdb commit 9e874f3

File tree

18 files changed

+133
-422
lines changed

18 files changed

+133
-422
lines changed

lib/msgfmt/message_box.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,33 @@ func removeMessageBox(msg string) string {
5151

5252
return strings.Join(lines, "\n")
5353
}
54+
55+
func removeCodexMessageBox(msg string) string {
56+
lines := strings.Split(msg, "\n")
57+
messageBoxEndIdx := -1
58+
messageBoxStartIdx := 0
59+
for i := len(lines) - 1; i >= 0; i-- {
60+
if messageBoxEndIdx == -1 {
61+
if strings.Contains(lines[i], "╰────────") && strings.Contains(lines[i], "───────╯") {
62+
messageBoxEndIdx = i
63+
}
64+
} else {
65+
// We reached the start of the message box (we don't want to show this line), also exit the loop
66+
if strings.Contains(lines[i], "╭") && strings.Contains(lines[i], "───────╮") {
67+
messageBoxStartIdx = i + 1
68+
break
69+
}
70+
71+
// We are in between the start and end of the message box, so remove the │ from the start and end of the line, let the trimEmptyLines handle the rest
72+
if strings.HasPrefix(lines[i], "│") {
73+
lines[i] = strings.TrimPrefix(lines[i], "│")
74+
}
75+
if strings.HasSuffix(lines[i], "│") {
76+
lines[i] = strings.TrimSuffix(lines[i], "│")
77+
lines[i] = strings.TrimRight(lines[i], " \t")
78+
}
79+
}
80+
}
81+
82+
return strings.Join(lines[messageBoxStartIdx:max(0, messageBoxEndIdx)], "\n")
83+
}

lib/msgfmt/msgfmt.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ func formatGenericMessage(message string, userInput string) string {
216216
return message
217217
}
218218

219+
func formatCodexMessage(message string, userInput string) string {
220+
message = RemoveUserInput(message, userInput)
221+
message = removeMessageBox(message)
222+
message = removeCodexMessageBox(message)
223+
message = trimEmptyLines(message)
224+
return message
225+
}
226+
219227
func FormatAgentMessage(agentType AgentType, message string, userInput string) string {
220228
switch agentType {
221229
case AgentTypeClaude:
@@ -225,7 +233,7 @@ func FormatAgentMessage(agentType AgentType, message string, userInput string) s
225233
case AgentTypeAider:
226234
return formatGenericMessage(message, userInput)
227235
case AgentTypeCodex:
228-
return formatGenericMessage(message, userInput)
236+
return formatCodexMessage(message, userInput)
229237
case AgentTypeGemini:
230238
return formatGenericMessage(message, userInput)
231239
case AgentTypeCustom:
Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
thinking for 9s
1+
Shell Command
2+
~/Documents/work/agentapi$ git rev-parse --show-toplevel
23

3-
command
4+
Allow command?
45

5-
$ git rev-parse --show-toplevel
6-
7-
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮
8-
│Shell Command │
9-
│ │
10-
│$ git rev-parse --show-toplevel │
11-
│ │
12-
│Allow command? │
13-
│ │
14-
│ ❯ Yes (y) │
15-
│ Yes, always approve this exact command for this session (a) │
16-
│ Edit or give feedback (e) │
17-
│ No, and keep going (n) │
18-
│ No, and stop for now (esc) │
19-
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯
6+
▶ Yes (y)
7+
Yes, always approve this exact command for this session (a)
8+
Edit or give feedback (e)
9+
No, and keep going (n)
10+
No, and stop for now (esc)
Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
user
2-
what repository are you in?
3-
4-
thinking for 9s
5-
6-
command
7-
8-
$ git rev-parse --show-toplevel
9-
10-
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮
11-
│Shell Command │
12-
│ │
13-
│$ git rev-parse --show-toplevel │
14-
│ │
15-
│Allow command? │
16-
│ │
17-
│ ❯ Yes (y) │
18-
│ Yes, always approve this exact command for this session (a) │
19-
│ Edit or give feedback (e) │
20-
│ No, and keep going (n) │
21-
│ No, and stop for now (esc) │
22-
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯
1+
╭Messages (tab to focus)──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
2+
│OpenAI Codex v0.10.0 (research preview) │
3+
│ │
4+
│codex session 790ba389-ab4d-47be-bb16-9cc7f36bcf2b │
5+
│workdir: /Users/jkmr/Documents/work/agentapi │
6+
│model: codex-mini-latest │
7+
│provider: openai │
8+
│approval: untrusted │
9+
│sandbox: read-only │
10+
│reasoning effort: medium │
11+
│reasoning summaries: auto │
12+
│ │
13+
│user │
14+
│what repository are you in? │
15+
│ │
16+
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
17+
╭Review───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
18+
│Shell Command │
19+
│~/Documents/work/agentapi$ git rev-parse --show-toplevel │
20+
│ │
21+
│Allow command? │
22+
│ │
23+
│ ▶ Yes (y) │
24+
│ Yes, always approve this exact command for this session (a) │
25+
│ Edit or give feedback (e) │
26+
│ No, and keep going (n) │
27+
│ No, and stop for now (esc) │
28+
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
╭──────────────────────────────────────────────────────────────╮
2-
│ ● OpenAI Codex (research preview) v0.1.2504161551 │
3-
╰──────────────────────────────────────────────────────────────╯
4-
╭──────────────────────────────────────────────────────────────╮
5-
│ localhost session: c4bf4c89c3fb483c935bdff223394646 │
6-
│ ↳ workdir: ~/dev/agentapi │
7-
│ ↳ model: o4-mini │
8-
│ ↳ approval: suggest │
9-
╰──────────────────────────────────────────────────────────────╯
1+
OpenAI Codex v0.10.0 (research preview)
102

11-
system
12-
Warning: model "o4-mini" is not in the list of available models returned by OpenAI.
3+
codex session 56576d81-529d-42f3-843b-78d870054a75
4+
workdir: /Users/jkmr/Documents/work/agentapi
5+
model: codex-mini-latest
6+
provider: openai
7+
approval: untrusted
8+
sandbox: read-only
9+
reasoning effort: medium
10+
reasoning summaries: auto

0 commit comments

Comments
 (0)