feat: add workspace-isolated toolhost runtime and capability-gap skill loop
This commit is contained in:
36
internal/toolhost/remote_tool.go
Normal file
36
internal/toolhost/remote_tool.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package toolhost
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
type RemoteTool struct {
|
||||
name string
|
||||
description string
|
||||
client *Client
|
||||
callTimeout time.Duration
|
||||
}
|
||||
|
||||
func NewRemoteTool(name, description string, callTimeout time.Duration, client *Client) *RemoteTool {
|
||||
if callTimeout <= 0 {
|
||||
callTimeout = 15 * time.Second
|
||||
}
|
||||
return &RemoteTool{name: name, description: description, client: client, callTimeout: callTimeout}
|
||||
}
|
||||
|
||||
func (t *RemoteTool) Name() string { return t.name }
|
||||
|
||||
func (t *RemoteTool) Description() string { return t.description }
|
||||
|
||||
func (t *RemoteTool) Call(ctx context.Context, input string) (string, error) {
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}
|
||||
if _, ok := ctx.Deadline(); !ok {
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(ctx, t.callTimeout)
|
||||
defer cancel()
|
||||
}
|
||||
return t.client.ToolCall(ctx, t.name, input)
|
||||
}
|
||||
Reference in New Issue
Block a user