diff --git a/coderd/coderd.go b/coderd/coderd.go index c4330acf11..c2d5986504 100644 --- a/coderd/coderd.go +++ b/coderd/coderd.go @@ -51,7 +51,6 @@ import ( "github.com/coder/coder/v2/coderd/audit" "github.com/coder/coder/v2/coderd/awsidentity" "github.com/coder/coder/v2/coderd/boundaryusage" - "github.com/coder/coder/v2/coderd/chatd" "github.com/coder/coder/v2/coderd/connectionlog" "github.com/coder/coder/v2/coderd/cryptokeys" "github.com/coder/coder/v2/coderd/database" @@ -63,7 +62,6 @@ import ( "github.com/coder/coder/v2/coderd/externalauth" "github.com/coder/coder/v2/coderd/files" "github.com/coder/coder/v2/coderd/gitsshkey" - "github.com/coder/coder/v2/coderd/gitsync" "github.com/coder/coder/v2/coderd/healthcheck" "github.com/coder/coder/v2/coderd/healthcheck/derphealth" "github.com/coder/coder/v2/coderd/httpapi" @@ -94,6 +92,8 @@ import ( "github.com/coder/coder/v2/coderd/workspaceapps/appurl" "github.com/coder/coder/v2/coderd/workspacestats" "github.com/coder/coder/v2/coderd/wsbuilder" + "github.com/coder/coder/v2/coderd/x/chatd" + "github.com/coder/coder/v2/coderd/x/gitsync" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/codersdk/drpcsdk" "github.com/coder/coder/v2/codersdk/healthsdk" @@ -767,43 +767,45 @@ func New(options *Options) *API { } api.agentProvider = stn - maxChatsPerAcquire := options.DeploymentValues.AI.Chat.AcquireBatchSize.Value() - if maxChatsPerAcquire > math.MaxInt32 { - maxChatsPerAcquire = math.MaxInt32 - } - if maxChatsPerAcquire < math.MinInt32 { - maxChatsPerAcquire = math.MinInt32 - } + { // Experimental: agents — chat daemon and git sync worker initialization. + maxChatsPerAcquire := options.DeploymentValues.AI.Chat.AcquireBatchSize.Value() + if maxChatsPerAcquire > math.MaxInt32 { + maxChatsPerAcquire = math.MaxInt32 + } + if maxChatsPerAcquire < math.MinInt32 { + maxChatsPerAcquire = math.MinInt32 + } - api.chatDaemon = chatd.New(chatd.Config{ - Logger: options.Logger.Named("chatd"), - Database: options.Database, - ReplicaID: api.ID, - SubscribeFn: options.ChatSubscribeFn, - MaxChatsPerAcquire: int32(maxChatsPerAcquire), //nolint:gosec // maxChatsPerAcquire is clamped to int32 range above. - ProviderAPIKeys: chatProviderAPIKeysFromDeploymentValues(options.DeploymentValues), - AgentConn: api.agentProvider.AgentConn, - CreateWorkspace: api.chatCreateWorkspace, - StartWorkspace: api.chatStartWorkspace, - Pubsub: options.Pubsub, - WebpushDispatcher: options.WebPushDispatcher, - UsageTracker: options.WorkspaceUsageTracker, - }) - gitSyncLogger := options.Logger.Named("gitsync") - refresher := gitsync.NewRefresher( - api.resolveGitProvider, - api.resolveChatGitAccessToken, - gitSyncLogger.Named("refresher"), - quartz.NewReal(), - ) - api.gitSyncWorker = gitsync.NewWorker(options.Database, - refresher, - api.chatDaemon.PublishDiffStatusChange, - quartz.NewReal(), - gitSyncLogger, - ) - // nolint:gocritic // chat diff worker needs to be able to CRUD chats. - go api.gitSyncWorker.Start(dbauthz.AsChatd(api.ctx)) + api.chatDaemon = chatd.New(chatd.Config{ + Logger: options.Logger.Named("chatd"), + Database: options.Database, + ReplicaID: api.ID, + SubscribeFn: options.ChatSubscribeFn, + MaxChatsPerAcquire: int32(maxChatsPerAcquire), //nolint:gosec // maxChatsPerAcquire is clamped to int32 range above. + ProviderAPIKeys: chatProviderAPIKeysFromDeploymentValues(options.DeploymentValues), + AgentConn: api.agentProvider.AgentConn, + CreateWorkspace: api.chatCreateWorkspace, + StartWorkspace: api.chatStartWorkspace, + Pubsub: options.Pubsub, + WebpushDispatcher: options.WebPushDispatcher, + UsageTracker: options.WorkspaceUsageTracker, + }) + gitSyncLogger := options.Logger.Named("gitsync") + refresher := gitsync.NewRefresher( + api.resolveGitProvider, + api.resolveChatGitAccessToken, + gitSyncLogger.Named("refresher"), + quartz.NewReal(), + ) + api.gitSyncWorker = gitsync.NewWorker(options.Database, + refresher, + api.chatDaemon.PublishDiffStatusChange, + quartz.NewReal(), + gitSyncLogger, + ) + // nolint:gocritic // chat diff worker needs to be able to CRUD chats. + go api.gitSyncWorker.Start(dbauthz.AsChatd(api.ctx)) + } if options.DeploymentValues.Prometheus.Enable { options.PrometheusRegistry.MustRegister(stn) api.lifecycleMetrics = agentapi.NewLifecycleMetrics(options.PrometheusRegistry) @@ -1146,6 +1148,7 @@ func New(options *Options) *API { }) }) }) + // Experimental(agents): chat API routes gated by ExperimentAgents. r.Route("/chats", func(r chi.Router) { r.Use( apiKeyMiddleware, @@ -2086,13 +2089,12 @@ type API struct { // dbRolluper rolls up template usage stats from raw agent and app // stats. This is used to provide insights in the WebUI. dbRolluper *dbrollup.Rolluper - // chatDaemon handles background processing of pending chats. + // Experimental(agents): chatDaemon handles background processing of pending chats. chatDaemon *chatd.Server + // Experimental(agents): gitSyncWorker refreshes stale chat diff statuses in the background. + gitSyncWorker *gitsync.Worker // AISeatTracker records AI seat usage. AISeatTracker aiseats.SeatTracker - // gitSyncWorker refreshes stale chat diff statuses in the - // background. - gitSyncWorker *gitsync.Worker // ProfileCollector abstracts the runtime/pprof and runtime/trace // calls used by the /debug/profile endpoint. Tests override this diff --git a/coderd/database/db2sdk/db2sdk.go b/coderd/database/db2sdk/db2sdk.go index cb4c8ee65f..32b1e427e2 100644 --- a/coderd/database/db2sdk/db2sdk.go +++ b/coderd/database/db2sdk/db2sdk.go @@ -19,7 +19,6 @@ import ( "tailscale.com/tailcfg" agentproto "github.com/coder/coder/v2/agent/proto" - "github.com/coder/coder/v2/coderd/chatd/chatprompt" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/externalauth/gitprovider" "github.com/coder/coder/v2/coderd/rbac" @@ -28,6 +27,7 @@ import ( "github.com/coder/coder/v2/coderd/util/ptr" "github.com/coder/coder/v2/coderd/util/slice" "github.com/coder/coder/v2/coderd/workspaceapps/appurl" + "github.com/coder/coder/v2/coderd/x/chatd/chatprompt" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/provisionersdk/proto" "github.com/coder/coder/v2/tailnet" diff --git a/coderd/database/querier_test.go b/coderd/database/querier_test.go index d3560afd72..f364e552f1 100644 --- a/coderd/database/querier_test.go +++ b/coderd/database/querier_test.go @@ -21,7 +21,6 @@ import ( "github.com/stretchr/testify/require" "cdr.dev/slog/v3/sloggers/slogtest" - "github.com/coder/coder/v2/coderd/chatd/chatprompt" "github.com/coder/coder/v2/coderd/coderdtest" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/database/dbauthz" @@ -35,6 +34,7 @@ import ( "github.com/coder/coder/v2/coderd/rbac" "github.com/coder/coder/v2/coderd/rbac/policy" "github.com/coder/coder/v2/coderd/util/slice" + "github.com/coder/coder/v2/coderd/x/chatd/chatprompt" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/provisionersdk" "github.com/coder/coder/v2/testutil" diff --git a/coderd/chats.go b/coderd/exp_chats.go similarity index 99% rename from coderd/chats.go rename to coderd/exp_chats.go index 5eb66bce52..90fdf51938 100644 --- a/coderd/chats.go +++ b/coderd/exp_chats.go @@ -28,14 +28,11 @@ import ( "cdr.dev/slog/v3" "github.com/coder/coder/v2/agent/agentssh" "github.com/coder/coder/v2/coderd/audit" - "github.com/coder/coder/v2/coderd/chatd" - "github.com/coder/coder/v2/coderd/chatd/chatprovider" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/database/db2sdk" "github.com/coder/coder/v2/coderd/database/dbauthz" "github.com/coder/coder/v2/coderd/externalauth" "github.com/coder/coder/v2/coderd/externalauth/gitprovider" - "github.com/coder/coder/v2/coderd/gitsync" "github.com/coder/coder/v2/coderd/httpapi" "github.com/coder/coder/v2/coderd/httpapi/httperror" "github.com/coder/coder/v2/coderd/httpmw" @@ -46,6 +43,9 @@ import ( "github.com/coder/coder/v2/coderd/tracing" "github.com/coder/coder/v2/coderd/util/ptr" "github.com/coder/coder/v2/coderd/workspaceapps" + "github.com/coder/coder/v2/coderd/x/chatd" + "github.com/coder/coder/v2/coderd/x/chatd/chatprovider" + "github.com/coder/coder/v2/coderd/x/gitsync" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/codersdk/wsjson" "github.com/coder/websocket" diff --git a/coderd/chats_test.go b/coderd/exp_chats_test.go similarity index 99% rename from coderd/chats_test.go rename to coderd/exp_chats_test.go index 888996beb1..15a097fd54 100644 --- a/coderd/chats_test.go +++ b/coderd/exp_chats_test.go @@ -18,8 +18,6 @@ import ( "github.com/shopspring/decimal" "github.com/stretchr/testify/require" - "github.com/coder/coder/v2/coderd/chatd" - "github.com/coder/coder/v2/coderd/chatd/chatprompt" "github.com/coder/coder/v2/coderd/coderdtest" "github.com/coder/coder/v2/coderd/coderdtest/oidctest" "github.com/coder/coder/v2/coderd/database" @@ -31,6 +29,8 @@ import ( coderdpubsub "github.com/coder/coder/v2/coderd/pubsub" "github.com/coder/coder/v2/coderd/rbac" "github.com/coder/coder/v2/coderd/util/ptr" + "github.com/coder/coder/v2/coderd/x/chatd" + "github.com/coder/coder/v2/coderd/x/chatd/chatprompt" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/testutil" "github.com/coder/websocket" diff --git a/coderd/chatd/chatcost/chatcost.go b/coderd/x/chatd/chatcost/chatcost.go similarity index 100% rename from coderd/chatd/chatcost/chatcost.go rename to coderd/x/chatd/chatcost/chatcost.go diff --git a/coderd/chatd/chatcost/chatcost_test.go b/coderd/x/chatd/chatcost/chatcost_test.go similarity index 98% rename from coderd/chatd/chatcost/chatcost_test.go rename to coderd/x/chatd/chatcost/chatcost_test.go index 0142f4f612..8f29092a06 100644 --- a/coderd/chatd/chatcost/chatcost_test.go +++ b/coderd/x/chatd/chatcost/chatcost_test.go @@ -6,8 +6,8 @@ import ( "github.com/shopspring/decimal" "github.com/stretchr/testify/require" - "github.com/coder/coder/v2/coderd/chatd/chatcost" "github.com/coder/coder/v2/coderd/util/ptr" + "github.com/coder/coder/v2/coderd/x/chatd/chatcost" "github.com/coder/coder/v2/codersdk" ) diff --git a/coderd/chatd/chatd.go b/coderd/x/chatd/chatd.go similarity index 99% rename from coderd/chatd/chatd.go rename to coderd/x/chatd/chatd.go index 44b0790850..e63e410090 100644 --- a/coderd/chatd/chatd.go +++ b/coderd/x/chatd/chatd.go @@ -20,12 +20,6 @@ import ( "golang.org/x/xerrors" "cdr.dev/slog/v3" - "github.com/coder/coder/v2/coderd/chatd/chatcost" - "github.com/coder/coder/v2/coderd/chatd/chatloop" - "github.com/coder/coder/v2/coderd/chatd/chatprompt" - "github.com/coder/coder/v2/coderd/chatd/chatprovider" - "github.com/coder/coder/v2/coderd/chatd/chattool" - "github.com/coder/coder/v2/coderd/chatd/mcpclient" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/database/db2sdk" "github.com/coder/coder/v2/coderd/database/dbauthz" @@ -34,6 +28,12 @@ import ( "github.com/coder/coder/v2/coderd/util/ptr" "github.com/coder/coder/v2/coderd/webpush" "github.com/coder/coder/v2/coderd/workspacestats" + "github.com/coder/coder/v2/coderd/x/chatd/chatcost" + "github.com/coder/coder/v2/coderd/x/chatd/chatloop" + "github.com/coder/coder/v2/coderd/x/chatd/chatprompt" + "github.com/coder/coder/v2/coderd/x/chatd/chatprovider" + "github.com/coder/coder/v2/coderd/x/chatd/chattool" + "github.com/coder/coder/v2/coderd/x/chatd/mcpclient" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/codersdk/workspacesdk" "github.com/coder/quartz" diff --git a/coderd/chatd/chatd_internal_test.go b/coderd/x/chatd/chatd_internal_test.go similarity index 100% rename from coderd/chatd/chatd_internal_test.go rename to coderd/x/chatd/chatd_internal_test.go diff --git a/coderd/chatd/chatd_test.go b/coderd/x/chatd/chatd_test.go similarity index 99% rename from coderd/chatd/chatd_test.go rename to coderd/x/chatd/chatd_test.go index 483063a77e..d8274950ec 100644 --- a/coderd/chatd/chatd_test.go +++ b/coderd/x/chatd/chatd_test.go @@ -26,10 +26,6 @@ import ( "cdr.dev/slog/v3/sloggers/slogtest" "github.com/coder/coder/v2/agent/agenttest" - "github.com/coder/coder/v2/coderd/chatd" - "github.com/coder/coder/v2/coderd/chatd/chatprompt" - "github.com/coder/coder/v2/coderd/chatd/chattest" - "github.com/coder/coder/v2/coderd/chatd/chattool" "github.com/coder/coder/v2/coderd/coderdtest" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/database/db2sdk" @@ -41,6 +37,10 @@ import ( "github.com/coder/coder/v2/coderd/rbac" "github.com/coder/coder/v2/coderd/util/slice" "github.com/coder/coder/v2/coderd/workspacestats" + "github.com/coder/coder/v2/coderd/x/chatd" + "github.com/coder/coder/v2/coderd/x/chatd/chatprompt" + "github.com/coder/coder/v2/coderd/x/chatd/chattest" + "github.com/coder/coder/v2/coderd/x/chatd/chattool" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/codersdk/workspacesdk" "github.com/coder/coder/v2/codersdk/workspacesdk/agentconnmock" diff --git a/coderd/chatd/chatloop/chatloop.go b/coderd/x/chatd/chatloop/chatloop.go similarity index 99% rename from coderd/chatd/chatloop/chatloop.go rename to coderd/x/chatd/chatloop/chatloop.go index 44feab87b6..38f7237ec0 100644 --- a/coderd/chatd/chatloop/chatloop.go +++ b/coderd/x/chatd/chatloop/chatloop.go @@ -16,8 +16,8 @@ import ( "charm.land/fantasy/schema" "golang.org/x/xerrors" - "github.com/coder/coder/v2/coderd/chatd/chatprompt" - "github.com/coder/coder/v2/coderd/chatd/chatretry" + "github.com/coder/coder/v2/coderd/x/chatd/chatprompt" + "github.com/coder/coder/v2/coderd/x/chatd/chatretry" "github.com/coder/coder/v2/codersdk" ) diff --git a/coderd/chatd/chatloop/chatloop_test.go b/coderd/x/chatd/chatloop/chatloop_test.go similarity index 100% rename from coderd/chatd/chatloop/chatloop_test.go rename to coderd/x/chatd/chatloop/chatloop_test.go diff --git a/coderd/chatd/chatloop/compaction.go b/coderd/x/chatd/chatloop/compaction.go similarity index 100% rename from coderd/chatd/chatloop/compaction.go rename to coderd/x/chatd/chatloop/compaction.go diff --git a/coderd/chatd/chatloop/compaction_test.go b/coderd/x/chatd/chatloop/compaction_test.go similarity index 100% rename from coderd/chatd/chatloop/compaction_test.go rename to coderd/x/chatd/chatloop/compaction_test.go diff --git a/coderd/chatd/chatloop/contextlimit_internal_test.go b/coderd/x/chatd/chatloop/contextlimit_internal_test.go similarity index 100% rename from coderd/chatd/chatloop/contextlimit_internal_test.go rename to coderd/x/chatd/chatloop/contextlimit_internal_test.go diff --git a/coderd/chatd/chatprompt/chatprompt.go b/coderd/x/chatd/chatprompt/chatprompt.go similarity index 100% rename from coderd/chatd/chatprompt/chatprompt.go rename to coderd/x/chatd/chatprompt/chatprompt.go diff --git a/coderd/chatd/chatprompt/chatprompt_test.go b/coderd/x/chatd/chatprompt/chatprompt_test.go similarity index 99% rename from coderd/chatd/chatprompt/chatprompt_test.go rename to coderd/x/chatd/chatprompt/chatprompt_test.go index b555b60922..30d0d66e31 100644 --- a/coderd/chatd/chatprompt/chatprompt_test.go +++ b/coderd/x/chatd/chatprompt/chatprompt_test.go @@ -14,11 +14,11 @@ import ( "github.com/stretchr/testify/require" "cdr.dev/slog/v3/sloggers/slogtest" - "github.com/coder/coder/v2/coderd/chatd/chatprompt" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/database/db2sdk" "github.com/coder/coder/v2/coderd/database/dbgen" "github.com/coder/coder/v2/coderd/database/dbtestutil" + "github.com/coder/coder/v2/coderd/x/chatd/chatprompt" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/testutil" ) diff --git a/coderd/chatd/chatprovider/chatprovider.go b/coderd/x/chatd/chatprovider/chatprovider.go similarity index 100% rename from coderd/chatd/chatprovider/chatprovider.go rename to coderd/x/chatd/chatprovider/chatprovider.go diff --git a/coderd/chatd/chatprovider/chatprovider_test.go b/coderd/x/chatd/chatprovider/chatprovider_test.go similarity index 98% rename from coderd/chatd/chatprovider/chatprovider_test.go rename to coderd/x/chatd/chatprovider/chatprovider_test.go index 88fe7a0fcb..bbd8e86186 100644 --- a/coderd/chatd/chatprovider/chatprovider_test.go +++ b/coderd/x/chatd/chatprovider/chatprovider_test.go @@ -9,8 +9,8 @@ import ( fantasyvercel "charm.land/fantasy/providers/vercel" "github.com/stretchr/testify/require" - "github.com/coder/coder/v2/coderd/chatd/chatprovider" "github.com/coder/coder/v2/coderd/util/ptr" + "github.com/coder/coder/v2/coderd/x/chatd/chatprovider" "github.com/coder/coder/v2/codersdk" ) diff --git a/coderd/chatd/chatprovider/useragent.go b/coderd/x/chatd/chatprovider/useragent.go similarity index 100% rename from coderd/chatd/chatprovider/useragent.go rename to coderd/x/chatd/chatprovider/useragent.go diff --git a/coderd/chatd/chatprovider/useragent_test.go b/coderd/x/chatd/chatprovider/useragent_test.go similarity index 94% rename from coderd/chatd/chatprovider/useragent_test.go rename to coderd/x/chatd/chatprovider/useragent_test.go index 2e2c482118..7df3f3a39a 100644 --- a/coderd/chatd/chatprovider/useragent_test.go +++ b/coderd/x/chatd/chatprovider/useragent_test.go @@ -12,8 +12,8 @@ import ( "github.com/stretchr/testify/require" "github.com/coder/coder/v2/buildinfo" - "github.com/coder/coder/v2/coderd/chatd/chatprovider" - "github.com/coder/coder/v2/coderd/chatd/chattest" + "github.com/coder/coder/v2/coderd/x/chatd/chatprovider" + "github.com/coder/coder/v2/coderd/x/chatd/chattest" ) func TestUserAgent(t *testing.T) { diff --git a/coderd/chatd/chatretry/chatretry.go b/coderd/x/chatd/chatretry/chatretry.go similarity index 100% rename from coderd/chatd/chatretry/chatretry.go rename to coderd/x/chatd/chatretry/chatretry.go diff --git a/coderd/chatd/chatretry/chatretry_test.go b/coderd/x/chatd/chatretry/chatretry_test.go similarity index 99% rename from coderd/chatd/chatretry/chatretry_test.go rename to coderd/x/chatd/chatretry/chatretry_test.go index 9c104ffced..df4659d23f 100644 --- a/coderd/chatd/chatretry/chatretry_test.go +++ b/coderd/x/chatd/chatretry/chatretry_test.go @@ -10,7 +10,7 @@ import ( "golang.org/x/xerrors" - "github.com/coder/coder/v2/coderd/chatd/chatretry" + "github.com/coder/coder/v2/coderd/x/chatd/chatretry" ) func TestIsRetryable(t *testing.T) { diff --git a/coderd/chatd/chattest/anthropic.go b/coderd/x/chatd/chattest/anthropic.go similarity index 100% rename from coderd/chatd/chattest/anthropic.go rename to coderd/x/chatd/chattest/anthropic.go diff --git a/coderd/chatd/chattest/anthropic_test.go b/coderd/x/chatd/chattest/anthropic_test.go similarity index 99% rename from coderd/chatd/chattest/anthropic_test.go rename to coderd/x/chatd/chattest/anthropic_test.go index 531183db38..e4643a4baa 100644 --- a/coderd/chatd/chattest/anthropic_test.go +++ b/coderd/x/chatd/chattest/anthropic_test.go @@ -9,7 +9,7 @@ import ( fantasyanthropic "charm.land/fantasy/providers/anthropic" "github.com/stretchr/testify/require" - "github.com/coder/coder/v2/coderd/chatd/chattest" + "github.com/coder/coder/v2/coderd/x/chatd/chattest" ) func TestAnthropic_Streaming(t *testing.T) { diff --git a/coderd/chatd/chattest/errors.go b/coderd/x/chatd/chattest/errors.go similarity index 100% rename from coderd/chatd/chattest/errors.go rename to coderd/x/chatd/chattest/errors.go diff --git a/coderd/chatd/chattest/openai.go b/coderd/x/chatd/chattest/openai.go similarity index 100% rename from coderd/chatd/chattest/openai.go rename to coderd/x/chatd/chattest/openai.go diff --git a/coderd/chatd/chattest/openai_test.go b/coderd/x/chatd/chattest/openai_test.go similarity index 99% rename from coderd/chatd/chattest/openai_test.go rename to coderd/x/chatd/chattest/openai_test.go index 56e05563d8..de1f6af38c 100644 --- a/coderd/chatd/chattest/openai_test.go +++ b/coderd/x/chatd/chattest/openai_test.go @@ -9,7 +9,7 @@ import ( fantasyopenai "charm.land/fantasy/providers/openai" "github.com/stretchr/testify/require" - "github.com/coder/coder/v2/coderd/chatd/chattest" + "github.com/coder/coder/v2/coderd/x/chatd/chattest" ) func TestOpenAI_Streaming(t *testing.T) { diff --git a/coderd/chatd/chattool/chattool.go b/coderd/x/chatd/chattool/chattool.go similarity index 100% rename from coderd/chatd/chattool/chattool.go rename to coderd/x/chatd/chattool/chattool.go diff --git a/coderd/chatd/chattool/computeruse.go b/coderd/x/chatd/chattool/computeruse.go similarity index 100% rename from coderd/chatd/chattool/computeruse.go rename to coderd/x/chatd/chattool/computeruse.go diff --git a/coderd/chatd/chattool/computeruse_internal_test.go b/coderd/x/chatd/chattool/computeruse_internal_test.go similarity index 100% rename from coderd/chatd/chattool/computeruse_internal_test.go rename to coderd/x/chatd/chattool/computeruse_internal_test.go diff --git a/coderd/chatd/chattool/computeruse_test.go b/coderd/x/chatd/chattool/computeruse_test.go similarity index 99% rename from coderd/chatd/chattool/computeruse_test.go rename to coderd/x/chatd/chattool/computeruse_test.go index a59d0141b1..50c4dc0d57 100644 --- a/coderd/chatd/chattool/computeruse_test.go +++ b/coderd/x/chatd/chattool/computeruse_test.go @@ -10,7 +10,7 @@ import ( "go.uber.org/mock/gomock" "golang.org/x/xerrors" - "github.com/coder/coder/v2/coderd/chatd/chattool" + "github.com/coder/coder/v2/coderd/x/chatd/chattool" "github.com/coder/coder/v2/codersdk/workspacesdk" "github.com/coder/coder/v2/codersdk/workspacesdk/agentconnmock" "github.com/coder/quartz" diff --git a/coderd/chatd/chattool/createworkspace.go b/coderd/x/chatd/chattool/createworkspace.go similarity index 100% rename from coderd/chatd/chattool/createworkspace.go rename to coderd/x/chatd/chattool/createworkspace.go diff --git a/coderd/chatd/chattool/createworkspace_test.go b/coderd/x/chatd/chattool/createworkspace_test.go similarity index 100% rename from coderd/chatd/chattool/createworkspace_test.go rename to coderd/x/chatd/chattool/createworkspace_test.go diff --git a/coderd/chatd/chattool/editfiles.go b/coderd/x/chatd/chattool/editfiles.go similarity index 100% rename from coderd/chatd/chattool/editfiles.go rename to coderd/x/chatd/chattool/editfiles.go diff --git a/coderd/chatd/chattool/execute.go b/coderd/x/chatd/chattool/execute.go similarity index 100% rename from coderd/chatd/chattool/execute.go rename to coderd/x/chatd/chattool/execute.go diff --git a/coderd/chatd/chattool/execute_internal_test.go b/coderd/x/chatd/chattool/execute_internal_test.go similarity index 100% rename from coderd/chatd/chattool/execute_internal_test.go rename to coderd/x/chatd/chattool/execute_internal_test.go diff --git a/coderd/chatd/chattool/execute_test.go b/coderd/x/chatd/chattool/execute_test.go similarity index 99% rename from coderd/chatd/chattool/execute_test.go rename to coderd/x/chatd/chattool/execute_test.go index 0b6e2c159c..8750b63c7c 100644 --- a/coderd/chatd/chattool/execute_test.go +++ b/coderd/x/chatd/chattool/execute_test.go @@ -11,7 +11,7 @@ import ( "go.uber.org/mock/gomock" "golang.org/x/xerrors" - "github.com/coder/coder/v2/coderd/chatd/chattool" + "github.com/coder/coder/v2/coderd/x/chatd/chattool" "github.com/coder/coder/v2/codersdk/workspacesdk" "github.com/coder/coder/v2/codersdk/workspacesdk/agentconnmock" "github.com/coder/coder/v2/testutil" diff --git a/coderd/chatd/chattool/listtemplates.go b/coderd/x/chatd/chattool/listtemplates.go similarity index 100% rename from coderd/chatd/chattool/listtemplates.go rename to coderd/x/chatd/chattool/listtemplates.go diff --git a/coderd/chatd/chattool/readfile.go b/coderd/x/chatd/chattool/readfile.go similarity index 100% rename from coderd/chatd/chattool/readfile.go rename to coderd/x/chatd/chattool/readfile.go diff --git a/coderd/chatd/chattool/readtemplate.go b/coderd/x/chatd/chattool/readtemplate.go similarity index 100% rename from coderd/chatd/chattool/readtemplate.go rename to coderd/x/chatd/chattool/readtemplate.go diff --git a/coderd/chatd/chattool/startworkspace.go b/coderd/x/chatd/chattool/startworkspace.go similarity index 100% rename from coderd/chatd/chattool/startworkspace.go rename to coderd/x/chatd/chattool/startworkspace.go diff --git a/coderd/chatd/chattool/startworkspace_test.go b/coderd/x/chatd/chattool/startworkspace_test.go similarity index 99% rename from coderd/chatd/chattool/startworkspace_test.go rename to coderd/x/chatd/chattool/startworkspace_test.go index d8952346a5..74629cc402 100644 --- a/coderd/chatd/chattool/startworkspace_test.go +++ b/coderd/x/chatd/chattool/startworkspace_test.go @@ -11,11 +11,11 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/require" - "github.com/coder/coder/v2/coderd/chatd/chattool" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/database/dbfake" "github.com/coder/coder/v2/coderd/database/dbgen" "github.com/coder/coder/v2/coderd/database/dbtestutil" + "github.com/coder/coder/v2/coderd/x/chatd/chattool" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/codersdk/workspacesdk" "github.com/coder/coder/v2/testutil" diff --git a/coderd/chatd/chattool/writefile.go b/coderd/x/chatd/chattool/writefile.go similarity index 100% rename from coderd/chatd/chattool/writefile.go rename to coderd/x/chatd/chattool/writefile.go diff --git a/coderd/chatd/instruction.go b/coderd/x/chatd/instruction.go similarity index 100% rename from coderd/chatd/instruction.go rename to coderd/x/chatd/instruction.go diff --git a/coderd/chatd/instruction_test.go b/coderd/x/chatd/instruction_test.go similarity index 99% rename from coderd/chatd/instruction_test.go rename to coderd/x/chatd/instruction_test.go index c367099882..610648c241 100644 --- a/coderd/chatd/instruction_test.go +++ b/coderd/x/chatd/instruction_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" - "github.com/coder/coder/v2/coderd/chatd/chatprompt" + "github.com/coder/coder/v2/coderd/x/chatd/chatprompt" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/codersdk/workspacesdk" "github.com/coder/coder/v2/codersdk/workspacesdk/agentconnmock" diff --git a/coderd/chatd/integration_test.go b/coderd/x/chatd/integration_test.go similarity index 100% rename from coderd/chatd/integration_test.go rename to coderd/x/chatd/integration_test.go diff --git a/coderd/chatd/mcpclient/mcpclient.go b/coderd/x/chatd/mcpclient/mcpclient.go similarity index 100% rename from coderd/chatd/mcpclient/mcpclient.go rename to coderd/x/chatd/mcpclient/mcpclient.go diff --git a/coderd/chatd/mcpclient/mcpclient_test.go b/coderd/x/chatd/mcpclient/mcpclient_test.go similarity index 99% rename from coderd/chatd/mcpclient/mcpclient_test.go rename to coderd/x/chatd/mcpclient/mcpclient_test.go index 1520187299..172f1e4a34 100644 --- a/coderd/chatd/mcpclient/mcpclient_test.go +++ b/coderd/x/chatd/mcpclient/mcpclient_test.go @@ -17,8 +17,8 @@ import ( "github.com/stretchr/testify/require" "cdr.dev/slog/v3/sloggers/slogtest" - "github.com/coder/coder/v2/coderd/chatd/mcpclient" "github.com/coder/coder/v2/coderd/database" + "github.com/coder/coder/v2/coderd/x/chatd/mcpclient" ) // newTestMCPServer creates a streamable HTTP MCP server with the diff --git a/coderd/chatd/prompt.go b/coderd/x/chatd/prompt.go similarity index 100% rename from coderd/chatd/prompt.go rename to coderd/x/chatd/prompt.go diff --git a/coderd/chatd/quickgen.go b/coderd/x/chatd/quickgen.go similarity index 98% rename from coderd/chatd/quickgen.go rename to coderd/x/chatd/quickgen.go index b403b34b3e..77c9ff5bd0 100644 --- a/coderd/chatd/quickgen.go +++ b/coderd/x/chatd/quickgen.go @@ -16,11 +16,11 @@ import ( "golang.org/x/xerrors" "cdr.dev/slog/v3" - "github.com/coder/coder/v2/coderd/chatd/chatprompt" - "github.com/coder/coder/v2/coderd/chatd/chatprovider" - "github.com/coder/coder/v2/coderd/chatd/chatretry" "github.com/coder/coder/v2/coderd/database" coderdpubsub "github.com/coder/coder/v2/coderd/pubsub" + "github.com/coder/coder/v2/coderd/x/chatd/chatprompt" + "github.com/coder/coder/v2/coderd/x/chatd/chatprovider" + "github.com/coder/coder/v2/coderd/x/chatd/chatretry" "github.com/coder/coder/v2/codersdk" ) diff --git a/coderd/chatd/subagent.go b/coderd/x/chatd/subagent.go similarity index 99% rename from coderd/chatd/subagent.go rename to coderd/x/chatd/subagent.go index f44be88fcc..efb3461ffd 100644 --- a/coderd/chatd/subagent.go +++ b/coderd/x/chatd/subagent.go @@ -12,10 +12,10 @@ import ( "github.com/google/uuid" "golang.org/x/xerrors" - "github.com/coder/coder/v2/coderd/chatd/chatprompt" - "github.com/coder/coder/v2/coderd/chatd/chatprovider" "github.com/coder/coder/v2/coderd/database" coderdpubsub "github.com/coder/coder/v2/coderd/pubsub" + "github.com/coder/coder/v2/coderd/x/chatd/chatprompt" + "github.com/coder/coder/v2/coderd/x/chatd/chatprovider" "github.com/coder/coder/v2/codersdk" ) diff --git a/coderd/chatd/subagent_internal_test.go b/coderd/x/chatd/subagent_internal_test.go similarity index 99% rename from coderd/chatd/subagent_internal_test.go rename to coderd/x/chatd/subagent_internal_test.go index 6e77514d23..4e912d4d0a 100644 --- a/coderd/chatd/subagent_internal_test.go +++ b/coderd/x/chatd/subagent_internal_test.go @@ -12,13 +12,13 @@ import ( "github.com/stretchr/testify/require" "cdr.dev/slog/v3/sloggers/slogtest" - "github.com/coder/coder/v2/coderd/chatd/chatprovider" - "github.com/coder/coder/v2/coderd/chatd/chattool" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/database/dbauthz" "github.com/coder/coder/v2/coderd/database/dbgen" "github.com/coder/coder/v2/coderd/database/dbtestutil" "github.com/coder/coder/v2/coderd/database/pubsub" + "github.com/coder/coder/v2/coderd/x/chatd/chatprovider" + "github.com/coder/coder/v2/coderd/x/chatd/chattool" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/testutil" ) diff --git a/coderd/chatd/subagent_test.go b/coderd/x/chatd/subagent_test.go similarity index 99% rename from coderd/chatd/subagent_test.go rename to coderd/x/chatd/subagent_test.go index a154a57ccb..98b012514e 100644 --- a/coderd/chatd/subagent_test.go +++ b/coderd/x/chatd/subagent_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/coder/coder/v2/coderd/chatd" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/database/dbtestutil" + "github.com/coder/coder/v2/coderd/x/chatd" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/testutil" ) diff --git a/coderd/chatd/usagelimit.go b/coderd/x/chatd/usagelimit.go similarity index 100% rename from coderd/chatd/usagelimit.go rename to coderd/x/chatd/usagelimit.go diff --git a/coderd/chatd/usagelimit_test.go b/coderd/x/chatd/usagelimit_test.go similarity index 100% rename from coderd/chatd/usagelimit_test.go rename to coderd/x/chatd/usagelimit_test.go diff --git a/coderd/gitsync/gitsync.go b/coderd/x/gitsync/gitsync.go similarity index 100% rename from coderd/gitsync/gitsync.go rename to coderd/x/gitsync/gitsync.go diff --git a/coderd/gitsync/gitsync_test.go b/coderd/x/gitsync/gitsync_test.go similarity index 99% rename from coderd/gitsync/gitsync_test.go rename to coderd/x/gitsync/gitsync_test.go index 1f81f78616..1033865df1 100644 --- a/coderd/gitsync/gitsync_test.go +++ b/coderd/x/gitsync/gitsync_test.go @@ -18,8 +18,8 @@ import ( "cdr.dev/slog/v3/sloggers/slogtest" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/externalauth/gitprovider" - "github.com/coder/coder/v2/coderd/gitsync" "github.com/coder/coder/v2/coderd/util/ptr" + "github.com/coder/coder/v2/coderd/x/gitsync" "github.com/coder/quartz" ) diff --git a/coderd/gitsync/worker.go b/coderd/x/gitsync/worker.go similarity index 100% rename from coderd/gitsync/worker.go rename to coderd/x/gitsync/worker.go diff --git a/coderd/gitsync/worker_test.go b/coderd/x/gitsync/worker_test.go similarity index 99% rename from coderd/gitsync/worker_test.go rename to coderd/x/gitsync/worker_test.go index 07f4e889bb..11d412b9fe 100644 --- a/coderd/gitsync/worker_test.go +++ b/coderd/x/gitsync/worker_test.go @@ -21,8 +21,8 @@ import ( "github.com/coder/coder/v2/coderd/database/dbmock" "github.com/coder/coder/v2/coderd/database/dbtestutil" "github.com/coder/coder/v2/coderd/externalauth/gitprovider" - "github.com/coder/coder/v2/coderd/gitsync" "github.com/coder/coder/v2/coderd/util/ptr" + "github.com/coder/coder/v2/coderd/x/gitsync" "github.com/coder/coder/v2/testutil" "github.com/coder/quartz" ) diff --git a/enterprise/coderd/coderd.go b/enterprise/coderd/coderd.go index 1ff6da8b42..070d496dba 100644 --- a/enterprise/coderd/coderd.go +++ b/enterprise/coderd/coderd.go @@ -46,7 +46,6 @@ import ( "github.com/coder/coder/v2/coderd/wsbuilder" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/enterprise/aiseats" - entchatd "github.com/coder/coder/v2/enterprise/coderd/chatd" "github.com/coder/coder/v2/enterprise/coderd/connectionlog" "github.com/coder/coder/v2/enterprise/coderd/dbauthz" "github.com/coder/coder/v2/enterprise/coderd/enidpsync" @@ -56,6 +55,7 @@ import ( "github.com/coder/coder/v2/enterprise/coderd/proxyhealth" "github.com/coder/coder/v2/enterprise/coderd/schedule" "github.com/coder/coder/v2/enterprise/coderd/usage" + entchatd "github.com/coder/coder/v2/enterprise/coderd/x/chatd" "github.com/coder/coder/v2/enterprise/dbcrypt" "github.com/coder/coder/v2/enterprise/derpmesh" "github.com/coder/coder/v2/enterprise/replicasync" diff --git a/enterprise/coderd/chats_test.go b/enterprise/coderd/exp_chats_test.go similarity index 99% rename from enterprise/coderd/chats_test.go rename to enterprise/coderd/exp_chats_test.go index 9a95e4e739..a4d4abb00b 100644 --- a/enterprise/coderd/chats_test.go +++ b/enterprise/coderd/exp_chats_test.go @@ -11,10 +11,10 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/require" - "github.com/coder/coder/v2/coderd/chatd/chattest" "github.com/coder/coder/v2/coderd/coderdtest" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/database/dbtestutil" + "github.com/coder/coder/v2/coderd/x/chatd/chattest" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/enterprise/coderd/coderdenttest" "github.com/coder/coder/v2/enterprise/coderd/license" diff --git a/enterprise/coderd/chatd/chatd.go b/enterprise/coderd/x/chatd/chatd.go similarity index 99% rename from enterprise/coderd/chatd/chatd.go rename to enterprise/coderd/x/chatd/chatd.go index 881e1c3caa..d16a6b0fff 100644 --- a/enterprise/coderd/chatd/chatd.go +++ b/enterprise/coderd/x/chatd/chatd.go @@ -12,9 +12,9 @@ import ( "golang.org/x/xerrors" "cdr.dev/slog/v3" - osschatd "github.com/coder/coder/v2/coderd/chatd" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/util/ptr" + osschatd "github.com/coder/coder/v2/coderd/x/chatd" "github.com/coder/coder/v2/codersdk" "github.com/coder/quartz" "github.com/coder/websocket" diff --git a/enterprise/coderd/chatd/chatd_test.go b/enterprise/coderd/x/chatd/chatd_test.go similarity index 99% rename from enterprise/coderd/chatd/chatd_test.go rename to enterprise/coderd/x/chatd/chatd_test.go index 36486da71d..eef216b143 100644 --- a/enterprise/coderd/chatd/chatd_test.go +++ b/enterprise/coderd/x/chatd/chatd_test.go @@ -16,15 +16,15 @@ import ( "golang.org/x/xerrors" "cdr.dev/slog/v3/sloggers/slogtest" - osschatd "github.com/coder/coder/v2/coderd/chatd" - "github.com/coder/coder/v2/coderd/chatd/chattest" "github.com/coder/coder/v2/coderd/database" "github.com/coder/coder/v2/coderd/database/dbgen" "github.com/coder/coder/v2/coderd/database/dbtestutil" dbpubsub "github.com/coder/coder/v2/coderd/database/pubsub" coderdpubsub "github.com/coder/coder/v2/coderd/pubsub" + osschatd "github.com/coder/coder/v2/coderd/x/chatd" + "github.com/coder/coder/v2/coderd/x/chatd/chattest" "github.com/coder/coder/v2/codersdk" - entchatd "github.com/coder/coder/v2/enterprise/coderd/chatd" + entchatd "github.com/coder/coder/v2/enterprise/coderd/x/chatd" "github.com/coder/coder/v2/testutil" "github.com/coder/quartz" )