// Code generated by protoc-gen-slimrpc-go. DO NOT EDIT.
// source: a2a.proto

package v1

import (
	"context"
	"fmt"
	"time"

	slim_bindings "github.com/agntcy/slim-bindings-go"
	"github.com/agntcy/slim-bindings-go/slimrpc"
	"google.golang.org/protobuf/proto"
	"google.golang.org/protobuf/types/descriptorpb"
	a2a_a2apb "github.com/a2aproject/a2a-go/a2apb"
)


// A2AServiceClient is the client API for A2AService service.
type A2AServiceClient interface {
	SendMessage(ctx context.Context, req *a2a_a2apb.SendMessageRequest) (*a2a_a2apb.SendMessageResponse, error)
	SendStreamingMessage(ctx context.Context, req *a2a_a2apb.SendMessageRequest) (slimrpc.ResponseStream[*a2a_a2apb.StreamResponse], error)
	GetTask(ctx context.Context, req *a2a_a2apb.GetTaskRequest) (*a2a_a2apb.Task, error)
	ListTasks(ctx context.Context, req *a2a_a2apb.ListTasksRequest) (*a2a_a2apb.ListTasksResponse, error)
	CancelTask(ctx context.Context, req *a2a_a2apb.CancelTaskRequest) (*a2a_a2apb.Task, error)
	TaskSubscription(ctx context.Context, req *a2a_a2apb.TaskSubscriptionRequest) (slimrpc.ResponseStream[*a2a_a2apb.StreamResponse], error)
	CreateTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.CreateTaskPushNotificationConfigRequest) (*a2a_a2apb.TaskPushNotificationConfig, error)
	GetTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.GetTaskPushNotificationConfigRequest) (*a2a_a2apb.TaskPushNotificationConfig, error)
	ListTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.ListTaskPushNotificationConfigRequest) (*a2a_a2apb.ListTaskPushNotificationConfigResponse, error)
	GetAgentCard(ctx context.Context, req *a2a_a2apb.GetAgentCardRequest) (*a2a_a2apb.AgentCard, error)
	DeleteTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.DeleteTaskPushNotificationConfigRequest) (*descriptorpb.Empty, error)
}

type A2AServiceClientImpl struct {
	channel *slim_bindings.Channel
}

// NewA2AServiceClient creates a new A2AService client.
func NewA2AServiceClient(channel *slim_bindings.Channel) A2AServiceClient {
	return &A2AServiceClientImpl{
		channel: channel,
	}
}


func (c *A2AServiceClientImpl) SendMessage(ctx context.Context, req *a2a_a2apb.SendMessageRequest) (*a2a_a2apb.SendMessageResponse, error) {
	// Serialize request
	reqBytes, err := proto.Marshal(req)
	if err != nil {
		return nil, err
	}

	// Extract timeout from context
	var timeout *time.Duration
	if deadline, ok := ctx.Deadline(); ok {
		t := time.Until(deadline)
		timeout = &t
	}

	// Extract metadata from context
	var metadata *map[string]string
	if md, ok := slimrpc.MetadataFromContext(ctx); ok {
		metadata = &md
	}

	// Make RPC call
	respBytes, err := c.channel.CallUnaryAsync("a2a.v1.A2AService", "SendMessage", reqBytes, timeout, metadata)
	if err != nil {
		return nil, err
	}

	// Deserialize response
	resp := &a2a_a2apb.SendMessageResponse{}
	if err := proto.Unmarshal(respBytes, resp); err != nil {
		return nil, err
	}

	return resp, nil
}

func (c *A2AServiceClientImpl) SendStreamingMessage(ctx context.Context, req *a2a_a2apb.SendMessageRequest) (slimrpc.ResponseStream[*a2a_a2apb.StreamResponse], error) {
	// Serialize request
	reqBytes, err := proto.Marshal(req)
	if err != nil {
		return nil, err
	}

	// Extract timeout from context
	var timeout *time.Duration
	if deadline, ok := ctx.Deadline(); ok {
		t := time.Until(deadline)
		timeout = &t
	}

	// Extract metadata from context
	var metadata *map[string]string
	if md, ok := slimrpc.MetadataFromContext(ctx); ok {
		metadata = &md
	}

	// Make RPC call
	stream, err := c.channel.CallUnaryStreamAsync("a2a.v1.A2AService", "SendStreamingMessage", reqBytes, timeout, metadata)
	if err != nil {
		return nil, err
	}

	return slimrpc.NewClientResponseStream[*a2a_a2apb.StreamResponse](stream), nil
}

