chat

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2026 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxTurns     = 10
	DefaultMaxBudgetUSD = 2.0
)

Variables

View Source
var (
	ErrConversationTerminalUnsupported     = errors.New("project conversation terminal is unsupported")
	ErrConversationTerminalSessionNotFound = errors.New("project conversation terminal session not found")
	ErrConversationTerminalAttachForbidden = errors.New("project conversation terminal attach forbidden")
	ErrConversationTerminalAlreadyAttached = errors.New("project conversation terminal session is already attached")
)
View Source
var (
	ErrConversationNotFound         = chatrepo.ErrNotFound
	ErrConversationConflict         = chatrepo.ErrConflict
	ErrConversationTurnActive       = chatrepo.ErrTurnAlreadyActive
	ErrConversationTurnNotActive    = fmt.Errorf("%w: project conversation does not have an active turn", domain.ErrConflict)
	ErrConversationInterruptPending = domain.ErrInterruptPending
	ErrPendingInterruptNotFound     = chatrepo.ErrNotFound
	ErrConversationRuntimeAbsent    = fmt.Errorf("chat conversation runtime is unavailable")
)
View Source
var (
	ErrProjectConversationWorkspaceUnavailable   = errors.New("project conversation workspace unavailable")
	ErrProjectConversationWorkspaceRepoNotFound  = errors.New("project conversation workspace repo not found")
	ErrProjectConversationWorkspacePathInvalid   = errors.New("project conversation workspace path is invalid")
	ErrProjectConversationWorkspaceEntryNotFound = errors.New("project conversation workspace entry not found")
)
View Source
var (
	ErrUnavailable             = errors.New("chat service unavailable")
	ErrSourceUnsupported       = errors.New("chat source is unsupported")
	ErrProviderNotFound        = errors.New("chat-capable provider not found for project")
	ErrProviderUnsupported     = errors.New("chat provider does not support ephemeral chat")
	ErrProviderUnavailable     = errors.New("chat provider is unavailable")
	ErrSessionNotFound         = errors.New("chat session not found")
	ErrSessionProviderMismatch = errors.New("chat session cannot resume across providers")
	ErrSessionTurnLimitReached = errors.New("chat session reached the turn limit; please create a ticket for further work")
	ErrSessionBudgetExceeded   = errors.New("chat session reached the budget cap; please create a ticket for further work")
)
View Source
var ErrProjectConversationWorkspaceSyncRequired = errors.New("project conversation workspace sync required")

Functions

This section is empty.

Types

type AttachedConversationTerminal added in v0.4.0

type AttachedConversationTerminal struct {
	Session ConversationTerminalSession
	Events  <-chan ConversationTerminalEvent
	// contains filtered or unexported fields
}

func (AttachedConversationTerminal) Close added in v0.4.0

func (AttachedConversationTerminal) Detach added in v0.4.0

func (AttachedConversationTerminal) Resize added in v0.4.0

func (a AttachedConversationTerminal) Resize(cols int, rows int) error

func (AttachedConversationTerminal) WriteInput added in v0.4.0

func (a AttachedConversationTerminal) WriteInput(data []byte) error

type ClaudeRuntime

type ClaudeRuntime struct {
	// contains filtered or unexported fields
}

func NewClaudeRuntime

func NewClaudeRuntime(adapter provider.ClaudeCodeAdapter) *ClaudeRuntime

func (*ClaudeRuntime) CloseSession

func (r *ClaudeRuntime) CloseSession(sessionID SessionID) bool

func (*ClaudeRuntime) ConfigureSecretResolver added in v0.3.0

func (r *ClaudeRuntime) ConfigureSecretResolver(resolver RuntimeEnvironmentResolver)

func (*ClaudeRuntime) InterruptTurn added in v0.4.0

func (r *ClaudeRuntime) InterruptTurn(
	_ context.Context,
	sessionID SessionID,
) (RuntimeSessionAnchor, error)

func (*ClaudeRuntime) RespondInterrupt

func (r *ClaudeRuntime) RespondInterrupt(
	ctx context.Context,
	input RuntimeInterruptResponseInput,
) (TurnStream, error)

func (*ClaudeRuntime) SessionAnchor

func (r *ClaudeRuntime) SessionAnchor(sessionID SessionID) RuntimeSessionAnchor

