interfaces.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package app
  2. import (
  3. "context"
  4. "time"
  5. "github.com/sst/opencode/internal/message"
  6. "github.com/sst/opencode/internal/pubsub"
  7. "github.com/sst/opencode/internal/session"
  8. )
  9. // SessionService defines the interface for session operations
  10. type SessionService interface {
  11. Create(ctx context.Context, title string) (session.Session, error)
  12. Get(ctx context.Context, id string) (session.Session, error)
  13. List(ctx context.Context) ([]session.Session, error)
  14. Update(ctx context.Context, id, title string) error
  15. Delete(ctx context.Context, id string) error
  16. }
  17. // MessageService defines the interface for message operations
  18. type MessageService interface {
  19. pubsub.Subscriber[message.Message]
  20. GetBySession(ctx context.Context, sessionID string) ([]message.Message, error)
  21. List(ctx context.Context, sessionID string) ([]message.Message, error)
  22. Create(ctx context.Context, sessionID string, params message.CreateMessageParams) (message.Message, error)
  23. Update(ctx context.Context, msg message.Message) (message.Message, error)
  24. Delete(ctx context.Context, id string) error
  25. DeleteSessionMessages(ctx context.Context, sessionID string) error
  26. Get(ctx context.Context, id string) (message.Message, error)
  27. ListAfter(ctx context.Context, sessionID string, timestamp time.Time) ([]message.Message, error)
  28. }
  29. // AgentService defines the interface for agent operations
  30. type AgentService interface {
  31. Run(ctx context.Context, sessionID string, text string, attachments ...message.Attachment) (string, error)
  32. Cancel(sessionID string) error
  33. IsBusy() bool
  34. IsSessionBusy(sessionID string) bool
  35. CompactSession(ctx context.Context, sessionID string, force bool) error
  36. }