func (c *A2AServiceClientImpl) GetTask(ctx context.Context, req *a2a_a2apb.GetTaskRequest) (*a2a_a2apb.Task, error) {
	// Serialize request
	reqBytes, err := proto.Marshal(req)
	if err != nil {
		return nil, err
	}

	// Extract timeout from context
	var timeout *time.Duration
	if deadline, ok := ctx.Deadline(); ok {
		t := time.Until(deadline)
		timeout = &t
	}

	// Extract metadata from context
	var metadata *map[string]string
	if md, ok := slimrpc.MetadataFromContext(ctx); ok {
		metadata = &md
	}

	// Make RPC call
	respBytes, err := c.channel.CallUnaryAsync("a2a.v1.A2AService", "GetTask", reqBytes, timeout, metadata)
	if err != nil {
		return nil, err
	}

	// Deserialize response
	resp := &a2a_a2apb.Task{}
	if err := proto.Unmarshal(respBytes, resp); err != nil {
		return nil, err
	}

	return resp, nil
}

func (c *A2AServiceClientImpl) ListTasks(ctx context.Context, req *a2a_a2apb.ListTasksRequest) (*a2a_a2apb.ListTasksResponse, error) {
	// Serialize request
	reqBytes, err := proto.Marshal(req)
	if err != nil {
		return nil, err
	}

	// Extract timeout from context
	var timeout *time.Duration
	if deadline, ok := ctx.Deadline(); ok {
		t := time.Until(deadline)
		timeout = &t
	}

	// Extract metadata from context
	var metadata *map[string]string
	if md, ok := slimrpc.MetadataFromContext(ctx); ok {
		metadata = &md
	}

	// Make RPC call
	respBytes, err := c.channel.CallUnaryAsync("a2a.v1.A2AService", "ListTasks", reqBytes, timeout, metadata)
	if err != nil {
		return nil, err
	}

	// Deserialize response
	resp := &a2a_a2apb.ListTasksResponse{}
	if err := proto.Unmarshal(respBytes, resp); err != nil {
		return nil, err
	}

	return resp, nil
}

func (c *A2AServiceClientImpl) CancelTask(ctx context.Context, req *a2a_a2apb.CancelTaskRequest) (*a2a_a2apb.Task, error) {
	// Serialize request
	reqBytes, err := proto.Marshal(req)
	if err != nil {
		return nil, err
	}

	// Extract timeout from context
	var timeout *time.Duration
	if deadline, ok := ctx.Deadline(); ok {
		t := time.Until(deadline)
		timeout = &t
	}

	// Extract metadata from context
	var metadata *map[string]string
	if md, ok := slimrpc.MetadataFromContext(ctx); ok {
		metadata = &md
	}

	// Make RPC call
	respBytes, err := c.channel.CallUnaryAsync("a2a.v1.A2AService", "CancelTask", reqBytes, timeout, metadata)
	if err != nil {
		return nil, err
	}

	// Deserialize response
	resp := &a2a_a2apb.Task{}
	if err := proto.Unmarshal(respBytes, resp); err != nil {
		return nil, err
	}

	return resp, nil
}