func (*ClaudeRuntime) StartTurn

func (r *ClaudeRuntime) StartTurn(ctx context.Context, input RuntimeTurnInput) (TurnStream, error)

func (*ClaudeRuntime) Supports

func (r *ClaudeRuntime) Supports(providerItem catalogdomain.AgentProvider) bool

type CodexRuntime

type CodexRuntime struct {
	// contains filtered or unexported fields
}

func NewCodexRuntime

func NewCodexRuntime(adapter *codexadapter.Adapter) *CodexRuntime

func (*CodexRuntime) CloseSession

func (r *CodexRuntime) CloseSession(sessionID SessionID) bool

func (*CodexRuntime) ConfigureSecretResolver added in v0.3.0

func (r *CodexRuntime) ConfigureSecretResolver(resolver RuntimeEnvironmentResolver)

func (*CodexRuntime) EnsureSession

func (r *CodexRuntime) EnsureSession(ctx context.Context, input RuntimeTurnInput) error

func (*CodexRuntime) InterruptTurn added in v0.4.0

func (r *CodexRuntime) InterruptTurn(
	ctx context.Context,
	sessionID SessionID,
) (RuntimeSessionAnchor, error)

func (*CodexRuntime) RespondInterrupt

func (r *CodexRuntime) RespondInterrupt(
	ctx context.Context,
	input RuntimeInterruptResponseInput,
) (TurnStream, error)

func (*CodexRuntime) SessionAnchor

func (r *CodexRuntime) SessionAnchor(sessionID SessionID) RuntimeSessionAnchor

func (*CodexRuntime) StartTurn

func (r *CodexRuntime) StartTurn(ctx context.Context, input RuntimeTurnInput) (TurnStream, error)

func (*CodexRuntime) Supports

func (r *CodexRuntime) Supports(providerItem catalogdomain.AgentProvider) bool

type Context

type Context struct {
	ProjectID    uuid.UUID
	TicketID     *uuid.UUID
	ProjectFocus *ProjectConversationFocus
}

type ConversationTerminalEvent added in v0.4.0

type ConversationTerminalEvent struct {
	Type     string
	Data     []byte
	ExitCode int
	Signal   string
	Message  string
}

type ConversationTerminalService added in v0.4.0

type ConversationTerminalService struct {
	// contains filtered or unexported fields
}

func NewConversationTerminalService added in v0.4.0

func NewConversationTerminalService(
	logger *slog.Logger,
	conversations *ProjectConversationService,
) *ConversationTerminalService

func (*ConversationTerminalService) AttachSession added in v0.4.0

func (s *ConversationTerminalService) AttachSession(
	userID UserID,
	conversationID uuid.UUID,
	sessionID uuid.UUID,
	attachToken string,
) (AttachedConversationTerminal, error)

func (*ConversationTerminalService) CloseSession added in v0.4.0

func (s *ConversationTerminalService) CloseSession(conversationID uuid.UUID, sessionID uuid.UUID) error

func (*ConversationTerminalService) CreateSession added in v0.4.0

type ConversationTerminalSession added in v0.4.0

type ConversationTerminalSession struct {
	ID             uuid.UUID
	ConversationID uuid.UUID
	UserID         UserID
	Mode           chatdomain.TerminalMode
	CWD            string
	WSPath         string
	AttachToken    string
	CreatedAt      time.Time
	LastAttachedAt *time.Time
}

type GeminiRuntime

type GeminiRuntime struct {
	// contains filtered or unexported fields
}

func NewGeminiRuntime

func NewGeminiRuntime(processManager provider.AgentCLIProcessManager) *GeminiRuntime

func (*GeminiRuntime) CloseSession

func (r *GeminiRuntime) CloseSession(sessionID SessionID) bool

func (*GeminiRuntime) ConfigureSecretResolver added in v0.3.0

func (r *GeminiRuntime) ConfigureSecretResolver(resolver RuntimeEnvironmentResolver)

func (*GeminiRuntime) InterruptTurn added in v0.4.0

func (r *GeminiRuntime) InterruptTurn(
	_ context.Context,
	sessionID SessionID,
) (RuntimeSessionAnchor, error)

func (*GeminiRuntime) SessionAnchor added in v0.4.0

func (r *GeminiRuntime) SessionAnchor(sessionID SessionID) RuntimeSessionAnchor

