Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit615585d

Browse files
authored
feat: addaibridgedserver pkg (#19902)
1 parentc8742ba commit615585d

15 files changed

+1587
-347
lines changed

‎Makefile‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ GEN_FILES := \
641641
provisionersdk/proto/provisioner.pb.go\
642642
provisionerd/proto/provisionerd.pb.go\
643643
vpn/vpn.pb.go\
644-
aibridged/proto/aibridged.pb.go\
644+
enterprise/x/aibridged/proto/aibridged.pb.go\
645645
$(DB_GEN_FILES)\
646646
$(SITE_GEN_FILES)\
647647
coderd/rbac/object_gen.go\
@@ -690,7 +690,7 @@ gen/mark-fresh:
690690
provisionersdk/proto/provisioner.pb.go\
691691
provisionerd/proto/provisionerd.pb.go\
692692
vpn/vpn.pb.go\
693-
aibridged/proto/aibridged.pb.go\
693+
enterprise/x/aibridged/proto/aibridged.pb.go\
694694
coderd/database/dump.sql\
695695
$(DB_GEN_FILES)\
696696
site/src/api/typesGenerated.ts\
@@ -810,13 +810,13 @@ vpn/vpn.pb.go: vpn/vpn.proto
810810
--go_opt=paths=source_relative\
811811
./vpn/vpn.proto
812812

813-
aibridged/proto/aibridged.pb.go: aibridged/proto/aibridged.proto
813+
enterprise/x/aibridged/proto/aibridged.pb.go:enterprise/x/aibridged/proto/aibridged.proto
814814
protoc\
815815
--go_out=.\
816816
--go_opt=paths=source_relative\
817817
--go-drpc_out=.\
818818
--go-drpc_opt=paths=source_relative\
819-
./aibridged/proto/aibridged.proto
819+
./enterprise/x/aibridged/proto/aibridged.proto
820820

821821
site/src/api/typesGenerated.ts: site/node_modules/.installed$(wildcard scripts/apitypings/*)$(shell find ./codersdk$(FIND_EXCLUSIONS) -type f -name '*.go')
822822
# -C sets the directory for the go run command

‎coderd/database/dump.sql‎

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTERTABLE aibridge_interceptions DROP COLUMN metadata;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTERTABLE aibridge_interceptions ADD COLUMN metadata JSONB DEFAULTNULL;

‎coderd/database/models.go‎

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries.sql.go‎

Lines changed: 13 additions & 9 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/aibridge.sql‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- name: InsertAIBridgeInterception :one
2-
INSERT INTO aibridge_interceptions (id, initiator_id, provider, model, started_at)
3-
VALUES (@id::uuid, @initiator_id::uuid, @provider, @model, @started_at)
2+
INSERT INTO aibridge_interceptions (id, initiator_id, provider, model,metadata,started_at)
3+
VALUES (@id::uuid, @initiator_id::uuid, @provider, @model,COALESCE(@metadata::jsonb,'{}'::jsonb),@started_at)
44
RETURNING*;
55

66
-- name: InsertAIBridgeTokenUsage :exec

‎coderd/mcp/mcp.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const (
2424
MCPServerName="Coder"
2525
// MCPServerInstructions is the instructions text for the MCP server.
2626
MCPServerInstructions="Coder MCP Server providing workspace and template management tools"
27+
28+
// Used in tests and aibridge.
29+
MCPEndpoint="/api/experimental/mcp/http"
2730
)
2831

2932
// Server represents an MCP HTTP server instance

‎coderd/mcp/mcp_e2e_test.go‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestMCPHTTP_E2E_ClientIntegration(t *testing.T) {
3434
_=coderdtest.CreateFirstUser(t,coderClient)
3535

3636
// Create MCP client pointing to our endpoint
37-
mcpURL:=api.AccessURL.String()+"/api/experimental/mcp/http"
37+
mcpURL:=api.AccessURL.String()+mcpserver.MCPEndpoint
3838

3939
// Configure client with authentication headers using RFC 6750 Bearer token
4040
mcpClient,err:=mcpclient.NewStreamableHttpClient(mcpURL,
@@ -133,7 +133,7 @@ func TestMCPHTTP_E2E_UnauthenticatedAccess(t *testing.T) {
133133
defercancel()
134134

135135
// Test direct HTTP request to verify 401 status code
136-
mcpURL:=api.AccessURL.String()+"/api/experimental/mcp/http"
136+
mcpURL:=api.AccessURL.String()+mcpserver.MCPEndpoint
137137

138138
// Make a POST request without authentication (MCP over HTTP uses POST)
139139
//nolint:gosec // Test code using controlled localhost URL
@@ -197,7 +197,7 @@ func TestMCPHTTP_E2E_ToolWithWorkspace(t *testing.T) {
197197
workspace:=coderdtest.CreateWorkspace(t,coderClient,template.ID)
198198

199199
// Create MCP client
200-
mcpURL:=api.AccessURL.String()+"/api/experimental/mcp/http"
200+
mcpURL:=api.AccessURL.String()+mcpserver.MCPEndpoint
201201
mcpClient,err:=mcpclient.NewStreamableHttpClient(mcpURL,
202202
transport.WithHTTPHeaders(map[string]string{
203203
"Authorization":"Bearer "+coderClient.SessionToken(),
@@ -280,7 +280,7 @@ func TestMCPHTTP_E2E_ErrorHandling(t *testing.T) {
280280
_=coderdtest.CreateFirstUser(t,coderClient)
281281

282282
// Create MCP client
283-
mcpURL:=api.AccessURL.String()+"/api/experimental/mcp/http"
283+
mcpURL:=api.AccessURL.String()+mcpserver.MCPEndpoint
284284
mcpClient,err:=mcpclient.NewStreamableHttpClient(mcpURL,
285285
transport.WithHTTPHeaders(map[string]string{
286286
"Authorization":"Bearer "+coderClient.SessionToken(),
@@ -339,7 +339,7 @@ func TestMCPHTTP_E2E_ConcurrentRequests(t *testing.T) {
339339
_=coderdtest.CreateFirstUser(t,coderClient)
340340

341341
// Create MCP client
342-
mcpURL:=api.AccessURL.String()+"/api/experimental/mcp/http"
342+
mcpURL:=api.AccessURL.String()+mcpserver.MCPEndpoint
343343
mcpClient,err:=mcpclient.NewStreamableHttpClient(mcpURL,
344344
transport.WithHTTPHeaders(map[string]string{
345345
"Authorization":"Bearer "+coderClient.SessionToken(),
@@ -410,7 +410,7 @@ func TestMCPHTTP_E2E_RFC6750_UnauthenticatedRequest(t *testing.T) {
410410
// Make a request without any authentication headers
411411
req:=&http.Request{
412412
Method:"POST",
413-
URL:mustParseURL(t,api.AccessURL.String()+"/api/experimental/mcp/http"),
413+
URL:mustParseURL(t,api.AccessURL.String()+mcpserver.MCPEndpoint),
414414
Header:make(http.Header),
415415
}
416416

@@ -493,7 +493,7 @@ func TestMCPHTTP_E2E_OAuth2_EndToEnd(t *testing.T) {
493493
// In a real OAuth2 flow, this would be an OAuth2 access token
494494
sessionToken:=coderClient.SessionToken()
495495

496-
mcpURL:=api.AccessURL.String()+"/api/experimental/mcp/http"
496+
mcpURL:=api.AccessURL.String()+mcpserver.MCPEndpoint
497497
mcpClient,err:=mcpclient.NewStreamableHttpClient(mcpURL,
498498
transport.WithHTTPHeaders(map[string]string{
499499
"Authorization":"Bearer "+sessionToken,
@@ -640,7 +640,7 @@ func TestMCPHTTP_E2E_OAuth2_EndToEnd(t *testing.T) {
640640
t.Logf("Successfully obtained refresh token: %s...",refreshToken[:10])
641641

642642
// Step 3: Use access token to authenticate with MCP endpoint
643-
mcpURL:=api.AccessURL.String()+"/api/experimental/mcp/http"
643+
mcpURL:=api.AccessURL.String()+mcpserver.MCPEndpoint
644644
mcpClient,err:=mcpclient.NewStreamableHttpClient(mcpURL,
645645
transport.WithHTTPHeaders(map[string]string{
646646
"Authorization":"Bearer "+accessToken,
@@ -776,7 +776,7 @@ func TestMCPHTTP_E2E_OAuth2_EndToEnd(t *testing.T) {
776776
t.Parallel()
777777
req:=&http.Request{
778778
Method:"POST",
779-
URL:mustParseURL(t,api.AccessURL.String()+"/api/experimental/mcp/http"),
779+
URL:mustParseURL(t,api.AccessURL.String()+mcpserver.MCPEndpoint),
780780
Header:map[string][]string{
781781
"Authorization": {"Bearer invalid_token_value"},
782782
"Content-Type": {"application/json"},
@@ -805,7 +805,7 @@ func TestMCPHTTP_E2E_OAuth2_EndToEnd(t *testing.T) {
805805
t.Run("DynamicClientRegistrationWithMCPFlow",func(t*testing.T) {
806806
t.Parallel()
807807
// Step 1: Attempt unauthenticated MCP access
808-
mcpURL:=api.AccessURL.String()+"/api/experimental/mcp/http"
808+
mcpURL:=api.AccessURL.String()+mcpserver.MCPEndpoint
809809
req:=&http.Request{
810810
Method:"POST",
811811
URL:mustParseURL(t,mcpURL),
@@ -1232,7 +1232,7 @@ func TestMCPHTTP_E2E_ChatGPTEndpoint(t *testing.T) {
12321232
template:=coderdtest.CreateTemplate(t,coderClient,user.OrganizationID,version.ID)
12331233

12341234
// Create MCP client pointing to the ChatGPT endpoint
1235-
mcpURL:=api.AccessURL.String()+"/api/experimental/mcp/http?toolset=chatgpt"
1235+
mcpURL:=api.AccessURL.String()+mcpserver.MCPEndpoint+"?toolset=chatgpt"
12361236

12371237
// Configure client with authentication headers using RFC 6750 Bearer token
12381238
mcpClient,err:=mcpclient.NewStreamableHttpClient(mcpURL,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp