package gateway import ( "context" "github.com/samcharles93/archie-core/internal/taskstate" ) // ChatContract is the conversational boundary consumed by channel frontends. // Results are snapshots: callers must not rely on shared object identity. type ChatContract interface { //nolint:interfacebloat // wire contract intentionally covers the complete Gateway facade Snapshot(context.Context) (ChatSnapshot, error) GetSession(context.Context, string) (SessionContext, bool, error) RecentMessages(context.Context, string, int) ([]Message, error) RecentTurns(context.Context, string, int) ([]TurnRecord, error) Route(context.Context, Message) (ChatReply, error) // Stream emits started, delta/tool/media, then done or error, in order. // Callers must drain the stream or cancel the context. Cancellation closes it. Stream(context.Context, Message) (<-chan ChatEvent, error) Cancel(context.Context, string) (ChatCancellation, error) SetPersona(context.Context, string, string) (bool, error) ChatTaskActionContract } // ChatTaskActionContract is the operator task mutation capability exposed by // the Gateway. It is separate so read/turn consumers do not need to model it. type ChatTaskActionContract interface { ApplyTaskAction(context.Context, string, int64, taskstate.Action) (TaskActionResult, error) } type ChatSnapshot struct { Sessions []SessionContext Models []string ModelsByProvider map[string][]string Providers []string ActiveModel string ActiveProvider string Personas []string ActivePersonas map[string]string RestartAvailable bool CancellationAvailable bool PersonasAvailable bool } type ChatReply struct { Text string SessionID string } type ChatCancellation struct { Cancelled bool Dropped int } // ChatEvent contains values only; Text holds the error message for error events. type ChatEvent struct { Kind string Text string SessionID string Tool ToolCallEvent Media MediaEvent }