tasks
Package tasks provides a client for the Memory Tasks API.
Tasks are human-review items — such as AI-generated suggestions or flagged content — that require explicit acceptance, rejection, or cancellation. They are project-scoped and tied to a review/resolution workflow.
Note: This client tracks reviewable work items, not background job execution. See monitoring for extraction job monitoring.
Import
Section titled “Import”import "github.com/emergent-company/emergent.memory/apps/server/pkg/sdk/tasks"Client
Section titled “Client”type Client struct { /* unexported */ }Obtained via sdk.Client.Tasks after calling client.SetContext(orgID, projectID).
SetContext
Section titled “SetContext”func (c *Client) SetContext(orgID, projectID string)Updates the X-Org-ID and X-Project-ID headers sent with every request. Thread-safe.
Methods
Section titled “Methods”func (c *Client) List(ctx context.Context, opts *ListOptions) (*TaskListResponse, error)Returns paginated tasks for the context project. Pass opts.ProjectID to override the header-based project.
Endpoint: GET /api/tasks
GetCounts
Section titled “GetCounts”func (c *Client) GetCounts(ctx context.Context, projectID string) (*TaskCounts, error)Returns task counts broken down by status for a specific project.
Endpoint: GET /api/tasks/counts
ListAll
Section titled “ListAll”func (c *Client) ListAll(ctx context.Context, opts *ListOptions) (*TaskListResponse, error)Returns paginated tasks across all projects accessible to the authenticated user. Useful for global dashboards.
Endpoint: GET /api/tasks/all
GetAllCounts
Section titled “GetAllCounts”func (c *Client) GetAllCounts(ctx context.Context) (*TaskCounts, error)Returns aggregated task counts across all projects for the authenticated user.
Endpoint: GET /api/tasks/all/counts
GetByID
Section titled “GetByID”func (c *Client) GetByID(ctx context.Context, taskID, projectID string) (*TaskResponse, error)Returns a specific task by ID. projectID may be provided as a query param or left empty to use the context header.
Endpoint: GET /api/tasks/{taskID}
Resolve
Section titled “Resolve”func (c *Client) Resolve(ctx context.Context, taskID, projectID string, resolveReq *ResolveTaskRequest) errorMarks a task as accepted or rejected. Resolution must be "accepted" or "rejected".
Endpoint: POST /api/tasks/{taskID}/resolve
Cancel
Section titled “Cancel”func (c *Client) Cancel(ctx context.Context, taskID, projectID string) errorCancels a pending task. Only pending tasks may be cancelled.
Endpoint: POST /api/tasks/{taskID}/cancel
type Task struct { ID string `json:"id"` ProjectID string `json:"projectId"` Title string `json:"title"` Description *string `json:"description,omitempty"` Type string `json:"type"` Status string `json:"status"` ResolvedAt *time.Time `json:"resolvedAt,omitempty"` ResolvedBy *string `json:"resolvedBy,omitempty"` ResolutionNotes *string `json:"resolutionNotes,omitempty"` SourceType *string `json:"sourceType,omitempty"` SourceID *string `json:"sourceId,omitempty"` Metadata json.RawMessage `json:"metadata,omitempty"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"`}| Field | Description |
|---|---|
Type |
Category of task (e.g., "suggestion", "review") |
Status |
"pending", "accepted", "rejected", "cancelled" |
SourceType / SourceID |
The resource that generated this task |
ResolvedBy |
User ID who resolved the task |
ResolutionNotes |
Optional notes attached at resolution |
TaskCounts
Section titled “TaskCounts”type TaskCounts struct { Pending int64 `json:"pending"` Accepted int64 `json:"accepted"` Rejected int64 `json:"rejected"` Cancelled int64 `json:"cancelled"`}TaskListResponse
Section titled “TaskListResponse”type TaskListResponse struct { Data []Task `json:"data"` Total int `json:"total"`}TaskResponse
Section titled “TaskResponse”type TaskResponse struct { Data Task `json:"data"`}ResolveTaskRequest
Section titled “ResolveTaskRequest”type ResolveTaskRequest struct { Resolution string `json:"resolution"` // "accepted" or "rejected" ResolutionNotes *string `json:"resolutionNotes,omitempty"`}ListOptions
Section titled “ListOptions”type ListOptions struct { ProjectID string // Override context project; passed as query param Status string // "pending", "accepted", "rejected", "cancelled" Type string // Filter by task type Limit int // Max results (1–100) Offset int // Pagination offset}Example
Section titled “Example”// Count pending tasks in the current projectcounts, err := client.Tasks.GetCounts(ctx, "")if err != nil { log.Fatal(err)}fmt.Printf("Pending review items: %d\n", counts.Pending)
// List and resolve each pending tasklist, err := client.Tasks.List(ctx, &tasks.ListOptions{Status: "pending"})if err != nil { log.Fatal(err)}for _, t := range list.Data { fmt.Printf("Reviewing: %s (%s)\n", t.Title, t.Type) notes := "Looks good" err := client.Tasks.Resolve(ctx, t.ID, t.ProjectID, &tasks.ResolveTaskRequest{ Resolution: "accepted", ResolutionNotes: ¬es, }) if err != nil { log.Printf("failed to resolve task %s: %v", t.ID, err) }}