func (*GeminiRuntime) StartTurn

func (r *GeminiRuntime) StartTurn(ctx context.Context, input RuntimeTurnInput) (TurnStream, error)

func (*GeminiRuntime) Supports

func (r *GeminiRuntime) Supports(providerItem catalogdomain.AgentProvider) bool

type ProjectConversationFocusKind

type ProjectConversationFocusKind string
const (
	ProjectConversationFocusWorkflow ProjectConversationFocusKind = "workflow"
	ProjectConversationFocusSkill    ProjectConversationFocusKind = "skill"
	ProjectConversationFocusTicket   ProjectConversationFocusKind = "ticket"
	ProjectConversationFocusMachine  ProjectConversationFocusKind = "machine"
)

type ProjectConversationMachineFocus

type ProjectConversationMachineFocus struct {
	ID            uuid.UUID
	Name          string
	Host          string
	Status        string
	SelectedArea  string
	HealthSummary string
}

type ProjectConversationMuxEvent

type ProjectConversationMuxEvent struct {
	Event          string
	ConversationID uuid.UUID
	Payload        any
	SentAt         time.Time
}

type ProjectConversationService

type ProjectConversationService struct {
	// contains filtered or unexported fields
}

func NewProjectConversationService

func NewProjectConversationService(
	logger *slog.Logger,
	stores projectConversationStoreSource,
	catalog projectConversationCatalog,
	tickets ticketReader,
	workflows workflowReader,
	localProcessManager provider.AgentCLIProcessManager,
	sshPool *sshinfra.Pool,
) *ProjectConversationService

func (*ProjectConversationService) AppendSystemEntry added in v0.3.0

func (s *ProjectConversationService) AppendSystemEntry(
	ctx context.Context,
	userID UserID,
	conversationID uuid.UUID,
	turnID *uuid.UUID,
	payload map[string]any,
) (domain.Entry, error)

func (*ProjectConversationService) CloseRuntime

func (s *ProjectConversationService) CloseRuntime(ctx context.Context, userID UserID, conversationID uuid.UUID) error

func (*ProjectConversationService) ConfigureActivityEmitter added in v0.4.0

func (s *ProjectConversationService) ConfigureActivityEmitter(emitter projectConversationActivityEmitter)

func (*ProjectConversationService) ConfigureGitHubCredentials

func (s *ProjectConversationService) ConfigureGitHubCredentials(resolver githubauthservice.TokenResolver)

func (*ProjectConversationService) ConfigurePlatformEnvironment

func (s *ProjectConversationService) ConfigurePlatformEnvironment(
	apiURL string,
	platform projectConversationAgentPlatform,
)

func (*ProjectConversationService) ConfigureSecretManager added in v0.3.0

func (s *ProjectConversationService) ConfigureSecretManager(manager projectConversationSecretManager)

func (*ProjectConversationService) ConfigureSecretResolver added in v0.3.0

func (s *ProjectConversationService) ConfigureSecretResolver(resolver RuntimeEnvironmentResolver)

func (*ProjectConversationService) CreateConversation

func (s *ProjectConversationService) CreateConversation(
	ctx context.Context,
	userID UserID,
	projectID uuid.UUID,
	providerID uuid.UUID,
) (domain.Conversation, error)

func (*ProjectConversationService) DeleteConversation added in v0.4.0

func (s *ProjectConversationService) DeleteConversation(
	ctx context.Context,
	userID UserID,
	conversationID uuid.UUID,
	input domain.DeleteConversationInput,
) (domain.DeleteConversationResult, error)

func (*ProjectConversationService) GetConversation

func (s *ProjectConversationService) GetConversation(ctx context.Context, userID UserID, conversationID uuid.UUID) (domain.Conversation, error)

func (*ProjectConversationService) GetPrincipal

func (s *ProjectConversationService) GetPrincipal(ctx context.Context, userID UserID, conversationID uuid.UUID) (domain.ProjectConversationPrincipal, error)

func (*ProjectConversationService) GetWorkspaceDiff

func (s *ProjectConversationService) GetWorkspaceDiff(
	ctx context.Context,
	userID UserID,
	conversationID uuid.UUID,
) (ProjectConversationWorkspaceDiff, error)

func (*ProjectConversationService) GetWorkspaceMetadata added in v0.4.0

