Add web UI and worker capture/approval command channel
Introduces the browser-facing surface and the worker-side protocol that backs it: - internal/ui: joined read model plus per-task lifecycle and approval controls, kept separate from the raw endpoints workers and harnesses depend on. - internal/webui + web/: Vite/React app, build output embedded via go:embed and served as an SPA fallback. - federation: per-(worker, task) captures with a monotonic revision that advances only when pane text actually changes, and a command queue restricted to grant_approval / deny_approval, each bound to the capture revision the operator acted on. - orchestra-worker: publishes captures and executes commands only after re-reading the pane and confirming the revision still matches. Sends keystrokes only for a visible y/n prompt or OpenCode's fully labelled selector, and refuses to deny through that selector rather than guess at unobservable navigation. This is the ownership boundary AUDIT.md's B14 and B17 call for: approval becomes an explicit, revision-bound operation executed by the worker that owns the pane, instead of a side effect of prompting over a coordinator-driven remote socket. Also ignores the web build inputs and outputs. node_modules ships vendored Go packages, so go build and go test walk into it if it is merely untracked; both node_modules and .node_modules are excluded. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01535A3Y8RtkAi8wYuWhtkEd
This commit is contained in:
@@ -66,6 +66,13 @@ type AgentBlocker interface {
|
||||
type PaneCapture interface {
|
||||
PaneCapture(context.Context, Session, string) (string, error)
|
||||
}
|
||||
|
||||
// ApprovalResponder executes an explicitly displayed permission decision.
|
||||
// Implementations must re-read the pane before sending input so callers can
|
||||
// bind a decision to the exact capture they rendered.
|
||||
type ApprovalResponder interface {
|
||||
RespondApproval(context.Context, Session, bool, string) error
|
||||
}
|
||||
type CLIAdapter struct {
|
||||
Client *Client
|
||||
Harness string
|
||||
@@ -595,6 +602,28 @@ func (a CLIAdapter) PaneCapture(ctx context.Context, s Session, source string) (
|
||||
return r.Read.Text, nil
|
||||
}
|
||||
|
||||
// RespondApproval only acts on harness prompts that visibly expose a y/n
|
||||
// choice. This deliberately refuses unknown dialog layouts rather than
|
||||
// guessing an Enter key could mean approval.
|
||||
func (a CLIAdapter) RespondApproval(ctx context.Context, s Session, grant bool, expectedCapture string) error {
|
||||
current, err := a.PaneCapture(ctx, s, "recent")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if current != expectedCapture {
|
||||
return fmt.Errorf("approval prompt changed")
|
||||
}
|
||||
low := strings.ToLower(current)
|
||||
if !strings.Contains(low, "[y/n]") && !strings.Contains(low, "(y/n)") {
|
||||
return fmt.Errorf("approval prompt has no unambiguous y/n confirmation")
|
||||
}
|
||||
input := "n\n"
|
||||
if grant {
|
||||
input = "y\n"
|
||||
}
|
||||
return a.Client.Call(ctx, "pane.send_text", map[string]any{"pane_id": s.PaneID, "text": input}, nil)
|
||||
}
|
||||
|
||||
func statusFromAgentResult(v any) string {
|
||||
if m, ok := v.(map[string]any); ok {
|
||||
for _, key := range []string{"status", "agent_status", "state"} {
|
||||
|
||||
Reference in New Issue
Block a user