feat(coderd): add support for external agents to API's and provisioner (#19286)

This pull request introduces support for external workspace management, allowing users to register and manage workspaces that are provisioned and managed outside of the Coder.

Depends on: https://github.com/coder/terraform-provider-coder/pull/424

* GET /api/v2/init-script - Gets the agent initialization script
  * By default, it returns a script for Linux (amd64), but with query parameters (os and arch) you can get the init script for different platforms
* GET /api/v2/workspaces/{workspace}/external-agent/{agent}/credentials - Gets credentials for an external agent **(enterprise)**
* Updated queries to filter workspaces/templates by the has_external_agent field
This commit is contained in:
Kacper Sawicki
2025-08-19 10:41:33 +02:00
committed by GitHub
parent f085c37af3
commit 9edceef0bf
53 changed files with 1616 additions and 98 deletions
+93 -1
View File
@@ -1280,6 +1280,39 @@ const docTemplate = `{
}
}
},
"/init-script/{os}/{arch}": {
"get": {
"produces": [
"text/plain"
],
"tags": [
"InitScript"
],
"summary": "Get agent init script",
"operationId": "get-agent-init-script",
"parameters": [
{
"type": "string",
"description": "Operating system",
"name": "os",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Architecture",
"name": "arch",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
},
"/insights/daus": {
"get": {
"security": [
@@ -9835,7 +9868,7 @@ const docTemplate = `{
"parameters": [
{
"type": "string",
"description": "Search query in the format ` + "`" + `key:value` + "`" + `. Available keys are: owner, template, name, status, has-agent, dormant, last_used_after, last_used_before, has-ai-task.",
"description": "Search query in the format ` + "`" + `key:value` + "`" + `. Available keys are: owner, template, name, status, has-agent, dormant, last_used_after, last_used_before, has-ai-task, has_external_agent.",
"name": "q",
"in": "query"
},
@@ -10271,6 +10304,48 @@ const docTemplate = `{
}
}
},
"/workspaces/{workspace}/external-agent/{agent}/credentials": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"Enterprise"
],
"summary": "Get workspace external agent credentials",
"operationId": "get-workspace-external-agent-credentials",
"parameters": [
{
"type": "string",
"format": "uuid",
"description": "Workspace ID",
"name": "workspace",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Agent name",
"name": "agent",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.ExternalAgentCredentials"
}
}
}
}
},
"/workspaces/{workspace}/favorite": {
"put": {
"security": [
@@ -12901,6 +12976,17 @@ const docTemplate = `{
"ExperimentWorkspaceSharing"
]
},
"codersdk.ExternalAgentCredentials": {
"type": "object",
"properties": {
"agent_token": {
"type": "string"
},
"command": {
"type": "string"
}
}
},
"codersdk.ExternalAuth": {
"type": "object",
"properties": {
@@ -16816,6 +16902,9 @@ const docTemplate = `{
"created_by": {
"$ref": "#/definitions/codersdk.MinimalUser"
},
"has_external_agent": {
"type": "boolean"
},
"id": {
"type": "string",
"format": "uuid"
@@ -18675,6 +18764,9 @@ const docTemplate = `{
"has_ai_task": {
"type": "boolean"
},
"has_external_agent": {
"type": "boolean"
},
"id": {
"type": "string",
"format": "uuid"