func (s *ProjectConversationService) GetWorkspaceMetadata(
	ctx context.Context,
	userID UserID,
	conversationID uuid.UUID,
) (ProjectConversationWorkspaceMetadata, error)

func (*ProjectConversationService) InterruptTurn added in v0.4.0

func (s *ProjectConversationService) InterruptTurn(
	ctx context.Context,
	userID UserID,
	conversationID uuid.UUID,
) error

func (*ProjectConversationService) ListConversations

func (s *ProjectConversationService) ListConversations(
	ctx context.Context,
	userID UserID,
	projectID uuid.UUID,
	providerID *uuid.UUID,
) ([]domain.Conversation, error)

func (*ProjectConversationService) ListEntries

func (s *ProjectConversationService) ListEntries(ctx context.Context, userID UserID, conversationID uuid.UUID) ([]domain.Entry, error)

func (*ProjectConversationService) ListWorkspaceTree added in v0.4.0

func (s *ProjectConversationService) ListWorkspaceTree(
	ctx context.Context,
	userID UserID,
	conversationID uuid.UUID,
	repoPath string,
	treePath string,
) (ProjectConversationWorkspaceTree, error)

func (*ProjectConversationService) ReadWorkspaceFilePatch added in v0.4.0

func (s *ProjectConversationService) ReadWorkspaceFilePatch(
	ctx context.Context,
	userID UserID,
	conversationID uuid.UUID,
	repoPath string,
	filePath string,
) (ProjectConversationWorkspaceFilePatch, error)

func (*ProjectConversationService) ReadWorkspaceFilePreview added in v0.4.0

func (s *ProjectConversationService) ReadWorkspaceFilePreview(
	ctx context.Context,
	userID UserID,
	conversationID uuid.UUID,
	repoPath string,
	filePath string,
) (ProjectConversationWorkspaceFilePreview, error)

func (*ProjectConversationService) RespondInterrupt

func (s *ProjectConversationService) RespondInterrupt(
	ctx context.Context,
	userID UserID,
	conversationID uuid.UUID,
	interruptID uuid.UUID,
	response domain.InterruptResponse,
) (domain.PendingInterrupt, error)

func (*ProjectConversationService) RunRetentionCleanup added in v0.4.0

func (s *ProjectConversationService) RunRetentionCleanup(
	ctx context.Context,
) ([]domain.RetentionCleanupResult, error)

func (*ProjectConversationService) StartTurn

func (s *ProjectConversationService) StartTurn(
	ctx context.Context,
	userID UserID,
	conversationID uuid.UUID,
	message string,
	focus *ProjectConversationFocus,
) (domain.Turn, error)

func (*ProjectConversationService) SyncWorkspace added in v0.4.0

func (s *ProjectConversationService) SyncWorkspace(
	ctx context.Context,
	userID UserID,
	conversationID uuid.UUID,
) (ProjectConversationWorkspaceMetadata, error)

func (*ProjectConversationService) WatchConversation

func (s *ProjectConversationService) WatchConversation(
	ctx context.Context,
	userID UserID,
	conversationID uuid.UUID,
) (<-chan StreamEvent, func(), error)

func (*ProjectConversationService) WatchProjectConversations

func (s *ProjectConversationService) WatchProjectConversations(
	ctx context.Context,
	userID UserID,
	projectID uuid.UUID,
) (<-chan ProjectConversationMuxEvent, func(), error)

type ProjectConversationSkillFocus

type ProjectConversationSkillFocus struct {
	ID                 uuid.UUID
	Name               string
	SelectedFilePath   string
	BoundWorkflowNames []string
	HasDirtyDraft      bool
}

type ProjectConversationTicketActivity

type ProjectConversationTicketActivity struct {
	EventType string
	Message   string
	CreatedAt string
}

type ProjectConversationTicketAssignedAgent

type ProjectConversationTicketAssignedAgent struct {
	ID                  string
	Name                string
	Provider            string
	RuntimeControlState string
	RuntimePhase        string
}

type ProjectConversationTicketDependency

type ProjectConversationTicketDependency struct {
	Identifier string
	Title      string
	Relation   string
	Status     string
}

type ProjectConversationTicketFocus

