diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.go index 8f0b82c01..a233e870c 100644 --- a/internal/gateway/gateway.go +++ b/internal/gateway/gateway.go @@ -138,13 +138,6 @@ type UpdateService interface { CanInstall() bool } -// DangerousApprover is the adapter-neutral decision surface for pending -// sandbox actions. Numeric /approve arguments remain task approvals; action -// IDs are routed here when this capability is present. -type DangerousApprover interface { - Decide(context.Context, string, string) (string, error) -} - // TaskController approves or cancels a chat-originated task. Both // methods must enforce authorization (identity must own the task) and // valid state transitions; see gateway.tasks.go's StoreTaskController @@ -213,8 +206,6 @@ type Router struct { Version string // Updates handles the shared /update command. Nil means unavailable. Updates UpdateService - // Dangerous handles typed approval decisions for sandbox actions. - Dangerous DangerousApprover // Restart requests a scoped chat-adapter reload. It deliberately does not // restart the daemon; Telegram's /restart has this same boundary. Restart func(context.Context) error @@ -334,10 +325,7 @@ func (r *Router) dispatchLocal(ctx context.Context, msg messaging.Message, text, reply, err := r.handleSpawn(ctx, rest) return reply, true, err case "/approve": - reply, err := r.handleApproveCommand(ctx, rest) - return reply, true, err - case "/deny": - reply, err := r.handleDeny(ctx, rest) + reply, err := r.handleApprove(ctx, rest) return reply, true, err case "/cancel": reply, err := r.handleCancel(ctx, rest) @@ -384,22 +372,6 @@ func (r *Router) dispatchLocalMisc(ctx context.Context, msg messaging.Message, c return r.dispatchSessionCommand(ctx, msg, cmd, rest) } -// handleDeny denies a pending dangerous action by ID. -func (r *Router) handleDeny(ctx context.Context, rest string) (string, error) { - if r.Dangerous == nil { - return "Dangerous approvals are not configured.", nil - } - fields := strings.Fields(rest) - if len(fields) != 1 { - return "Usage: /deny ", nil - } - result, err := r.Dangerous.Decide(ctx, fields[0], "deny") - if err != nil { - return fmt.Sprintf("Cannot deny action: %v", err), nil - } - return result, nil -} - // handleVersion reports the configured build version. func (r *Router) handleVersion() string { if r.Version == "" { @@ -611,30 +583,6 @@ func parseTaskID(arg string) (int64, error) { return id, nil } -func (r *Router) handleApproveCommand(ctx context.Context, rest string) (string, error) { - fields := strings.Fields(rest) - if r.Dangerous != nil && len(fields) == 1 && !isTaskID(fields[0]) { - result, err := r.Dangerous.Decide(ctx, fields[0], "approve") - if err != nil { - return fmt.Sprintf("Cannot approve action: %v", err), nil - } - return result, nil - } - if r.Dangerous != nil && len(fields) == 2 && strings.EqualFold(fields[0], "permanent") { - result, err := r.Dangerous.Decide(ctx, fields[1], "permanent") - if err != nil { - return fmt.Sprintf("Cannot approve action: %v", err), nil - } - return result, nil - } - return r.handleApprove(ctx, rest) -} - -func isTaskID(value string) bool { - _, err := strconv.ParseInt(value, 10, 64) - return err == nil -} - func (r *Router) handleApprove(ctx context.Context, rest string) (string, error) { if r.Controller == nil { return "Task control is not configured.", nil diff --git a/internal/gateway/web_parity_test.go b/internal/gateway/web_parity_test.go index 211e645c7..ab484cf96 100644 --- a/internal/gateway/web_parity_test.go +++ b/internal/gateway/web_parity_test.go @@ -19,13 +19,6 @@ func (parityUpdateStub) Install(context.Context, releaseupdate.Snapshot, release } func (parityUpdateStub) CanInstall() bool { return true } -type parityDangerousStub struct{ decisions []string } - -func (s *parityDangerousStub) Decide(_ context.Context, id, decision string) (string, error) { - s.decisions = append(s.decisions, id+":"+decision) - return "dangerous decision applied", nil -} - func TestSharedRouterWebParityCommands(t *testing.T) { t.Parallel() r := NewRouter(nil, nil, "web") @@ -33,8 +26,6 @@ func TestSharedRouterWebParityCommands(t *testing.T) { restarted := false r.Restart = func(context.Context) error { restarted = true; return nil } r.Updates = parityUpdateStub{} - dangerous := &parityDangerousStub{} - r.Dangerous = dangerous r.Personas = NewPersonaRegistry(DefaultPersonas()) sessions := NewSessionStoreMemory() t.Cleanup(func() { _ = sessions.Close() }) @@ -59,16 +50,4 @@ func TestSharedRouterWebParityCommands(t *testing.T) { if err != nil || !strings.Contains(reply, "v2 available") { t.Fatalf("/update = %q, err=%v", reply, err) } - reply, err = r.Route(context.Background(), inbound("browser", "/approve action-1")) - if err != nil || !strings.Contains(reply, "decision applied") || len(dangerous.decisions) != 1 || dangerous.decisions[0] != "action-1:approve" { - t.Fatalf("typed /approve = %q, decisions=%v, err=%v", reply, dangerous.decisions, err) - } - _, err = r.Route(context.Background(), inbound("browser", "/approve permanent action-2")) - if err != nil || len(dangerous.decisions) != 2 || dangerous.decisions[1] != "action-2:permanent" { - t.Fatalf("permanent /approve decisions=%v, err=%v", dangerous.decisions, err) - } - _, err = r.Route(context.Background(), inbound("browser", "/deny action-3")) - if err != nil || len(dangerous.decisions) != 3 || dangerous.decisions[2] != "action-3:deny" { - t.Fatalf("/deny decisions=%v, err=%v", dangerous.decisions, err) - } }