func (c *A2AServiceClientImpl) TaskSubscription(ctx context.Context, req *a2a_a2apb.TaskSubscriptionRequest) (slimrpc.ResponseStream[*a2a_a2apb.StreamResponse], error) {
	// Serialize request
	reqBytes, err := proto.Marshal(req)
	if err != nil {
		return nil, err
	}

	// Extract timeout from context
	var timeout *time.Duration
	if deadline, ok := ctx.Deadline(); ok {
		t := time.Until(deadline)
		timeout = &t
	}

	// Extract metadata from context
	var metadata *map[string]string
	if md, ok := slimrpc.MetadataFromContext(ctx); ok {
		metadata = &md
	}

	// Make RPC call
	stream, err := c.channel.CallUnaryStreamAsync("a2a.v1.A2AService", "TaskSubscription", reqBytes, timeout, metadata)
	if err != nil {
		return nil, err
	}

	return slimrpc.NewClientResponseStream[*a2a_a2apb.StreamResponse](stream), nil
}

func (c *A2AServiceClientImpl) CreateTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.CreateTaskPushNotificationConfigRequest) (*a2a_a2apb.TaskPushNotificationConfig, error) {
	// Serialize request
	reqBytes, err := proto.Marshal(req)
	if err != nil {
		return nil, err
	}

	// Extract timeout from context
	var timeout *time.Duration
	if deadline, ok := ctx.Deadline(); ok {
		t := time.Until(deadline)
		timeout = &t
	}

	// Extract metadata from context
	var metadata *map[string]string
	if md, ok := slimrpc.MetadataFromContext(ctx); ok {
		metadata = &md
	}

	// Make RPC call
	respBytes, err := c.channel.CallUnaryAsync("a2a.v1.A2AService", "CreateTaskPushNotificationConfig", reqBytes, timeout, metadata)
	if err != nil {
		return nil, err
	}

	// Deserialize response
	resp := &a2a_a2apb.TaskPushNotificationConfig{}
	if err := proto.Unmarshal(respBytes, resp); err != nil {
		return nil, err
	}

	return resp, nil
}

func (c *A2AServiceClientImpl) GetTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.GetTaskPushNotificationConfigRequest) (*a2a_a2apb.TaskPushNotificationConfig, error) {
	// Serialize request
	reqBytes, err := proto.Marshal(req)
	if err != nil {
		return nil, err
	}

	// Extract timeout from context
	var timeout *time.Duration
	if deadline, ok := ctx.Deadline(); ok {
		t := time.Until(deadline)
		timeout = &t
	}

	// Extract metadata from context
	var metadata *map[string]string
	if md, ok := slimrpc.MetadataFromContext(ctx); ok {
		metadata = &md
	}

	// Make RPC call
	respBytes, err := c.channel.CallUnaryAsync("a2a.v1.A2AService", "GetTaskPushNotificationConfig", reqBytes, timeout, metadata)
	if err != nil {
		return nil, err
	}

	// Deserialize response
	resp := &a2a_a2apb.TaskPushNotificationConfig{}
	if err := proto.Unmarshal(respBytes, resp); err != nil {
		return nil, err
	}

	return resp, nil
}

func (c *A2AServiceClientImpl) ListTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.ListTaskPushNotificationConfigRequest) (*a2a_a2apb.ListTaskPushNotificationConfigResponse, error) {
	// Serialize request
	reqBytes, err := proto.Marshal(req)
	if err != nil {
		return nil, err
	}

	// Extract timeout from context
	var timeout *time.Duration
	if deadline, ok := ctx.Deadline(); ok {
		t := time.Until(deadline)
		timeout = &t
	}

	// Extract metadata from context
	var metadata *map[string]string
	if md, ok := slimrpc.MetadataFromContext(ctx); ok {
		metadata = &md
	}

	// Make RPC call
	respBytes, err := c.channel.CallUnaryAsync("a2a.v1.A2AService", "ListTaskPushNotificationConfig", reqBytes, timeout, metadata)
	if err != nil {
		return nil, err
	}

	// Deserialize response
	resp := &a2a_a2apb.ListTaskPushNotificationConfigResponse{}
	if err := proto.Unmarshal(respBytes, resp); err != nil {
		return nil, err
	}

	return resp, nil
}

