package agent

import (
	"context"
	"errors"

	"github.com/keepmind9/acp-sdk-go/schema"
)

// ErrNotSupported is returned by optional Agent methods that are not implemented.
var ErrNotSupported = errors.New("not supported")

// Base implements all Agent interface methods with default (no-op / error) responses.
// Embed it in your agent struct to inherit these defaults and override only the
// methods you need.
//
// Required methods (must override): Initialize, NewSession, Prompt
//
// Optional methods (defaults provided):
//   - Authenticate, LoadSession, ListSessions, Cancel, SetSessionMode,
//     SetSessionConfigOption
//
// Base also implements ExtMethodHandler, ExtNotificationHandler, and
// OnConnectHandler with no-op defaults.
type Base struct{}

// Authenticate returns ErrNotSupported by default.
func (*Base) Authenticate(_ context.Context, _ *schema.AuthenticateRequest) (*schema.AuthenticateResponse, error) {
	return nil, ErrNotSupported
}

// LoadSession returns ErrNotSupported by default.
func (*Base) LoadSession(_ context.Context, _ *schema.LoadSessionRequest) (*schema.LoadSessionResponse, error) {
	return nil, ErrNotSupported
}

// ListSessions returns an empty list by default.
func (*Base) ListSessions(_ context.Context, _ *schema.ListSessionsRequest) (*schema.ListSessionsResponse, error) {
	return &schema.ListSessionsResponse{}, nil
}

// Cancel is a no-op by default.
func (*Base) Cancel(_ context.Context, _ *schema.CancelNotification) error {
	return nil
}

// SetSessionMode returns ErrNotSupported by default.
func (*Base) SetSessionMode(_ context.Context, _ *schema.SetSessionModeRequest) (*schema.SetSessionModeResponse, error) {
	return nil, ErrNotSupported
}

// SetSessionConfigOption returns ErrNotSupported by default.
func (*Base) SetSessionConfigOption(_ context.Context, _ *schema.SetSessionConfigOptionRequest) (*schema.SetSessionConfigOptionResponse, error) {
	return nil, ErrNotSupported
}

// ExtMethod is a no-op returning ErrNotSupported by default.
func (*Base) ExtMethod(_ context.Context, name string, _ map[string]any) (any, error) {
	return nil, ErrNotSupported
}

// ExtNotification is a no-op by default.
func (*Base) ExtNotification(_ context.Context, _ string, _ map[string]any) error {
	return nil
}

// OnConnect is a no-op by default.
func (*Base) OnConnect(_ *AgentSideConnection) {}