type ProjectConversationTicketFocus struct {
	ID             uuid.UUID
	Identifier     string
	Title          string
	Description    string
	Status         string
	Priority       string
	AttemptCount   int
	RetryPaused    bool
	PauseReason    string
	SelectedArea   string
	Dependencies   []ProjectConversationTicketDependency
	RepoScopes     []ProjectConversationTicketRepoScope
	RecentActivity []ProjectConversationTicketActivity
	HookHistory    []ProjectConversationTicketHook
	AssignedAgent  *ProjectConversationTicketAssignedAgent
	CurrentRun     *ProjectConversationTicketRun
	TargetMachine  *ProjectConversationTicketTargetMachine
}

type ProjectConversationTicketHook

type ProjectConversationTicketHook struct {
	HookName  string
	Status    string
	Output    string
	Timestamp string
}

type ProjectConversationTicketRepoScope

type ProjectConversationTicketRepoScope struct {
	RepoID         string
	RepoName       string
	BranchName     string
	PullRequestURL string
}

type ProjectConversationTicketRun

type ProjectConversationTicketRun struct {
	ID                 string
	AttemptNumber      int
	Status             string
	CurrentStepStatus  string
	CurrentStepSummary string
	LastError          string
}

type ProjectConversationTicketTargetMachine

type ProjectConversationTicketTargetMachine struct {
	ID   string
	Name string
	Host string
}

type ProjectConversationWorkflowFocus

type ProjectConversationWorkflowFocus struct {
	ID            uuid.UUID
	Name          string
	Type          string
	HarnessPath   string
	IsActive      bool
	SelectedArea  string
	HasDirtyDraft bool
}

type ProjectConversationWorkspaceDiff

type ProjectConversationWorkspaceDiff struct {
	ConversationID uuid.UUID
	WorkspacePath  string
	Dirty          bool
	ReposChanged   int
	FilesChanged   int
	Added          int
	Removed        int
	Repos          []ProjectConversationWorkspaceRepoDiff
	SyncPrompt     *ProjectConversationWorkspaceSyncPrompt
}

type ProjectConversationWorkspaceDiffKind added in v0.4.0

type ProjectConversationWorkspaceDiffKind string
const (
	ProjectConversationWorkspaceDiffKindNone   ProjectConversationWorkspaceDiffKind = "none"
	ProjectConversationWorkspaceDiffKindText   ProjectConversationWorkspaceDiffKind = "text"
	ProjectConversationWorkspaceDiffKindBinary ProjectConversationWorkspaceDiffKind = "binary"
)

type ProjectConversationWorkspaceFileDiff

type ProjectConversationWorkspaceFileDiff struct {
	Path    string
	Status  ProjectConversationWorkspaceFileStatus
	Added   int
	Removed int
}

type ProjectConversationWorkspaceFilePatch added in v0.4.0

type ProjectConversationWorkspaceFilePatch struct {
	ConversationID uuid.UUID
	RepoPath       string
	Path           string
	Status         ProjectConversationWorkspaceFileStatus
	DiffKind       ProjectConversationWorkspaceDiffKind
	Truncated      bool
	Diff           string
}

type ProjectConversationWorkspaceFilePreview added in v0.4.0

type ProjectConversationWorkspaceFilePreview struct {
	ConversationID uuid.UUID
	RepoPath       string
	Path           string
	SizeBytes      int64
	MediaType      string
	PreviewKind    ProjectConversationWorkspacePreviewKind
	Truncated      bool
	Content        string
}

type ProjectConversationWorkspaceFileStatus

type ProjectConversationWorkspaceFileStatus string
const (
	ProjectConversationWorkspaceFileStatusModified  ProjectConversationWorkspaceFileStatus = "modified"
	ProjectConversationWorkspaceFileStatusAdded     ProjectConversationWorkspaceFileStatus = "added"
	ProjectConversationWorkspaceFileStatusDeleted   ProjectConversationWorkspaceFileStatus = "deleted"
	ProjectConversationWorkspaceFileStatusRenamed   ProjectConversationWorkspaceFileStatus = "renamed"
	ProjectConversationWorkspaceFileStatusUntracked ProjectConversationWorkspaceFileStatus = "untracked"
)

type ProjectConversationWorkspaceMetadata added in v0.4.0