func (c *A2AServiceClientImpl) GetAgentCard(ctx context.Context, req *a2a_a2apb.GetAgentCardRequest) (*a2a_a2apb.AgentCard, error) {
	// Serialize request
	reqBytes, err := proto.Marshal(req)
	if err != nil {
		return nil, err
	}

	// Extract timeout from context
	var timeout *time.Duration
	if deadline, ok := ctx.Deadline(); ok {
		t := time.Until(deadline)
		timeout = &t
	}

	// Extract metadata from context
	var metadata *map[string]string
	if md, ok := slimrpc.MetadataFromContext(ctx); ok {
		metadata = &md
	}

	// Make RPC call
	respBytes, err := c.channel.CallUnaryAsync("a2a.v1.A2AService", "GetAgentCard", reqBytes, timeout, metadata)
	if err != nil {
		return nil, err
	}

	// Deserialize response
	resp := &a2a_a2apb.AgentCard{}
	if err := proto.Unmarshal(respBytes, resp); err != nil {
		return nil, err
	}

	return resp, nil
}

func (c *A2AServiceClientImpl) DeleteTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.DeleteTaskPushNotificationConfigRequest) (*descriptorpb.Empty, error) {
	// Serialize request
	reqBytes, err := proto.Marshal(req)
	if err != nil {
		return nil, err
	}

	// Extract timeout from context
	var timeout *time.Duration
	if deadline, ok := ctx.Deadline(); ok {
		t := time.Until(deadline)
		timeout = &t
	}

	// Extract metadata from context
	var metadata *map[string]string
	if md, ok := slimrpc.MetadataFromContext(ctx); ok {
		metadata = &md
	}

	// Make RPC call
	respBytes, err := c.channel.CallUnaryAsync("a2a.v1.A2AService", "DeleteTaskPushNotificationConfig", reqBytes, timeout, metadata)
	if err != nil {
		return nil, err
	}

	// Deserialize response
	resp := &descriptorpb.Empty{}
	if err := proto.Unmarshal(respBytes, resp); err != nil {
		return nil, err
	}

	return resp, nil
}


// A2AServiceServer is the server API for A2AService service.
// All implementations must embed UnimplementedA2AServiceServer
// for forward compatibility
type A2AServiceServer interface {
	SendMessage(ctx context.Context, req *a2a_a2apb.SendMessageRequest) (*a2a_a2apb.SendMessageResponse, error)
	SendStreamingMessage(ctx context.Context, req *a2a_a2apb.SendMessageRequest, stream slimrpc.RequestStream[*a2a_a2apb.StreamResponse]) error
	GetTask(ctx context.Context, req *a2a_a2apb.GetTaskRequest) (*a2a_a2apb.Task, error)
	ListTasks(ctx context.Context, req *a2a_a2apb.ListTasksRequest) (*a2a_a2apb.ListTasksResponse, error)
	CancelTask(ctx context.Context, req *a2a_a2apb.CancelTaskRequest) (*a2a_a2apb.Task, error)
	TaskSubscription(ctx context.Context, req *a2a_a2apb.TaskSubscriptionRequest, stream slimrpc.RequestStream[*a2a_a2apb.StreamResponse]) error
	CreateTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.CreateTaskPushNotificationConfigRequest) (*a2a_a2apb.TaskPushNotificationConfig, error)
	GetTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.GetTaskPushNotificationConfigRequest) (*a2a_a2apb.TaskPushNotificationConfig, error)
	ListTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.ListTaskPushNotificationConfigRequest) (*a2a_a2apb.ListTaskPushNotificationConfigResponse, error)
	GetAgentCard(ctx context.Context, req *a2a_a2apb.GetAgentCardRequest) (*a2a_a2apb.AgentCard, error)
	DeleteTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.DeleteTaskPushNotificationConfigRequest) (*descriptorpb.Empty, error)
}

// UnimplementedA2AServiceServer must be embedded to have forward compatible implementations.
type UnimplementedA2AServiceServer struct {
}


func (UnimplementedA2AServiceServer) SendMessage(ctx context.Context, req *a2a_a2apb.SendMessageRequest) (*a2a_a2apb.SendMessageResponse, error) {
	return nil, fmt.Errorf("method SendMessage not implemented")
}

