@@ -88,35 +88,41 @@ const (
88
88
//
89
89
// Experimental: This type is experimental and may change in the future.
90
90
type 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" `
102
102
}
103
103
104
104
// TaskStateEntry represents a single entry in the task's state history.
105
105
//
106
106
// Experimental: This type is experimental and may change in the future.
107
107
type 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:"-" `
112
112
}
113
113
114
114
// TasksFilter filters the list of tasks.
115
115
//
116
116
// Experimental: This type is experimental and may change in the future.
117
117
type TasksFilter struct {
118
- // Owner can be a username, UUID, or "me"
118
+ // Owner can be a username, UUID, or "me".
119
119
Owner string `json:"owner,omitempty"`
120
+ // Status is a task status.
121
+ Status string `json:"status,omitempty" typescript:"-"`
122
+ // Offset is the number of tasks to skip before returning results.
123
+ Offset int `json:"offset,omitempty" typescript:"-"`
124
+ // Limit is a limit on the number of tasks returned.
125
+ Limit int `json:"limit,omitempty" typescript:"-"`
120
126
}
121
127
122
128
// Tasks lists all tasks belonging to the user or specified owner.
@@ -126,12 +132,16 @@ func (c *ExperimentalClient) Tasks(ctx context.Context, filter *TasksFilter) ([]
126
132
if filter == nil {
127
133
filter = & TasksFilter {}
128
134
}
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 ,
132
142
}
133
143
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 () )
135
145
if err != nil {
136
146
return nil , err
137
147
}
0 commit comments