type ProjectConversationWorkspaceMetadata struct {
	ConversationID uuid.UUID
	Available      bool
	WorkspacePath  string
	Repos          []ProjectConversationWorkspaceRepoMetadata
	SyncPrompt     *ProjectConversationWorkspaceSyncPrompt
}

type ProjectConversationWorkspaceMissingRepo added in v0.4.0

type ProjectConversationWorkspaceMissingRepo struct {
	Name string
	Path string
}

type ProjectConversationWorkspacePreviewKind added in v0.4.0

type ProjectConversationWorkspacePreviewKind string
const (
	ProjectConversationWorkspacePreviewKindText   ProjectConversationWorkspacePreviewKind = "text"
	ProjectConversationWorkspacePreviewKindBinary ProjectConversationWorkspacePreviewKind = "binary"
)

type ProjectConversationWorkspaceRepoDiff

type ProjectConversationWorkspaceRepoDiff struct {
	Name         string
	Path         string
	Branch       string
	Dirty        bool
	FilesChanged int
	Added        int
	Removed      int
	Files        []ProjectConversationWorkspaceFileDiff
}

type ProjectConversationWorkspaceRepoMetadata added in v0.4.0

type ProjectConversationWorkspaceRepoMetadata struct {
	Name         string
	Path         string
	Branch       string
	HeadCommit   string
	HeadSummary  string
	Dirty        bool
	FilesChanged int
	Added        int
	Removed      int
}

type ProjectConversationWorkspaceSyncPrompt added in v0.4.0

type ProjectConversationWorkspaceSyncPrompt struct {
	Reason       ProjectConversationWorkspaceSyncReason
	MissingRepos []ProjectConversationWorkspaceMissingRepo
}

type ProjectConversationWorkspaceSyncReason added in v0.4.0

type ProjectConversationWorkspaceSyncReason string
const (
	ProjectConversationWorkspaceSyncReasonRepoBindingChanged ProjectConversationWorkspaceSyncReason = "repo_binding_changed"
	ProjectConversationWorkspaceSyncReasonRepoMissing        ProjectConversationWorkspaceSyncReason = "repo_missing"
)

type ProjectConversationWorkspaceSyncRequiredError added in v0.4.0

type ProjectConversationWorkspaceSyncRequiredError struct {
	Prompt   ProjectConversationWorkspaceSyncPrompt
	RepoPath string
}

func (*ProjectConversationWorkspaceSyncRequiredError) Error added in v0.4.0

func (*ProjectConversationWorkspaceSyncRequiredError) Is added in v0.4.0

type ProjectConversationWorkspaceTree added in v0.4.0

type ProjectConversationWorkspaceTree struct {
	ConversationID uuid.UUID
	RepoPath       string
	Path           string
	Entries        []ProjectConversationWorkspaceTreeEntry
}

type ProjectConversationWorkspaceTreeEntry added in v0.4.0

type ProjectConversationWorkspaceTreeEntry struct {
	Path      string
	Name      string
	Kind      ProjectConversationWorkspaceTreeEntryKind
	SizeBytes int64
}

type ProjectConversationWorkspaceTreeEntryKind added in v0.4.0

type ProjectConversationWorkspaceTreeEntryKind string
const (
	ProjectConversationWorkspaceTreeEntryKindDirectory ProjectConversationWorkspaceTreeEntryKind = "directory"
	ProjectConversationWorkspaceTreeEntryKindFile      ProjectConversationWorkspaceTreeEntryKind = "file"
)

type RawChatContext

type RawChatContext struct {
	ProjectID *string `json:"project_id"`
	TicketID  *string `json:"ticket_id"`
}

type RawProjectConversationFocus