func (UnimplementedA2AServiceServer) SendStreamingMessage(ctx context.Context, req *a2a_a2apb.SendMessageRequest, stream slimrpc.RequestStream[*a2a_a2apb.StreamResponse]) error {
	return fmt.Errorf("method SendStreamingMessage not implemented")
}

func (UnimplementedA2AServiceServer) GetTask(ctx context.Context, req *a2a_a2apb.GetTaskRequest) (*a2a_a2apb.Task, error) {
	return nil, fmt.Errorf("method GetTask not implemented")
}

func (UnimplementedA2AServiceServer) ListTasks(ctx context.Context, req *a2a_a2apb.ListTasksRequest) (*a2a_a2apb.ListTasksResponse, error) {
	return nil, fmt.Errorf("method ListTasks not implemented")
}

func (UnimplementedA2AServiceServer) CancelTask(ctx context.Context, req *a2a_a2apb.CancelTaskRequest) (*a2a_a2apb.Task, error) {
	return nil, fmt.Errorf("method CancelTask not implemented")
}

func (UnimplementedA2AServiceServer) TaskSubscription(ctx context.Context, req *a2a_a2apb.TaskSubscriptionRequest, stream slimrpc.RequestStream[*a2a_a2apb.StreamResponse]) error {
	return fmt.Errorf("method TaskSubscription not implemented")
}

func (UnimplementedA2AServiceServer) CreateTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.CreateTaskPushNotificationConfigRequest) (*a2a_a2apb.TaskPushNotificationConfig, error) {
	return nil, fmt.Errorf("method CreateTaskPushNotificationConfig not implemented")
}

func (UnimplementedA2AServiceServer) GetTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.GetTaskPushNotificationConfigRequest) (*a2a_a2apb.TaskPushNotificationConfig, error) {
	return nil, fmt.Errorf("method GetTaskPushNotificationConfig not implemented")
}

func (UnimplementedA2AServiceServer) ListTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.ListTaskPushNotificationConfigRequest) (*a2a_a2apb.ListTaskPushNotificationConfigResponse, error) {
	return nil, fmt.Errorf("method ListTaskPushNotificationConfig not implemented")
}

func (UnimplementedA2AServiceServer) GetAgentCard(ctx context.Context, req *a2a_a2apb.GetAgentCardRequest) (*a2a_a2apb.AgentCard, error) {
	return nil, fmt.Errorf("method GetAgentCard not implemented")
}

func (UnimplementedA2AServiceServer) DeleteTaskPushNotificationConfig(ctx context.Context, req *a2a_a2apb.DeleteTaskPushNotificationConfigRequest) (*descriptorpb.Empty, error) {
	return nil, fmt.Errorf("method DeleteTaskPushNotificationConfig not implemented")
}


// RegisterA2AServiceServer registers the server with slim_bindings.
func RegisterA2AServiceServer(server *slim_bindings.Server, impl A2AServiceServer) {
	server.RegisterUnaryUnary("a2a.v1.A2AService", "SendMessage", &A2AService_SendMessage_Handler{impl: impl})
	server.RegisterUnaryStream("a2a.v1.A2AService", "SendStreamingMessage", &A2AService_SendStreamingMessage_Handler{impl: impl})
	server.RegisterUnaryUnary("a2a.v1.A2AService", "GetTask", &A2AService_GetTask_Handler{impl: impl})
	server.RegisterUnaryUnary("a2a.v1.A2AService", "ListTasks", &A2AService_ListTasks_Handler{impl: impl})
	server.RegisterUnaryUnary("a2a.v1.A2AService", "CancelTask", &A2AService_CancelTask_Handler{impl: impl})
	server.RegisterUnaryStream("a2a.v1.A2AService", "TaskSubscription", &A2AService_TaskSubscription_Handler{impl: impl})
	server.RegisterUnaryUnary("a2a.v1.A2AService", "CreateTaskPushNotificationConfig", &A2AService_CreateTaskPushNotificationConfig_Handler{impl: impl})
	server.RegisterUnaryUnary("a2a.v1.A2AService", "GetTaskPushNotificationConfig", &A2AService_GetTaskPushNotificationConfig_Handler{impl: impl})
	server.RegisterUnaryUnary("a2a.v1.A2AService", "ListTaskPushNotificationConfig", &A2AService_ListTaskPushNotificationConfig_Handler{impl: impl})
	server.RegisterUnaryUnary("a2a.v1.A2AService", "GetAgentCard", &A2AService_GetAgentCard_Handler{impl: impl})
	server.RegisterUnaryUnary("a2a.v1.A2AService", "DeleteTaskPushNotificationConfig", &A2AService_DeleteTaskPushNotificationConfig_Handler{impl: impl})
}


