Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions cmd/impl/convert_pb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,29 @@ func TestChatAIEnabledByModelConfig(t *testing.T) {
enabled bool
}{
{name: "missing configuration"},
{name: "missing model", setting: model.TerminalConfig{GptApiKey: "key"}},
{name: "missing api key", setting: model.TerminalConfig{GptModel: "model"}},
{
name: "disabled with complete configuration",
setting: model.TerminalConfig{
ChatAIApiKey: "key", ChatAIModel: "model",
},
},
{
name: "missing model",
setting: model.TerminalConfig{
ChatAIEnabled: true, ChatAIApiKey: "key",
},
},
{
name: "missing api key",
setting: model.TerminalConfig{
ChatAIEnabled: true, ChatAIModel: "model",
},
},
{
name: "configured without base url",
setting: model.TerminalConfig{
GptApiKey: " key ", GptModel: " model ",
ChatAIEnabled: true,
ChatAIApiKey: " key ", ChatAIModel: " model ",
},
enabled: true,
},
Expand Down
16 changes: 7 additions & 9 deletions cmd/impl/jms.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@ type JMServer struct {
agentLimiter *agentRequestLimiter
}

// chatAIEnabledByModelConfig mirrors Koko new_terminal while Core versions do
// not expose CHAT_AI_ENABLED. The provider URL is optional and may use its
// default; both the API key and model are required.
func chatAIEnabledByModelConfig(setting model.TerminalConfig) bool {
return strings.TrimSpace(setting.GptApiKey) != "" &&
strings.TrimSpace(setting.GptModel) != ""
return setting.ChatAIEnabled &&
strings.TrimSpace(setting.ChatAIApiKey) != "" &&
strings.TrimSpace(setting.ChatAIModel) != ""
}

func (j *JMServer) GetTokenAuthInfo(ctx context.Context, req *pb.TokenRequest) (*pb.TokenResponse, error) {
Expand Down Expand Up @@ -414,10 +412,10 @@ func (j *JMServer) GetPublicSetting(ctx context.Context, empty *pb.Empty) (*pb.P
pbSetting := pb.PublicSetting{
XpackEnabled: data.XpackEnabled,
ValidLicense: data.ValidLicense,
GptBaseUrl: setting.GptBaseUrl,
GptApiKey: setting.GptApiKey,
GptProxy: setting.GptProxy,
GptModel: setting.GptModel,
ChatAiBaseUrl: setting.ChatAIBaseUrl,
ChatAiApiKey: setting.ChatAIApiKey,
ChatAiProxy: setting.ChatAIProxy,
ChatAiModel: setting.ChatAIModel,
LicenseContent: setting.LicenseContent,
}
return &pb.PublicSettingResponse{Status: &status, Data: &pbSetting}, nil
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.25.0

require (
github.com/gorilla/websocket v1.5.3
github.com/jumpserver-dev/sdk-go v0.0.0-20260821083952-82cf2e23d207
github.com/jumpserver-dev/sdk-go v0.0.0-20260828033126-f4e075c4714b
github.com/openai/openai-go/v3 v3.46.0
github.com/sirupsen/logrus v1.9.4
github.com/spf13/cobra v1.10.1
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
github.com/jumpserver-dev/sdk-go v0.0.0-20260821083952-82cf2e23d207 h1:hbYIaxsxF47XyTGRxxKt74lmPaGjjNlYBomnaSEhnR8=
github.com/jumpserver-dev/sdk-go v0.0.0-20260821083952-82cf2e23d207/go.mod h1:QmnL7BRb74/XY1nu8kWQWs6DHXt3uIaWkDCkQSRyZlM=
github.com/jumpserver-dev/sdk-go v0.0.0-20260828032902-adf185d94ce0 h1:Pzp9f9v+taN+i60jiFMqp4/NTfcrXLsGGZeNT4Qffl4=
github.com/jumpserver-dev/sdk-go v0.0.0-20260828032902-adf185d94ce0/go.mod h1:QmnL7BRb74/XY1nu8kWQWs6DHXt3uIaWkDCkQSRyZlM=
github.com/jumpserver-dev/sdk-go v0.0.0-20260828033126-f4e075c4714b h1:QKPiNmNt1LXPTKwRHs5OX4bbl6F5RIlgk8O1rpTT3A0=
github.com/jumpserver-dev/sdk-go v0.0.0-20260828033126-f4e075c4714b/go.mod h1:QmnL7BRb74/XY1nu8kWQWs6DHXt3uIaWkDCkQSRyZlM=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
Expand Down
10 changes: 5 additions & 5 deletions pkg/agent/config_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ func NewConfigWithDataRoot(
dataRoot string,
auditEnabled bool,
) Config {
name := strings.TrimSpace(modelConfig.ChatAIType)
name := strings.TrimSpace(modelConfig.ChatAIProvider)
if name == "" {
name = strings.TrimSpace(os.Getenv(providerEnvName))
}
if name == "" {
name = provider.NameGPT
name = provider.NameOpenAICompatible
}
providerConfig := provider.NormalizeConfig(provider.Config{
Name: name, APIKey: modelConfig.GptApiKey,
BaseURL: modelConfig.GptBaseUrl, Model: modelConfig.GptModel,
Proxy: modelConfig.GptProxy, ToolCallMode: os.Getenv(toolCallEnvName),
Name: name, APIKey: modelConfig.ChatAIApiKey,
BaseURL: modelConfig.ChatAIBaseUrl, Model: modelConfig.ChatAIModel,
Proxy: modelConfig.ChatAIProxy, ToolCallMode: os.Getenv(toolCallEnvName),
ReasoningMode: provider.ReasoningAuto,
Store: false, NativeCompaction: false,
ContextSoftLimitPercent: 80, RequestTimeout: 5 * time.Minute,
Expand Down
6 changes: 3 additions & 3 deletions pkg/agent/config_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"github.com/jumpserver/wisp/pkg/agent/provider"
)

func TestConfigPrefersChatAIType(t *testing.T) {
func TestConfigPrefersChatAIProvider(t *testing.T) {
t.Setenv(providerEnvName, provider.NameOpenAI)
config := NewConfig(model.TerminalConfig{ChatAIType: provider.NameDeepSeek})
config := NewConfig(model.TerminalConfig{ChatAIProvider: provider.NameDeepSeek})
if config.Provider.Name != provider.NameDeepSeek {
t.Fatalf("provider = %q, want ChatAIType", config.Provider.Name)
t.Fatalf("provider = %q, want ChatAIProvider", config.Provider.Name)
}
config = NewConfig(model.TerminalConfig{})
if config.Provider.Name != provider.NameOpenAI {
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestProviderRoutingAndModelLimits(t *testing.T) {
name string
transport string
}{
{NameGPT, "chat-completions"},
{NameOpenAICompatible, "chat-completions"},
{NameOpenAI, "responses"},
{NameDeepSeek, "deepseek-chat-completions"},
{"custom", "chat-completions"},
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/provider/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var registry = struct {
}{factories: make(map[string]Factory)}

func init() {
mustRegister(NameGPT, newCompatibleProvider)
mustRegister(NameOpenAICompatible, newCompatibleProvider)
mustRegister(NameOpenAI, newOpenAIProvider)
mustRegister(NameDeepSeek, newDeepSeekProvider)
mustRegister("deepseek", newDeepSeekProvider)
Expand Down Expand Up @@ -64,7 +64,7 @@ func NormalizeName(name string) string {
func NormalizeConfig(config Config) Config {
config.Name = NormalizeName(config.Name)
if config.Name == "" {
config.Name = NameGPT
config.Name = NameOpenAICompatible
}
config.Model = strings.TrimSpace(config.Model)
config.BaseURL = strings.TrimSpace(config.BaseURL)
Expand Down
6 changes: 3 additions & 3 deletions pkg/agent/provider/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
)

const (
NameGPT = "gpt"
NameOpenAI = "openai"
NameDeepSeek = "deep-seek"
NameOpenAICompatible = "openai_compatible"
NameOpenAI = "openai"
NameDeepSeek = "deep-seek"

ToolCallAuto = "auto"
ToolCallEnabled = "true"
Expand Down
Loading