type RawProjectConversationFocus struct {
	Kind                 string                                     `json:"kind"`
	WorkflowID           *string                                    `json:"workflow_id"`
	WorkflowName         *string                                    `json:"workflow_name"`
	WorkflowType         *string                                    `json:"workflow_type"`
	HarnessPath          *string                                    `json:"harness_path"`
	IsActive             *bool                                      `json:"is_active"`
	SelectedArea         *string                                    `json:"selected_area"`
	HasDirtyDraft        *bool                                      `json:"has_dirty_draft"`
	SkillID              *string                                    `json:"skill_id"`
	SkillName            *string                                    `json:"skill_name"`
	SelectedFilePath     *string                                    `json:"selected_file_path"`
	BoundWorkflowNames   []string                                   `json:"bound_workflow_names"`
	TicketID             *string                                    `json:"ticket_id"`
	TicketIdentifier     *string                                    `json:"ticket_identifier"`
	TicketTitle          *string                                    `json:"ticket_title"`
	TicketDescription    *string                                    `json:"ticket_description"`
	TicketStatus         *string                                    `json:"ticket_status"`
	TicketPriority       *string                                    `json:"ticket_priority"`
	TicketAttemptCount   *int                                       `json:"ticket_attempt_count"`
	TicketRetryPaused    *bool                                      `json:"ticket_retry_paused"`
	TicketPauseReason    *string                                    `json:"ticket_pause_reason"`
	TicketDependencies   []RawProjectConversationTicketDependency   `json:"ticket_dependencies"`
	TicketRepoScopes     []RawProjectConversationTicketRepoScope    `json:"ticket_repo_scopes"`
	TicketRecentActivity []RawProjectConversationTicketActivity     `json:"ticket_recent_activity"`
	TicketHookHistory    []RawProjectConversationTicketHook         `json:"ticket_hook_history"`
	TicketAssignedAgent  *RawProjectConversationTicketAssignedAgent `json:"ticket_assigned_agent"`
	TicketCurrentRun     *RawProjectConversationTicketRun           `json:"ticket_current_run"`
	TicketTargetMachine  *RawProjectConversationTicketTargetMachine `json:"ticket_target_machine"`
	MachineID            *string                                    `json:"machine_id"`
	MachineName          *string                                    `json:"machine_name"`
	MachineHost          *string                                    `json:"machine_host"`
	MachineStatus        *string                                    `json:"machine_status"`
	HealthSummary        *string                                    `json:"health_summary"`
}

type RawProjectConversationTicketActivity

type RawProjectConversationTicketActivity struct {
	EventType *string `json:"event_type"`
	Message   *string `json:"message"`
	CreatedAt *string `json:"created_at"`
}

type RawProjectConversationTicketAssignedAgent

type RawProjectConversationTicketAssignedAgent struct {
	ID                  *string `json:"id"`
	Name                *string `json:"name"`
	Provider            *string `json:"provider"`
	RuntimeControlState *string `json:"runtime_control_state"`
	RuntimePhase        *string `json:"runtime_phase"`
}

type RawProjectConversationTicketDependency

type RawProjectConversationTicketDependency struct {
	Identifier *string `json:"identifier"`
	Title      *string `json:"title"`
	Relation   *string `json:"relation"`
	Status     *string `json:"status"`
}

type RawProjectConversationTicketHook

type RawProjectConversationTicketHook struct {
	HookName  *string `json:"hook_name"`
	Status    *string `json:"status"`
	Output    *string `json:"output"`
	Timestamp *string `json:"timestamp"`
}

type RawProjectConversationTicketRepoScope

type RawProjectConversationTicketRepoScope struct {
	RepoID         *string `json:"repo_id"`
	RepoName       *string `json:"repo_name"`
	BranchName     *string `json:"branch_name"`
	PullRequestURL *string `json:"pull_request_url"`
}

type RawProjectConversationTicketRun

type RawProjectConversationTicketRun struct {
	ID                 *string `json:"id"`
	AttemptNumber      *int    `json:"attempt_number"`
	Status             *string `json:"status"`
	CurrentStepStatus  *string `json:"current_step_status"`
	CurrentStepSummary *string `json:"current_step_summary"`
	LastError          *string `json:"last_error"`
}

type RawProjectConversationTicketTargetMachine

type RawProjectConversationTicketTargetMachine struct {
	ID   *string `json:"id"`
	Name *string `json:"name"`
	Host *string `json:"host"`
}

type RawStartInput

type RawStartInput struct {
	Message    string         `json:"message"`
	Source     string         `json:"source"`
	ProviderID *string        `json:"provider_id"`
	Context    RawChatContext `json:"context"`
	SessionID  *string        `json:"session_id"`
}

type Runtime

type Runtime interface {
	Supports(catalogdomain.AgentProvider) bool
	StartTurn(context.Context, RuntimeTurnInput) (TurnStream, error)
	CloseSession(SessionID) bool
}

func NewRuntime

func NewRuntime(runtimes ...Runtime) Runtime

