summaryrefslogtreecommitdiffhomepage
path: root/internal/llm/tools/fetch.go
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-04-08 19:42:59 +0200
committerGitHub <[email protected]>2025-04-08 19:42:59 +0200
commit124bd57c507fdcbb56ab27137cbe892f12e1b48f (patch)
tree894d335a5f2f6587a19e94f139f681b91b01e877 /internal/llm/tools/fetch.go
parent5acf0cba6040aaf90acb5dcacd3e4127d6833ac5 (diff)
parentc571283ac26cdf03be5a1d5c1e36051e3b7ea7be (diff)
downloadopencode-124bd57c507fdcbb56ab27137cbe892f12e1b48f.tar.gz
opencode-124bd57c507fdcbb56ab27137cbe892f12e1b48f.zip
Merge pull request #24 from kujtimiihoxha/cleanup-tools
Cleanup tools
Diffstat (limited to 'internal/llm/tools/fetch.go')
-rw-r--r--internal/llm/tools/fetch.go39
1 files changed, 20 insertions, 19 deletions
diff --git a/internal/llm/tools/fetch.go b/internal/llm/tools/fetch.go
index 0a852626c..5ea0c7633 100644
--- a/internal/llm/tools/fetch.go
+++ b/internal/llm/tools/fetch.go
@@ -15,6 +15,23 @@ import (
"github.com/kujtimiihoxha/termai/internal/permission"
)
+type FetchParams struct {
+ URL string `json:"url"`
+ Format string `json:"format"`
+ Timeout int `json:"timeout,omitempty"`
+}
+
+type FetchPermissionsParams struct {
+ URL string `json:"url"`
+ Format string `json:"format"`
+ Timeout int `json:"timeout,omitempty"`
+}
+
+type fetchTool struct {
+ client *http.Client
+ permissions permission.Service
+}
+
const (
FetchToolName = "fetch"
fetchToolDescription = `Fetches content from a URL and returns it in the specified format.
@@ -48,27 +65,12 @@ TIPS:
- Set appropriate timeouts for potentially slow websites`
)
-type FetchParams struct {
- URL string `json:"url"`
- Format string `json:"format"`
- Timeout int `json:"timeout,omitempty"`
-}
-
-type FetchPermissionsParams struct {
- URL string `json:"url"`
- Format string `json:"format"`
- Timeout int `json:"timeout,omitempty"`
-}
-
-type fetchTool struct {
- client *http.Client
-}
-
-func NewFetchTool() BaseTool {
+func NewFetchTool(permissions permission.Service) BaseTool {
return &fetchTool{
client: &http.Client{
Timeout: 30 * time.Second,
},
+ permissions: permissions,
}
}
@@ -113,7 +115,7 @@ func (t *fetchTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error
return NewTextErrorResponse("URL must start with http:// or https://"), nil
}
- p := permission.Default.Request(
+ p := t.permissions.Request(
permission.CreatePermissionRequest{
Path: config.WorkingDirectory(),
ToolName: FetchToolName,
@@ -220,4 +222,3 @@ func convertHTMLToMarkdown(html string) (string, error) {
return markdown, nil
}
-