feat: reinitialize agents when a prebuilt workspace is claimed (#17475)

This pull request allows coder workspace agents to be reinitialized when
a prebuilt workspace is claimed by a user. This facilitates the transfer
of ownership between the anonymous prebuilds system user and the new
owner of the workspace.

Only a single agent per prebuilt workspace is supported for now, but
plumbing has already been done to facilitate the seamless transition to
multi-agent support.

---------

Signed-off-by: Danny Kopping <dannykopping@gmail.com>
Co-authored-by: Danny Kopping <dannykopping@gmail.com>
This commit is contained in:
Sas Swart
2025-05-14 14:15:36 +02:00
committed by GitHub
parent fcbdd1a28e
commit 425ee6fa55
38 changed files with 2184 additions and 449 deletions

45
coderd/apidoc/docs.go generated
View File

@ -8446,6 +8446,31 @@ const docTemplate = `{
}
}
},
"/workspaceagents/me/reinit": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"Agents"
],
"summary": "Get workspace agent reinitialization",
"operationId": "get-workspace-agent-reinitialization",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/agentsdk.ReinitializationEvent"
}
}
}
}
},
"/workspaceagents/me/rpc": {
"get": {
"security": [
@ -10491,6 +10516,26 @@ const docTemplate = `{
}
}
},
"agentsdk.ReinitializationEvent": {
"type": "object",
"properties": {
"reason": {
"$ref": "#/definitions/agentsdk.ReinitializationReason"
},
"workspaceID": {
"type": "string"
}
}
},
"agentsdk.ReinitializationReason": {
"type": "string",
"enum": [
"prebuild_claimed"
],
"x-enum-varnames": [
"ReinitializeReasonPrebuildClaimed"
]
},
"aisdk.Attachment": {
"type": "object",
"properties": {