on main help sign in
handle errros correctly in the bash tool
commit9ae05fea12ad05ea356a057f67afdde46d548843 authorKujtim Hoxha <kujtimii.h@gmail.com> dateMon 14 Apr 2025, 10:52 (2 years ago) parent80cd75c
2 files changed+6−2
internal/llm/tools/bash.go+2−2 internal/permission/permission.go+4
internal/llm/tools/bash.go+2−2
@@ -273,14 +273,14 @@ func (b *bashTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error)
273273 },
274274 )
275275 if !p {
276− return NewTextErrorResponse("permission denied"), nil
276+ return ToolResponse{}, permission.ErrorPermissionDenied
277277 }
278278 }
279279 startTime := time.Now()
280280 shell := shell.GetPersistentShell(config.WorkingDirectory())
281281 stdout, stderr, exitCode, interrupted, err := shell.Exec(ctx, params.Command, params.Timeout)
282282 if err != nil {
283− return NewTextErrorResponse(fmt.Sprintf("error executing command: %s", err)), nil
283+ return ToolResponse{}, fmt.Errorf("error executing command: %w", err)
284284 }
285285 took := time.Since(startTime).Milliseconds()
286286
internal/permission/permission.go+4
@@ -1,6 +1,7 @@
11package permission
22
33import (
4+ "errors"
45 "sync"
56 "time"
67
@@ -8,6 +9,8 @@ import (
89 "github.com/kujtimiihoxha/termai/internal/pubsub"
910)
1011
12+var ErrorPermissionDenied = errors.New("permission denied")
13+
1114type CreatePermissionRequest struct {
1215 ToolName string `json:"tool_name"`
1316 Description string `json:"description"`
@@ -15,6 +18,7 @@ type CreatePermissionRequest struct {
1518 Params any `json:"params"`
1619 Path string `json:"path"`
1720}
21+
1822type PermissionRequest struct {
1923 ID string `json:"id"`
2024 SessionID string `json:"session_id"`