package client

import (
	"context"

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

// Client is the interface that ACP client implementations must satisfy.
// Each method corresponds to a JSON-RPC method that the agent can call.
type Client interface {
	// RequestPermission asks the user to approve or deny a tool call.
	RequestPermission(ctx context.Context, req *schema.RequestPermissionRequest) (*schema.RequestPermissionResponse, error)

	// SessionUpdate receives a streaming session update from the agent.
	SessionUpdate(ctx context.Context, notif *schema.SessionNotification) error

	// ReadTextFile reads a text file from the client's filesystem.
	ReadTextFile(ctx context.Context, req *schema.ReadTextFileRequest) (*schema.ReadTextFileResponse, error)

	// WriteTextFile writes a text file on the client's filesystem.
	WriteTextFile(ctx context.Context, req *schema.WriteTextFileRequest) (*schema.WriteTextFileResponse, error)

	// CreateTerminal creates a terminal on the client side.
	CreateTerminal(ctx context.Context, req *schema.CreateTerminalRequest) (*schema.CreateTerminalResponse, error)

	// TerminalOutput reads output from a terminal.
	TerminalOutput(ctx context.Context, req *schema.TerminalOutputRequest) (*schema.TerminalOutputResponse, error)

	// ReleaseTerminal releases a terminal.
	ReleaseTerminal(ctx context.Context, req *schema.ReleaseTerminalRequest) (*schema.ReleaseTerminalResponse, error)

	// WaitForTerminalExit waits for a terminal to exit.
	WaitForTerminalExit(ctx context.Context, req *schema.WaitForTerminalExitRequest) (*schema.WaitForTerminalExitResponse, error)

	// KillTerminal kills a terminal.
	KillTerminal(ctx context.Context, req *schema.KillTerminalRequest) (*schema.KillTerminalResponse, error)
}

// ExtMethodHandler is an optional interface for handling extension RPC requests.
type ExtMethodHandler interface {
	ExtMethod(ctx context.Context, name string, params map[string]any) (any, error)
}

// ExtNotificationHandler is an optional interface for handling extension RPC notifications.
type ExtNotificationHandler interface {
	ExtNotification(ctx context.Context, name string, params map[string]any) error
}

// OnConnectHandler is an optional interface called when the connection is established.
type OnConnectHandler interface {
	OnConnect(conn *ClientSideConnection)
}
