mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add experimental agents support (#22290)
feat: add AI chat system with agent tools and chat UI Introduce the chatd subsystem and Agents UI for AI-powered chat within Coder workspaces. - Add chatd package with chat loop, message compaction, prompt management, and LLM provider integration (OpenAI, Anthropic) - Add agent tools: create workspace, list/read templates, read/write/ edit files, execute commands - Add chat API endpoints with streaming, message editing, and durable reconnection - Add database schema and migrations for chats, chat messages, chat providers, and chat model configs - Add RBAC policies and dbauthz enforcement for chat resources - Add Agents UI pages with conversation timeline, queued messages list, diff viewer, and model configuration panel - Add comprehensive test coverage including coderd integration tests, chatd unit tests, and Storybook stories - Gate feature behind experiments flag --------- Co-authored-by: Cian Johnston <cian@coder.com> Co-authored-by: Danielle Maywood <danielle@themaywoods.com> Co-authored-by: Jeremy Ruppel <jeremy@coder.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Cian Johnston
Danielle Maywood
Jeremy Ruppel
Claude Sonnet 4.6
parent
67da4e8b56
commit
edee917d88
@@ -638,6 +638,14 @@ type ExternalAuthRequest struct {
|
||||
ID string
|
||||
// Match is an arbitrary string matched against the regex of the provider.
|
||||
Match string
|
||||
// GitBranch is the current git branch in the working directory.
|
||||
// Sent by the agent so the control plane can resolve diffs
|
||||
// without SSHing into the workspace.
|
||||
GitBranch string
|
||||
// GitRemoteOrigin is the remote origin URL of the git repository.
|
||||
// Sent by the agent so the control plane can resolve diffs
|
||||
// without SSHing into the workspace.
|
||||
GitRemoteOrigin string
|
||||
// Listen indicates that the request should be long-lived and listen for
|
||||
// a new token to be requested.
|
||||
Listen bool
|
||||
@@ -653,6 +661,12 @@ func (c *Client) ExternalAuth(ctx context.Context, req ExternalAuthRequest) (Ext
|
||||
if req.Listen {
|
||||
q.Set("listen", "true")
|
||||
}
|
||||
if req.GitBranch != "" {
|
||||
q.Set("git_branch", req.GitBranch)
|
||||
}
|
||||
if req.GitRemoteOrigin != "" {
|
||||
q.Set("git_remote_origin", req.GitRemoteOrigin)
|
||||
}
|
||||
reqURL := "/api/v2/workspaceagents/me/external-auth?" + q.Encode()
|
||||
res, err := c.SDK.Request(ctx, http.MethodGet, reqURL, nil)
|
||||
if err != nil {
|
||||
|
||||
@@ -153,3 +153,33 @@ func TestRewriteDERPMap(t *testing.T) {
|
||||
require.Equal(t, "coconuts.org", node.HostName)
|
||||
require.Equal(t, 44558, node.DERPPort)
|
||||
}
|
||||
|
||||
func TestExternalAuthRequestQuery(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("IncludesGitRefFieldsAndOmitsWorkdir", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
require.Equal(t, "/api/v2/workspaceagents/me/external-auth", r.URL.Path)
|
||||
require.Equal(t, "true", r.URL.Query().Get("listen"))
|
||||
require.Equal(t, "main", r.URL.Query().Get("git_branch"))
|
||||
require.Equal(t, "https://github.com/coder/coder.git", r.URL.Query().Get("git_remote_origin"))
|
||||
require.False(t, r.URL.Query().Has("workdir"))
|
||||
_, _ = w.Write([]byte(`{"type":"github","access_token":"token"}`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
parsedURL, err := url.Parse(srv.URL)
|
||||
require.NoError(t, err)
|
||||
|
||||
client := agentsdk.New(parsedURL, agentsdk.WithFixedToken("token"))
|
||||
_, err = client.ExternalAuth(testutil.Context(t, testutil.WaitShort), agentsdk.ExternalAuthRequest{
|
||||
Match: "github.com",
|
||||
Listen: true,
|
||||
GitBranch: "main",
|
||||
GitRemoteOrigin: "https://github.com/coder/coder.git",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user