@@ -29,19 +29,17 @@ import (
2929
3030// Server represents the HTTP server
3131type Server struct {
32- router chi.Router
33- api huma.API
34- port int
35- srv * http.Server
36- mu sync.RWMutex
37- logger * slog.Logger
38- conversation * st.Conversation
39- agentio * termexec.Process
40- agentType mf.AgentType
41- emitter * EventEmitter
42- chatBasePath string
43- initialPrompt string
44- initialPromptSent bool
32+ router chi.Router
33+ api huma.API
34+ port int
35+ srv * http.Server
36+ mu sync.RWMutex
37+ logger * slog.Logger
38+ conversation * st.Conversation
39+ agentio * termexec.Process
40+ agentType mf.AgentType
41+ emitter * EventEmitter
42+ chatBasePath string
4543}
4644
4745func (s * Server ) NormalizeSchema (schema any ) any {
@@ -233,20 +231,18 @@ func NewServer(ctx context.Context, config ServerConfig) (*Server, error) {
233231 SnapshotInterval : snapshotInterval ,
234232 ScreenStabilityLength : 2 * time .Second ,
235233 FormatMessage : formatMessage ,
236- })
234+ }, config . InitialPrompt )
237235 emitter := NewEventEmitter (1024 )
238236 s := & Server {
239- router : router ,
240- api : api ,
241- port : config .Port ,
242- conversation : conversation ,
243- logger : logger ,
244- agentio : config .Process ,
245- agentType : config .AgentType ,
246- emitter : emitter ,
247- chatBasePath : strings .TrimSuffix (config .ChatBasePath , "/" ),
248- initialPrompt : config .InitialPrompt ,
249- initialPromptSent : len (config .InitialPrompt ) == 0 ,
237+ router : router ,
238+ api : api ,
239+ port : config .Port ,
240+ conversation : conversation ,
241+ logger : logger ,
242+ agentio : config .Process ,
243+ agentType : config .AgentType ,
244+ emitter : emitter ,
245+ chatBasePath : strings .TrimSuffix (config .ChatBasePath , "/" ),
250246 }
251247
252248 // Register API routes
@@ -314,11 +310,11 @@ func (s *Server) StartSnapshotLoop(ctx context.Context) {
314310 currentStatus := s .conversation .Status ()
315311
316312 // Send initial prompt when agent becomes stable for the first time
317- if ! s .initialPromptSent && convertStatus (currentStatus ) == AgentStatusStable {
318- if err := s .conversation .SendMessage (FormatMessage (s .agentType , s .initialPrompt )... ); err != nil {
313+ if ! s .conversation . InitialPromptSent && convertStatus (currentStatus ) == AgentStatusStable {
314+ if err := s .conversation .SendMessage (FormatMessage (s .agentType , s .conversation . InitialPrompt )... ); err != nil {
319315 s .logger .Error ("Failed to send initial prompt" , "error" , err )
320316 } else {
321- s .initialPromptSent = true
317+ s .conversation . InitialPromptSent = true
322318 currentStatus = st .ConversationStatusChanging
323319 s .logger .Info ("Initial prompt sent successfully" )
324320 }
0 commit comments