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
43 lines
1.5 KiB
Go
43 lines
1.5 KiB
Go
package computer
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
agentruntime "github.com/tutti-os/tutti/packages/agent/daemon/runtime"
|
|
mcpservice "github.com/tutti-os/tutti/packages/connector/runtime/mcp"
|
|
)
|
|
|
|
// mcpClient preserves the computer session's private adapter while sharing the
|
|
// protocol implementation with browser and connector hosts.
|
|
type mcpClient struct{ shared *mcpservice.StdioClient }
|
|
|
|
func newMCPClient(connection agentruntime.ProcessConnection) *mcpClient {
|
|
shared, err := mcpservice.NewStdioClient(mcpservice.StdioClientConfig{
|
|
Connection: connection,
|
|
ProcessName: "computer MCP",
|
|
// Preserve the existing computer behavior. Connector clients omit this
|
|
// handler and therefore fail closed with method-not-supported.
|
|
ServerRequestHandler: func(request mcpservice.ServerRequest) (any, *mcpservice.RPCError) {
|
|
if request.Method == "elicitation/create" {
|
|
return map[string]any{"action": "accept", "content": map[string]any{}}, nil
|
|
}
|
|
return nil, &mcpservice.RPCError{Code: -32601, Message: "method not supported"}
|
|
},
|
|
})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return &mcpClient{shared: shared}
|
|
}
|
|
|
|
func (client *mcpClient) call(ctx context.Context, method string, params any) (json.RawMessage, error) {
|
|
return client.shared.Call(ctx, method, params)
|
|
}
|
|
|
|
func (client *mcpClient) notify(method string, params any) error {
|
|
return client.shared.Notify(method, params)
|
|
}
|
|
|
|
func (client *mcpClient) isClosed() bool { return client == nil || client.shared.IsClosed() }
|