type A2AService_SendMessage_Handler struct {
	impl A2AServiceServer
}

func (h *A2AService_SendMessage_Handler) Handle(request []byte, rpcContext *slim_bindings.Context) ([]byte, error) {
	req := &a2a_a2apb.SendMessageRequest{}
	if err := proto.Unmarshal(request, req); err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInvalidArgument,
			err.Error(),
			nil,
		)
	}

	// Convert slim_bindings.Context to context.Context
	ctx, cancel := slimrpc.ContextFromRpcContext(rpcContext)
	defer cancel()

	resp, err := h.impl.SendMessage(ctx, req)
	if err != nil {
		// Check if it's already an RpcError
		if rpcErr, ok := err.(*slim_bindings.RpcError); ok {
			return nil, rpcErr
		}
		// Convert generic errors to RpcError
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}

	respBytes, err := proto.Marshal(resp)
	if err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}
	return respBytes, nil
}

type A2AService_SendStreamingMessage_Handler struct {
	impl A2AServiceServer
}

func (h *A2AService_SendStreamingMessage_Handler) Handle(request []byte, rpcContext *slim_bindings.Context, sink *slim_bindings.ResponseSink) error {
	req := &a2a_a2apb.SendMessageRequest{}
	if err := proto.Unmarshal(request, req); err != nil {
		rpcErr := slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInvalidArgument,
			err.Error(),
			nil,
		)
		sink.SendErrorAsync(rpcErr)
		return rpcErr
	}

	// Convert slim_bindings.Context to context.Context
	ctx, cancel := slimrpc.ContextFromRpcContext(rpcContext)
	defer cancel()

	stream := slimrpc.NewServerRequestStream[*a2a_a2apb.StreamResponse](sink)
	err := h.impl.SendStreamingMessage(ctx, req, stream)

	// Close the stream after handler returns
	closeErr := sink.CloseAsync()
	if err == nil {
		err = closeErr
	}

	if err != nil {
		// Check if it's already an RpcError
		if rpcErr, ok := err.(*slim_bindings.RpcError); ok {
			sink.SendErrorAsync(rpcErr)
			return rpcErr
		}
		// Convert generic errors to RpcError
		rpcErr := slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
		sink.SendErrorAsync(rpcErr)
		return rpcErr
	}

	return nil
}

type A2AService_GetTask_Handler struct {
	impl A2AServiceServer
}

func (h *A2AService_GetTask_Handler) Handle(request []byte, rpcContext *slim_bindings.Context) ([]byte, error) {
	req := &a2a_a2apb.GetTaskRequest{}
	if err := proto.Unmarshal(request, req); err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInvalidArgument,
			err.Error(),
			nil,
		)
	}

	// Convert slim_bindings.Context to context.Context
	ctx, cancel := slimrpc.ContextFromRpcContext(rpcContext)
	defer cancel()

	resp, err := h.impl.GetTask(ctx, req)
	if err != nil {
		// Check if it's already an RpcError
		if rpcErr, ok := err.(*slim_bindings.RpcError); ok {
			return nil, rpcErr
		}
		// Convert generic errors to RpcError
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}

	respBytes, err := proto.Marshal(resp)
	if err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}
	return respBytes, nil
}

type A2AService_ListTasks_Handler struct {
	impl A2AServiceServer
}

