opencode-cursor-agent/pkg/domain/usecase/chat.go

48 lines
1.1 KiB
Go

package usecase
import (
"context"
"cursor-api-proxy/pkg/domain/entity"
)
// ChatUsecase defines the interface for chat operations
type ChatUsecase interface {
Execute(ctx context.Context, input ChatInput) (ChatOutput, error)
Stream(ctx context.Context, input ChatInput, callback func(entity.StreamChunk)) error
}
// ChatInput represents the input for chat operations
type ChatInput struct {
Model string
Messages []entity.Message
Tools []entity.Tool
Stream bool
}
// ChatOutput represents the output from chat operations
type ChatOutput struct {
Content string
Thinking string
ToolCalls []entity.ToolCall
}
// AgentRunner defines the interface for running AI agents
type AgentRunner interface {
RunSync(ctx context.Context, config interface{}, args []string) (RunResult, error)
RunStream(ctx context.Context, config interface{}, args []string, onLine func(string)) (StreamResult, error)
}
// RunResult represents the result of a synchronous agent run
type RunResult struct {
Code int
Stdout string
Stderr string
}
// StreamResult represents the result of a streaming agent run
type StreamResult struct {
Code int
Stderr string
}