Run tasks on Codex beside Claude; drop turn caps and mid-turn snapshots
This commit is contained in:
+18
-12
@@ -56,6 +56,15 @@ type callResult struct {
|
||||
IsError bool `json:"isError,omitempty"`
|
||||
}
|
||||
|
||||
func (s *Server) Tool(name string) (Tool, bool) {
|
||||
for _, t := range s.Tools {
|
||||
if t.Name == name {
|
||||
return t, true
|
||||
}
|
||||
}
|
||||
return Tool{}, false
|
||||
}
|
||||
|
||||
func (s *Server) Handle(ctx context.Context, raw json.RawMessage) (json.RawMessage, error) {
|
||||
req := request{}
|
||||
err := json.Unmarshal(raw, &req)
|
||||
@@ -108,18 +117,15 @@ func (s *Server) call(ctx context.Context, params json.RawMessage) (any, *rpcErr
|
||||
return nil, &rpcError{Code: -32602, Message: err.Error()}
|
||||
}
|
||||
|
||||
for _, t := range s.Tools {
|
||||
if t.Name != p.Name {
|
||||
continue
|
||||
}
|
||||
|
||||
text, err := t.Handler(ctx, p.Arguments)
|
||||
if err != nil {
|
||||
return callResult{Content: []content{{Type: "text", Text: err.Error()}}, IsError: true}, nil
|
||||
}
|
||||
|
||||
return callResult{Content: []content{{Type: "text", Text: text}}}, nil
|
||||
t, ok := s.Tool(p.Name)
|
||||
if !ok {
|
||||
return nil, &rpcError{Code: -32602, Message: fmt.Sprintf("unknown tool: %s", p.Name)}
|
||||
}
|
||||
|
||||
return nil, &rpcError{Code: -32602, Message: fmt.Sprintf("unknown tool: %s", p.Name)}
|
||||
text, err := t.Handler(ctx, p.Arguments)
|
||||
if err != nil {
|
||||
return callResult{Content: []content{{Type: "text", Text: err.Error()}}, IsError: true}, nil
|
||||
}
|
||||
|
||||
return callResult{Content: []content{{Type: "text", Text: text}}}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user