package clusterflowtools import ( "context" "encoding/json" "fmt" "clusterflow.dev/cfbrowser/agenttools" "clusterflow.dev/cfbrowser/api" "clusterflow/internal/tooling" ) // RegisterPrototypeBrowserTools adapts the SDK catalog to ClusterFlow's Tool Bus. func RegisterPrototypeBrowserTools(registry *tooling.Registry, service *agenttools.Service) error { if registry == nil || service == nil || service.Manager == nil { return fmt.Errorf("browser service is unavailable") } for _, item := range agenttools.Catalog() { descriptor := item if err := registry.Register(tooling.Entry{ Descriptor: tooling.Descriptor{ ID: descriptor.ID, ModelName: descriptor.Name, Title: descriptor.Name, Description: descriptor.Description, InputSchema: descriptor.InputSchema, MaxArgumentsBytes: 32768, Risk: tooling.Risk(descriptor.Risk), Source: tooling.SourceBuiltin, ExecutorKind: tooling.ExecutorBackend, }, Handler: func(ctx context.Context, scope tooling.ExecutionScope, arguments json.RawMessage) (tooling.Result, error) { owner := api.Owner{ EnvironmentID: scope.EnvironmentID, ThreadID: scope.ThreadID, RunID: scope.RunID, SSHSessionID: scope.SessionID, } content, err := service.Call(ctx, owner, descriptor.Name, arguments) return tooling.Result{Content: content, IsError: err != nil}, err }, }); err != nil { return err } } return nil }