Files
byre/internal/agents/hands.go
T

48 lines
1.5 KiB
Go
Raw Normal View History

package agents
2026-10-18 09:20:01 -07:00
import (
"os"
"os/exec"
"path/filepath"
2026-10-18 15:32:07 -07:00
"g.fc.run/ai/byre/internal/mcp"
2026-10-18 09:20:01 -07:00
)
2026-10-18 00:39:04 -07:00
const screenshotGuidance = "\n- When a turn changes something you can see, you can show it in your final message: save screenshots with the Playwright tools (pages you serve on this task's ports) or hands' capture with save (apps on this Mac), and embed each as a Markdown image, ![what it shows](<path>), with the path the tool returned. They go to the task's media folder, outside the worktree, so they are never committed, and are deleted when the task closes. Leave out a screenshot that adds nothing to the text."
func MediaDir(worktreePath string) string {
return worktreePath + "-media"
}
2026-10-18 09:20:01 -07:00
func (m *Manager) handsDir(sessionID string) string {
return filepath.Join(m.handsRoot, sessionID)
}
// replayd keys ScreenCaptureKit clients by executable path, so two hands
// processes run from one path keep cancelling each other's connection.
func (m *Manager) handsMCP(sessionID, mediaDir string) (mcp.Stdio, error) {
src, err := exec.LookPath("byre-hands")
if err != nil {
return mcp.Stdio{}, err
}
data, err := os.ReadFile(src)
if err != nil {
return mcp.Stdio{}, err
}
dir := m.handsDir(sessionID)
err = os.RemoveAll(dir)
if err != nil {
return mcp.Stdio{}, err
}
err = os.MkdirAll(dir, 0o755)
if err != nil {
return mcp.Stdio{}, err
}
bin := filepath.Join(dir, "byre-hands")
err = os.WriteFile(bin, data, 0o755)
if err != nil {
return mcp.Stdio{}, err
}
return mcp.Stdio{Name: "hands", Command: bin, Args: []string{"--media-dir", mediaDir}}, nil
}