type RuntimeEnvironmentResolveInput added in v0.3.0

type RuntimeEnvironmentResolveInput struct {
	ProjectID          uuid.UUID
	ProviderAuthConfig map[string]any
	BaseEnvironment    []string
	TicketID           *uuid.UUID
	WorkflowID         *uuid.UUID
	AgentID            *uuid.UUID
}

type RuntimeEnvironmentResolver added in v0.3.0

type RuntimeEnvironmentResolver interface {
	ResolveProviderEnvironment(ctx context.Context, input RuntimeEnvironmentResolveInput) ([]string, error)
}

type RuntimeInterruptDecision

type RuntimeInterruptDecision struct {
	ID    string `json:"id"`
	Label string `json:"label"`
}

type RuntimeInterruptEvent

type RuntimeInterruptEvent struct {
	RequestID string                     `json:"request_id"`
	Kind      string                     `json:"kind"`
	Options   []RuntimeInterruptDecision `json:"options,omitempty"`
	Payload   map[string]any             `json:"payload,omitempty"`
}

type RuntimeInterruptResponseInput

type RuntimeInterruptResponseInput struct {
	SessionID              SessionID
	ProjectID              uuid.UUID
	TicketID               *uuid.UUID
	WorkflowID             *uuid.UUID
	AgentID                *uuid.UUID
	Provider               catalogdomain.AgentProvider
	RequestID              string
	Kind                   string
	Decision               string
	Answer                 map[string]any
	Payload                map[string]any
	WorkingDirectory       provider.AbsolutePath
	Environment            []string
	ResumeProviderThreadID string
	ResumeProviderTurnID   string
	PersistentConversation bool
}

type RuntimeSessionAnchor

type RuntimeSessionAnchor struct {
	ProviderThreadID          string
	LastTurnID                string
	ProviderThreadStatus      string
	ProviderThreadActiveFlags []string
	ProviderAnchorID          string
	ProviderAnchorKind        string
	ProviderTurnSupported     bool
}

type RuntimeTurnInput

type RuntimeTurnInput struct {
	SessionID              SessionID
	ProjectID              uuid.UUID
	TicketID               *uuid.UUID
	WorkflowID             *uuid.UUID
	AgentID                *uuid.UUID
	Provider               catalogdomain.AgentProvider
	Message                string
	SystemPrompt           string
	WorkingDirectory       provider.AbsolutePath
	Environment            []string
	ResumeProviderThreadID string
	ResumeProviderTurnID   string
	MaxTurns               int
	MaxBudgetUSD           float64
	PersistentConversation bool
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(
	logger *slog.Logger,
	runtime Runtime,
	catalog catalogReader,
	tickets ticketReader,
	workflows workflowReader,
	statuses statusReader,
	projectsRoot provider.AbsolutePath,
) *Service

func (*Service) CloseSession

func (s *Service) CloseSession(userID UserID, sessionID SessionID) bool

func (*Service) EnableDurableSessions

func (s *Service) EnableDurableSessions(path string)

func (*Service) StartTurn

func (s *Service) StartTurn(ctx context.Context, userID UserID, input StartInput) (TurnStream, error)

type SessionID

type SessionID string

func ParseCloseSessionID

func ParseCloseSessionID(raw string) (SessionID, error)

func ParseSessionID

func ParseSessionID(raw string) (SessionID, error)

func (SessionID) String

func (s SessionID) String() string

type Source

type Source string
const (
	SourceProjectSidebar Source = "project_sidebar"
	SourceTicketDetail   Source = "ticket_detail"
)

type StartInput

type StartInput struct {
	Message    string
	Source     Source
	ProviderID *uuid.UUID
	Context    Context
	SessionID  *SessionID
}

func ParseStartInput

func ParseStartInput(raw RawStartInput) (StartInput, error)

type StreamEvent

type StreamEvent struct {
	Event   string
	Payload any
}

type TurnStream

type TurnStream struct {
	Events <-chan StreamEvent
}

type UserID

type UserID string
const AnonymousUserID UserID = "anonymous"
const LocalProjectConversationUserID UserID = "local-user:default"

LocalProjectConversationUserID is the stable non-OIDC owner used for persistent project conversations when browser login is disabled.

func ParseUserID

func ParseUserID(raw string) (UserID, error)

func (UserID) String

func (u UserID) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL