mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: rename aiproxyd to aibridgeproxyd
This commit is contained in:
+5
-5
@@ -139,18 +139,18 @@ AI BRIDGE OPTIONS:
|
||||
Maximum number of AI Bridge requests per second per replica. Set to 0
|
||||
to disable (unlimited).
|
||||
|
||||
AI PROXY OPTIONS:
|
||||
--aiproxy-cert-file string, $CODER_AIPROXY_CERT_FILE
|
||||
AI BRIDGE PROXY OPTIONS:
|
||||
--aibridge-proxy-cert-file string, $CODER_AIBRIDGE_PROXY_CERT_FILE
|
||||
Path to the CA certificate file for MITM.
|
||||
|
||||
--aiproxy-enabled bool, $CODER_AIPROXY_ENABLED (default: false)
|
||||
--aibridge-proxy-enabled bool, $CODER_AIBRIDGE_PROXY_ENABLED (default: false)
|
||||
Enable the AI MITM proxy for intercepting and decrypting AI provider
|
||||
requests.
|
||||
|
||||
--aiproxy-key-file string, $CODER_AIPROXY_KEY_FILE
|
||||
--aibridge-proxy-key-file string, $CODER_AIBRIDGE_PROXY_KEY_FILE
|
||||
Path to the CA private key file for MITM.
|
||||
|
||||
--aiproxy-listen-addr string, $CODER_AIPROXY_LISTEN_ADDR (default: :8888)
|
||||
--aibridge-proxy-listen-addr string, $CODER_AIBRIDGE_PROXY_LISTEN_ADDR (default: :8888)
|
||||
The address the AI proxy will listen on.
|
||||
|
||||
CLIENT OPTIONS:
|
||||
|
||||
+1
-1
@@ -765,7 +765,7 @@ aibridge:
|
||||
# (unlimited).
|
||||
# (default: 0, type: int)
|
||||
rateLimit: 0
|
||||
aiproxy:
|
||||
aibridgeproxy:
|
||||
# Enable the AI MITM proxy for intercepting and decrypting AI provider requests.
|
||||
# (default: false, type: bool)
|
||||
enabled: false
|
||||
|
||||
Generated
+20
-20
@@ -12009,6 +12009,23 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.AIBridgeProxyConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cert_file": {
|
||||
"type": "string"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"key_file": {
|
||||
"type": "string"
|
||||
},
|
||||
"listen_addr": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.AIBridgeTokenUsage": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -12108,28 +12125,11 @@ const docTemplate = `{
|
||||
"codersdk.AIConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"aibridge_proxy": {
|
||||
"$ref": "#/definitions/codersdk.AIBridgeProxyConfig"
|
||||
},
|
||||
"bridge": {
|
||||
"$ref": "#/definitions/codersdk.AIBridgeConfig"
|
||||
},
|
||||
"proxy": {
|
||||
"$ref": "#/definitions/codersdk.AIProxyConfig"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.AIProxyConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cert_file": {
|
||||
"type": "string"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"key_file": {
|
||||
"type": "string"
|
||||
},
|
||||
"listen_addr": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Generated
+20
-20
@@ -10673,6 +10673,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.AIBridgeProxyConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cert_file": {
|
||||
"type": "string"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"key_file": {
|
||||
"type": "string"
|
||||
},
|
||||
"listen_addr": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.AIBridgeTokenUsage": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -10772,28 +10789,11 @@
|
||||
"codersdk.AIConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"aibridge_proxy": {
|
||||
"$ref": "#/definitions/codersdk.AIBridgeProxyConfig"
|
||||
},
|
||||
"bridge": {
|
||||
"$ref": "#/definitions/codersdk.AIBridgeConfig"
|
||||
},
|
||||
"proxy": {
|
||||
"$ref": "#/definitions/codersdk.AIProxyConfig"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.AIProxyConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cert_file": {
|
||||
"type": "string"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"key_file": {
|
||||
"type": "string"
|
||||
},
|
||||
"listen_addr": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+27
-27
@@ -1217,9 +1217,9 @@ func (c *DeploymentValues) Options() serpent.OptionSet {
|
||||
Name: "AI Bridge",
|
||||
YAML: "aibridge",
|
||||
}
|
||||
deploymentGroupAIProxy = serpent.Group{
|
||||
Name: "AI Proxy",
|
||||
YAML: "aiproxy",
|
||||
deploymentGroupAIBridgeProxy = serpent.Group{
|
||||
Name: "AI Bridge Proxy",
|
||||
YAML: "aibridgeproxy",
|
||||
}
|
||||
deploymentGroupRetention = serpent.Group{
|
||||
Name: "Retention",
|
||||
@@ -3448,45 +3448,45 @@ Write out the current server config as YAML to stdout.`,
|
||||
YAML: "rateLimit",
|
||||
},
|
||||
|
||||
// AI Proxy Options
|
||||
// AI Bridge Proxy Options
|
||||
{
|
||||
Name: "AI Proxy Enabled",
|
||||
Name: "AI Bridge Proxy Enabled",
|
||||
Description: "Enable the AI MITM proxy for intercepting and decrypting AI provider requests.",
|
||||
Flag: "aiproxy-enabled",
|
||||
Env: "CODER_AIPROXY_ENABLED",
|
||||
Value: &c.AI.ProxyConfig.Enabled,
|
||||
Flag: "aibridge-proxy-enabled",
|
||||
Env: "CODER_AIBRIDGE_PROXY_ENABLED",
|
||||
Value: &c.AI.BridgeProxyConfig.Enabled,
|
||||
Default: "false",
|
||||
Group: &deploymentGroupAIProxy,
|
||||
Group: &deploymentGroupAIBridgeProxy,
|
||||
YAML: "enabled",
|
||||
},
|
||||
{
|
||||
Name: "AI Proxy Listen Address",
|
||||
Name: "AI Bridge Proxy Listen Address",
|
||||
Description: "The address the AI proxy will listen on.",
|
||||
Flag: "aiproxy-listen-addr",
|
||||
Env: "CODER_AIPROXY_LISTEN_ADDR",
|
||||
Value: &c.AI.ProxyConfig.ListenAddr,
|
||||
Flag: "aibridge-proxy-listen-addr",
|
||||
Env: "CODER_AIBRIDGE_PROXY_LISTEN_ADDR",
|
||||
Value: &c.AI.BridgeProxyConfig.ListenAddr,
|
||||
Default: ":8888",
|
||||
Group: &deploymentGroupAIProxy,
|
||||
Group: &deploymentGroupAIBridgeProxy,
|
||||
YAML: "listen_addr",
|
||||
},
|
||||
{
|
||||
Name: "AI Proxy Certificate File",
|
||||
Name: "AI Bridge Proxy Certificate File",
|
||||
Description: "Path to the CA certificate file for MITM.",
|
||||
Flag: "aiproxy-cert-file",
|
||||
Env: "CODER_AIPROXY_CERT_FILE",
|
||||
Value: &c.AI.ProxyConfig.CertFile,
|
||||
Flag: "aibridge-proxy-cert-file",
|
||||
Env: "CODER_AIBRIDGE_PROXY_CERT_FILE",
|
||||
Value: &c.AI.BridgeProxyConfig.CertFile,
|
||||
Default: "",
|
||||
Group: &deploymentGroupAIProxy,
|
||||
Group: &deploymentGroupAIBridgeProxy,
|
||||
YAML: "cert_file",
|
||||
},
|
||||
{
|
||||
Name: "AI Proxy Key File",
|
||||
Name: "AI Bridge Proxy Key File",
|
||||
Description: "Path to the CA private key file for MITM.",
|
||||
Flag: "aiproxy-key-file",
|
||||
Env: "CODER_AIPROXY_KEY_FILE",
|
||||
Value: &c.AI.ProxyConfig.KeyFile,
|
||||
Flag: "aibridge-proxy-key-file",
|
||||
Env: "CODER_AIBRIDGE_PROXY_KEY_FILE",
|
||||
Value: &c.AI.BridgeProxyConfig.KeyFile,
|
||||
Default: "",
|
||||
Group: &deploymentGroupAIProxy,
|
||||
Group: &deploymentGroupAIBridgeProxy,
|
||||
YAML: "key_file",
|
||||
},
|
||||
|
||||
@@ -3582,7 +3582,7 @@ type AIBridgeBedrockConfig struct {
|
||||
SmallFastModel serpent.String `json:"small_fast_model" typescript:",notnull"`
|
||||
}
|
||||
|
||||
type AIProxyConfig struct {
|
||||
type AIBridgeProxyConfig struct {
|
||||
Enabled serpent.Bool `json:"enabled" typescript:",notnull"`
|
||||
ListenAddr serpent.String `json:"listen_addr" typescript:",notnull"`
|
||||
CertFile serpent.String `json:"cert_file" typescript:",notnull"`
|
||||
@@ -3590,8 +3590,8 @@ type AIProxyConfig struct {
|
||||
}
|
||||
|
||||
type AIConfig struct {
|
||||
BridgeConfig AIBridgeConfig `json:"bridge,omitempty"`
|
||||
ProxyConfig AIProxyConfig `json:"proxy,omitempty"`
|
||||
BridgeConfig AIBridgeConfig `json:"bridge,omitempty"`
|
||||
BridgeProxyConfig AIBridgeProxyConfig `json:"aibridge_proxy,omitempty"`
|
||||
}
|
||||
|
||||
type SupportConfig struct {
|
||||
|
||||
Generated
+6
-6
@@ -162,6 +162,12 @@ curl -X GET http://coder-server:8080/api/v2/deployment/config \
|
||||
},
|
||||
"agent_stat_refresh_interval": 0,
|
||||
"ai": {
|
||||
"aibridge_proxy": {
|
||||
"cert_file": "string",
|
||||
"enabled": true,
|
||||
"key_file": "string",
|
||||
"listen_addr": "string"
|
||||
},
|
||||
"bridge": {
|
||||
"anthropic": {
|
||||
"base_url": "string",
|
||||
@@ -183,12 +189,6 @@ curl -X GET http://coder-server:8080/api/v2/deployment/config \
|
||||
},
|
||||
"rate_limit": 0,
|
||||
"retention": 0
|
||||
},
|
||||
"proxy": {
|
||||
"cert_file": "string",
|
||||
"enabled": true,
|
||||
"key_file": "string",
|
||||
"listen_addr": "string"
|
||||
}
|
||||
},
|
||||
"allow_workspace_renames": true,
|
||||
|
||||
Generated
+42
-42
@@ -592,6 +592,26 @@
|
||||
| `base_url` | string | false | | |
|
||||
| `key` | string | false | | |
|
||||
|
||||
## codersdk.AIBridgeProxyConfig
|
||||
|
||||
```json
|
||||
{
|
||||
"cert_file": "string",
|
||||
"enabled": true,
|
||||
"key_file": "string",
|
||||
"listen_addr": "string"
|
||||
}
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|---------------|---------|----------|--------------|-------------|
|
||||
| `cert_file` | string | false | | |
|
||||
| `enabled` | boolean | false | | |
|
||||
| `key_file` | string | false | | |
|
||||
| `listen_addr` | string | false | | |
|
||||
|
||||
## codersdk.AIBridgeTokenUsage
|
||||
|
||||
```json
|
||||
@@ -690,6 +710,12 @@
|
||||
|
||||
```json
|
||||
{
|
||||
"aibridge_proxy": {
|
||||
"cert_file": "string",
|
||||
"enabled": true,
|
||||
"key_file": "string",
|
||||
"listen_addr": "string"
|
||||
},
|
||||
"bridge": {
|
||||
"anthropic": {
|
||||
"base_url": "string",
|
||||
@@ -711,42 +737,16 @@
|
||||
},
|
||||
"rate_limit": 0,
|
||||
"retention": 0
|
||||
},
|
||||
"proxy": {
|
||||
"cert_file": "string",
|
||||
"enabled": true,
|
||||
"key_file": "string",
|
||||
"listen_addr": "string"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|----------|----------------------------------------------------|----------|--------------|-------------|
|
||||
| `bridge` | [codersdk.AIBridgeConfig](#codersdkaibridgeconfig) | false | | |
|
||||
| `proxy` | [codersdk.AIProxyConfig](#codersdkaiproxyconfig) | false | | |
|
||||
|
||||
## codersdk.AIProxyConfig
|
||||
|
||||
```json
|
||||
{
|
||||
"cert_file": "string",
|
||||
"enabled": true,
|
||||
"key_file": "string",
|
||||
"listen_addr": "string"
|
||||
}
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|---------------|---------|----------|--------------|-------------|
|
||||
| `cert_file` | string | false | | |
|
||||
| `enabled` | boolean | false | | |
|
||||
| `key_file` | string | false | | |
|
||||
| `listen_addr` | string | false | | |
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|------------------|--------------------------------------------------------------|----------|--------------|-------------|
|
||||
| `aibridge_proxy` | [codersdk.AIBridgeProxyConfig](#codersdkaibridgeproxyconfig) | false | | |
|
||||
| `bridge` | [codersdk.AIBridgeConfig](#codersdkaibridgeconfig) | false | | |
|
||||
|
||||
## codersdk.APIAllowListTarget
|
||||
|
||||
@@ -2622,6 +2622,12 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
|
||||
},
|
||||
"agent_stat_refresh_interval": 0,
|
||||
"ai": {
|
||||
"aibridge_proxy": {
|
||||
"cert_file": "string",
|
||||
"enabled": true,
|
||||
"key_file": "string",
|
||||
"listen_addr": "string"
|
||||
},
|
||||
"bridge": {
|
||||
"anthropic": {
|
||||
"base_url": "string",
|
||||
@@ -2643,12 +2649,6 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
|
||||
},
|
||||
"rate_limit": 0,
|
||||
"retention": 0
|
||||
},
|
||||
"proxy": {
|
||||
"cert_file": "string",
|
||||
"enabled": true,
|
||||
"key_file": "string",
|
||||
"listen_addr": "string"
|
||||
}
|
||||
},
|
||||
"allow_workspace_renames": true,
|
||||
@@ -3159,6 +3159,12 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
|
||||
},
|
||||
"agent_stat_refresh_interval": 0,
|
||||
"ai": {
|
||||
"aibridge_proxy": {
|
||||
"cert_file": "string",
|
||||
"enabled": true,
|
||||
"key_file": "string",
|
||||
"listen_addr": "string"
|
||||
},
|
||||
"bridge": {
|
||||
"anthropic": {
|
||||
"base_url": "string",
|
||||
@@ -3180,12 +3186,6 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
|
||||
},
|
||||
"rate_limit": 0,
|
||||
"retention": 0
|
||||
},
|
||||
"proxy": {
|
||||
"cert_file": "string",
|
||||
"enabled": true,
|
||||
"key_file": "string",
|
||||
"listen_addr": "string"
|
||||
}
|
||||
},
|
||||
"allow_workspace_renames": true,
|
||||
|
||||
Generated
+26
-26
@@ -1814,45 +1814,45 @@ Maximum number of concurrent AI Bridge requests per replica. Set to 0 to disable
|
||||
|
||||
Maximum number of AI Bridge requests per second per replica. Set to 0 to disable (unlimited).
|
||||
|
||||
### --aiproxy-enabled
|
||||
### --aibridge-proxy-enabled
|
||||
|
||||
| | |
|
||||
|-------------|-------------------------------------|
|
||||
| Type | <code>bool</code> |
|
||||
| Environment | <code>$CODER_AIPROXY_ENABLED</code> |
|
||||
| YAML | <code>aiproxy.enabled</code> |
|
||||
| Default | <code>false</code> |
|
||||
| | |
|
||||
|-------------|--------------------------------------------|
|
||||
| Type | <code>bool</code> |
|
||||
| Environment | <code>$CODER_AIBRIDGE_PROXY_ENABLED</code> |
|
||||
| YAML | <code>aibridgeproxy.enabled</code> |
|
||||
| Default | <code>false</code> |
|
||||
|
||||
Enable the AI MITM proxy for intercepting and decrypting AI provider requests.
|
||||
|
||||
### --aiproxy-listen-addr
|
||||
### --aibridge-proxy-listen-addr
|
||||
|
||||
| | |
|
||||
|-------------|-----------------------------------------|
|
||||
| Type | <code>string</code> |
|
||||
| Environment | <code>$CODER_AIPROXY_LISTEN_ADDR</code> |
|
||||
| YAML | <code>aiproxy.listen_addr</code> |
|
||||
| Default | <code>:8888</code> |
|
||||
| | |
|
||||
|-------------|------------------------------------------------|
|
||||
| Type | <code>string</code> |
|
||||
| Environment | <code>$CODER_AIBRIDGE_PROXY_LISTEN_ADDR</code> |
|
||||
| YAML | <code>aibridgeproxy.listen_addr</code> |
|
||||
| Default | <code>:8888</code> |
|
||||
|
||||
The address the AI proxy will listen on.
|
||||
|
||||
### --aiproxy-cert-file
|
||||
### --aibridge-proxy-cert-file
|
||||
|
||||
| | |
|
||||
|-------------|---------------------------------------|
|
||||
| Type | <code>string</code> |
|
||||
| Environment | <code>$CODER_AIPROXY_CERT_FILE</code> |
|
||||
| YAML | <code>aiproxy.cert_file</code> |
|
||||
| | |
|
||||
|-------------|----------------------------------------------|
|
||||
| Type | <code>string</code> |
|
||||
| Environment | <code>$CODER_AIBRIDGE_PROXY_CERT_FILE</code> |
|
||||
| YAML | <code>aibridgeproxy.cert_file</code> |
|
||||
|
||||
Path to the CA certificate file for MITM.
|
||||
|
||||
### --aiproxy-key-file
|
||||
### --aibridge-proxy-key-file
|
||||
|
||||
| | |
|
||||
|-------------|--------------------------------------|
|
||||
| Type | <code>string</code> |
|
||||
| Environment | <code>$CODER_AIPROXY_KEY_FILE</code> |
|
||||
| YAML | <code>aiproxy.key_file</code> |
|
||||
| | |
|
||||
|-------------|---------------------------------------------|
|
||||
| Type | <code>string</code> |
|
||||
| Environment | <code>$CODER_AIBRIDGE_PROXY_KEY_FILE</code> |
|
||||
| YAML | <code>aibridgeproxy.key_file</code> |
|
||||
|
||||
Path to the CA private key file for MITM.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package aiproxyd
|
||||
package aibridgeproxyd
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -74,7 +74,7 @@ func New(ctx context.Context, logger slog.Logger, opts Options) (*Server, error)
|
||||
go func() {
|
||||
logger.Info(ctx, "starting AI proxy", slog.F("addr", opts.ListenAddr))
|
||||
if err := srv.httpServer.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
logger.Error(ctx, "aiproxyd server error", slog.Error(err))
|
||||
logger.Error(ctx, "aibridgeproxyd server error", slog.Error(err))
|
||||
}
|
||||
}()
|
||||
|
||||
+9
-9
@@ -1,4 +1,4 @@
|
||||
package aiproxyd_test
|
||||
package aibridgeproxyd_test
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
"cdr.dev/slog/sloggers/slogtest"
|
||||
|
||||
"github.com/coder/coder/v2/enterprise/aiproxyd"
|
||||
"github.com/coder/coder/v2/enterprise/aibridgeproxyd"
|
||||
"github.com/coder/coder/v2/testutil"
|
||||
)
|
||||
|
||||
@@ -72,7 +72,7 @@ func TestNew(t *testing.T) {
|
||||
certFile, keyFile := generateTestCA(t)
|
||||
logger := slogtest.Make(t, nil)
|
||||
|
||||
_, err := aiproxyd.New(t.Context(), logger, aiproxyd.Options{
|
||||
_, err := aibridgeproxyd.New(t.Context(), logger, aibridgeproxyd.Options{
|
||||
ListenAddr: "",
|
||||
CertFile: certFile,
|
||||
KeyFile: keyFile,
|
||||
@@ -86,7 +86,7 @@ func TestNew(t *testing.T) {
|
||||
|
||||
logger := slogtest.Make(t, nil)
|
||||
|
||||
_, err := aiproxyd.New(t.Context(), logger, aiproxyd.Options{
|
||||
_, err := aibridgeproxyd.New(t.Context(), logger, aibridgeproxyd.Options{
|
||||
ListenAddr: ":0",
|
||||
KeyFile: "key.pem",
|
||||
})
|
||||
@@ -99,7 +99,7 @@ func TestNew(t *testing.T) {
|
||||
|
||||
logger := slogtest.Make(t, nil)
|
||||
|
||||
_, err := aiproxyd.New(t.Context(), logger, aiproxyd.Options{
|
||||
_, err := aibridgeproxyd.New(t.Context(), logger, aibridgeproxyd.Options{
|
||||
ListenAddr: ":0",
|
||||
CertFile: "cert.pem",
|
||||
})
|
||||
@@ -112,7 +112,7 @@ func TestNew(t *testing.T) {
|
||||
|
||||
logger := slogtest.Make(t, nil)
|
||||
|
||||
_, err := aiproxyd.New(t.Context(), logger, aiproxyd.Options{
|
||||
_, err := aibridgeproxyd.New(t.Context(), logger, aibridgeproxyd.Options{
|
||||
ListenAddr: ":0",
|
||||
CertFile: "/nonexistent/cert.pem",
|
||||
KeyFile: "/nonexistent/key.pem",
|
||||
@@ -127,7 +127,7 @@ func TestNew(t *testing.T) {
|
||||
certFile, keyFile := generateTestCA(t)
|
||||
logger := slogtest.Make(t, nil)
|
||||
|
||||
srv, err := aiproxyd.New(t.Context(), logger, aiproxyd.Options{
|
||||
srv, err := aibridgeproxyd.New(t.Context(), logger, aibridgeproxyd.Options{
|
||||
ListenAddr: "127.0.0.1:0",
|
||||
CertFile: certFile,
|
||||
KeyFile: keyFile,
|
||||
@@ -146,7 +146,7 @@ func TestClose(t *testing.T) {
|
||||
certFile, keyFile := generateTestCA(t)
|
||||
logger := slogtest.Make(t, nil)
|
||||
|
||||
srv, err := aiproxyd.New(t.Context(), logger, aiproxyd.Options{
|
||||
srv, err := aibridgeproxyd.New(t.Context(), logger, aibridgeproxyd.Options{
|
||||
ListenAddr: "127.0.0.1:0",
|
||||
CertFile: certFile,
|
||||
KeyFile: keyFile,
|
||||
@@ -175,7 +175,7 @@ func TestProxy_MITM(t *testing.T) {
|
||||
logger := slogtest.Make(t, nil)
|
||||
|
||||
// Start the proxy server.
|
||||
srv, err := aiproxyd.New(t.Context(), logger, aiproxyd.Options{
|
||||
srv, err := aibridgeproxyd.New(t.Context(), logger, aibridgeproxyd.Options{
|
||||
ListenAddr: "127.0.0.1:8888",
|
||||
CertFile: certFile,
|
||||
KeyFile: keyFile,
|
||||
@@ -0,0 +1,30 @@
|
||||
//go:build !slim
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/coder/coder/v2/enterprise/aibridgeproxyd"
|
||||
"github.com/coder/coder/v2/enterprise/coderd"
|
||||
)
|
||||
|
||||
func newAIBridgeProxyDaemon(coderAPI *coderd.API) (*aibridgeproxyd.Server, error) {
|
||||
ctx := context.Background()
|
||||
coderAPI.Logger.Debug(ctx, "starting in-memory aibridgeproxy daemon")
|
||||
|
||||
logger := coderAPI.Logger.Named("aibridgeproxyd")
|
||||
|
||||
srv, err := aibridgeproxyd.New(ctx, logger, aibridgeproxyd.Options{
|
||||
ListenAddr: coderAPI.DeploymentValues.AI.BridgeProxyConfig.ListenAddr.String(),
|
||||
CertFile: coderAPI.DeploymentValues.AI.BridgeProxyConfig.CertFile.String(),
|
||||
KeyFile: coderAPI.DeploymentValues.AI.BridgeProxyConfig.KeyFile.String(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to start in-memory aibridgeproxy daemon: %w", err)
|
||||
}
|
||||
|
||||
return srv, nil
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
//go:build !slim
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/coder/coder/v2/enterprise/aiproxyd"
|
||||
"github.com/coder/coder/v2/enterprise/coderd"
|
||||
)
|
||||
|
||||
func newAIProxyDaemon(coderAPI *coderd.API) (*aiproxyd.Server, error) {
|
||||
ctx := context.Background()
|
||||
coderAPI.Logger.Debug(ctx, "starting in-memory aiproxy daemon")
|
||||
|
||||
logger := coderAPI.Logger.Named("aiproxyd")
|
||||
|
||||
srv, err := aiproxyd.New(ctx, logger, aiproxyd.Options{
|
||||
ListenAddr: coderAPI.DeploymentValues.AI.ProxyConfig.ListenAddr.String(),
|
||||
CertFile: coderAPI.DeploymentValues.AI.ProxyConfig.CertFile.String(),
|
||||
KeyFile: coderAPI.DeploymentValues.AI.ProxyConfig.KeyFile.String(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to start in-memory aiproxy daemon: %w", err)
|
||||
}
|
||||
|
||||
return srv, nil
|
||||
}
|
||||
@@ -166,11 +166,11 @@ func (r *RootCmd) Server(_ func()) *serpent.Command {
|
||||
}
|
||||
|
||||
// In-memory AI proxy daemon
|
||||
if options.DeploymentValues.AI.ProxyConfig.Enabled.Value() {
|
||||
aiProxyServer, err := newAIProxyDaemon(api)
|
||||
if options.DeploymentValues.AI.BridgeProxyConfig.Enabled.Value() {
|
||||
aiProxyServer, err := newAIBridgeProxyDaemon(api)
|
||||
if err != nil {
|
||||
_ = closers.Close()
|
||||
return nil, nil, xerrors.Errorf("create aiproxyd: %w", err)
|
||||
return nil, nil, xerrors.Errorf("create aibridgeproxyd: %w", err)
|
||||
}
|
||||
closers.Add(aiProxyServer)
|
||||
}
|
||||
|
||||
+5
-5
@@ -140,18 +140,18 @@ AI BRIDGE OPTIONS:
|
||||
Maximum number of AI Bridge requests per second per replica. Set to 0
|
||||
to disable (unlimited).
|
||||
|
||||
AI PROXY OPTIONS:
|
||||
--aiproxy-cert-file string, $CODER_AIPROXY_CERT_FILE
|
||||
AI BRIDGE PROXY OPTIONS:
|
||||
--aibridge-proxy-cert-file string, $CODER_AIBRIDGE_PROXY_CERT_FILE
|
||||
Path to the CA certificate file for MITM.
|
||||
|
||||
--aiproxy-enabled bool, $CODER_AIPROXY_ENABLED (default: false)
|
||||
--aibridge-proxy-enabled bool, $CODER_AIBRIDGE_PROXY_ENABLED (default: false)
|
||||
Enable the AI MITM proxy for intercepting and decrypting AI provider
|
||||
requests.
|
||||
|
||||
--aiproxy-key-file string, $CODER_AIPROXY_KEY_FILE
|
||||
--aibridge-proxy-key-file string, $CODER_AIBRIDGE_PROXY_KEY_FILE
|
||||
Path to the CA private key file for MITM.
|
||||
|
||||
--aiproxy-listen-addr string, $CODER_AIPROXY_LISTEN_ADDR (default: :8888)
|
||||
--aibridge-proxy-listen-addr string, $CODER_AIBRIDGE_PROXY_LISTEN_ADDR (default: :8888)
|
||||
The address the AI proxy will listen on.
|
||||
|
||||
CLIENT OPTIONS:
|
||||
|
||||
Generated
+9
-9
@@ -65,6 +65,14 @@ export interface AIBridgeOpenAIConfig {
|
||||
readonly key: string;
|
||||
}
|
||||
|
||||
// From codersdk/deployment.go
|
||||
export interface AIBridgeProxyConfig {
|
||||
readonly enabled: boolean;
|
||||
readonly listen_addr: string;
|
||||
readonly cert_file: string;
|
||||
readonly key_file: string;
|
||||
}
|
||||
|
||||
// From codersdk/aibridge.go
|
||||
export interface AIBridgeTokenUsage {
|
||||
readonly id: string;
|
||||
@@ -106,15 +114,7 @@ export interface AIBridgeUserPrompt {
|
||||
// From codersdk/deployment.go
|
||||
export interface AIConfig {
|
||||
readonly bridge?: AIBridgeConfig;
|
||||
readonly proxy?: AIProxyConfig;
|
||||
}
|
||||
|
||||
// From codersdk/deployment.go
|
||||
export interface AIProxyConfig {
|
||||
readonly enabled: boolean;
|
||||
readonly listen_addr: string;
|
||||
readonly cert_file: string;
|
||||
readonly key_file: string;
|
||||
readonly aibridge_proxy?: AIBridgeProxyConfig;
|
||||
}
|
||||
|
||||
// From codersdk/allowlist.go
|
||||
|
||||
Reference in New Issue
Block a user