diff --git a/coderd/aitasks.go b/coderd/aitasks.go index 275cfe8556..6bb706d1a5 100644 --- a/coderd/aitasks.go +++ b/coderd/aitasks.go @@ -82,8 +82,18 @@ func (api *API) aiTasksPrompts(rw http.ResponseWriter, r *http.Request) { }) } -// This endpoint is experimental and not guaranteed to be stable, so we're not -// generating public-facing documentation for it. +// @Summary Create a new AI task +// @Description: EXPERIMENTAL: this endpoint is experimental and not guaranteed to be stable. +// @ID create-task +// @Security CoderSessionToken +// @Tags Experimental +// @Param user path string true "Username, user ID, or 'me' for the authenticated user" +// @Param request body codersdk.CreateTaskRequest true "Create task request" +// @Success 201 {object} codersdk.Task +// @Router /api/experimental/tasks/{user} [post] +// +// EXPERIMENTAL: This endpoint is experimental and not guaranteed to be stable. +// This endpoint creates a new task for the given user. func (api *API) tasksCreate(rw http.ResponseWriter, r *http.Request) { var ( ctx = r.Context() @@ -316,6 +326,19 @@ type tasksListResponse struct { Count int `json:"count"` } +// @Summary List AI tasks +// @Description: EXPERIMENTAL: this endpoint is experimental and not guaranteed to be stable. +// @ID list-tasks +// @Security CoderSessionToken +// @Tags Experimental +// @Param q query string false "Search query for filtering tasks" +// @Param after_id query string false "Return tasks after this ID for pagination" +// @Param limit query int false "Maximum number of tasks to return" minimum(1) maximum(100) default(25) +// @Param offset query int false "Offset for pagination" minimum(0) default(0) +// @Success 200 {object} coderd.tasksListResponse +// @Router /api/experimental/tasks [get] +// +// EXPERIMENTAL: This endpoint is experimental and not guaranteed to be stable. // tasksList is an experimental endpoint to list AI tasks by mapping // workspaces to a task-shaped response. func (api *API) tasksList(rw http.ResponseWriter, r *http.Request) { @@ -419,6 +442,17 @@ func (api *API) tasksList(rw http.ResponseWriter, r *http.Request) { }) } +// @Summary Get AI task by ID +// @Description: EXPERIMENTAL: this endpoint is experimental and not guaranteed to be stable. +// @ID get-task +// @Security CoderSessionToken +// @Tags Experimental +// @Param user path string true "Username, user ID, or 'me' for the authenticated user" +// @Param id path string true "Task ID" format(uuid) +// @Success 200 {object} codersdk.Task +// @Router /api/experimental/tasks/{user}/{id} [get] +// +// EXPERIMENTAL: This endpoint is experimental and not guaranteed to be stable. // taskGet is an experimental endpoint to fetch a single AI task by ID // (workspace ID). It returns a synthesized task response including // prompt and status. @@ -525,6 +559,17 @@ func (api *API) taskGet(rw http.ResponseWriter, r *http.Request) { httpapi.Write(ctx, rw, http.StatusOK, tasks[0]) } +// @Summary Delete AI task by ID +// @Description: EXPERIMENTAL: this endpoint is experimental and not guaranteed to be stable. +// @ID delete-task +// @Security CoderSessionToken +// @Tags Experimental +// @Param user path string true "Username, user ID, or 'me' for the authenticated user" +// @Param id path string true "Task ID" format(uuid) +// @Success 202 "Task deletion initiated" +// @Router /api/experimental/tasks/{user}/{id} [delete] +// +// EXPERIMENTAL: This endpoint is experimental and not guaranteed to be stable. // taskDelete is an experimental endpoint to delete a task by ID (workspace ID). // It creates a delete workspace build and returns 202 Accepted if the build was // created. @@ -600,6 +645,18 @@ func (api *API) taskDelete(rw http.ResponseWriter, r *http.Request) { rw.WriteHeader(http.StatusAccepted) } +// @Summary Send input to AI task +// @Description: EXPERIMENTAL: this endpoint is experimental and not guaranteed to be stable. +// @ID send-task-input +// @Security CoderSessionToken +// @Tags Experimental +// @Param user path string true "Username, user ID, or 'me' for the authenticated user" +// @Param id path string true "Task ID" format(uuid) +// @Param request body codersdk.TaskSendRequest true "Task input request" +// @Success 204 "Input sent successfully" +// @Router /api/experimental/tasks/{user}/{id}/send [post] +// +// EXPERIMENTAL: This endpoint is experimental and not guaranteed to be stable. // taskSend submits task input to the tasks sidebar app by dialing the agent // directly over the tailnet. We enforce ApplicationConnect RBAC on the // workspace and validate the sidebar app health. @@ -670,6 +727,19 @@ func (api *API) taskSend(rw http.ResponseWriter, r *http.Request) { rw.WriteHeader(http.StatusNoContent) } +// @Summary Get AI task logs +// @Description: EXPERIMENTAL: this endpoint is experimental and not guaranteed to be stable. +// @ID get-task-logs +// @Security CoderSessionToken +// @Tags Experimental +// @Param user path string true "Username, user ID, or 'me' for the authenticated user" +// @Param id path string true "Task ID" format(uuid) +// @Success 200 {object} codersdk.TaskLogsResponse +// @Router /api/experimental/tasks/{user}/{id}/logs [get] +// +// EXPERIMENTAL: This endpoint is experimental and not guaranteed to be stable. +// taskLogs reads task output by dialing the agent directly over the tailnet. +// We enforce ApplicationConnect RBAC on the workspace and validate the sidebar app health. func (api *API) taskLogs(rw http.ResponseWriter, r *http.Request) { ctx := r.Context() diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index b444d50a8c..d10e39fa06 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -130,6 +130,256 @@ const docTemplate = `{ } } }, + "/api/experimental/tasks": { + "get": { + "security": [ + { + "CoderSessionToken": [] + } + ], + "tags": [ + "Experimental" + ], + "summary": "List AI tasks", + "operationId": "list-tasks", + "parameters": [ + { + "type": "string", + "description": "Search query for filtering tasks", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Return tasks after this ID for pagination", + "name": "after_id", + "in": "query" + }, + { + "maximum": 100, + "minimum": 1, + "type": "integer", + "default": 25, + "description": "Maximum number of tasks to return", + "name": "limit", + "in": "query" + }, + { + "minimum": 0, + "type": "integer", + "default": 0, + "description": "Offset for pagination", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/coderd.tasksListResponse" + } + } + } + } + }, + "/api/experimental/tasks/{user}": { + "post": { + "security": [ + { + "CoderSessionToken": [] + } + ], + "tags": [ + "Experimental" + ], + "summary": "Create a new AI task", + "operationId": "create-task", + "parameters": [ + { + "type": "string", + "description": "Username, user ID, or 'me' for the authenticated user", + "name": "user", + "in": "path", + "required": true + }, + { + "description": "Create task request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/codersdk.CreateTaskRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/codersdk.Task" + } + } + } + } + }, + "/api/experimental/tasks/{user}/{id}": { + "get": { + "security": [ + { + "CoderSessionToken": [] + } + ], + "tags": [ + "Experimental" + ], + "summary": "Get AI task by ID", + "operationId": "get-task", + "parameters": [ + { + "type": "string", + "description": "Username, user ID, or 'me' for the authenticated user", + "name": "user", + "in": "path", + "required": true + }, + { + "type": "string", + "format": "uuid", + "description": "Task ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/codersdk.Task" + } + } + } + }, + "delete": { + "security": [ + { + "CoderSessionToken": [] + } + ], + "tags": [ + "Experimental" + ], + "summary": "Delete AI task by ID", + "operationId": "delete-task", + "parameters": [ + { + "type": "string", + "description": "Username, user ID, or 'me' for the authenticated user", + "name": "user", + "in": "path", + "required": true + }, + { + "type": "string", + "format": "uuid", + "description": "Task ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "Task deletion initiated" + } + } + } + }, + "/api/experimental/tasks/{user}/{id}/logs": { + "get": { + "security": [ + { + "CoderSessionToken": [] + } + ], + "tags": [ + "Experimental" + ], + "summary": "Get AI task logs", + "operationId": "get-task-logs", + "parameters": [ + { + "type": "string", + "description": "Username, user ID, or 'me' for the authenticated user", + "name": "user", + "in": "path", + "required": true + }, + { + "type": "string", + "format": "uuid", + "description": "Task ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/codersdk.TaskLogsResponse" + } + } + } + } + }, + "/api/experimental/tasks/{user}/{id}/send": { + "post": { + "security": [ + { + "CoderSessionToken": [] + } + ], + "tags": [ + "Experimental" + ], + "summary": "Send input to AI task", + "operationId": "send-task-input", + "parameters": [ + { + "type": "string", + "description": "Username, user ID, or 'me' for the authenticated user", + "name": "user", + "in": "path", + "required": true + }, + { + "type": "string", + "format": "uuid", + "description": "Task ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Task input request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/codersdk.TaskSendRequest" + } + } + ], + "responses": { + "204": { + "description": "Input sent successfully" + } + } + } + }, "/appearance": { "get": { "security": [ @@ -11236,6 +11486,20 @@ const docTemplate = `{ } } }, + "coderd.tasksListResponse": { + "type": "object", + "properties": { + "count": { + "type": "integer" + }, + "tasks": { + "type": "array", + "items": { + "$ref": "#/definitions/codersdk.Task" + } + } + } + }, "codersdk.ACLAvailable": { "type": "object", "properties": { @@ -12719,6 +12983,25 @@ const docTemplate = `{ } } }, + "codersdk.CreateTaskRequest": { + "type": "object", + "properties": { + "input": { + "type": "string" + }, + "name": { + "type": "string" + }, + "template_version_id": { + "type": "string", + "format": "uuid" + }, + "template_version_preset_id": { + "type": "string", + "format": "uuid" + } + } + }, "codersdk.CreateTemplateRequest": { "type": "object", "required": [ @@ -17218,6 +17501,178 @@ const docTemplate = `{ } } }, + "codersdk.Task": { + "type": "object", + "properties": { + "created_at": { + "type": "string", + "format": "date-time" + }, + "current_state": { + "$ref": "#/definitions/codersdk.TaskStateEntry" + }, + "id": { + "type": "string", + "format": "uuid" + }, + "initial_prompt": { + "type": "string" + }, + "name": { + "type": "string" + }, + "organization_id": { + "type": "string", + "format": "uuid" + }, + "owner_id": { + "type": "string", + "format": "uuid" + }, + "owner_name": { + "type": "string" + }, + "status": { + "enum": [ + "pending", + "starting", + "running", + "stopping", + "stopped", + "failed", + "canceling", + "canceled", + "deleting", + "deleted" + ], + "allOf": [ + { + "$ref": "#/definitions/codersdk.WorkspaceStatus" + } + ] + }, + "template_display_name": { + "type": "string" + }, + "template_icon": { + "type": "string" + }, + "template_id": { + "type": "string", + "format": "uuid" + }, + "template_name": { + "type": "string" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "workspace_agent_health": { + "$ref": "#/definitions/codersdk.WorkspaceAgentHealth" + }, + "workspace_agent_id": { + "format": "uuid", + "allOf": [ + { + "$ref": "#/definitions/uuid.NullUUID" + } + ] + }, + "workspace_agent_lifecycle": { + "$ref": "#/definitions/codersdk.WorkspaceAgentLifecycle" + }, + "workspace_id": { + "format": "uuid", + "allOf": [ + { + "$ref": "#/definitions/uuid.NullUUID" + } + ] + } + } + }, + "codersdk.TaskLogEntry": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "time": { + "type": "string", + "format": "date-time" + }, + "type": { + "$ref": "#/definitions/codersdk.TaskLogType" + } + } + }, + "codersdk.TaskLogType": { + "type": "string", + "enum": [ + "input", + "output" + ], + "x-enum-varnames": [ + "TaskLogTypeInput", + "TaskLogTypeOutput" + ] + }, + "codersdk.TaskLogsResponse": { + "type": "object", + "properties": { + "logs": { + "type": "array", + "items": { + "$ref": "#/definitions/codersdk.TaskLogEntry" + } + } + } + }, + "codersdk.TaskSendRequest": { + "type": "object", + "properties": { + "input": { + "type": "string" + } + } + }, + "codersdk.TaskState": { + "type": "string", + "enum": [ + "working", + "idle", + "complete", + "failed" + ], + "x-enum-varnames": [ + "TaskStateWorking", + "TaskStateIdle", + "TaskStateComplete", + "TaskStateFailed" + ] + }, + "codersdk.TaskStateEntry": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "state": { + "$ref": "#/definitions/codersdk.TaskState" + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "uri": { + "type": "string" + } + } + }, "codersdk.TelemetryConfig": { "type": "object", "properties": { diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 1a222932de..df4aae91d3 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -106,6 +106,244 @@ } } }, + "/api/experimental/tasks": { + "get": { + "security": [ + { + "CoderSessionToken": [] + } + ], + "tags": ["Experimental"], + "summary": "List AI tasks", + "operationId": "list-tasks", + "parameters": [ + { + "type": "string", + "description": "Search query for filtering tasks", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "Return tasks after this ID for pagination", + "name": "after_id", + "in": "query" + }, + { + "maximum": 100, + "minimum": 1, + "type": "integer", + "default": 25, + "description": "Maximum number of tasks to return", + "name": "limit", + "in": "query" + }, + { + "minimum": 0, + "type": "integer", + "default": 0, + "description": "Offset for pagination", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/coderd.tasksListResponse" + } + } + } + } + }, + "/api/experimental/tasks/{user}": { + "post": { + "security": [ + { + "CoderSessionToken": [] + } + ], + "tags": ["Experimental"], + "summary": "Create a new AI task", + "operationId": "create-task", + "parameters": [ + { + "type": "string", + "description": "Username, user ID, or 'me' for the authenticated user", + "name": "user", + "in": "path", + "required": true + }, + { + "description": "Create task request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/codersdk.CreateTaskRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/codersdk.Task" + } + } + } + } + }, + "/api/experimental/tasks/{user}/{id}": { + "get": { + "security": [ + { + "CoderSessionToken": [] + } + ], + "tags": ["Experimental"], + "summary": "Get AI task by ID", + "operationId": "get-task", + "parameters": [ + { + "type": "string", + "description": "Username, user ID, or 'me' for the authenticated user", + "name": "user", + "in": "path", + "required": true + }, + { + "type": "string", + "format": "uuid", + "description": "Task ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/codersdk.Task" + } + } + } + }, + "delete": { + "security": [ + { + "CoderSessionToken": [] + } + ], + "tags": ["Experimental"], + "summary": "Delete AI task by ID", + "operationId": "delete-task", + "parameters": [ + { + "type": "string", + "description": "Username, user ID, or 'me' for the authenticated user", + "name": "user", + "in": "path", + "required": true + }, + { + "type": "string", + "format": "uuid", + "description": "Task ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "Task deletion initiated" + } + } + } + }, + "/api/experimental/tasks/{user}/{id}/logs": { + "get": { + "security": [ + { + "CoderSessionToken": [] + } + ], + "tags": ["Experimental"], + "summary": "Get AI task logs", + "operationId": "get-task-logs", + "parameters": [ + { + "type": "string", + "description": "Username, user ID, or 'me' for the authenticated user", + "name": "user", + "in": "path", + "required": true + }, + { + "type": "string", + "format": "uuid", + "description": "Task ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/codersdk.TaskLogsResponse" + } + } + } + } + }, + "/api/experimental/tasks/{user}/{id}/send": { + "post": { + "security": [ + { + "CoderSessionToken": [] + } + ], + "tags": ["Experimental"], + "summary": "Send input to AI task", + "operationId": "send-task-input", + "parameters": [ + { + "type": "string", + "description": "Username, user ID, or 'me' for the authenticated user", + "name": "user", + "in": "path", + "required": true + }, + { + "type": "string", + "format": "uuid", + "description": "Task ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Task input request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/codersdk.TaskSendRequest" + } + } + ], + "responses": { + "204": { + "description": "Input sent successfully" + } + } + } + }, "/appearance": { "get": { "security": [ @@ -9960,6 +10198,20 @@ } } }, + "coderd.tasksListResponse": { + "type": "object", + "properties": { + "count": { + "type": "integer" + }, + "tasks": { + "type": "array", + "items": { + "$ref": "#/definitions/codersdk.Task" + } + } + } + }, "codersdk.ACLAvailable": { "type": "object", "properties": { @@ -11397,6 +11649,25 @@ } } }, + "codersdk.CreateTaskRequest": { + "type": "object", + "properties": { + "input": { + "type": "string" + }, + "name": { + "type": "string" + }, + "template_version_id": { + "type": "string", + "format": "uuid" + }, + "template_version_preset_id": { + "type": "string", + "format": "uuid" + } + } + }, "codersdk.CreateTemplateRequest": { "type": "object", "required": ["name", "template_version_id"], @@ -15738,6 +16009,167 @@ } } }, + "codersdk.Task": { + "type": "object", + "properties": { + "created_at": { + "type": "string", + "format": "date-time" + }, + "current_state": { + "$ref": "#/definitions/codersdk.TaskStateEntry" + }, + "id": { + "type": "string", + "format": "uuid" + }, + "initial_prompt": { + "type": "string" + }, + "name": { + "type": "string" + }, + "organization_id": { + "type": "string", + "format": "uuid" + }, + "owner_id": { + "type": "string", + "format": "uuid" + }, + "owner_name": { + "type": "string" + }, + "status": { + "enum": [ + "pending", + "starting", + "running", + "stopping", + "stopped", + "failed", + "canceling", + "canceled", + "deleting", + "deleted" + ], + "allOf": [ + { + "$ref": "#/definitions/codersdk.WorkspaceStatus" + } + ] + }, + "template_display_name": { + "type": "string" + }, + "template_icon": { + "type": "string" + }, + "template_id": { + "type": "string", + "format": "uuid" + }, + "template_name": { + "type": "string" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "workspace_agent_health": { + "$ref": "#/definitions/codersdk.WorkspaceAgentHealth" + }, + "workspace_agent_id": { + "format": "uuid", + "allOf": [ + { + "$ref": "#/definitions/uuid.NullUUID" + } + ] + }, + "workspace_agent_lifecycle": { + "$ref": "#/definitions/codersdk.WorkspaceAgentLifecycle" + }, + "workspace_id": { + "format": "uuid", + "allOf": [ + { + "$ref": "#/definitions/uuid.NullUUID" + } + ] + } + } + }, + "codersdk.TaskLogEntry": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "time": { + "type": "string", + "format": "date-time" + }, + "type": { + "$ref": "#/definitions/codersdk.TaskLogType" + } + } + }, + "codersdk.TaskLogType": { + "type": "string", + "enum": ["input", "output"], + "x-enum-varnames": ["TaskLogTypeInput", "TaskLogTypeOutput"] + }, + "codersdk.TaskLogsResponse": { + "type": "object", + "properties": { + "logs": { + "type": "array", + "items": { + "$ref": "#/definitions/codersdk.TaskLogEntry" + } + } + } + }, + "codersdk.TaskSendRequest": { + "type": "object", + "properties": { + "input": { + "type": "string" + } + } + }, + "codersdk.TaskState": { + "type": "string", + "enum": ["working", "idle", "complete", "failed"], + "x-enum-varnames": [ + "TaskStateWorking", + "TaskStateIdle", + "TaskStateComplete", + "TaskStateFailed" + ] + }, + "codersdk.TaskStateEntry": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "state": { + "$ref": "#/definitions/codersdk.TaskState" + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "uri": { + "type": "string" + } + } + }, "codersdk.TelemetryConfig": { "type": "object", "properties": { diff --git a/docs/reference/api/experimental.md b/docs/reference/api/experimental.md new file mode 100644 index 0000000000..edf6b729d8 --- /dev/null +++ b/docs/reference/api/experimental.md @@ -0,0 +1,207 @@ +# Experimental + +## List AI tasks + +### Code samples + +```shell +# Example request using curl +curl -X GET http://coder-server:8080/api/v2/api/experimental/tasks \ + -H 'Accept: */*' \ + -H 'Coder-Session-Token: API_KEY' +``` + +`GET /api/experimental/tasks` + +### Parameters + +| Name | In | Type | Required | Description | +|------------|-------|---------|----------|-------------------------------------------| +| `q` | query | string | false | Search query for filtering tasks | +| `after_id` | query | string | false | Return tasks after this ID for pagination | +| `limit` | query | integer | false | Maximum number of tasks to return | +| `offset` | query | integer | false | Offset for pagination | + +### Example responses + +> 200 Response + +### Responses + +| Status | Meaning | Description | Schema | +|--------|---------------------------------------------------------|-------------|----------------------------------------------------------------| +| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [coderd.tasksListResponse](schemas.md#coderdtaskslistresponse) | + +To perform this operation, you must be authenticated. [Learn more](authentication.md). + +## Create a new AI task + +### Code samples + +```shell +# Example request using curl +curl -X POST http://coder-server:8080/api/v2/api/experimental/tasks/{user} \ + -H 'Content-Type: application/json' \ + -H 'Accept: */*' \ + -H 'Coder-Session-Token: API_KEY' +``` + +`POST /api/experimental/tasks/{user}` + +> Body parameter + +```json +{ + "input": "string", + "name": "string", + "template_version_id": "0ba39c92-1f1b-4c32-aa3e-9925d7713eb1", + "template_version_preset_id": "512a53a7-30da-446e-a1fc-713c630baff1" +} +``` + +### Parameters + +| Name | In | Type | Required | Description | +|--------|------|--------------------------------------------------------------------|----------|-------------------------------------------------------| +| `user` | path | string | true | Username, user ID, or 'me' for the authenticated user | +| `body` | body | [codersdk.CreateTaskRequest](schemas.md#codersdkcreatetaskrequest) | true | Create task request | + +### Example responses + +> 201 Response + +### Responses + +| Status | Meaning | Description | Schema | +|--------|--------------------------------------------------------------|-------------|------------------------------------------| +| 201 | [Created](https://tools.ietf.org/html/rfc7231#section-6.3.2) | Created | [codersdk.Task](schemas.md#codersdktask) | + +To perform this operation, you must be authenticated. [Learn more](authentication.md). + +## Get AI task by ID + +### Code samples + +```shell +# Example request using curl +curl -X GET http://coder-server:8080/api/v2/api/experimental/tasks/{user}/{id} \ + -H 'Accept: */*' \ + -H 'Coder-Session-Token: API_KEY' +``` + +`GET /api/experimental/tasks/{user}/{id}` + +### Parameters + +| Name | In | Type | Required | Description | +|--------|------|--------------|----------|-------------------------------------------------------| +| `user` | path | string | true | Username, user ID, or 'me' for the authenticated user | +| `id` | path | string(uuid) | true | Task ID | + +### Example responses + +> 200 Response + +### Responses + +| Status | Meaning | Description | Schema | +|--------|---------------------------------------------------------|-------------|------------------------------------------| +| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.Task](schemas.md#codersdktask) | + +To perform this operation, you must be authenticated. [Learn more](authentication.md). + +## Delete AI task by ID + +### Code samples + +```shell +# Example request using curl +curl -X DELETE http://coder-server:8080/api/v2/api/experimental/tasks/{user}/{id} \ + -H 'Coder-Session-Token: API_KEY' +``` + +`DELETE /api/experimental/tasks/{user}/{id}` + +### Parameters + +| Name | In | Type | Required | Description | +|--------|------|--------------|----------|-------------------------------------------------------| +| `user` | path | string | true | Username, user ID, or 'me' for the authenticated user | +| `id` | path | string(uuid) | true | Task ID | + +### Responses + +| Status | Meaning | Description | Schema | +|--------|---------------------------------------------------------------|-------------------------|--------| +| 202 | [Accepted](https://tools.ietf.org/html/rfc7231#section-6.3.3) | Task deletion initiated | | + +To perform this operation, you must be authenticated. [Learn more](authentication.md). + +## Get AI task logs + +### Code samples + +```shell +# Example request using curl +curl -X GET http://coder-server:8080/api/v2/api/experimental/tasks/{user}/{id}/logs \ + -H 'Accept: */*' \ + -H 'Coder-Session-Token: API_KEY' +``` + +`GET /api/experimental/tasks/{user}/{id}/logs` + +### Parameters + +| Name | In | Type | Required | Description | +|--------|------|--------------|----------|-------------------------------------------------------| +| `user` | path | string | true | Username, user ID, or 'me' for the authenticated user | +| `id` | path | string(uuid) | true | Task ID | + +### Example responses + +> 200 Response + +### Responses + +| Status | Meaning | Description | Schema | +|--------|---------------------------------------------------------|-------------|------------------------------------------------------------------| +| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.TaskLogsResponse](schemas.md#codersdktasklogsresponse) | + +To perform this operation, you must be authenticated. [Learn more](authentication.md). + +## Send input to AI task + +### Code samples + +```shell +# Example request using curl +curl -X POST http://coder-server:8080/api/v2/api/experimental/tasks/{user}/{id}/send \ + -H 'Content-Type: application/json' \ + -H 'Coder-Session-Token: API_KEY' +``` + +`POST /api/experimental/tasks/{user}/{id}/send` + +> Body parameter + +```json +{ + "input": "string" +} +``` + +### Parameters + +| Name | In | Type | Required | Description | +|--------|------|----------------------------------------------------------------|----------|-------------------------------------------------------| +| `user` | path | string | true | Username, user ID, or 'me' for the authenticated user | +| `id` | path | string(uuid) | true | Task ID | +| `body` | body | [codersdk.TaskSendRequest](schemas.md#codersdktasksendrequest) | true | Task input request | + +### Responses + +| Status | Meaning | Description | Schema | +|--------|-----------------------------------------------------------------|-------------------------|--------| +| 204 | [No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5) | Input sent successfully | | + +To perform this operation, you must be authenticated. [Learn more](authentication.md). diff --git a/docs/reference/api/schemas.md b/docs/reference/api/schemas.md index c121096b09..7b09607802 100644 --- a/docs/reference/api/schemas.md +++ b/docs/reference/api/schemas.md @@ -277,6 +277,57 @@ |--------------|--------|----------|--------------|-------------| | `csp-report` | object | false | | | +## coderd.tasksListResponse + +```json +{ + "count": 0, + "tasks": [ + { + "created_at": "2019-08-24T14:15:22Z", + "current_state": { + "message": "string", + "state": "working", + "timestamp": "2019-08-24T14:15:22Z", + "uri": "string" + }, + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "initial_prompt": "string", + "name": "string", + "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05", + "owner_name": "string", + "status": "pending", + "template_display_name": "string", + "template_icon": "string", + "template_id": "c6d67e98-83ea-49f0-8812-e4abae2b68bc", + "template_name": "string", + "updated_at": "2019-08-24T14:15:22Z", + "workspace_agent_health": { + "healthy": false, + "reason": "agent has lost connection" + }, + "workspace_agent_id": { + "uuid": "string", + "valid": true + }, + "workspace_agent_lifecycle": "created", + "workspace_id": { + "uuid": "string", + "valid": true + } + } + ] +} +``` + +### Properties + +| Name | Type | Required | Restrictions | Description | +|---------|-----------------------------------------|----------|--------------|-------------| +| `count` | integer | false | | | +| `tasks` | array of [codersdk.Task](#codersdktask) | false | | | + ## codersdk.ACLAvailable ```json @@ -1981,6 +2032,26 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in |-------|--------|----------|--------------|-------------| | `key` | string | false | | | +## codersdk.CreateTaskRequest + +```json +{ + "input": "string", + "name": "string", + "template_version_id": "0ba39c92-1f1b-4c32-aa3e-9925d7713eb1", + "template_version_preset_id": "512a53a7-30da-446e-a1fc-713c630baff1" +} +``` + +### Properties + +| Name | Type | Required | Restrictions | Description | +|------------------------------|--------|----------|--------------|-------------| +| `input` | string | false | | | +| `name` | string | false | | | +| `template_version_id` | string | false | | | +| `template_version_preset_id` | string | false | | | + ## codersdk.CreateTemplateRequest ```json @@ -7572,6 +7643,190 @@ Only certain features set these fields: - FeatureManagedAgentLimit| | `redirect_http` | boolean | false | | | | `supported_ciphers` | array of string | false | | | +## codersdk.Task + +```json +{ + "created_at": "2019-08-24T14:15:22Z", + "current_state": { + "message": "string", + "state": "working", + "timestamp": "2019-08-24T14:15:22Z", + "uri": "string" + }, + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "initial_prompt": "string", + "name": "string", + "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05", + "owner_name": "string", + "status": "pending", + "template_display_name": "string", + "template_icon": "string", + "template_id": "c6d67e98-83ea-49f0-8812-e4abae2b68bc", + "template_name": "string", + "updated_at": "2019-08-24T14:15:22Z", + "workspace_agent_health": { + "healthy": false, + "reason": "agent has lost connection" + }, + "workspace_agent_id": { + "uuid": "string", + "valid": true + }, + "workspace_agent_lifecycle": "created", + "workspace_id": { + "uuid": "string", + "valid": true + } +} +``` + +### Properties + +| Name | Type | Required | Restrictions | Description | +|-----------------------------|----------------------------------------------------------------------|----------|--------------|-------------| +| `created_at` | string | false | | | +| `current_state` | [codersdk.TaskStateEntry](#codersdktaskstateentry) | false | | | +| `id` | string | false | | | +| `initial_prompt` | string | false | | | +| `name` | string | false | | | +| `organization_id` | string | false | | | +| `owner_id` | string | false | | | +| `owner_name` | string | false | | | +| `status` | [codersdk.WorkspaceStatus](#codersdkworkspacestatus) | false | | | +| `template_display_name` | string | false | | | +| `template_icon` | string | false | | | +| `template_id` | string | false | | | +| `template_name` | string | false | | | +| `updated_at` | string | false | | | +| `workspace_agent_health` | [codersdk.WorkspaceAgentHealth](#codersdkworkspaceagenthealth) | false | | | +| `workspace_agent_id` | [uuid.NullUUID](#uuidnulluuid) | false | | | +| `workspace_agent_lifecycle` | [codersdk.WorkspaceAgentLifecycle](#codersdkworkspaceagentlifecycle) | false | | | +| `workspace_id` | [uuid.NullUUID](#uuidnulluuid) | false | | | + +#### Enumerated Values + +| Property | Value | +|----------|-------------| +| `status` | `pending` | +| `status` | `starting` | +| `status` | `running` | +| `status` | `stopping` | +| `status` | `stopped` | +| `status` | `failed` | +| `status` | `canceling` | +| `status` | `canceled` | +| `status` | `deleting` | +| `status` | `deleted` | + +## codersdk.TaskLogEntry + +```json +{ + "content": "string", + "id": 0, + "time": "2019-08-24T14:15:22Z", + "type": "input" +} +``` + +### Properties + +| Name | Type | Required | Restrictions | Description | +|-----------|----------------------------------------------|----------|--------------|-------------| +| `content` | string | false | | | +| `id` | integer | false | | | +| `time` | string | false | | | +| `type` | [codersdk.TaskLogType](#codersdktasklogtype) | false | | | + +## codersdk.TaskLogType + +```json +"input" +``` + +### Properties + +#### Enumerated Values + +| Value | +|----------| +| `input` | +| `output` | + +## codersdk.TaskLogsResponse + +```json +{ + "logs": [ + { + "content": "string", + "id": 0, + "time": "2019-08-24T14:15:22Z", + "type": "input" + } + ] +} +``` + +### Properties + +| Name | Type | Required | Restrictions | Description | +|--------|---------------------------------------------------------|----------|--------------|-------------| +| `logs` | array of [codersdk.TaskLogEntry](#codersdktasklogentry) | false | | | + +## codersdk.TaskSendRequest + +```json +{ + "input": "string" +} +``` + +### Properties + +| Name | Type | Required | Restrictions | Description | +|---------|--------|----------|--------------|-------------| +| `input` | string | false | | | + +## codersdk.TaskState + +```json +"working" +``` + +### Properties + +#### Enumerated Values + +| Value | +|------------| +| `working` | +| `idle` | +| `complete` | +| `failed` | + +## codersdk.TaskStateEntry + +```json +{ + "message": "string", + "state": "working", + "timestamp": "2019-08-24T14:15:22Z", + "uri": "string" +} +``` + +### Properties + +| Name | Type | Required | Restrictions | Description | +|-------------|------------------------------------------|----------|--------------|-------------| +| `message` | string | false | | | +| `state` | [codersdk.TaskState](#codersdktaskstate) | false | | | +| `timestamp` | string | false | | | +| `uri` | string | false | | | + ## codersdk.TelemetryConfig ```json