feat: add workspace-isolated toolhost runtime and capability-gap skill loop

This commit is contained in:
2026-02-28 17:48:33 +08:00
parent ce9346e350
commit 7d6cf6b435
28 changed files with 2223 additions and 143 deletions

View 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)
}