func (h *A2AService_ListTasks_Handler) Handle(request []byte, rpcContext *slim_bindings.Context) ([]byte, error) {
	req := &a2a_a2apb.ListTasksRequest{}
	if err := proto.Unmarshal(request, req); err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInvalidArgument,
			err.Error(),
			nil,
		)
	}

	// Convert slim_bindings.Context to context.Context
	ctx, cancel := slimrpc.ContextFromRpcContext(rpcContext)
	defer cancel()

	resp, err := h.impl.ListTasks(ctx, req)
	if err != nil {
		// Check if it's already an RpcError
		if rpcErr, ok := err.(*slim_bindings.RpcError); ok {
			return nil, rpcErr
		}
		// Convert generic errors to RpcError
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}

	respBytes, err := proto.Marshal(resp)
	if err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}
	return respBytes, nil
}

type A2AService_CancelTask_Handler struct {
	impl A2AServiceServer
}

func (h *A2AService_CancelTask_Handler) Handle(request []byte, rpcContext *slim_bindings.Context) ([]byte, error) {
	req := &a2a_a2apb.CancelTaskRequest{}
	if err := proto.Unmarshal(request, req); err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInvalidArgument,
			err.Error(),
			nil,
		)
	}

	// Convert slim_bindings.Context to context.Context
	ctx, cancel := slimrpc.ContextFromRpcContext(rpcContext)
	defer cancel()

	resp, err := h.impl.CancelTask(ctx, req)
	if err != nil {
		// Check if it's already an RpcError
		if rpcErr, ok := err.(*slim_bindings.RpcError); ok {
			return nil, rpcErr
		}
		// Convert generic errors to RpcError
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}

	respBytes, err := proto.Marshal(resp)
	if err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}
	return respBytes, nil
}

type A2AService_TaskSubscription_Handler struct {
	impl A2AServiceServer
}

func (h *A2AService_TaskSubscription_Handler) Handle(request []byte, rpcContext *slim_bindings.Context, sink *slim_bindings.ResponseSink) error {
	req := &a2a_a2apb.TaskSubscriptionRequest{}
	if err := proto.Unmarshal(request, req); err != nil {
		rpcErr := slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInvalidArgument,
			err.Error(),
			nil,
		)
		sink.SendErrorAsync(rpcErr)
		return rpcErr
	}

	// Convert slim_bindings.Context to context.Context
	ctx, cancel := slimrpc.ContextFromRpcContext(rpcContext)
	defer cancel()

	stream := slimrpc.NewServerRequestStream[*a2a_a2apb.StreamResponse](sink)
	err := h.impl.TaskSubscription(ctx, req, stream)

	// Close the stream after handler returns
	closeErr := sink.CloseAsync()
	if err == nil {
		err = closeErr
	}

	if err != nil {
		// Check if it's already an RpcError
		if rpcErr, ok := err.(*slim_bindings.RpcError); ok {
			sink.SendErrorAsync(rpcErr)
			return rpcErr
		}
		// Convert generic errors to RpcError
		rpcErr := slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
		sink.SendErrorAsync(rpcErr)
		return rpcErr
	}

	return nil
}

type A2AService_CreateTaskPushNotificationConfig_Handler struct {
	impl A2AServiceServer
}

func (h *A2AService_CreateTaskPushNotificationConfig_Handler) Handle(request []byte, rpcContext *slim_bindings.Context) ([]byte, error) {
	req := &a2a_a2apb.CreateTaskPushNotificationConfigRequest{}
	if err := proto.Unmarshal(request, req); err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInvalidArgument,
			err.Error(),
			nil,
		)
	}

	// Convert slim_bindings.Context to context.Context
	ctx, cancel := slimrpc.ContextFromRpcContext(rpcContext)
	defer cancel()

	resp, err := h.impl.CreateTaskPushNotificationConfig(ctx, req)
	if err != nil {
		// Check if it's already an RpcError
		if rpcErr, ok := err.(*slim_bindings.RpcError); ok {
			return nil, rpcErr
		}
		// Convert generic errors to RpcError
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}

	respBytes, err := proto.Marshal(resp)
	if err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}
	return respBytes, nil
}

type A2AService_GetTaskPushNotificationConfig_Handler struct {
	impl A2AServiceServer
}

