mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-09-19 09:40:12 +00:00
fix(mcp): harden dashboard dispatch lifecycle
Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
This commit is contained in:
@@ -2,7 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -115,11 +115,22 @@ func handleServerExec(c *gin.Context, raw json.RawMessage) (any, error) {
|
||||
// handlers do, so MCP isError=true and audit outcome=agent_error. Non-zero
|
||||
// ExitCode alone is a normal command outcome, not a tool error.
|
||||
if res.Error != "" {
|
||||
return nil, errors.New(res.Error)
|
||||
return nil, &execToolError{mcpError: mcpError{Code: model.MCPOutcomeAgentError, Msg: res.Error}, result: res}
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
type execToolError struct {
|
||||
mcpError
|
||||
result model.ExecResult
|
||||
}
|
||||
|
||||
func (err *execToolError) StructuredResult() any { return err.result }
|
||||
|
||||
func (err *execToolError) Error() string {
|
||||
return fmt.Sprintf("%s: %s", err.Code, err.Msg)
|
||||
}
|
||||
|
||||
// callAgentTimeout 给 dashboard 侧 CallAgent 计算等待上限。
|
||||
// 在用户请求的 timeout 基础上加 5s buffer,让 agent 端的 hard timeout 先触发,
|
||||
// 这样 dashboard 收到的总是结构化结果(包含 timed_out=true),
|
||||
|
||||
Reference in New Issue
Block a user