chore: add agent-connection-watch for workspaces (#24507)

<!--

If you have used AI to produce some or all of this PR, please ensure you have read our [AI Contribution guidelines](https://coder.com/docs/about/contributing/AI_CONTRIBUTING) before submitting.

-->

relates to GRU-18  
  
Adds basic implementation for Workspace Agent Connection Watch and tests.  
  
Missing are handling of logs.
This commit is contained in:
Spike Curtis
2026-05-20 13:09:11 -04:00
committed by GitHub
parent 05e47b9c0f
commit 8dc4d76890
20 changed files with 1679 additions and 61 deletions
+122
View File
@@ -12783,6 +12783,41 @@ const docTemplate = `{
]
}
},
"/api/v2/workspaces/{workspace}/agent-connection-watch": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Workspaces"
],
"summary": "Workspace Agent Connection Watch",
"operationId": "workspace-agent-connection-watch",
"parameters": [
{
"type": "string",
"format": "uuid",
"description": "Workspace ID",
"name": "workspace",
"in": "path",
"required": true
}
],
"responses": {
"101": {
"description": "Switching Protocols",
"schema": {
"$ref": "#/definitions/workspacesdk.ConnectionWatchEvent"
}
}
},
"security": [
{
"CoderSessionToken": []
}
]
}
},
"/api/v2/workspaces/{workspace}/autostart": {
"put": {
"consumes": [
@@ -27964,6 +27999,93 @@ const docTemplate = `{
}
}
},
"workspacesdk.AgentUpdate": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"lifecycle": {
"$ref": "#/definitions/codersdk.WorkspaceAgentLifecycle"
}
}
},
"workspacesdk.BuildUpdate": {
"type": "object",
"properties": {
"job_status": {
"$ref": "#/definitions/codersdk.ProvisionerJobStatus"
},
"transition": {
"$ref": "#/definitions/codersdk.WorkspaceTransition"
}
}
},
"workspacesdk.ConnectionWatchEvent": {
"type": "object",
"properties": {
"agent_update": {
"$ref": "#/definitions/workspacesdk.AgentUpdate"
},
"build_update": {
"$ref": "#/definitions/workspacesdk.BuildUpdate"
},
"error": {
"$ref": "#/definitions/workspacesdk.WatchError"
}
}
},
"workspacesdk.WatchError": {
"type": "object",
"properties": {
"code": {
"$ref": "#/definitions/workspacesdk.WatchErrorCode"
},
"details": {
"type": "string"
},
"message": {
"type": "string"
},
"retryable": {
"type": "boolean"
}
}
},
"workspacesdk.WatchErrorCode": {
"type": "integer",
"enum": [
0,
1,
2,
3,
4,
5,
6
],
"x-enum-comments": {
"_": "Ensure that zero value is not a valid code"
},
"x-enum-descriptions": [
"Ensure that zero value is not a valid code",
"",
"",
"",
"",
"",
""
],
"x-enum-varnames": [
"_",
"WatchErrorTooManyAgents",
"WatchErrorNameNotFound",
"WatchErrorNoAgents",
"WatchErrorServerShutdown",
"WatchErrorDatabase",
"WatchErrorInternal"
]
},
"wsproxysdk.CryptoKeysResponse": {
"type": "object",
"properties": {