package mcp

import (
	
)

// TaskOption is a function that configures a Task.
// It provides a flexible way to set various properties of a Task using the functional options pattern.
type TaskOption func(*Task)

//
// Core Task Functions
//

// NewTask creates a new Task with the given ID and options.
// The task will be configured based on the provided options.
// Options are applied in order, allowing for flexible task configuration.
func ( string,  ...TaskOption) Task {
	 := time.Now().UTC().Format(time.RFC3339)
	 := Task{
		TaskId:        ,
		Status:        TaskStatusWorking,
		CreatedAt:     ,
		LastUpdatedAt: ,
	}

	for ,  := range  {
		(&)
	}

	return 
}

// WithTaskStatus sets the status of the task.
func ( TaskStatus) TaskOption {
	return func( *Task) {
		.Status = 
	}
}

// WithTaskStatusMessage sets a human-readable status message for the task.
func ( string) TaskOption {
	return func( *Task) {
		.StatusMessage = 
	}
}

// WithTaskTTL sets the time-to-live for the task in milliseconds.
// After this duration from creation, the task may be deleted.
func ( int64) TaskOption {
	return func( *Task) {
		.TTL = &
	}
}

// WithTaskPollInterval sets the suggested polling interval in milliseconds.
func ( int64) TaskOption {
	return func( *Task) {
		.PollInterval = &
	}
}

// WithTaskCreatedAt sets a specific creation timestamp for the task.
// By default, NewTask uses the current time.
func ( string) TaskOption {
	return func( *Task) {
		.CreatedAt = 
	}
}

//
// Task Helper Functions
//

// NewTaskParams creates TaskParams with the given TTL.
func ( *int64) TaskParams {
	return TaskParams{
		TTL: ,
	}
}

// NewCreateTaskResult creates a CreateTaskResult with the given task.
func ( Task) CreateTaskResult {
	return CreateTaskResult{
		Task: ,
	}
}

// NewGetTaskResult creates a GetTaskResult from a Task.
func ( Task) GetTaskResult {
	return GetTaskResult{
		Task: ,
	}
}

// NewListTasksResult creates a ListTasksResult with the given tasks.
func ( []Task) ListTasksResult {
	return ListTasksResult{
		Tasks: ,
	}
}

// NewCancelTaskResult creates a CancelTaskResult from a Task.
func ( Task) CancelTaskResult {
	return CancelTaskResult{
		Task: ,
	}
}

// NewTaskStatusNotification creates a notification for a task status change.
func ( Task) TaskStatusNotification {
	return TaskStatusNotification{
		Notification: Notification{
			Method: string(MethodNotificationTasksStatus),
		},
		Params: TaskStatusNotificationParams{
			Task: ,
		},
	}
}

//
// Task Capability Helper Functions
//

// NewTasksCapability creates a TasksCapability with all operations enabled.
func () *TasksCapability {
	return &TasksCapability{
		List:   &struct{}{},
		Cancel: &struct{}{},
		Requests: &TaskRequestsCapability{
			Tools: &struct {
				 *struct{} `json:"call,omitempty"`
			}{
				: &struct{}{},
			},
		},
	}
}

// NewTasksCapabilityWithToolsOnly creates a TasksCapability with only tool call support.
// List and Cancel operations are not enabled with this capability.
func () *TasksCapability {
	return &TasksCapability{
		Requests: &TaskRequestsCapability{
			Tools: &struct {
				 *struct{} `json:"call,omitempty"`
			}{
				: &struct{}{},
			},
		},
	}
}

//
// Related Task Metadata Functions
//

// RelatedTaskMetaKey is the metadata key for associating a message with a task.
const RelatedTaskMetaKey = "io.modelcontextprotocol/related-task"

// RelatedTaskMeta creates the metadata for associating a message with a task.
// The returned map contains a "taskId" field with the provided task ID.
func ( string) map[string]any {
	return map[string]any{
		"taskId": ,
	}
}

// WithRelatedTask returns a Meta with the related task ID set.
// This is useful for associating task results with their originating task.
func ( string) *Meta {
	return &Meta{
		AdditionalFields: map[string]any{
			RelatedTaskMetaKey: RelatedTaskMeta(),
		},
	}
}

//
// Model Immediate Response Metadata Functions
//

// ModelImmediateResponseMetaKey is the metadata key for providing an immediate response to the model.
// Servers can use this optional key in the _meta field of CreateTaskResult to provide
// a string that should be passed as an immediate tool result to the model while the task
// continues executing asynchronously in the background.
const ModelImmediateResponseMetaKey = "io.modelcontextprotocol/model-immediate-response"

// WithModelImmediateResponse creates Meta with an immediate response message for the model.
// This allows the model to continue processing while the task executes asynchronously.
// The message parameter is a human-readable string that will be shown to the model.
//
// Example:
//
//	return &mcp.CreateTaskResult{
//	    Task: task,
//	    Result: mcp.Result{
//	        Meta: mcp.WithModelImmediateResponse("Processing your request. This may take a few minutes."),
//	    },
//	}
func ( string) *Meta {
	return &Meta{
		AdditionalFields: map[string]any{
			ModelImmediateResponseMetaKey: ,
		},
	}
}