为 Foundry 添加项目级 Codex HTTP 接口 #4

Merged
Zayden-Jung merged 4 commits from codex/foundry-codex-http into main 2026-11-05 07:33:05 +00:00
Showing only changes of commit 81c2d2e6df - Show all commits
+4 -4
View File
@@ -20,16 +20,16 @@ const executable = "/opt/codex/node_modules/.bin/codex"
var errOutputLimit = errors.New("Codex output limit exceeded")
type outputBuffer struct {
bytes.Buffer
buffer bytes.Buffer
exceeded bool
}
func (b *outputBuffer) Write(p []byte) (int, error) {
if len(p) > maxOutput-b.Len() {
if len(p) > maxOutput-b.buffer.Len() {
b.exceeded = true
return 0, errOutputLimit
}
return b.Buffer.Write(p)
return b.buffer.Write(p)
}
func ServeWorker(socket string) error {
@@ -97,7 +97,7 @@ func execute(w http.ResponseWriter, r *http.Request, prompt string) {
default:
var result string
var completed bool
for _, line := range bytes.Split(bytes.TrimSpace(output.Bytes()), []byte("\n")) {
for _, line := range bytes.Split(bytes.TrimSpace(output.buffer.Bytes()), []byte("\n")) {
var event struct {
Type string `json:"type"`
Item struct {