@@ -88,35 +88,41 @@ const (
8888//
8989// Experimental: This type is experimental and may change in the future.
9090type Task struct {
91- ID uuid.UUID `json:"id" format:"uuid"`
92- OrganizationID uuid.UUID `json:"organization_id" format:"uuid"`
93- OwnerID uuid.UUID `json:"owner_id" format:"uuid"`
94- Name string `json:"name"`
95- TemplateID uuid.UUID `json:"template_id" format:"uuid"`
96- WorkspaceID uuid.NullUUID `json:"workspace_id" format:"uuid"`
97- InitialPrompt string `json:"initial_prompt"`
98- Status WorkspaceStatus `json:"status" enums:"pending,starting,running,stopping,stopped,failed,canceling,canceled,deleting,deleted"`
99- CurrentState * TaskStateEntry `json:"current_state"`
100- CreatedAt time.Time `json:"created_at" format:"date-time"`
101- UpdatedAt time.Time `json:"updated_at" format:"date-time"`
91+ ID uuid.UUID `json:"id" format:"uuid" table:"id" `
92+ OrganizationID uuid.UUID `json:"organization_id" format:"uuid" table:"organization id" `
93+ OwnerID uuid.UUID `json:"owner_id" format:"uuid" table:"owner id" `
94+ Name string `json:"name" table:"name,default_sort" `
95+ TemplateID uuid.UUID `json:"template_id" format:"uuid" table:"template id" `
96+ WorkspaceID uuid.NullUUID `json:"workspace_id" format:"uuid" table:"workspace id" `
97+ InitialPrompt string `json:"initial_prompt" table:"initial prompt" `
98+ Status WorkspaceStatus `json:"status" enums:"pending,starting,running,stopping,stopped,failed,canceling,canceled,deleting,deleted" table:"status" `
99+ CurrentState * TaskStateEntry `json:"current_state" table:"cs,recursive_inline" `
100+ CreatedAt time.Time `json:"created_at" format:"date-time" table:"created at" `
101+ UpdatedAt time.Time `json:"updated_at" format:"date-time" table:"updated at" `
102102}
103103
104104// TaskStateEntry represents a single entry in the task's state history.
105105//
106106// Experimental: This type is experimental and may change in the future.
107107type TaskStateEntry struct {
108- Timestamp time.Time `json:"timestamp" format:"date-time"`
109- State TaskState `json:"state" enum:"working,idle,completed,failed"`
110- Message string `json:"message"`
111- URI string `json:"uri"`
108+ Timestamp time.Time `json:"timestamp" format:"date-time" table:"-" `
109+ State TaskState `json:"state" enum:"working,idle,completed,failed" table:"state" `
110+ Message string `json:"message" table:"message" `
111+ URI string `json:"uri" table:"-" `
112112}
113113
114114// TasksFilter filters the list of tasks.
115115//
116116// Experimental: This type is experimental and may change in the future.
117117type TasksFilter struct {
118- // Owner can be a username, UUID, or "me"
118+ // Owner can be a username, UUID, or "me".
119119Owner string `json:"owner,omitempty"`
120+ // Status is a task status.
121+ Status string `json:"status,omitempty" typescript:"-"`
122+ // Offset is the number of workspaces to skip before returning results.
123+ Offset int `json:"offset,omitempty" typescript:"-"`
124+ // Limit is a limit on the number of workspaces returned.
125+ Limit int `json:"limit,omitempty" typescript:"-"`
120126}
121127
122128// Tasks lists all tasks belonging to the user or specified owner.
@@ -126,12 +132,16 @@ func (c *ExperimentalClient) Tasks(ctx context.Context, filter *TasksFilter) ([]
126132if filter == nil {
127133filter = & TasksFilter {}
128134}
129- user := filter .Owner
130- if user == "" {
131- user = "me"
135+
136+ var wsFilter WorkspaceFilter
137+ wsFilter .Owner = filter .Owner
138+ wsFilter .Status = filter .Status
139+ page := Pagination {
140+ Offset :filter .Offset ,
141+ Limit :filter .Limit ,
132142}
133143
134- res ,err := c .Request (ctx ,http .MethodGet ,fmt . Sprintf ( "/api/experimental/tasks/%s " ,user ),nil )
144+ res ,err := c .Request (ctx ,http .MethodGet ,"/api/experimental/tasks" ,nil , wsFilter . asRequestOption ( ),page . asRequestOption () )
135145if err != nil {
136146return nil ,err
137147}