Skip to content

Commit a8a899c

Browse files
committed
chore: refactor InteractionType and error
1 parent a56cfe7 commit a8a899c

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

cmd/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func parseAgentType(firstArg string, agentTypeVar string) (AgentType, error) {
7070
}
7171

7272
func parseInteractionType(interactionModeVar string) (types.InteractionType, error) {
73-
return types.CLIInteractionType, nil
73+
return types.InteractionTypeCLI, nil
7474
}
7575

7676
func runServer(ctx context.Context, logger *slog.Logger, argsToPass []string) error {

lib/httpapi/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ func NewServer(ctx context.Context, config ServerConfig) (*Server, error) {
195195
}
196196

197197
// Get the appropriate Interaction Handler
198-
if config.InteractionType == types.CLIInteractionType {
198+
if config.InteractionType == types.InteractionTypeCLI {
199199
s.AgentHandler = cli.NewCLIHandler(ctx, logger, config.Process, config.AgentType)
200-
} else if config.InteractionType == types.SDKInteractionType {
200+
} else if config.InteractionType == types.InteractionTypeSDK {
201201
// TODO add a SDKHandler for SDK
202202
} else {
203-
return nil, xerrors.Errorf("%s", config.InteractionType)
203+
return nil, xerrors.Errorf("unknown interaction type %q", config.InteractionType)
204204
}
205205

206206
// Register API routes

lib/httpapi/server_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestOpenAPISchema(t *testing.T) {
5555
ChatBasePath: "/chat",
5656
AllowedHosts: []string{"*"},
5757
AllowedOrigins: []string{"*"},
58-
InteractionType: types.CLIInteractionType,
58+
InteractionType: types.InteractionTypeCLI,
5959
})
6060
require.NoError(t, err)
6161
currentSchemaStr := srv.GetOpenAPI()
@@ -108,7 +108,7 @@ func TestServer_redirectToChat(t *testing.T) {
108108
ChatBasePath: tc.chatBasePath,
109109
AllowedHosts: []string{"*"},
110110
AllowedOrigins: []string{"*"},
111-
InteractionType: types.CLIInteractionType,
111+
InteractionType: types.InteractionTypeCLI,
112112
})
113113
require.NoError(t, err)
114114
tsServer := httptest.NewServer(s.Handler())
@@ -273,7 +273,7 @@ func TestServer_AllowedHosts(t *testing.T) {
273273
ChatBasePath: "/chat",
274274
AllowedHosts: tc.allowedHosts,
275275
AllowedOrigins: []string{"https://example.com"}, // Set a default to isolate host testing
276-
InteractionType: types.CLIInteractionType,
276+
InteractionType: types.InteractionTypeCLI,
277277
})
278278
if tc.validationErrorMsg != "" {
279279
require.Error(t, err)
@@ -357,7 +357,7 @@ func TestServer_CORSPreflightWithHosts(t *testing.T) {
357357
ChatBasePath: "/chat",
358358
AllowedHosts: tc.allowedHosts,
359359
AllowedOrigins: []string{"*"}, // Set wildcard origins to isolate host testing
360-
InteractionType: types.CLIInteractionType,
360+
InteractionType: types.InteractionTypeCLI,
361361
})
362362
require.NoError(t, err)
363363
tsServer := httptest.NewServer(s.Handler())
@@ -517,7 +517,7 @@ func TestServer_CORSOrigins(t *testing.T) {
517517
ChatBasePath: "/chat",
518518
AllowedHosts: []string{"*"}, // Set wildcard to isolate CORS testing
519519
AllowedOrigins: tc.allowedOrigins,
520-
InteractionType: types.CLIInteractionType,
520+
InteractionType: types.InteractionTypeCLI,
521521
})
522522
if tc.validationErrorMsg != "" {
523523
require.Error(t, err)
@@ -598,7 +598,7 @@ func TestServer_CORSPreflightOrigins(t *testing.T) {
598598
ChatBasePath: "/chat",
599599
AllowedHosts: []string{"*"}, // Set wildcard to isolate CORS testing
600600
AllowedOrigins: tc.allowedOrigins,
601-
InteractionType: types.CLIInteractionType,
601+
InteractionType: types.InteractionTypeCLI,
602602
})
603603
require.NoError(t, err)
604604
tsServer := httptest.NewServer(s.Handler())
@@ -650,7 +650,7 @@ func TestServer_SSEMiddleware_Events(t *testing.T) {
650650
ChatBasePath: "/chat",
651651
AllowedHosts: []string{"*"},
652652
AllowedOrigins: []string{"*"},
653-
InteractionType: types.CLIInteractionType,
653+
InteractionType: types.InteractionTypeCLI,
654654
})
655655
require.NoError(t, err)
656656
tsServer := httptest.NewServer(srv.Handler())

lib/types/conversation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ func (c ConversationRole) Schema(r huma.Registry) *huma.Schema {
3333
type InteractionType string
3434

3535
const (
36-
SDKInteractionType InteractionType = "sdk"
37-
CLIInteractionType InteractionType = "cli"
36+
InteractionTypeSDK InteractionType = "sdk"
37+
InteractionTypeCLI InteractionType = "cli"
3838
)
3939

4040
type MessageType string

0 commit comments

Comments
 (0)