java.lang.Object
dev.tachyonmcp.core.server.features.tasks.TaskEntry
All Implemented Interfaces:
HasMeta, Task, ServerFeature<TaskDescriptor>

@InternalApi public class TaskEntry extends Object implements ServerFeature<TaskDescriptor>, Task
  • Constructor Details

  • Method Details

    • sessionId

      public @Nullable String sessionId()
      The session that created this task, or null for programmatic/server-global tasks.
    • progressToken

      public @Nullable ProgressToken progressToken()
    • meta

      public @Nullable Map<String,Object> meta()
      Description copied from interface: HasMeta
      Returns the optional metadata map for protocol extensions.
      Specified by:
      meta in interface HasMeta
      Returns:
      the metadata map, or null if none
    • descriptor

      public TaskDescriptor descriptor()
      Description copied from interface: ServerFeature
      Returns the metadata descriptor for this feature.
      Specified by:
      descriptor in interface ServerFeature<TaskDescriptor>
      Returns:
      the descriptor
    • id

      public String id()
      Description copied from interface: Task
      Returns the unique task identifier.
      Specified by:
      id in interface Task
    • status

      public TaskState status()
      Description copied from interface: Task
      Returns the current task status.
      Specified by:
      status in interface Task
    • statusMessage

      public @Nullable String statusMessage()
      Description copied from interface: Task
      Optional human-readable status message for this task.
      Specified by:
      statusMessage in interface Task
    • createdAt

      public Instant createdAt()
      Description copied from interface: Task
      Timestamp when this task was created.
      Specified by:
      createdAt in interface Task
    • ttl

      public @Nullable Long ttl()
      Description copied from interface: Task
      Time-to-live duration after which the task is eligible for eviction, or null.
      Specified by:
      ttl in interface Task
    • keepAlive

      public Duration keepAlive()
      How long after this task reaches a terminal state its result stays retrievable.
    • pollInterval

      public @Nullable Duration pollInterval()
      Description copied from interface: Task
      Suggested polling interval for tasks/get, or null to not suggest one.
      Specified by:
      pollInterval in interface Task
    • result

      public @Nullable TaskResult result()
      Description copied from interface: Task
      The task result if the task has reached a terminal state, or null.
      Specified by:
      result in interface Task
    • completion

      public CompletionStage<TaskResult> completion()
      Description copied from interface: Task
      A future that completes when the task reaches a terminal state.
      Specified by:
      completion in interface Task
    • complete

      public boolean complete(TaskResult.Completed result)
      Description copied from interface: Task
      Transitions the task to the completed state.
      Specified by:
      complete in interface Task
      Parameters:
      result - the completion result
      Returns:
      true if the state transition was applied
    • fail

      public boolean fail(TaskResult.Failed result)
      Description copied from interface: Task
      Transitions the task to the failed state.
      Specified by:
      fail in interface Task
      Parameters:
      result - the failure result
      Returns:
      true if the state transition was applied
    • cancel

      public boolean cancel(@Nullable String statusMessage)
      Description copied from interface: Task
      Requests cancellation of this task.
      Specified by:
      cancel in interface Task
      Parameters:
      statusMessage - optional cancellation reason
      Returns:
      true if the state transition was applied
    • requireInput

      public boolean requireInput(InputRequest request, @Nullable String statusMessage)
      Description copied from interface: Task
      Signals that this task requires additional input from the client.
      Specified by:
      requireInput in interface Task
      Parameters:
      request - the input request
      statusMessage - optional status message
      Returns:
      true if the state transition was applied
    • resume

      public boolean resume(@Nullable String statusMessage)
      Description copied from interface: Task
      Resumes a task that was waiting for input.
      Specified by:
      resume in interface Task
      Parameters:
      statusMessage - optional status message
      Returns:
      true if the state transition was applied
    • updateMessage

      public boolean updateMessage(String statusMessage)
      Description copied from interface: Task
      Updates the status message of this task.
      Specified by:
      updateMessage in interface Task
      Parameters:
      statusMessage - the new status message
      Returns:
      true if the message was updated
    • reportProgress

      public void reportProgress(double progress, @Nullable Double total, @Nullable String message)
      Description copied from interface: Task
      Reports progress for this task.
      Specified by:
      reportProgress in interface Task
      Parameters:
      progress - the current progress value
      total - the total expected value, or null if unknown
      message - optional progress message
    • createdAtMillis

      public long createdAtMillis()
    • lastUpdatedAt

      public long lastUpdatedAt()
    • resultJson

      public @Nullable String resultJson()
    • transitionTo

      public boolean transitionTo(TaskState newStatus)
      Transitions to newStatus without a result value.
    • transitionTo

      public boolean transitionTo(TaskState newStatus, @Nullable TaskResult result)
      Transitions to newStatus, publishing result (when non-null).
    • isExpired

      public boolean isExpired()
    • isResultExpired

      public boolean isResultExpired()
      Whether this task's result has outlived its keepAlive retention window.
    • createdAtIso

      public String createdAtIso()
    • lastUpdatedAtIso

      public String lastUpdatedAtIso()