Simplify codebase per audit of 7aff773

This commit is contained in:
Ian Gulliver
2026-10-23 16:31:34 -07:00
parent f8798f3150
commit 48e3457286
13 changed files with 491 additions and 606 deletions
+27 -42
View File
@@ -23,10 +23,10 @@ type agentProcess interface {
send(ctx context.Context, text string, images []agentinput.Image) error
interrupt(ctx context.Context) error
setModel(ctx context.Context, model, effort string) error
kill()
pid() int
lastLine() time.Time
exited() bool
Kill()
Pid() int
LastLine() time.Time
Exited() bool
drive(m *Manager, l *live)
discard()
}
@@ -76,7 +76,7 @@ func (m *Manager) changeModel(ctx context.Context, sess api.AgentSession, model,
}
type claudeProcess struct {
s *claude.Session
*claude.Session
}
func (m *Manager) startClaude(ctx context.Context, sess api.AgentSession, l *live, g string, servers []*mcp.Server, stdio []mcp.Stdio, env []string) (agentProcess, error) {
@@ -125,19 +125,19 @@ func (m *Manager) startClaude(ctx context.Context, sess api.AgentSession, l *liv
if err != nil {
return nil, fmt.Errorf("start claude: %w", err)
}
return claudeProcess{s: s}, nil
return claudeProcess{s}, nil
}
func (p claudeProcess) send(ctx context.Context, text string, images []agentinput.Image) error {
return p.s.Send(text, images...)
return p.Send(text, images...)
}
func (p claudeProcess) interrupt(ctx context.Context) error {
return p.s.Interrupt(ctx)
return p.Interrupt(ctx)
}
func (p claudeProcess) setModel(ctx context.Context, model, effort string) error {
_, err := p.s.Control(ctx, map[string]any{"subtype": "set_model", "model": model})
_, err := p.Control(ctx, map[string]any{"subtype": "set_model", "model": model})
if err != nil {
return err
}
@@ -145,23 +145,18 @@ func (p claudeProcess) setModel(ctx context.Context, model, effort string) error
if effort == "" {
level = nil
}
_, err = p.s.Control(ctx, map[string]any{"subtype": "apply_flag_settings", "settings": map[string]any{"effortLevel": level}})
_, err = p.Control(ctx, map[string]any{"subtype": "apply_flag_settings", "settings": map[string]any{"effortLevel": level}})
return err
}
func (p claudeProcess) kill() { p.s.Kill() }
func (p claudeProcess) pid() int { return p.s.Pid() }
func (p claudeProcess) lastLine() time.Time { return p.s.LastLine() }
func (p claudeProcess) exited() bool { return p.s.Exited() }
func (p claudeProcess) discard() {
for range p.s.Events() {
for range p.Events() {
}
}
func (p claudeProcess) drive(m *Manager, l *live) {
ctx := context.Background()
for ev := range p.s.Events() {
for ev := range p.Events() {
m.handleProcessEvent(l, ev.Read, ev.Type, ev.Raw, func() error {
return m.handle(ctx, l, ev)
})
@@ -169,7 +164,7 @@ func (p claudeProcess) drive(m *Manager, l *live) {
}
type codexProcess struct {
s *codex.Session
*codex.Session
}
func (m *Manager) startCodex(ctx context.Context, sess api.AgentSession, l *live, g string, servers []*mcp.Server, stdio []mcp.Stdio, env []string) (agentProcess, error) {
@@ -211,44 +206,39 @@ func (m *Manager) startCodex(ctx context.Context, sess api.AgentSession, l *live
return nil, err
}
}
return codexProcess{s: s}, nil
return codexProcess{s}, nil
}
func (p codexProcess) send(ctx context.Context, text string, images []agentinput.Image) error {
_, err := p.s.Send(ctx, text, images...)
_, err := p.Send(ctx, text, images...)
return err
}
func (p codexProcess) interrupt(ctx context.Context) error {
return p.s.Interrupt(ctx)
return p.Interrupt(ctx)
}
func (p codexProcess) setModel(ctx context.Context, model, effort string) error {
p.s.SetModel(model, effort)
p.SetModel(model, effort)
return nil
}
func (p codexProcess) kill() { p.s.Kill() }
func (p codexProcess) pid() int { return p.s.Pid() }
func (p codexProcess) lastLine() time.Time { return p.s.LastLine() }
func (p codexProcess) exited() bool { return p.s.Exited() }
func (p codexProcess) discard() {
for range p.s.Events() {
for range p.Events() {
}
}
func (p codexProcess) drive(m *Manager, l *live) {
ctx := context.Background()
for ev := range p.s.Events() {
for ev := range p.Events() {
m.handleProcessEvent(l, ev.Read, ev.Method, ev.Params, func() error {
return m.handleCodex(ctx, l, p.s, ev)
return m.handleCodex(ctx, l, p.Session, ev)
})
}
}
type antigravityProcess struct {
s *antigravity.Session
*antigravity.Session
}
func (m *Manager) startAntigravity(ctx context.Context, sess api.AgentSession, l *live, g string, servers []*mcp.Server, stdio []mcp.Stdio, env []string) (agentProcess, error) {
@@ -279,35 +269,30 @@ func (m *Manager) startAntigravity(ctx context.Context, sess api.AgentSession, l
return nil, err
}
}
return antigravityProcess{s: s}, nil
return antigravityProcess{s}, nil
}
func (p antigravityProcess) send(ctx context.Context, text string, images []agentinput.Image) error {
return p.s.Send(text, images...)
return p.Send(text, images...)
}
func (p antigravityProcess) interrupt(ctx context.Context) error {
return p.s.Interrupt()
return p.Interrupt()
}
func (p antigravityProcess) setModel(ctx context.Context, model, effort string) error {
return p.s.SetModel(model, effort)
return p.SetModel(model, effort)
}
func (p antigravityProcess) kill() { p.s.Kill() }
func (p antigravityProcess) pid() int { return p.s.Pid() }
func (p antigravityProcess) lastLine() time.Time { return p.s.LastLine() }
func (p antigravityProcess) exited() bool { return p.s.Exited() }
func (p antigravityProcess) discard() {
for range p.s.Events() {
for range p.Events() {
}
}
func (p antigravityProcess) drive(m *Manager, l *live) {
ctx := context.Background()
steps := &agySteps{text: map[int]*strings.Builder{}, tools: map[string]bool{}}
for ev := range p.s.Events() {
for ev := range p.Events() {
m.handleProcessEvent(l, ev.Read, ev.Kind, ev.Raw, func() error {
return m.handleAntigravity(ctx, l, p, steps, ev)
})