From 9eba9be2e550d31d318405aba8c39d46c8d17534 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 6 Sep 2026 22:49:39 +1000 Subject: [PATCH] fix(gateway): share NATS and session ownership --- internal/app/archied/bootstrap.go | 53 +- internal/app/archied/gateway.go | 40 +- internal/app/archied/nats_endpoint.go | 64 + internal/app/archied/nats_endpoint_test.go | 28 + internal/contracts/gateway/v1/chat.pb.go | 1255 ++++++++++++++++- internal/contracts/gateway/v1/chat_grpc.pb.go | 436 +++++- internal/infrastructure/gatewayrpc/client.go | 78 +- internal/infrastructure/gatewayrpc/server.go | 113 +- proto/gateway/v1/chat.proto | 33 + 9 files changed, 1999 insertions(+), 101 deletions(-) create mode 100644 internal/app/archied/nats_endpoint.go create mode 100644 internal/app/archied/nats_endpoint_test.go diff --git a/internal/app/archied/bootstrap.go b/internal/app/archied/bootstrap.go index 5795dabd1..5252c5f0e 100644 --- a/internal/app/archied/bootstrap.go +++ b/internal/app/archied/bootstrap.go @@ -43,6 +43,7 @@ import ( "github.com/samcharles93/archie-core/internal/infrastructure/configuration" "github.com/samcharles93/archie-core/internal/infrastructure/configuration/overlay" "github.com/samcharles93/archie-core/internal/infrastructure/eventbus/nats" + "github.com/samcharles93/archie-core/internal/infrastructure/gatewayrpc" infraMemory "github.com/samcharles93/archie-core/internal/infrastructure/memory" "github.com/samcharles93/archie-core/internal/infrastructure/modelcatalog" "github.com/samcharles93/archie-core/internal/infrastructure/sessioncurator" @@ -272,21 +273,18 @@ func (b *boot) openStores(ctx context.Context) error { log.Error("close store", "err", err) } }) - // The conversation store is Gateway-owned data, but Phase 1 keeps the - // daemon's own Telegram/email routers and the session-memory curator - // reading the same SQLite file directly (Messaging extraction is - // Phase 4). Both processes opening the same file is the accepted - // Phase 1 shape; remote consumers of the conversation store arrive - // when a process that cannot open the file needs it. - chatSessionStore, err := makeTelegramSessionStore(cfg) //nolint:contextcheck // the session store opener takes no context by design; its schema init must complete at boot regardless of cancellation + return nil +} + +func (b *boot) openChatSessions(_ context.Context) error { //nolint:unparam // context keeps the composition phase contract aligned with other openers + chatSessionStore, err := makeTelegramSessionStore(b.cfg) //nolint:contextcheck // SQLite schema initialization is synchronous and has no context-aware API if err != nil { - log.Error("open conversation store", "path", conversationDBPath(cfg.DBPath), "err", err) - return err + return fmt.Errorf("open conversation store: %w", err) } b.chatSessionStore = chatSessionStore b.addCleanup(func() { if err := chatSessionStore.Close(); err != nil { - log.Error("close conversation store", "err", err) + b.log.Error("close conversation store", "err", err) } }) return nil @@ -409,11 +407,11 @@ func (b *boot) wireWebStoreSurfaces() { // embedded mode starts an in-process nats-server and dials it, so single- // process deployments get task distribution and reaction delivery without a // separate server. Broker deployment never changes the worker executor. -func (b *boot) connectNATS(ctx context.Context) error { +func (b *boot) connectNATS(ctx context.Context) error { //nolint:nestif // embedded broker discovery and startup require explicit fallback branches cfg, log := b.cfg, b.log url := cfg.NATS.URL var natsToken string - if cfg.NATS.Mode == config.NATSModeExternal { + if cfg.NATS.Mode == config.NATSModeExternal { //nolint:nestif // embedded broker discovery and startup require explicit fallback branches if url == "" { return fmt.Errorf("nats.url is required when nats.mode is external") } @@ -424,10 +422,26 @@ func (b *boot) connectNATS(ctx context.Context) error { return err } } else { - var err error - url, natsToken, err = b.startEmbeddedNATS(ctx) - if err != nil { - return err + endpoint, readErr := readEmbeddedNATSEndpoint(cfg.DBPath) + if readErr == nil { + url, natsToken = endpoint.URL, endpoint.Token + if probe, err := nats.Connect(ctx, nats.Config{URL: url, Token: natsToken, Subjects: []string{workintake.SubjectTaskWildcard}, FilterSubject: workintake.SubjectTaskWildcard}, log); err == nil { + probe.Close() + // The endpoint is live; the connection is recreated below with the + // same subject configuration and becomes the daemon's owner. + url, natsToken = endpoint.URL, endpoint.Token + } else { + url, natsToken, err = b.startEmbeddedNATS(ctx) + if err != nil { + return err + } + } + } else { + var err error + url, natsToken, err = b.startEmbeddedNATS(ctx) + if err != nil { + return err + } } } @@ -470,6 +484,10 @@ func (b *boot) startEmbeddedNATS(ctx context.Context) (string, string, error) { } b.addCleanup(func() { srv.Shutdown() }) log.Info("embedded nats started", "url", srv.ClientURL()) + if err := writeEmbeddedNATSEndpoint(cfg.DBPath, srv.ClientURL(), srv.Token()); err != nil { + srv.Shutdown() + return "", "", err + } return srv.ClientURL(), srv.Token(), nil } @@ -499,6 +517,9 @@ func (b *boot) setupLLMAndChat() error { return err } b.addCleanup(cleanup) + if remote, ok := contract.(*gatewayrpc.Client); ok { + b.chatSessionStore = remote + } b.web.Chat = &webui.ChatService{Contract: contract, Updates: b.updateService} b.web.WorkRequests = b.chatTasks b.setupReadinessProbes() diff --git a/internal/app/archied/gateway.go b/internal/app/archied/gateway.go index fff023eaf..425a9ad49 100644 --- a/internal/app/archied/gateway.go +++ b/internal/app/archied/gateway.go @@ -10,6 +10,7 @@ import ( natsio "github.com/nats-io/nats.go" "google.golang.org/grpc" + "github.com/samcharles93/archie-core/internal/config" "github.com/samcharles93/archie-core/internal/events" "github.com/samcharles93/archie-core/internal/gateway" "github.com/samcharles93/archie-core/internal/infrastructure/gatewayrpc" @@ -37,15 +38,34 @@ func RunGateway(ctx context.Context, options GatewayOptions) error { if err := b.openStores(ctx); err != nil { return err } - b.loadCatalog(ctx, options.Config) - if b.cfg.NATS.URL == "" { - return fmt.Errorf("archie-gateway requires nats.url pointing to the daemon's shared NATS server") - } - token, err := configuredNATSToken(b.cfg.NATS, os.Getenv) - if err != nil { + if err := b.openChatSessions(ctx); err != nil { return err } - nc, err := natsio.Connect(b.cfg.NATS.URL, natsio.Token(token)) + b.loadCatalog(ctx, options.Config) + url, token := b.cfg.NATS.URL, "" + var nc *natsio.Conn + var err error + if b.cfg.NATS.Mode == config.NATSModeExternal { //nolint:nestif // external and embedded transports have distinct credential and discovery flows + token, err = configuredNATSToken(b.cfg.NATS, os.Getenv) + if err != nil { + return err + } + nc, err = natsio.Connect(url, natsio.Token(token)) + } else { + var endpoint embeddedNATSEndpoint + endpoint, err = readEmbeddedNATSEndpoint(b.cfg.DBPath) + if err == nil { + url, token = endpoint.URL, endpoint.Token + nc, err = natsio.Connect(url, natsio.Token(token)) + } + if nc == nil || err != nil { + url, token, err = b.startEmbeddedNATS(ctx) + if err != nil { + return err + } + nc, err = natsio.Connect(url, natsio.Token(token)) + } + } if err != nil { return fmt.Errorf("connect gateway task actions: %w", err) } @@ -64,7 +84,7 @@ func RunGateway(ctx context.Context, options GatewayOptions) error { } defer listener.Close() b.log.Info("archie-gateway running", "addr", listener.Addr().String()) - return serveGateway(ctx, listener, contract) + return serveGateway(ctx, listener, contract, b.chatSessionStore) } func (b *boot) startGatewayRuntime(ctx context.Context, actor gateway.ChatTaskActor) (gateway.ChatContract, error) { @@ -93,9 +113,9 @@ func (b *boot) startGatewayRuntime(ctx context.Context, actor gateway.ChatTaskAc return contract, nil } -func serveGateway(ctx context.Context, listener net.Listener, contract gateway.ChatContract) error { +func serveGateway(ctx context.Context, listener net.Listener, contract gateway.ChatContract, sessions gateway.SessionStore) error { server := grpc.NewServer() - gatewayrpc.RegisterServer(server, contract) + gatewayrpc.RegisterServer(server, contract, sessions) serveErr := make(chan error, 1) go func() { serveErr <- server.Serve(listener) }() select { diff --git a/internal/app/archied/nats_endpoint.go b/internal/app/archied/nats_endpoint.go new file mode 100644 index 000000000..83dcff59f --- /dev/null +++ b/internal/app/archied/nats_endpoint.go @@ -0,0 +1,64 @@ +package archied + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" +) + +type embeddedNATSEndpoint struct { + URL string `json:"url"` + Token string `json:"token"` +} + +func embeddedNATSEndpointPath(dbPath string) string { + return filepath.Join(filepath.Dir(dbPath), "nats", "endpoint.json") +} + +func writeEmbeddedNATSEndpoint(dbPath, url, token string) error { + path := embeddedNATSEndpointPath(dbPath) + data, err := json.Marshal(embeddedNATSEndpoint{URL: url, Token: token}) + if err != nil { + return fmt.Errorf("marshal embedded NATS endpoint: %w", err) + } + if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil { + return fmt.Errorf("create embedded NATS directory: %w", err) + } + tmp, err := os.CreateTemp(filepath.Dir(path), ".endpoint-*") + if err != nil { + return fmt.Errorf("create embedded NATS endpoint: %w", err) + } + tmpName := tmp.Name() + defer os.Remove(tmpName) + if err := tmp.Chmod(0o600); err != nil { + tmp.Close() + return fmt.Errorf("protect embedded NATS endpoint: %w", err) + } + if _, err := tmp.Write(data); err != nil { + tmp.Close() + return fmt.Errorf("write embedded NATS endpoint: %w", err) + } + if err := tmp.Close(); err != nil { + return fmt.Errorf("close embedded NATS endpoint: %w", err) + } + if err := os.Rename(tmpName, path); err != nil { + return fmt.Errorf("publish embedded NATS endpoint: %w", err) + } + return nil +} + +func readEmbeddedNATSEndpoint(dbPath string) (embeddedNATSEndpoint, error) { + data, err := os.ReadFile(embeddedNATSEndpointPath(dbPath)) + if err != nil { + return embeddedNATSEndpoint{}, err + } + var endpoint embeddedNATSEndpoint + if err := json.Unmarshal(data, &endpoint); err != nil { + return embeddedNATSEndpoint{}, fmt.Errorf("decode embedded NATS endpoint: %w", err) + } + if endpoint.URL == "" || endpoint.Token == "" { + return embeddedNATSEndpoint{}, fmt.Errorf("embedded NATS endpoint is incomplete") + } + return endpoint, nil +} diff --git a/internal/app/archied/nats_endpoint_test.go b/internal/app/archied/nats_endpoint_test.go new file mode 100644 index 000000000..fcfea6984 --- /dev/null +++ b/internal/app/archied/nats_endpoint_test.go @@ -0,0 +1,28 @@ +package archied + +import ( + "os" + "path/filepath" + "testing" +) + +func TestEmbeddedNATSEndpointRoundTripIsPrivateAndAtomic(t *testing.T) { + dbPath := filepath.Join(t.TempDir(), "archie.db") + if err := writeEmbeddedNATSEndpoint(dbPath, "nats://127.0.0.1:4222", "secret"); err != nil { + t.Fatal(err) + } + got, err := readEmbeddedNATSEndpoint(dbPath) + if err != nil { + t.Fatal(err) + } + if got.URL != "nats://127.0.0.1:4222" || got.Token != "secret" { + t.Fatalf("endpoint = %+v", got) + } + info, err := os.Stat(embeddedNATSEndpointPath(dbPath)) + if err != nil { + t.Fatal(err) + } + if info.Mode().Perm() != 0o600 { + t.Fatalf("endpoint permissions = %o, want 600", info.Mode().Perm()) + } +} diff --git a/internal/contracts/gateway/v1/chat.pb.go b/internal/contracts/gateway/v1/chat.pb.go index a81a28008..95cef3ce6 100644 --- a/internal/contracts/gateway/v1/chat.pb.go +++ b/internal/contracts/gateway/v1/chat.pb.go @@ -1606,6 +1606,1014 @@ func (x *ApplyTaskActionResponse) GetMessage() string { return "" } +type SaveSessionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SaveSessionResponse) Reset() { + *x = SaveSessionResponse{} + mi := &file_gateway_v1_chat_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SaveSessionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SaveSessionResponse) ProtoMessage() {} + +func (x *SaveSessionResponse) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[24] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SaveSessionResponse.ProtoReflect.Descriptor instead. +func (*SaveSessionResponse) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{24} +} + +type SaveSessionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Session *Session `protobuf:"bytes,1,opt,name=session,proto3" json:"session,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SaveSessionRequest) Reset() { + *x = SaveSessionRequest{} + mi := &file_gateway_v1_chat_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SaveSessionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SaveSessionRequest) ProtoMessage() {} + +func (x *SaveSessionRequest) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[25] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SaveSessionRequest.ProtoReflect.Descriptor instead. +func (*SaveSessionRequest) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{25} +} + +func (x *SaveSessionRequest) GetSession() *Session { + if x != nil { + return x.Session + } + return nil +} + +type GetSessionsByChannelRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Platform string `protobuf:"bytes,1,opt,name=platform,proto3" json:"platform,omitempty"` + ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSessionsByChannelRequest) Reset() { + *x = GetSessionsByChannelRequest{} + mi := &file_gateway_v1_chat_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSessionsByChannelRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSessionsByChannelRequest) ProtoMessage() {} + +func (x *GetSessionsByChannelRequest) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[26] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSessionsByChannelRequest.ProtoReflect.Descriptor instead. +func (*GetSessionsByChannelRequest) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{26} +} + +func (x *GetSessionsByChannelRequest) GetPlatform() string { + if x != nil { + return x.Platform + } + return "" +} + +func (x *GetSessionsByChannelRequest) GetChannelId() string { + if x != nil { + return x.ChannelId + } + return "" +} + +type GetSessionsByChannelResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Sessions []*Session `protobuf:"bytes,1,rep,name=sessions,proto3" json:"sessions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSessionsByChannelResponse) Reset() { + *x = GetSessionsByChannelResponse{} + mi := &file_gateway_v1_chat_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSessionsByChannelResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSessionsByChannelResponse) ProtoMessage() {} + +func (x *GetSessionsByChannelResponse) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[27] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSessionsByChannelResponse.ProtoReflect.Descriptor instead. +func (*GetSessionsByChannelResponse) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{27} +} + +func (x *GetSessionsByChannelResponse) GetSessions() []*Session { + if x != nil { + return x.Sessions + } + return nil +} + +type ListSessionsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Sessions []*Session `protobuf:"bytes,1,rep,name=sessions,proto3" json:"sessions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListSessionsResponse) Reset() { + *x = ListSessionsResponse{} + mi := &file_gateway_v1_chat_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListSessionsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListSessionsResponse) ProtoMessage() {} + +func (x *ListSessionsResponse) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[28] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListSessionsResponse.ProtoReflect.Descriptor instead. +func (*ListSessionsResponse) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{28} +} + +func (x *ListSessionsResponse) GetSessions() []*Session { + if x != nil { + return x.Sessions + } + return nil +} + +type DeleteSessionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteSessionResponse) Reset() { + *x = DeleteSessionResponse{} + mi := &file_gateway_v1_chat_proto_msgTypes[29] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteSessionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteSessionResponse) ProtoMessage() {} + +func (x *DeleteSessionResponse) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[29] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteSessionResponse.ProtoReflect.Descriptor instead. +func (*DeleteSessionResponse) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{29} +} + +type TouchSessionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TouchSessionResponse) Reset() { + *x = TouchSessionResponse{} + mi := &file_gateway_v1_chat_proto_msgTypes[30] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TouchSessionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TouchSessionResponse) ProtoMessage() {} + +func (x *TouchSessionResponse) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[30] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TouchSessionResponse.ProtoReflect.Descriptor instead. +func (*TouchSessionResponse) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{30} +} + +type SaveMessageResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SaveMessageResponse) Reset() { + *x = SaveMessageResponse{} + mi := &file_gateway_v1_chat_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SaveMessageResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SaveMessageResponse) ProtoMessage() {} + +func (x *SaveMessageResponse) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[31] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SaveMessageResponse.ProtoReflect.Descriptor instead. +func (*SaveMessageResponse) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{31} +} + +type SaveMessagesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SaveMessagesResponse) Reset() { + *x = SaveMessagesResponse{} + mi := &file_gateway_v1_chat_proto_msgTypes[32] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SaveMessagesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SaveMessagesResponse) ProtoMessage() {} + +func (x *SaveMessagesResponse) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[32] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SaveMessagesResponse.ProtoReflect.Descriptor instead. +func (*SaveMessagesResponse) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{32} +} + +type ReplaceMessagesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReplaceMessagesResponse) Reset() { + *x = ReplaceMessagesResponse{} + mi := &file_gateway_v1_chat_proto_msgTypes[33] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReplaceMessagesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReplaceMessagesResponse) ProtoMessage() {} + +func (x *ReplaceMessagesResponse) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[33] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReplaceMessagesResponse.ProtoReflect.Descriptor instead. +func (*ReplaceMessagesResponse) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{33} +} + +type DeleteSessionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteSessionRequest) Reset() { + *x = DeleteSessionRequest{} + mi := &file_gateway_v1_chat_proto_msgTypes[34] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteSessionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteSessionRequest) ProtoMessage() {} + +func (x *DeleteSessionRequest) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[34] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteSessionRequest.ProtoReflect.Descriptor instead. +func (*DeleteSessionRequest) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{34} +} + +func (x *DeleteSessionRequest) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +type TouchSessionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TouchSessionRequest) Reset() { + *x = TouchSessionRequest{} + mi := &file_gateway_v1_chat_proto_msgTypes[35] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TouchSessionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TouchSessionRequest) ProtoMessage() {} + +func (x *TouchSessionRequest) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[35] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TouchSessionRequest.ProtoReflect.Descriptor instead. +func (*TouchSessionRequest) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{35} +} + +func (x *TouchSessionRequest) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +type ListSessionsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListSessionsRequest) Reset() { + *x = ListSessionsRequest{} + mi := &file_gateway_v1_chat_proto_msgTypes[36] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListSessionsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListSessionsRequest) ProtoMessage() {} + +func (x *ListSessionsRequest) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[36] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListSessionsRequest.ProtoReflect.Descriptor instead. +func (*ListSessionsRequest) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{36} +} + +type SaveMessageRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + Message *Message `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SaveMessageRequest) Reset() { + *x = SaveMessageRequest{} + mi := &file_gateway_v1_chat_proto_msgTypes[37] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SaveMessageRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SaveMessageRequest) ProtoMessage() {} + +func (x *SaveMessageRequest) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[37] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SaveMessageRequest.ProtoReflect.Descriptor instead. +func (*SaveMessageRequest) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{37} +} + +func (x *SaveMessageRequest) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +func (x *SaveMessageRequest) GetMessage() *Message { + if x != nil { + return x.Message + } + return nil +} + +type DeleteRecentMessagesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + Limit int64 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteRecentMessagesRequest) Reset() { + *x = DeleteRecentMessagesRequest{} + mi := &file_gateway_v1_chat_proto_msgTypes[38] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteRecentMessagesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteRecentMessagesRequest) ProtoMessage() {} + +func (x *DeleteRecentMessagesRequest) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[38] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteRecentMessagesRequest.ProtoReflect.Descriptor instead. +func (*DeleteRecentMessagesRequest) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{38} +} + +func (x *DeleteRecentMessagesRequest) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +func (x *DeleteRecentMessagesRequest) GetLimit() int64 { + if x != nil { + return x.Limit + } + return 0 +} + +type DeleteRecentMessagesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Deleted int64 `protobuf:"varint,1,opt,name=deleted,proto3" json:"deleted,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteRecentMessagesResponse) Reset() { + *x = DeleteRecentMessagesResponse{} + mi := &file_gateway_v1_chat_proto_msgTypes[39] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteRecentMessagesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteRecentMessagesResponse) ProtoMessage() {} + +func (x *DeleteRecentMessagesResponse) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[39] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteRecentMessagesResponse.ProtoReflect.Descriptor instead. +func (*DeleteRecentMessagesResponse) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{39} +} + +func (x *DeleteRecentMessagesResponse) GetDeleted() int64 { + if x != nil { + return x.Deleted + } + return 0 +} + +type MessageCountRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *MessageCountRequest) Reset() { + *x = MessageCountRequest{} + mi := &file_gateway_v1_chat_proto_msgTypes[40] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *MessageCountRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MessageCountRequest) ProtoMessage() {} + +func (x *MessageCountRequest) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[40] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MessageCountRequest.ProtoReflect.Descriptor instead. +func (*MessageCountRequest) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{40} +} + +func (x *MessageCountRequest) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +type MessageCountResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *MessageCountResponse) Reset() { + *x = MessageCountResponse{} + mi := &file_gateway_v1_chat_proto_msgTypes[41] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *MessageCountResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MessageCountResponse) ProtoMessage() {} + +func (x *MessageCountResponse) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[41] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MessageCountResponse.ProtoReflect.Descriptor instead. +func (*MessageCountResponse) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{41} +} + +func (x *MessageCountResponse) GetCount() int64 { + if x != nil { + return x.Count + } + return 0 +} + +type SaveMessagesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + Messages []*Message `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SaveMessagesRequest) Reset() { + *x = SaveMessagesRequest{} + mi := &file_gateway_v1_chat_proto_msgTypes[42] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SaveMessagesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SaveMessagesRequest) ProtoMessage() {} + +func (x *SaveMessagesRequest) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[42] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SaveMessagesRequest.ProtoReflect.Descriptor instead. +func (*SaveMessagesRequest) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{42} +} + +func (x *SaveMessagesRequest) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +func (x *SaveMessagesRequest) GetMessages() []*Message { + if x != nil { + return x.Messages + } + return nil +} + +type ReplaceMessagesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + Messages []*Message `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages,omitempty"` + Superseded []string `protobuf:"bytes,3,rep,name=superseded,proto3" json:"superseded,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReplaceMessagesRequest) Reset() { + *x = ReplaceMessagesRequest{} + mi := &file_gateway_v1_chat_proto_msgTypes[43] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReplaceMessagesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReplaceMessagesRequest) ProtoMessage() {} + +func (x *ReplaceMessagesRequest) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[43] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReplaceMessagesRequest.ProtoReflect.Descriptor instead. +func (*ReplaceMessagesRequest) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{43} +} + +func (x *ReplaceMessagesRequest) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +func (x *ReplaceMessagesRequest) GetMessages() []*Message { + if x != nil { + return x.Messages + } + return nil +} + +func (x *ReplaceMessagesRequest) GetSuperseded() []string { + if x != nil { + return x.Superseded + } + return nil +} + +type SearchMessagesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + Query string `protobuf:"bytes,2,opt,name=query,proto3" json:"query,omitempty"` + Limit int64 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` + Offset int64 `protobuf:"varint,4,opt,name=offset,proto3" json:"offset,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SearchMessagesRequest) Reset() { + *x = SearchMessagesRequest{} + mi := &file_gateway_v1_chat_proto_msgTypes[44] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SearchMessagesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SearchMessagesRequest) ProtoMessage() {} + +func (x *SearchMessagesRequest) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[44] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SearchMessagesRequest.ProtoReflect.Descriptor instead. +func (*SearchMessagesRequest) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{44} +} + +func (x *SearchMessagesRequest) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +func (x *SearchMessagesRequest) GetQuery() string { + if x != nil { + return x.Query + } + return "" +} + +func (x *SearchMessagesRequest) GetLimit() int64 { + if x != nil { + return x.Limit + } + return 0 +} + +func (x *SearchMessagesRequest) GetOffset() int64 { + if x != nil { + return x.Offset + } + return 0 +} + +type SearchMessagesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Messages []*Message `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"` + NextOffset int64 `protobuf:"varint,2,opt,name=next_offset,json=nextOffset,proto3" json:"next_offset,omitempty"` + HasMore bool `protobuf:"varint,3,opt,name=has_more,json=hasMore,proto3" json:"has_more,omitempty"` + Truncated bool `protobuf:"varint,4,opt,name=truncated,proto3" json:"truncated,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SearchMessagesResponse) Reset() { + *x = SearchMessagesResponse{} + mi := &file_gateway_v1_chat_proto_msgTypes[45] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SearchMessagesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SearchMessagesResponse) ProtoMessage() {} + +func (x *SearchMessagesResponse) ProtoReflect() protoreflect.Message { + mi := &file_gateway_v1_chat_proto_msgTypes[45] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SearchMessagesResponse.ProtoReflect.Descriptor instead. +func (*SearchMessagesResponse) Descriptor() ([]byte, []int) { + return file_gateway_v1_chat_proto_rawDescGZIP(), []int{45} +} + +func (x *SearchMessagesResponse) GetMessages() []*Message { + if x != nil { + return x.Messages + } + return nil +} + +func (x *SearchMessagesResponse) GetNextOffset() int64 { + if x != nil { + return x.NextOffset + } + return 0 +} + +func (x *SearchMessagesResponse) GetHasMore() bool { + if x != nil { + return x.HasMore + } + return false +} + +func (x *SearchMessagesResponse) GetTruncated() bool { + if x != nil { + return x.Truncated + } + return false +} + var File_gateway_v1_chat_proto protoreflect.FileDescriptor const file_gateway_v1_chat_proto_rawDesc = "" + @@ -1760,7 +2768,68 @@ const file_gateway_v1_chat_proto_rawDesc = "" + "\x17ApplyTaskActionResponse\x12\x17\n" + "\atask_id\x18\x01 \x01(\x03R\x06taskId\x12\x16\n" + "\x06action\x18\x02 \x01(\tR\x06action\x12\x18\n" + - "\amessage\x18\x03 \x01(\tR\amessage2\xb5\x05\n" + + "\amessage\x18\x03 \x01(\tR\amessage\"\x15\n" + + "\x13SaveSessionResponse\"C\n" + + "\x12SaveSessionRequest\x12-\n" + + "\asession\x18\x01 \x01(\v2\x13.gateway.v1.SessionR\asession\"X\n" + + "\x1bGetSessionsByChannelRequest\x12\x1a\n" + + "\bplatform\x18\x01 \x01(\tR\bplatform\x12\x1d\n" + + "\n" + + "channel_id\x18\x02 \x01(\tR\tchannelId\"O\n" + + "\x1cGetSessionsByChannelResponse\x12/\n" + + "\bsessions\x18\x01 \x03(\v2\x13.gateway.v1.SessionR\bsessions\"G\n" + + "\x14ListSessionsResponse\x12/\n" + + "\bsessions\x18\x01 \x03(\v2\x13.gateway.v1.SessionR\bsessions\"\x17\n" + + "\x15DeleteSessionResponse\"\x16\n" + + "\x14TouchSessionResponse\"\x15\n" + + "\x13SaveMessageResponse\"\x16\n" + + "\x14SaveMessagesResponse\"\x19\n" + + "\x17ReplaceMessagesResponse\"5\n" + + "\x14DeleteSessionRequest\x12\x1d\n" + + "\n" + + "session_id\x18\x01 \x01(\tR\tsessionId\"4\n" + + "\x13TouchSessionRequest\x12\x1d\n" + + "\n" + + "session_id\x18\x01 \x01(\tR\tsessionId\"\x15\n" + + "\x13ListSessionsRequest\"b\n" + + "\x12SaveMessageRequest\x12\x1d\n" + + "\n" + + "session_id\x18\x01 \x01(\tR\tsessionId\x12-\n" + + "\amessage\x18\x02 \x01(\v2\x13.gateway.v1.MessageR\amessage\"R\n" + + "\x1bDeleteRecentMessagesRequest\x12\x1d\n" + + "\n" + + "session_id\x18\x01 \x01(\tR\tsessionId\x12\x14\n" + + "\x05limit\x18\x02 \x01(\x03R\x05limit\"8\n" + + "\x1cDeleteRecentMessagesResponse\x12\x18\n" + + "\adeleted\x18\x01 \x01(\x03R\adeleted\"4\n" + + "\x13MessageCountRequest\x12\x1d\n" + + "\n" + + "session_id\x18\x01 \x01(\tR\tsessionId\",\n" + + "\x14MessageCountResponse\x12\x14\n" + + "\x05count\x18\x01 \x01(\x03R\x05count\"e\n" + + "\x13SaveMessagesRequest\x12\x1d\n" + + "\n" + + "session_id\x18\x01 \x01(\tR\tsessionId\x12/\n" + + "\bmessages\x18\x02 \x03(\v2\x13.gateway.v1.MessageR\bmessages\"\x88\x01\n" + + "\x16ReplaceMessagesRequest\x12\x1d\n" + + "\n" + + "session_id\x18\x01 \x01(\tR\tsessionId\x12/\n" + + "\bmessages\x18\x02 \x03(\v2\x13.gateway.v1.MessageR\bmessages\x12\x1e\n" + + "\n" + + "superseded\x18\x03 \x03(\tR\n" + + "superseded\"z\n" + + "\x15SearchMessagesRequest\x12\x1d\n" + + "\n" + + "session_id\x18\x01 \x01(\tR\tsessionId\x12\x14\n" + + "\x05query\x18\x02 \x01(\tR\x05query\x12\x14\n" + + "\x05limit\x18\x03 \x01(\x03R\x05limit\x12\x16\n" + + "\x06offset\x18\x04 \x01(\x03R\x06offset\"\xa3\x01\n" + + "\x16SearchMessagesResponse\x12/\n" + + "\bmessages\x18\x01 \x03(\v2\x13.gateway.v1.MessageR\bmessages\x12\x1f\n" + + "\vnext_offset\x18\x02 \x01(\x03R\n" + + "nextOffset\x12\x19\n" + + "\bhas_more\x18\x03 \x01(\bR\ahasMore\x12\x1c\n" + + "\ttruncated\x18\x04 \x01(\bR\ttruncated2\x82\r\n" + "\vChatService\x12E\n" + "\bSnapshot\x12\x1b.gateway.v1.SnapshotRequest\x1a\x1c.gateway.v1.SnapshotResponse\x12K\n" + "\n" + @@ -1772,7 +2841,18 @@ const file_gateway_v1_chat_proto_rawDesc = "" + "\x06Cancel\x12\x19.gateway.v1.CancelRequest\x1a\x1a.gateway.v1.CancelResponse\x12K\n" + "\n" + "SetPersona\x12\x1d.gateway.v1.SetPersonaRequest\x1a\x1e.gateway.v1.SetPersonaResponse\x12Z\n" + - "\x0fApplyTaskAction\x12\".gateway.v1.ApplyTaskActionRequest\x1a#.gateway.v1.ApplyTaskActionResponseB\xb1\x01\n" + + "\x0fApplyTaskAction\x12\".gateway.v1.ApplyTaskActionRequest\x1a#.gateway.v1.ApplyTaskActionResponse\x12N\n" + + "\vSaveSession\x12\x1e.gateway.v1.SaveSessionRequest\x1a\x1f.gateway.v1.SaveSessionResponse\x12i\n" + + "\x14GetSessionsByChannel\x12'.gateway.v1.GetSessionsByChannelRequest\x1a(.gateway.v1.GetSessionsByChannelResponse\x12T\n" + + "\rDeleteSession\x12 .gateway.v1.DeleteSessionRequest\x1a!.gateway.v1.DeleteSessionResponse\x12Q\n" + + "\fTouchSession\x12\x1f.gateway.v1.TouchSessionRequest\x1a .gateway.v1.TouchSessionResponse\x12Q\n" + + "\fListSessions\x12\x1f.gateway.v1.ListSessionsRequest\x1a .gateway.v1.ListSessionsResponse\x12N\n" + + "\vSaveMessage\x12\x1e.gateway.v1.SaveMessageRequest\x1a\x1f.gateway.v1.SaveMessageResponse\x12i\n" + + "\x14DeleteRecentMessages\x12'.gateway.v1.DeleteRecentMessagesRequest\x1a(.gateway.v1.DeleteRecentMessagesResponse\x12Q\n" + + "\fMessageCount\x12\x1f.gateway.v1.MessageCountRequest\x1a .gateway.v1.MessageCountResponse\x12Q\n" + + "\fSaveMessages\x12\x1f.gateway.v1.SaveMessagesRequest\x1a .gateway.v1.SaveMessagesResponse\x12Z\n" + + "\x0fReplaceMessages\x12\".gateway.v1.ReplaceMessagesRequest\x1a#.gateway.v1.ReplaceMessagesResponse\x12W\n" + + "\x0eSearchMessages\x12!.gateway.v1.SearchMessagesRequest\x1a\".gateway.v1.SearchMessagesResponseB\xb1\x01\n" + "\x0ecom.gateway.v1B\tChatProtoP\x01ZKgithub.com/samcharles93/archie-core/internal/contracts/gateway/v1;gatewayv1\xa2\x02\x03GXX\xaa\x02\n" + "Gateway.V1\xca\x02\n" + "Gateway\\V1\xe2\x02\x16Gateway\\V1\\GPBMetadata\xea\x02\vGateway::V1b\x06proto3" @@ -1789,46 +2869,68 @@ func file_gateway_v1_chat_proto_rawDescGZIP() []byte { return file_gateway_v1_chat_proto_rawDescData } -var file_gateway_v1_chat_proto_msgTypes = make([]protoimpl.MessageInfo, 26) +var file_gateway_v1_chat_proto_msgTypes = make([]protoimpl.MessageInfo, 48) var file_gateway_v1_chat_proto_goTypes = []any{ - (*Session)(nil), // 0: gateway.v1.Session - (*Message)(nil), // 1: gateway.v1.Message - (*ToolCall)(nil), // 2: gateway.v1.ToolCall - (*Media)(nil), // 3: gateway.v1.Media - (*Turn)(nil), // 4: gateway.v1.Turn - (*StringList)(nil), // 5: gateway.v1.StringList - (*SnapshotRequest)(nil), // 6: gateway.v1.SnapshotRequest - (*SnapshotResponse)(nil), // 7: gateway.v1.SnapshotResponse - (*GetSessionRequest)(nil), // 8: gateway.v1.GetSessionRequest - (*GetSessionResponse)(nil), // 9: gateway.v1.GetSessionResponse - (*RecentMessagesRequest)(nil), // 10: gateway.v1.RecentMessagesRequest - (*RecentMessagesResponse)(nil), // 11: gateway.v1.RecentMessagesResponse - (*RecentTurnsRequest)(nil), // 12: gateway.v1.RecentTurnsRequest - (*RecentTurnsResponse)(nil), // 13: gateway.v1.RecentTurnsResponse - (*RouteRequest)(nil), // 14: gateway.v1.RouteRequest - (*RouteResponse)(nil), // 15: gateway.v1.RouteResponse - (*StreamRequest)(nil), // 16: gateway.v1.StreamRequest - (*StreamResponse)(nil), // 17: gateway.v1.StreamResponse - (*CancelRequest)(nil), // 18: gateway.v1.CancelRequest - (*CancelResponse)(nil), // 19: gateway.v1.CancelResponse - (*SetPersonaRequest)(nil), // 20: gateway.v1.SetPersonaRequest - (*SetPersonaResponse)(nil), // 21: gateway.v1.SetPersonaResponse - (*ApplyTaskActionRequest)(nil), // 22: gateway.v1.ApplyTaskActionRequest - (*ApplyTaskActionResponse)(nil), // 23: gateway.v1.ApplyTaskActionResponse - nil, // 24: gateway.v1.SnapshotResponse.ModelsByProviderEntry - nil, // 25: gateway.v1.SnapshotResponse.ActivePersonasEntry - (*timestamppb.Timestamp)(nil), // 26: google.protobuf.Timestamp + (*Session)(nil), // 0: gateway.v1.Session + (*Message)(nil), // 1: gateway.v1.Message + (*ToolCall)(nil), // 2: gateway.v1.ToolCall + (*Media)(nil), // 3: gateway.v1.Media + (*Turn)(nil), // 4: gateway.v1.Turn + (*StringList)(nil), // 5: gateway.v1.StringList + (*SnapshotRequest)(nil), // 6: gateway.v1.SnapshotRequest + (*SnapshotResponse)(nil), // 7: gateway.v1.SnapshotResponse + (*GetSessionRequest)(nil), // 8: gateway.v1.GetSessionRequest + (*GetSessionResponse)(nil), // 9: gateway.v1.GetSessionResponse + (*RecentMessagesRequest)(nil), // 10: gateway.v1.RecentMessagesRequest + (*RecentMessagesResponse)(nil), // 11: gateway.v1.RecentMessagesResponse + (*RecentTurnsRequest)(nil), // 12: gateway.v1.RecentTurnsRequest + (*RecentTurnsResponse)(nil), // 13: gateway.v1.RecentTurnsResponse + (*RouteRequest)(nil), // 14: gateway.v1.RouteRequest + (*RouteResponse)(nil), // 15: gateway.v1.RouteResponse + (*StreamRequest)(nil), // 16: gateway.v1.StreamRequest + (*StreamResponse)(nil), // 17: gateway.v1.StreamResponse + (*CancelRequest)(nil), // 18: gateway.v1.CancelRequest + (*CancelResponse)(nil), // 19: gateway.v1.CancelResponse + (*SetPersonaRequest)(nil), // 20: gateway.v1.SetPersonaRequest + (*SetPersonaResponse)(nil), // 21: gateway.v1.SetPersonaResponse + (*ApplyTaskActionRequest)(nil), // 22: gateway.v1.ApplyTaskActionRequest + (*ApplyTaskActionResponse)(nil), // 23: gateway.v1.ApplyTaskActionResponse + (*SaveSessionResponse)(nil), // 24: gateway.v1.SaveSessionResponse + (*SaveSessionRequest)(nil), // 25: gateway.v1.SaveSessionRequest + (*GetSessionsByChannelRequest)(nil), // 26: gateway.v1.GetSessionsByChannelRequest + (*GetSessionsByChannelResponse)(nil), // 27: gateway.v1.GetSessionsByChannelResponse + (*ListSessionsResponse)(nil), // 28: gateway.v1.ListSessionsResponse + (*DeleteSessionResponse)(nil), // 29: gateway.v1.DeleteSessionResponse + (*TouchSessionResponse)(nil), // 30: gateway.v1.TouchSessionResponse + (*SaveMessageResponse)(nil), // 31: gateway.v1.SaveMessageResponse + (*SaveMessagesResponse)(nil), // 32: gateway.v1.SaveMessagesResponse + (*ReplaceMessagesResponse)(nil), // 33: gateway.v1.ReplaceMessagesResponse + (*DeleteSessionRequest)(nil), // 34: gateway.v1.DeleteSessionRequest + (*TouchSessionRequest)(nil), // 35: gateway.v1.TouchSessionRequest + (*ListSessionsRequest)(nil), // 36: gateway.v1.ListSessionsRequest + (*SaveMessageRequest)(nil), // 37: gateway.v1.SaveMessageRequest + (*DeleteRecentMessagesRequest)(nil), // 38: gateway.v1.DeleteRecentMessagesRequest + (*DeleteRecentMessagesResponse)(nil), // 39: gateway.v1.DeleteRecentMessagesResponse + (*MessageCountRequest)(nil), // 40: gateway.v1.MessageCountRequest + (*MessageCountResponse)(nil), // 41: gateway.v1.MessageCountResponse + (*SaveMessagesRequest)(nil), // 42: gateway.v1.SaveMessagesRequest + (*ReplaceMessagesRequest)(nil), // 43: gateway.v1.ReplaceMessagesRequest + (*SearchMessagesRequest)(nil), // 44: gateway.v1.SearchMessagesRequest + (*SearchMessagesResponse)(nil), // 45: gateway.v1.SearchMessagesResponse + nil, // 46: gateway.v1.SnapshotResponse.ModelsByProviderEntry + nil, // 47: gateway.v1.SnapshotResponse.ActivePersonasEntry + (*timestamppb.Timestamp)(nil), // 48: google.protobuf.Timestamp } var file_gateway_v1_chat_proto_depIdxs = []int32{ - 26, // 0: gateway.v1.Session.created_at:type_name -> google.protobuf.Timestamp - 26, // 1: gateway.v1.Session.last_active_at:type_name -> google.protobuf.Timestamp - 26, // 2: gateway.v1.Message.at:type_name -> google.protobuf.Timestamp + 48, // 0: gateway.v1.Session.created_at:type_name -> google.protobuf.Timestamp + 48, // 1: gateway.v1.Session.last_active_at:type_name -> google.protobuf.Timestamp + 48, // 2: gateway.v1.Message.at:type_name -> google.protobuf.Timestamp 2, // 3: gateway.v1.Turn.tool_calls:type_name -> gateway.v1.ToolCall - 26, // 4: gateway.v1.Turn.created_at:type_name -> google.protobuf.Timestamp - 26, // 5: gateway.v1.Turn.updated_at:type_name -> google.protobuf.Timestamp + 48, // 4: gateway.v1.Turn.created_at:type_name -> google.protobuf.Timestamp + 48, // 5: gateway.v1.Turn.updated_at:type_name -> google.protobuf.Timestamp 0, // 6: gateway.v1.SnapshotResponse.sessions:type_name -> gateway.v1.Session - 24, // 7: gateway.v1.SnapshotResponse.models_by_provider:type_name -> gateway.v1.SnapshotResponse.ModelsByProviderEntry - 25, // 8: gateway.v1.SnapshotResponse.active_personas:type_name -> gateway.v1.SnapshotResponse.ActivePersonasEntry + 46, // 7: gateway.v1.SnapshotResponse.models_by_provider:type_name -> gateway.v1.SnapshotResponse.ModelsByProviderEntry + 47, // 8: gateway.v1.SnapshotResponse.active_personas:type_name -> gateway.v1.SnapshotResponse.ActivePersonasEntry 0, // 9: gateway.v1.GetSessionResponse.session:type_name -> gateway.v1.Session 1, // 10: gateway.v1.RecentMessagesResponse.messages:type_name -> gateway.v1.Message 4, // 11: gateway.v1.RecentTurnsResponse.turns:type_name -> gateway.v1.Turn @@ -1836,30 +2938,59 @@ var file_gateway_v1_chat_proto_depIdxs = []int32{ 1, // 13: gateway.v1.StreamRequest.message:type_name -> gateway.v1.Message 2, // 14: gateway.v1.StreamResponse.tool:type_name -> gateway.v1.ToolCall 3, // 15: gateway.v1.StreamResponse.media:type_name -> gateway.v1.Media - 5, // 16: gateway.v1.SnapshotResponse.ModelsByProviderEntry.value:type_name -> gateway.v1.StringList - 6, // 17: gateway.v1.ChatService.Snapshot:input_type -> gateway.v1.SnapshotRequest - 8, // 18: gateway.v1.ChatService.GetSession:input_type -> gateway.v1.GetSessionRequest - 10, // 19: gateway.v1.ChatService.RecentMessages:input_type -> gateway.v1.RecentMessagesRequest - 12, // 20: gateway.v1.ChatService.RecentTurns:input_type -> gateway.v1.RecentTurnsRequest - 14, // 21: gateway.v1.ChatService.Route:input_type -> gateway.v1.RouteRequest - 16, // 22: gateway.v1.ChatService.Stream:input_type -> gateway.v1.StreamRequest - 18, // 23: gateway.v1.ChatService.Cancel:input_type -> gateway.v1.CancelRequest - 20, // 24: gateway.v1.ChatService.SetPersona:input_type -> gateway.v1.SetPersonaRequest - 22, // 25: gateway.v1.ChatService.ApplyTaskAction:input_type -> gateway.v1.ApplyTaskActionRequest - 7, // 26: gateway.v1.ChatService.Snapshot:output_type -> gateway.v1.SnapshotResponse - 9, // 27: gateway.v1.ChatService.GetSession:output_type -> gateway.v1.GetSessionResponse - 11, // 28: gateway.v1.ChatService.RecentMessages:output_type -> gateway.v1.RecentMessagesResponse - 13, // 29: gateway.v1.ChatService.RecentTurns:output_type -> gateway.v1.RecentTurnsResponse - 15, // 30: gateway.v1.ChatService.Route:output_type -> gateway.v1.RouteResponse - 17, // 31: gateway.v1.ChatService.Stream:output_type -> gateway.v1.StreamResponse - 19, // 32: gateway.v1.ChatService.Cancel:output_type -> gateway.v1.CancelResponse - 21, // 33: gateway.v1.ChatService.SetPersona:output_type -> gateway.v1.SetPersonaResponse - 23, // 34: gateway.v1.ChatService.ApplyTaskAction:output_type -> gateway.v1.ApplyTaskActionResponse - 26, // [26:35] is the sub-list for method output_type - 17, // [17:26] is the sub-list for method input_type - 17, // [17:17] is the sub-list for extension type_name - 17, // [17:17] is the sub-list for extension extendee - 0, // [0:17] is the sub-list for field type_name + 0, // 16: gateway.v1.SaveSessionRequest.session:type_name -> gateway.v1.Session + 0, // 17: gateway.v1.GetSessionsByChannelResponse.sessions:type_name -> gateway.v1.Session + 0, // 18: gateway.v1.ListSessionsResponse.sessions:type_name -> gateway.v1.Session + 1, // 19: gateway.v1.SaveMessageRequest.message:type_name -> gateway.v1.Message + 1, // 20: gateway.v1.SaveMessagesRequest.messages:type_name -> gateway.v1.Message + 1, // 21: gateway.v1.ReplaceMessagesRequest.messages:type_name -> gateway.v1.Message + 1, // 22: gateway.v1.SearchMessagesResponse.messages:type_name -> gateway.v1.Message + 5, // 23: gateway.v1.SnapshotResponse.ModelsByProviderEntry.value:type_name -> gateway.v1.StringList + 6, // 24: gateway.v1.ChatService.Snapshot:input_type -> gateway.v1.SnapshotRequest + 8, // 25: gateway.v1.ChatService.GetSession:input_type -> gateway.v1.GetSessionRequest + 10, // 26: gateway.v1.ChatService.RecentMessages:input_type -> gateway.v1.RecentMessagesRequest + 12, // 27: gateway.v1.ChatService.RecentTurns:input_type -> gateway.v1.RecentTurnsRequest + 14, // 28: gateway.v1.ChatService.Route:input_type -> gateway.v1.RouteRequest + 16, // 29: gateway.v1.ChatService.Stream:input_type -> gateway.v1.StreamRequest + 18, // 30: gateway.v1.ChatService.Cancel:input_type -> gateway.v1.CancelRequest + 20, // 31: gateway.v1.ChatService.SetPersona:input_type -> gateway.v1.SetPersonaRequest + 22, // 32: gateway.v1.ChatService.ApplyTaskAction:input_type -> gateway.v1.ApplyTaskActionRequest + 25, // 33: gateway.v1.ChatService.SaveSession:input_type -> gateway.v1.SaveSessionRequest + 26, // 34: gateway.v1.ChatService.GetSessionsByChannel:input_type -> gateway.v1.GetSessionsByChannelRequest + 34, // 35: gateway.v1.ChatService.DeleteSession:input_type -> gateway.v1.DeleteSessionRequest + 35, // 36: gateway.v1.ChatService.TouchSession:input_type -> gateway.v1.TouchSessionRequest + 36, // 37: gateway.v1.ChatService.ListSessions:input_type -> gateway.v1.ListSessionsRequest + 37, // 38: gateway.v1.ChatService.SaveMessage:input_type -> gateway.v1.SaveMessageRequest + 38, // 39: gateway.v1.ChatService.DeleteRecentMessages:input_type -> gateway.v1.DeleteRecentMessagesRequest + 40, // 40: gateway.v1.ChatService.MessageCount:input_type -> gateway.v1.MessageCountRequest + 42, // 41: gateway.v1.ChatService.SaveMessages:input_type -> gateway.v1.SaveMessagesRequest + 43, // 42: gateway.v1.ChatService.ReplaceMessages:input_type -> gateway.v1.ReplaceMessagesRequest + 44, // 43: gateway.v1.ChatService.SearchMessages:input_type -> gateway.v1.SearchMessagesRequest + 7, // 44: gateway.v1.ChatService.Snapshot:output_type -> gateway.v1.SnapshotResponse + 9, // 45: gateway.v1.ChatService.GetSession:output_type -> gateway.v1.GetSessionResponse + 11, // 46: gateway.v1.ChatService.RecentMessages:output_type -> gateway.v1.RecentMessagesResponse + 13, // 47: gateway.v1.ChatService.RecentTurns:output_type -> gateway.v1.RecentTurnsResponse + 15, // 48: gateway.v1.ChatService.Route:output_type -> gateway.v1.RouteResponse + 17, // 49: gateway.v1.ChatService.Stream:output_type -> gateway.v1.StreamResponse + 19, // 50: gateway.v1.ChatService.Cancel:output_type -> gateway.v1.CancelResponse + 21, // 51: gateway.v1.ChatService.SetPersona:output_type -> gateway.v1.SetPersonaResponse + 23, // 52: gateway.v1.ChatService.ApplyTaskAction:output_type -> gateway.v1.ApplyTaskActionResponse + 24, // 53: gateway.v1.ChatService.SaveSession:output_type -> gateway.v1.SaveSessionResponse + 27, // 54: gateway.v1.ChatService.GetSessionsByChannel:output_type -> gateway.v1.GetSessionsByChannelResponse + 29, // 55: gateway.v1.ChatService.DeleteSession:output_type -> gateway.v1.DeleteSessionResponse + 30, // 56: gateway.v1.ChatService.TouchSession:output_type -> gateway.v1.TouchSessionResponse + 28, // 57: gateway.v1.ChatService.ListSessions:output_type -> gateway.v1.ListSessionsResponse + 31, // 58: gateway.v1.ChatService.SaveMessage:output_type -> gateway.v1.SaveMessageResponse + 39, // 59: gateway.v1.ChatService.DeleteRecentMessages:output_type -> gateway.v1.DeleteRecentMessagesResponse + 41, // 60: gateway.v1.ChatService.MessageCount:output_type -> gateway.v1.MessageCountResponse + 32, // 61: gateway.v1.ChatService.SaveMessages:output_type -> gateway.v1.SaveMessagesResponse + 33, // 62: gateway.v1.ChatService.ReplaceMessages:output_type -> gateway.v1.ReplaceMessagesResponse + 45, // 63: gateway.v1.ChatService.SearchMessages:output_type -> gateway.v1.SearchMessagesResponse + 44, // [44:64] is the sub-list for method output_type + 24, // [24:44] is the sub-list for method input_type + 24, // [24:24] is the sub-list for extension type_name + 24, // [24:24] is the sub-list for extension extendee + 0, // [0:24] is the sub-list for field type_name } func init() { file_gateway_v1_chat_proto_init() } @@ -1874,7 +3005,7 @@ func file_gateway_v1_chat_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_gateway_v1_chat_proto_rawDesc), len(file_gateway_v1_chat_proto_rawDesc)), NumEnums: 0, - NumMessages: 26, + NumMessages: 48, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/contracts/gateway/v1/chat_grpc.pb.go b/internal/contracts/gateway/v1/chat_grpc.pb.go index adec876a9..af45ec237 100644 --- a/internal/contracts/gateway/v1/chat_grpc.pb.go +++ b/internal/contracts/gateway/v1/chat_grpc.pb.go @@ -19,15 +19,26 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - ChatService_Snapshot_FullMethodName = "/gateway.v1.ChatService/Snapshot" - ChatService_GetSession_FullMethodName = "/gateway.v1.ChatService/GetSession" - ChatService_RecentMessages_FullMethodName = "/gateway.v1.ChatService/RecentMessages" - ChatService_RecentTurns_FullMethodName = "/gateway.v1.ChatService/RecentTurns" - ChatService_Route_FullMethodName = "/gateway.v1.ChatService/Route" - ChatService_Stream_FullMethodName = "/gateway.v1.ChatService/Stream" - ChatService_Cancel_FullMethodName = "/gateway.v1.ChatService/Cancel" - ChatService_SetPersona_FullMethodName = "/gateway.v1.ChatService/SetPersona" - ChatService_ApplyTaskAction_FullMethodName = "/gateway.v1.ChatService/ApplyTaskAction" + ChatService_Snapshot_FullMethodName = "/gateway.v1.ChatService/Snapshot" + ChatService_GetSession_FullMethodName = "/gateway.v1.ChatService/GetSession" + ChatService_RecentMessages_FullMethodName = "/gateway.v1.ChatService/RecentMessages" + ChatService_RecentTurns_FullMethodName = "/gateway.v1.ChatService/RecentTurns" + ChatService_Route_FullMethodName = "/gateway.v1.ChatService/Route" + ChatService_Stream_FullMethodName = "/gateway.v1.ChatService/Stream" + ChatService_Cancel_FullMethodName = "/gateway.v1.ChatService/Cancel" + ChatService_SetPersona_FullMethodName = "/gateway.v1.ChatService/SetPersona" + ChatService_ApplyTaskAction_FullMethodName = "/gateway.v1.ChatService/ApplyTaskAction" + ChatService_SaveSession_FullMethodName = "/gateway.v1.ChatService/SaveSession" + ChatService_GetSessionsByChannel_FullMethodName = "/gateway.v1.ChatService/GetSessionsByChannel" + ChatService_DeleteSession_FullMethodName = "/gateway.v1.ChatService/DeleteSession" + ChatService_TouchSession_FullMethodName = "/gateway.v1.ChatService/TouchSession" + ChatService_ListSessions_FullMethodName = "/gateway.v1.ChatService/ListSessions" + ChatService_SaveMessage_FullMethodName = "/gateway.v1.ChatService/SaveMessage" + ChatService_DeleteRecentMessages_FullMethodName = "/gateway.v1.ChatService/DeleteRecentMessages" + ChatService_MessageCount_FullMethodName = "/gateway.v1.ChatService/MessageCount" + ChatService_SaveMessages_FullMethodName = "/gateway.v1.ChatService/SaveMessages" + ChatService_ReplaceMessages_FullMethodName = "/gateway.v1.ChatService/ReplaceMessages" + ChatService_SearchMessages_FullMethodName = "/gateway.v1.ChatService/SearchMessages" ) // ChatServiceClient is the client API for ChatService service. @@ -43,6 +54,17 @@ type ChatServiceClient interface { Cancel(ctx context.Context, in *CancelRequest, opts ...grpc.CallOption) (*CancelResponse, error) SetPersona(ctx context.Context, in *SetPersonaRequest, opts ...grpc.CallOption) (*SetPersonaResponse, error) ApplyTaskAction(ctx context.Context, in *ApplyTaskActionRequest, opts ...grpc.CallOption) (*ApplyTaskActionResponse, error) + SaveSession(ctx context.Context, in *SaveSessionRequest, opts ...grpc.CallOption) (*SaveSessionResponse, error) + GetSessionsByChannel(ctx context.Context, in *GetSessionsByChannelRequest, opts ...grpc.CallOption) (*GetSessionsByChannelResponse, error) + DeleteSession(ctx context.Context, in *DeleteSessionRequest, opts ...grpc.CallOption) (*DeleteSessionResponse, error) + TouchSession(ctx context.Context, in *TouchSessionRequest, opts ...grpc.CallOption) (*TouchSessionResponse, error) + ListSessions(ctx context.Context, in *ListSessionsRequest, opts ...grpc.CallOption) (*ListSessionsResponse, error) + SaveMessage(ctx context.Context, in *SaveMessageRequest, opts ...grpc.CallOption) (*SaveMessageResponse, error) + DeleteRecentMessages(ctx context.Context, in *DeleteRecentMessagesRequest, opts ...grpc.CallOption) (*DeleteRecentMessagesResponse, error) + MessageCount(ctx context.Context, in *MessageCountRequest, opts ...grpc.CallOption) (*MessageCountResponse, error) + SaveMessages(ctx context.Context, in *SaveMessagesRequest, opts ...grpc.CallOption) (*SaveMessagesResponse, error) + ReplaceMessages(ctx context.Context, in *ReplaceMessagesRequest, opts ...grpc.CallOption) (*ReplaceMessagesResponse, error) + SearchMessages(ctx context.Context, in *SearchMessagesRequest, opts ...grpc.CallOption) (*SearchMessagesResponse, error) } type chatServiceClient struct { @@ -152,6 +174,116 @@ func (c *chatServiceClient) ApplyTaskAction(ctx context.Context, in *ApplyTaskAc return out, nil } +func (c *chatServiceClient) SaveSession(ctx context.Context, in *SaveSessionRequest, opts ...grpc.CallOption) (*SaveSessionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(SaveSessionResponse) + err := c.cc.Invoke(ctx, ChatService_SaveSession_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatServiceClient) GetSessionsByChannel(ctx context.Context, in *GetSessionsByChannelRequest, opts ...grpc.CallOption) (*GetSessionsByChannelResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetSessionsByChannelResponse) + err := c.cc.Invoke(ctx, ChatService_GetSessionsByChannel_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatServiceClient) DeleteSession(ctx context.Context, in *DeleteSessionRequest, opts ...grpc.CallOption) (*DeleteSessionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteSessionResponse) + err := c.cc.Invoke(ctx, ChatService_DeleteSession_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatServiceClient) TouchSession(ctx context.Context, in *TouchSessionRequest, opts ...grpc.CallOption) (*TouchSessionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(TouchSessionResponse) + err := c.cc.Invoke(ctx, ChatService_TouchSession_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatServiceClient) ListSessions(ctx context.Context, in *ListSessionsRequest, opts ...grpc.CallOption) (*ListSessionsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListSessionsResponse) + err := c.cc.Invoke(ctx, ChatService_ListSessions_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatServiceClient) SaveMessage(ctx context.Context, in *SaveMessageRequest, opts ...grpc.CallOption) (*SaveMessageResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(SaveMessageResponse) + err := c.cc.Invoke(ctx, ChatService_SaveMessage_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatServiceClient) DeleteRecentMessages(ctx context.Context, in *DeleteRecentMessagesRequest, opts ...grpc.CallOption) (*DeleteRecentMessagesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteRecentMessagesResponse) + err := c.cc.Invoke(ctx, ChatService_DeleteRecentMessages_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatServiceClient) MessageCount(ctx context.Context, in *MessageCountRequest, opts ...grpc.CallOption) (*MessageCountResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(MessageCountResponse) + err := c.cc.Invoke(ctx, ChatService_MessageCount_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatServiceClient) SaveMessages(ctx context.Context, in *SaveMessagesRequest, opts ...grpc.CallOption) (*SaveMessagesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(SaveMessagesResponse) + err := c.cc.Invoke(ctx, ChatService_SaveMessages_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatServiceClient) ReplaceMessages(ctx context.Context, in *ReplaceMessagesRequest, opts ...grpc.CallOption) (*ReplaceMessagesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ReplaceMessagesResponse) + err := c.cc.Invoke(ctx, ChatService_ReplaceMessages_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *chatServiceClient) SearchMessages(ctx context.Context, in *SearchMessagesRequest, opts ...grpc.CallOption) (*SearchMessagesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(SearchMessagesResponse) + err := c.cc.Invoke(ctx, ChatService_SearchMessages_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // ChatServiceServer is the server API for ChatService service. // All implementations must embed UnimplementedChatServiceServer // for forward compatibility. @@ -165,6 +297,17 @@ type ChatServiceServer interface { Cancel(context.Context, *CancelRequest) (*CancelResponse, error) SetPersona(context.Context, *SetPersonaRequest) (*SetPersonaResponse, error) ApplyTaskAction(context.Context, *ApplyTaskActionRequest) (*ApplyTaskActionResponse, error) + SaveSession(context.Context, *SaveSessionRequest) (*SaveSessionResponse, error) + GetSessionsByChannel(context.Context, *GetSessionsByChannelRequest) (*GetSessionsByChannelResponse, error) + DeleteSession(context.Context, *DeleteSessionRequest) (*DeleteSessionResponse, error) + TouchSession(context.Context, *TouchSessionRequest) (*TouchSessionResponse, error) + ListSessions(context.Context, *ListSessionsRequest) (*ListSessionsResponse, error) + SaveMessage(context.Context, *SaveMessageRequest) (*SaveMessageResponse, error) + DeleteRecentMessages(context.Context, *DeleteRecentMessagesRequest) (*DeleteRecentMessagesResponse, error) + MessageCount(context.Context, *MessageCountRequest) (*MessageCountResponse, error) + SaveMessages(context.Context, *SaveMessagesRequest) (*SaveMessagesResponse, error) + ReplaceMessages(context.Context, *ReplaceMessagesRequest) (*ReplaceMessagesResponse, error) + SearchMessages(context.Context, *SearchMessagesRequest) (*SearchMessagesResponse, error) mustEmbedUnimplementedChatServiceServer() } @@ -202,6 +345,39 @@ func (UnimplementedChatServiceServer) SetPersona(context.Context, *SetPersonaReq func (UnimplementedChatServiceServer) ApplyTaskAction(context.Context, *ApplyTaskActionRequest) (*ApplyTaskActionResponse, error) { return nil, status.Error(codes.Unimplemented, "method ApplyTaskAction not implemented") } +func (UnimplementedChatServiceServer) SaveSession(context.Context, *SaveSessionRequest) (*SaveSessionResponse, error) { + return nil, status.Error(codes.Unimplemented, "method SaveSession not implemented") +} +func (UnimplementedChatServiceServer) GetSessionsByChannel(context.Context, *GetSessionsByChannelRequest) (*GetSessionsByChannelResponse, error) { + return nil, status.Error(codes.Unimplemented, "method GetSessionsByChannel not implemented") +} +func (UnimplementedChatServiceServer) DeleteSession(context.Context, *DeleteSessionRequest) (*DeleteSessionResponse, error) { + return nil, status.Error(codes.Unimplemented, "method DeleteSession not implemented") +} +func (UnimplementedChatServiceServer) TouchSession(context.Context, *TouchSessionRequest) (*TouchSessionResponse, error) { + return nil, status.Error(codes.Unimplemented, "method TouchSession not implemented") +} +func (UnimplementedChatServiceServer) ListSessions(context.Context, *ListSessionsRequest) (*ListSessionsResponse, error) { + return nil, status.Error(codes.Unimplemented, "method ListSessions not implemented") +} +func (UnimplementedChatServiceServer) SaveMessage(context.Context, *SaveMessageRequest) (*SaveMessageResponse, error) { + return nil, status.Error(codes.Unimplemented, "method SaveMessage not implemented") +} +func (UnimplementedChatServiceServer) DeleteRecentMessages(context.Context, *DeleteRecentMessagesRequest) (*DeleteRecentMessagesResponse, error) { + return nil, status.Error(codes.Unimplemented, "method DeleteRecentMessages not implemented") +} +func (UnimplementedChatServiceServer) MessageCount(context.Context, *MessageCountRequest) (*MessageCountResponse, error) { + return nil, status.Error(codes.Unimplemented, "method MessageCount not implemented") +} +func (UnimplementedChatServiceServer) SaveMessages(context.Context, *SaveMessagesRequest) (*SaveMessagesResponse, error) { + return nil, status.Error(codes.Unimplemented, "method SaveMessages not implemented") +} +func (UnimplementedChatServiceServer) ReplaceMessages(context.Context, *ReplaceMessagesRequest) (*ReplaceMessagesResponse, error) { + return nil, status.Error(codes.Unimplemented, "method ReplaceMessages not implemented") +} +func (UnimplementedChatServiceServer) SearchMessages(context.Context, *SearchMessagesRequest) (*SearchMessagesResponse, error) { + return nil, status.Error(codes.Unimplemented, "method SearchMessages not implemented") +} func (UnimplementedChatServiceServer) mustEmbedUnimplementedChatServiceServer() {} func (UnimplementedChatServiceServer) testEmbeddedByValue() {} @@ -378,6 +554,204 @@ func _ChatService_ApplyTaskAction_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _ChatService_SaveSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SaveSessionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServiceServer).SaveSession(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ChatService_SaveSession_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServiceServer).SaveSession(ctx, req.(*SaveSessionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ChatService_GetSessionsByChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetSessionsByChannelRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServiceServer).GetSessionsByChannel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ChatService_GetSessionsByChannel_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServiceServer).GetSessionsByChannel(ctx, req.(*GetSessionsByChannelRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ChatService_DeleteSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteSessionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServiceServer).DeleteSession(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ChatService_DeleteSession_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServiceServer).DeleteSession(ctx, req.(*DeleteSessionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ChatService_TouchSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TouchSessionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServiceServer).TouchSession(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ChatService_TouchSession_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServiceServer).TouchSession(ctx, req.(*TouchSessionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ChatService_ListSessions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListSessionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServiceServer).ListSessions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ChatService_ListSessions_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServiceServer).ListSessions(ctx, req.(*ListSessionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ChatService_SaveMessage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SaveMessageRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServiceServer).SaveMessage(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ChatService_SaveMessage_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServiceServer).SaveMessage(ctx, req.(*SaveMessageRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ChatService_DeleteRecentMessages_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteRecentMessagesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServiceServer).DeleteRecentMessages(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ChatService_DeleteRecentMessages_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServiceServer).DeleteRecentMessages(ctx, req.(*DeleteRecentMessagesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ChatService_MessageCount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MessageCountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServiceServer).MessageCount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ChatService_MessageCount_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServiceServer).MessageCount(ctx, req.(*MessageCountRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ChatService_SaveMessages_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SaveMessagesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServiceServer).SaveMessages(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ChatService_SaveMessages_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServiceServer).SaveMessages(ctx, req.(*SaveMessagesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ChatService_ReplaceMessages_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReplaceMessagesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServiceServer).ReplaceMessages(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ChatService_ReplaceMessages_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServiceServer).ReplaceMessages(ctx, req.(*ReplaceMessagesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ChatService_SearchMessages_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SearchMessagesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChatServiceServer).SearchMessages(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ChatService_SearchMessages_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChatServiceServer).SearchMessages(ctx, req.(*SearchMessagesRequest)) + } + return interceptor(ctx, in, info, handler) +} + // ChatService_ServiceDesc is the grpc.ServiceDesc for ChatService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -417,6 +791,50 @@ var ChatService_ServiceDesc = grpc.ServiceDesc{ MethodName: "ApplyTaskAction", Handler: _ChatService_ApplyTaskAction_Handler, }, + { + MethodName: "SaveSession", + Handler: _ChatService_SaveSession_Handler, + }, + { + MethodName: "GetSessionsByChannel", + Handler: _ChatService_GetSessionsByChannel_Handler, + }, + { + MethodName: "DeleteSession", + Handler: _ChatService_DeleteSession_Handler, + }, + { + MethodName: "TouchSession", + Handler: _ChatService_TouchSession_Handler, + }, + { + MethodName: "ListSessions", + Handler: _ChatService_ListSessions_Handler, + }, + { + MethodName: "SaveMessage", + Handler: _ChatService_SaveMessage_Handler, + }, + { + MethodName: "DeleteRecentMessages", + Handler: _ChatService_DeleteRecentMessages_Handler, + }, + { + MethodName: "MessageCount", + Handler: _ChatService_MessageCount_Handler, + }, + { + MethodName: "SaveMessages", + Handler: _ChatService_SaveMessages_Handler, + }, + { + MethodName: "ReplaceMessages", + Handler: _ChatService_ReplaceMessages_Handler, + }, + { + MethodName: "SearchMessages", + Handler: _ChatService_SearchMessages_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/internal/infrastructure/gatewayrpc/client.go b/internal/infrastructure/gatewayrpc/client.go index d5a165909..01b3b34fa 100644 --- a/internal/infrastructure/gatewayrpc/client.go +++ b/internal/infrastructure/gatewayrpc/client.go @@ -13,10 +13,86 @@ import ( "github.com/samcharles93/archie-core/internal/taskstate" ) -var _ gateway.ChatContract = (*Client)(nil) +var ( + _ gateway.ChatContract = (*Client)(nil) + _ gateway.SessionStore = (*Client)(nil) +) type Client struct{ client pb.ChatServiceClient } +func (c *Client) Get(ctx context.Context, id string) (*gateway.SessionContext, error) { + s, found, err := c.GetSession(ctx, id) + if err != nil || !found { + return nil, err + } + return &s, nil +} + +func (c *Client) Save(ctx context.Context, s gateway.SessionContext) error { + _, e := c.client.SaveSession(ctx, &pb.SaveSessionRequest{Session: sessionProto(s)}) + return e +} + +func (c *Client) GetByChannel(ctx context.Context, p, ch string) ([]gateway.SessionContext, error) { + v, e := c.client.GetSessionsByChannel(ctx, &pb.GetSessionsByChannelRequest{Platform: p, ChannelId: ch}) + if e != nil { + return nil, e + } + return mapValues(v.Sessions, sessionValue), nil +} + +func (c *Client) Delete(ctx context.Context, id string) error { + _, e := c.client.DeleteSession(ctx, &pb.DeleteSessionRequest{SessionId: id}) + return e +} + +func (c *Client) Touch(ctx context.Context, id string) error { + _, e := c.client.TouchSession(ctx, &pb.TouchSessionRequest{SessionId: id}) + return e +} + +func (c *Client) List(ctx context.Context) ([]gateway.SessionContext, error) { + v, e := c.client.ListSessions(ctx, &pb.ListSessionsRequest{}) + if e != nil { + return nil, e + } + return mapValues(v.Sessions, sessionValue), nil +} + +func (c *Client) SaveMessage(ctx context.Context, id string, m gateway.Message) error { + _, e := c.client.SaveMessage(ctx, &pb.SaveMessageRequest{SessionId: id, Message: messageProto(m)}) + return e +} + +func (c *Client) DeleteRecentMessages(ctx context.Context, id string, n int) (int, error) { + v, e := c.client.DeleteRecentMessages(ctx, &pb.DeleteRecentMessagesRequest{SessionId: id, Limit: int64(n)}) + return int(v.Deleted), e +} + +func (c *Client) MessageCount(ctx context.Context, id string) (int, error) { + v, e := c.client.MessageCount(ctx, &pb.MessageCountRequest{SessionId: id}) + return int(v.Count), e +} + +func (c *Client) SaveMessages(ctx context.Context, id string, m []gateway.Message) error { + _, e := c.client.SaveMessages(ctx, &pb.SaveMessagesRequest{SessionId: id, Messages: mapValues(m, messageProto)}) + return e +} + +func (c *Client) ReplaceMessages(ctx context.Context, id string, m []gateway.Message, s []string) error { + _, e := c.client.ReplaceMessages(ctx, &pb.ReplaceMessagesRequest{SessionId: id, Messages: mapValues(m, messageProto), Superseded: s}) + return e +} + +func (c *Client) SearchMessages(ctx context.Context, id string, q gateway.MessageQuery) (gateway.MessagePage, error) { + v, e := c.client.SearchMessages(ctx, &pb.SearchMessagesRequest{SessionId: id, Query: q.Query, Limit: int64(q.Limit), Offset: int64(q.Offset)}) + if e != nil { + return gateway.MessagePage{}, e + } + return gateway.MessagePage{Messages: mapValues(v.Messages, messageValue), NextOffset: int(v.NextOffset), HasMore: v.HasMore, Truncated: v.Truncated}, nil +} +func (c *Client) Close() error { return nil } + func NewClient(conn grpc.ClientConnInterface) *Client { return &Client{client: pb.NewChatServiceClient(conn)} } diff --git a/internal/infrastructure/gatewayrpc/server.go b/internal/infrastructure/gatewayrpc/server.go index c51a4ab4c..d47506702 100644 --- a/internal/infrastructure/gatewayrpc/server.go +++ b/internal/infrastructure/gatewayrpc/server.go @@ -4,6 +4,8 @@ import ( "context" "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" pb "github.com/samcharles93/archie-core/internal/contracts/gateway/v1" "github.com/samcharles93/archie-core/internal/gateway" @@ -12,11 +14,23 @@ import ( type server struct { pb.UnimplementedChatServiceServer - chat gateway.ChatContract + chat gateway.ChatContract + sessions gateway.SessionStore } -func RegisterServer(registrar grpc.ServiceRegistrar, chat gateway.ChatContract) { - pb.RegisterChatServiceServer(registrar, &server{chat: chat}) +func RegisterServer(registrar grpc.ServiceRegistrar, chat gateway.ChatContract, sessions ...gateway.SessionStore) { + var ss gateway.SessionStore + if len(sessions) > 0 { + ss = sessions[0] + } + pb.RegisterChatServiceServer(registrar, &server{chat: chat, sessions: ss}) +} + +func (s *server) sessionStore() (gateway.SessionStore, error) { + if s.sessions == nil { + return nil, status.Error(codes.Unavailable, "session store unavailable") + } + return s.sessions, nil } func (s *server) Snapshot(ctx context.Context, _ *pb.SnapshotRequest) (*pb.SnapshotResponse, error) { @@ -83,6 +97,99 @@ func (s *server) ApplyTaskAction(ctx context.Context, r *pb.ApplyTaskActionReque return &pb.ApplyTaskActionResponse{TaskId: v.TaskID, Action: v.Action, Message: v.Message}, nil } +func (s *server) SaveSession(ctx context.Context, r *pb.SaveSessionRequest) (*pb.SaveSessionResponse, error) { + ss, e := s.sessionStore() + if e != nil { + return nil, e + } + return &pb.SaveSessionResponse{}, ss.Save(ctx, sessionValue(r.Session)) +} + +func (s *server) GetSessionsByChannel(ctx context.Context, r *pb.GetSessionsByChannelRequest) (*pb.GetSessionsByChannelResponse, error) { + ss, e := s.sessionStore() + if e != nil { + return nil, e + } + v, e := ss.GetByChannel(ctx, r.Platform, r.ChannelId) + return &pb.GetSessionsByChannelResponse{Sessions: mapValues(v, sessionProto)}, e +} + +func (s *server) DeleteSession(ctx context.Context, r *pb.DeleteSessionRequest) (*pb.DeleteSessionResponse, error) { + ss, e := s.sessionStore() + if e != nil { + return nil, e + } + return &pb.DeleteSessionResponse{}, ss.Delete(ctx, r.SessionId) +} + +func (s *server) TouchSession(ctx context.Context, r *pb.TouchSessionRequest) (*pb.TouchSessionResponse, error) { + ss, e := s.sessionStore() + if e != nil { + return nil, e + } + return &pb.TouchSessionResponse{}, ss.Touch(ctx, r.SessionId) +} + +func (s *server) ListSessions(ctx context.Context, _ *pb.ListSessionsRequest) (*pb.ListSessionsResponse, error) { + ss, e := s.sessionStore() + if e != nil { + return nil, e + } + v, e := ss.List(ctx) + return &pb.ListSessionsResponse{Sessions: mapValues(v, sessionProto)}, e +} + +func (s *server) SaveMessage(ctx context.Context, r *pb.SaveMessageRequest) (*pb.SaveMessageResponse, error) { + ss, e := s.sessionStore() + if e != nil { + return nil, e + } + return &pb.SaveMessageResponse{}, ss.SaveMessage(ctx, r.SessionId, messageValue(r.Message)) +} + +func (s *server) DeleteRecentMessages(ctx context.Context, r *pb.DeleteRecentMessagesRequest) (*pb.DeleteRecentMessagesResponse, error) { + ss, e := s.sessionStore() + if e != nil { + return nil, e + } + v, e := ss.DeleteRecentMessages(ctx, r.SessionId, int(r.Limit)) + return &pb.DeleteRecentMessagesResponse{Deleted: int64(v)}, e +} + +func (s *server) MessageCount(ctx context.Context, r *pb.MessageCountRequest) (*pb.MessageCountResponse, error) { + ss, e := s.sessionStore() + if e != nil { + return nil, e + } + v, e := ss.MessageCount(ctx, r.SessionId) + return &pb.MessageCountResponse{Count: int64(v)}, e +} + +func (s *server) SaveMessages(ctx context.Context, r *pb.SaveMessagesRequest) (*pb.SaveMessagesResponse, error) { + ss, e := s.sessionStore() + if e != nil { + return nil, e + } + return &pb.SaveMessagesResponse{}, ss.SaveMessages(ctx, r.SessionId, mapValues(r.Messages, messageValue)) +} + +func (s *server) ReplaceMessages(ctx context.Context, r *pb.ReplaceMessagesRequest) (*pb.ReplaceMessagesResponse, error) { + ss, e := s.sessionStore() + if e != nil { + return nil, e + } + return &pb.ReplaceMessagesResponse{}, ss.ReplaceMessages(ctx, r.SessionId, mapValues(r.Messages, messageValue), r.Superseded) +} + +func (s *server) SearchMessages(ctx context.Context, r *pb.SearchMessagesRequest) (*pb.SearchMessagesResponse, error) { + ss, e := s.sessionStore() + if e != nil { + return nil, e + } + v, e := ss.SearchMessages(ctx, r.SessionId, gateway.MessageQuery{Query: r.Query, Limit: int(r.Limit), Offset: int(r.Offset)}) + return &pb.SearchMessagesResponse{Messages: mapValues(v.Messages, messageProto), NextOffset: int64(v.NextOffset), HasMore: v.HasMore, Truncated: v.Truncated}, e +} + func (s *server) Stream(r *pb.StreamRequest, out grpc.ServerStreamingServer[pb.StreamResponse]) error { events, err := s.chat.Stream(out.Context(), messageValue(r.Message)) if err != nil { diff --git a/proto/gateway/v1/chat.proto b/proto/gateway/v1/chat.proto index 5657a5a81..15494b7f5 100644 --- a/proto/gateway/v1/chat.proto +++ b/proto/gateway/v1/chat.proto @@ -14,6 +14,17 @@ service ChatService { rpc Cancel(CancelRequest) returns (CancelResponse); rpc SetPersona(SetPersonaRequest) returns (SetPersonaResponse); rpc ApplyTaskAction(ApplyTaskActionRequest) returns (ApplyTaskActionResponse); + rpc SaveSession(SaveSessionRequest) returns (SaveSessionResponse); + rpc GetSessionsByChannel(GetSessionsByChannelRequest) returns (GetSessionsByChannelResponse); + rpc DeleteSession(DeleteSessionRequest) returns (DeleteSessionResponse); + rpc TouchSession(TouchSessionRequest) returns (TouchSessionResponse); + rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse); + rpc SaveMessage(SaveMessageRequest) returns (SaveMessageResponse); + rpc DeleteRecentMessages(DeleteRecentMessagesRequest) returns (DeleteRecentMessagesResponse); + rpc MessageCount(MessageCountRequest) returns (MessageCountResponse); + rpc SaveMessages(SaveMessagesRequest) returns (SaveMessagesResponse); + rpc ReplaceMessages(ReplaceMessagesRequest) returns (ReplaceMessagesResponse); + rpc SearchMessages(SearchMessagesRequest) returns (SearchMessagesResponse); } message Session { @@ -111,3 +122,25 @@ message SetPersonaRequest { string session_id = 1; string name = 2; } message SetPersonaResponse { bool found = 1; } message ApplyTaskActionRequest { string identity = 1; int64 task_id = 2; string action = 3; } message ApplyTaskActionResponse { int64 task_id = 1; string action = 2; string message = 3; } +message SaveSessionResponse {} +message SaveSessionRequest { Session session = 1; } +message GetSessionsByChannelRequest { string platform = 1; string channel_id = 2; } +message GetSessionsByChannelResponse { repeated Session sessions = 1; } +message ListSessionsResponse { repeated Session sessions = 1; } +message DeleteSessionResponse {} +message TouchSessionResponse {} +message SaveMessageResponse {} +message SaveMessagesResponse {} +message ReplaceMessagesResponse {} +message DeleteSessionRequest { string session_id = 1; } +message TouchSessionRequest { string session_id = 1; } +message ListSessionsRequest {} +message SaveMessageRequest { string session_id = 1; Message message = 2; } +message DeleteRecentMessagesRequest { string session_id = 1; int64 limit = 2; } +message DeleteRecentMessagesResponse { int64 deleted = 1; } +message MessageCountRequest { string session_id = 1; } +message MessageCountResponse { int64 count = 1; } +message SaveMessagesRequest { string session_id = 1; repeated Message messages = 2; } +message ReplaceMessagesRequest { string session_id = 1; repeated Message messages = 2; repeated string superseded = 3; } +message SearchMessagesRequest { string session_id = 1; string query = 2; int64 limit = 3; int64 offset = 4; } +message SearchMessagesResponse { repeated Message messages = 1; int64 next_offset = 2; bool has_more = 3; bool truncated = 4; }