createTask method

Task createTask({
  1. String? statusMessage,
  2. int? ttlMs,
  3. int? pollIntervalMs,
})

Create a working task and store it. Returns the Task handle whose Task.toCreateTaskResult a tools/call (or other) handler can return so the client tracks it via tasks/get. Server-directed per the spec.

Implementation

Task createTask({String? statusMessage, int? ttlMs, int? pollIntervalMs}) {
  final now = _nowIso();
  final task = Task(
    taskId: Uuid().v4(),
    status: TaskStatus.working,
    createdAt: now,
    lastUpdatedAt: now,
    statusMessage: statusMessage,
    ttlMs: ttlMs,
    pollIntervalMs: pollIntervalMs,
  );
  _tasks[task.taskId] = task;
  return task;
}