func (h *A2AService_GetTaskPushNotificationConfig_Handler) Handle(request []byte, rpcContext *slim_bindings.Context) ([]byte, error) {
	req := &a2a_a2apb.GetTaskPushNotificationConfigRequest{}
	if err := proto.Unmarshal(request, req); err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInvalidArgument,
			err.Error(),
			nil,
		)
	}

	// Convert slim_bindings.Context to context.Context
	ctx, cancel := slimrpc.ContextFromRpcContext(rpcContext)
	defer cancel()

	resp, err := h.impl.GetTaskPushNotificationConfig(ctx, req)
	if err != nil {
		// Check if it's already an RpcError
		if rpcErr, ok := err.(*slim_bindings.RpcError); ok {
			return nil, rpcErr
		}
		// Convert generic errors to RpcError
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}

	respBytes, err := proto.Marshal(resp)
	if err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}
	return respBytes, nil
}

type A2AService_ListTaskPushNotificationConfig_Handler struct {
	impl A2AServiceServer
}

func (h *A2AService_ListTaskPushNotificationConfig_Handler) Handle(request []byte, rpcContext *slim_bindings.Context) ([]byte, error) {
	req := &a2a_a2apb.ListTaskPushNotificationConfigRequest{}
	if err := proto.Unmarshal(request, req); err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInvalidArgument,
			err.Error(),
			nil,
		)
	}

	// Convert slim_bindings.Context to context.Context
	ctx, cancel := slimrpc.ContextFromRpcContext(rpcContext)
	defer cancel()

	resp, err := h.impl.ListTaskPushNotificationConfig(ctx, req)
	if err != nil {
		// Check if it's already an RpcError
		if rpcErr, ok := err.(*slim_bindings.RpcError); ok {
			return nil, rpcErr
		}
		// Convert generic errors to RpcError
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}

	respBytes, err := proto.Marshal(resp)
	if err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}
	return respBytes, nil
}

type A2AService_GetAgentCard_Handler struct {
	impl A2AServiceServer
}

func (h *A2AService_GetAgentCard_Handler) Handle(request []byte, rpcContext *slim_bindings.Context) ([]byte, error) {
	req := &a2a_a2apb.GetAgentCardRequest{}
	if err := proto.Unmarshal(request, req); err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInvalidArgument,
			err.Error(),
			nil,
		)
	}

	// Convert slim_bindings.Context to context.Context
	ctx, cancel := slimrpc.ContextFromRpcContext(rpcContext)
	defer cancel()

	resp, err := h.impl.GetAgentCard(ctx, req)
	if err != nil {
		// Check if it's already an RpcError
		if rpcErr, ok := err.(*slim_bindings.RpcError); ok {
			return nil, rpcErr
		}
		// Convert generic errors to RpcError
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}

	respBytes, err := proto.Marshal(resp)
	if err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}
	return respBytes, nil
}

type A2AService_DeleteTaskPushNotificationConfig_Handler struct {
	impl A2AServiceServer
}

func (h *A2AService_DeleteTaskPushNotificationConfig_Handler) Handle(request []byte, rpcContext *slim_bindings.Context) ([]byte, error) {
	req := &a2a_a2apb.DeleteTaskPushNotificationConfigRequest{}
	if err := proto.Unmarshal(request, req); err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInvalidArgument,
			err.Error(),
			nil,
		)
	}

	// Convert slim_bindings.Context to context.Context
	ctx, cancel := slimrpc.ContextFromRpcContext(rpcContext)
	defer cancel()

	resp, err := h.impl.DeleteTaskPushNotificationConfig(ctx, req)
	if err != nil {
		// Check if it's already an RpcError
		if rpcErr, ok := err.(*slim_bindings.RpcError); ok {
			return nil, rpcErr
		}
		// Convert generic errors to RpcError
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}

	respBytes, err := proto.Marshal(resp)
	if err != nil {
		return nil, slim_bindings.NewRpcErrorRpc(
			slim_bindings.RpcCodeInternal,
			err.Error(),
			nil,
		)
	}
	return respBytes, nil
}


