PKU harness
SDK reference

todo

The Todo and TodoInput types for to-do items, used by services.todos.

This module defines the data types for to-do items. A plugin uses them when it reads, adds or changes the user's to-dos through services.todos. Each to-do can carry a reminder, which a job in the scheduler sends.

Source: packages/sdk/src/todo.ts.

type Todo = {
  id: string;
  title: string;
  notes: string | null;
  dueAt: number | null;
  doneAt: number | null;
  /** Reminder job in the scheduler, if any. */
  jobId: string | null;
  createdAt: number;
};

type TodoInput = {
  title: string;
  notes?: string | null;
  dueAt?: number | null;
  /** When to remind; null = no reminder. A trigger allows repeating reminders. */
  remind?: Trigger | null;
};

The example below adds a to-do due Friday at 23:59, with a reminder at 8 pm the evening before:

// a to-do due Friday 23:59 with a reminder the evening before
const due = new Date(2026, 9, 30, 23, 59).getTime();
await ctx.services.todos.add(
  { title: '交高数作业', dueAt: due, remind: { type: 'at', at: new Date(2026, 9, 29, 20, 0).getTime() } },
  'plugin',
);

Completing and removing to-dos

When you mark a to-do as done with setDone(id, true), its reminder job is paused. Calling setDone(id, false) marks it as not done and turns the reminder job back on. Removing the to-do deletes its reminder job as well.

On this page