Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
63 lines
2.0 KiB
Go
63 lines
2.0 KiB
Go
// Package computer exposes the daemon-owned computer session to agents as
|
|
// `tutti computer ...` CLI commands. Agents automate a supported desktop through
|
|
// these pre-approved commands instead of a per-provider MCP server.
|
|
package computer
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
cliservice "github.com/tutti-os/tutti/services/tuttid/service/cli"
|
|
computersvc "github.com/tutti-os/tutti/services/tuttid/service/computer"
|
|
)
|
|
|
|
const appID = "computer"
|
|
|
|
var errComputerUnavailable = errors.New("computer service is unavailable")
|
|
|
|
// ComputerService is the subset of the daemon computer service the CLI needs.
|
|
type ComputerService interface {
|
|
CallTool(ctx context.Context, workspaceID, cwd, tool string, args map[string]any) (computersvc.ToolResult, error)
|
|
CallNativeTool(ctx context.Context, workspaceID, cwd, tool string, args map[string]any) (computersvc.ToolResult, error)
|
|
ListTools(ctx context.Context, workspaceID, cwd string) (computersvc.ToolCatalog, error)
|
|
}
|
|
|
|
type Provider struct {
|
|
workspaces cliservice.WorkspaceCatalog
|
|
computer ComputerService
|
|
}
|
|
|
|
func NewProvider(workspaces cliservice.WorkspaceCatalog, computer ComputerService) Provider {
|
|
return Provider{workspaces: workspaces, computer: computer}
|
|
}
|
|
|
|
func (Provider) AppID() string { return appID }
|
|
|
|
func (p Provider) Commands() []cliservice.Command {
|
|
return []cliservice.Command{
|
|
p.newScreenshotCommand(),
|
|
p.newClickCommand(),
|
|
p.newDoubleClickCommand(),
|
|
p.newRightClickCommand(),
|
|
p.newTypeCommand(),
|
|
p.newPressKeyCommand(),
|
|
p.newScrollCommand(),
|
|
p.newMoveCursorCommand(),
|
|
p.newToolListCommand(),
|
|
p.newToolDescribeCommand(),
|
|
p.newToolCallCommand(),
|
|
}
|
|
}
|
|
|
|
// call invokes the mapped cua-driver tool and preserves its structured result.
|
|
func (p Provider) call(ctx context.Context, workspaceID string, tool string, args map[string]any) (computersvc.ToolResult, error) {
|
|
if p.computer == nil {
|
|
return computersvc.ToolResult{}, errComputerUnavailable
|
|
}
|
|
result, err := p.computer.CallTool(ctx, workspaceID, "", tool, args)
|
|
if err != nil {
|
|
return computersvc.ToolResult{}, err
|
|
}
|
|
return result, nil
|
|
}
|