chat

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound  = errors.New("payload not found")
	ErrNoContent = errors.New("no content")
)

Functions

This section is empty.

Types

type ConversationSummary

type ConversationSummary struct {
	ID      string  `json:"id"`
	Title   string  `json:"title"`
	Summary *string `json:"summary"`
}

ConversationSummary lists id + title only.

type CreateConversationRequest

type CreateConversationRequest struct {
	Model      string `json:"model"`
	Agent      string `json:"agent"`
	Tools      string `json:"tools"` // comma-separated
	Title      string `json:"title"`
	Visibility string `json:"visibility"`
}

CreateConversationRequest mirrors HTTP payload for POST /conversations.

type CreateConversationResponse

type CreateConversationResponse struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	CreatedAt string `json:"createdAt"`
	Model     string `json:"model,omitempty"`
	Agent     string `json:"agent,omitempty"`
	Tools     string `json:"tools,omitempty"`
}

CreateConversationResponse echoes created entity details.

type GetRequest

type GetRequest struct {
	ConversationID          string
	IncludeModelCallPayload bool
	SinceID                 string // optional: inclusive slice starting from this message id
	IncludeToolCall         bool
	ToolExtensions          []*toolfeed.FeedSpec
}

GetRequest defines inputs to fetch messages.

type GetResponse

type GetResponse struct {
	Conversation *apiconv.Conversation
}

GetResponse carries the rich conversation view for the given request.

type PostRequest

type PostRequest struct {
	Content string                 `json:"content"`
	Agent   string                 `json:"agent,omitempty"`
	Model   string                 `json:"model,omitempty"`
	Tools   []string               `json:"tools"`
	Context map[string]interface{} `json:"context,omitempty"`
	// Optional single-turn overrides
	ToolCallExposure *agent.ToolCallExposure `json:"toolCallExposure,omitempty"`
	AutoSummarize    *bool                   `json:"autoSummarize,omitempty"`
	DisableChains    bool                    `json:"disableChains,omitempty"`
	AllowedChains    []string                `json:"allowedChains"`
	// Attachments carries staged upload descriptors returned by Forge upload endpoint.
	// Each item must include at least name and uri (relative to storage root), optionally size, stagingFolder, mime.
	Attachments []UploadedAttachment `json:"attachments,omitempty"`
}

PostRequest defines inputs to submit a user message.

type Service

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

Service exposes message retrieval independent of HTTP concerns.

func NewService

func NewService() *Service

func NewServiceFromEnv added in v0.2.1

func NewServiceFromEnv(ctx context.Context) (*Service, error)

NewServiceFromEnv wires conversation client using environment configuration. Returns an error when conversation client cannot be initialized so that callers can fail fast instead of starting partially configured services.

func NewServiceWithClient added in v0.2.2

func NewServiceWithClient(cli apiconv.Client, dao *datly.Service) *Service

NewServiceWithClient constructs a chat service bound to a provided conversation client and shared datly.

func (*Service) Approve

func (s *Service) Approve(ctx context.Context, messageID, action, reason string) error

Approve processes an approval decision for a message. It acknowledges "cancel" without persisting any changes; for accept/decline it stores the status and forwards to the approval service when configured.

func (*Service) AttachApproval

func (s *Service) AttachApproval(svc approval.Service)

AttachApproval configures the approval service bridge for policy decisions.

func (*Service) AttachCore added in v0.2.1

func (s *Service) AttachCore(core *corellm.Service)

func (*Service) AttachDefaults added in v0.2.1

func (s *Service) AttachDefaults(d *execcfg.Defaults)

func (*Service) AttachElicitationService

func (s *Service) AttachElicitationService(es *elicitation.Service)

AttachElicitationService wires the elicitation service to avoid ad-hoc constructions.

func (*Service) AttachFileService

func (s *Service) AttachFileService(fs *fservice.Service)

AttachFileService wires the Forge file service instance so that attachment reads can reuse the same staging root and resolution.

func (*Service) AttachManager

func (s *Service) AttachManager(mgr *genconv.Manager, tp *tool.Policy)

AttachManager configures the conversation manager and optional default policies.

func (*Service) AttacheAgentFinder added in v0.2.1

func (s *Service) AttacheAgentFinder(agentFinder agent.Finder)

func (*Service) Cancel

func (s *Service) Cancel(conversationID string) bool

Cancel aborts all in-flight turns for the given conversation; returns true if any were cancelled.

func (*Service) CancelTurn

func (s *Service) CancelTurn(turnID string) bool

CancelTurn aborts a specific user turn (keyed by messageId) if running.

func (*Service) Compact added in v0.2.1

func (s *Service) Compact(ctx context.Context, conversationID string) error

Compact creates a summary message and flags prior messages as compacted (excluding elicitation I/O).

func (*Service) ConversationClient

func (s *Service) ConversationClient() apiconv.Client

ConversationClient exposes the underlying conversation client for handlers that need fine-grained operations without adding more methods to this service.

func (*Service) CreateConversation

CreateConversation persists a new conversation using DAO store.

func (*Service) DAO added in v0.2.2

func (s *Service) DAO() *datly.Service

DAO returns the underlying datly service when available.

func (*Service) DeleteConversation

func (s *Service) DeleteConversation(ctx context.Context, id string) error

DeleteConversation removes a conversation and cascades to dependent rows via DB FKs. It delegates to the underlying conversation client implementation.

func (*Service) DeleteMessage added in v0.2.2

func (s *Service) DeleteMessage(ctx context.Context, convID, messageID string) error

DeleteMessage removes a message from a conversation via the underlying client.

func (*Service) Elicit

func (s *Service) Elicit(ctx context.Context, messageID, action string, payload map[string]interface{}) error

Elicit processes an elicitation decision (accept/decline/cancel) and forwards the result to an MCP waiter if present.

func (*Service) ElicitationService

func (s *Service) ElicitationService() *elicitation.Service

func (*Service) Generate added in v0.2.1

func (s *Service) Generate(ctx context.Context, input *corellm.GenerateInput) (*corellm.GenerateOutput, error)

Generate exposes low-level core LLM generate bypassing agentic enrichment.

func (*Service) Get

func (s *Service) Get(ctx context.Context, req GetRequest) (*GetResponse, error)

Get fetches a conversation using the rich transcript API.

func (*Service) GetConversation

func (s *Service) GetConversation(ctx context.Context, id string) (*ConversationSummary, error)

GetConversation returns id + title by conversation id.

func (*Service) GetPayload

func (s *Service) GetPayload(ctx context.Context, id string) ([]byte, string, error)

GetPayload returns raw payload bytes and a content-type. It does not return metadata.

func (*Service) ListConversations

func (s *Service) ListConversations(ctx context.Context, input *apiconv.Input) ([]ConversationSummary, error)

ListConversations returns all conversation summaries.

func (*Service) MatchToolFeedSpec added in v0.2.1

func (s *Service) MatchToolFeedSpec(ctx context.Context, conversationID, sinceID string) ([]*toolfeed.FeedSpec, error)

ResolveToolExtensions computes applicable ToolExtensions for a conversation by inspecting observed tool calls and matching them against workspace extensions. When no tools are observed it includes any extensions with activation.kind==tool_call so that the hook can invoke them live.

func (*Service) Post

func (s *Service) Post(ctx context.Context, conversationID string, req PostRequest) (string, error)

Post accepts a user message and triggers asynchronous processing via manager. Returns generated message ID that can be used to track status.

func (*Service) PreflightPost

func (s *Service) PreflightPost(ctx context.Context, conversationID string, req PostRequest) error

PreflightPost validates minimal conditions before accepting a post. It ensures an agent can be determined either from request or conversation defaults.

func (*Service) PrepareToolContext added in v0.2.1

func (s *Service) PrepareToolContext(ctx context.Context, convID string, args map[string]interface{}) (context.Context, map[string]interface{}, error)

PrepareToolContext enriches args with conversation context (conversationId, lastTurnId) and returns a context carrying the conversationId for downstream services. convID must be non-empty.

func (*Service) Query added in v0.2.2

func (s *Service) Query(ctx context.Context, input *agentpkg.QueryInput) (*agentpkg.QueryOutput, error)

Query executes a synchronous agent turn using the configured conversation manager. It bubbles up any errors from downstream services without printing.

func (*Service) SetConversationStatus

func (s *Service) SetConversationStatus(ctx context.Context, conversationID string, status string) error

func (*Service) SetLastAssistentMessageStatus added in v0.2.2

func (s *Service) SetLastAssistentMessageStatus(ctx context.Context, conversationID, status string) error

SetLastAssistentMessageStatus updates the latest turn in a conversation.

func (*Service) SetMessageStatus

func (s *Service) SetMessageStatus(ctx context.Context, messageID, status string) error

SetMessageStatus patches a message status.

func (*Service) SetTurnStatus

func (s *Service) SetTurnStatus(ctx context.Context, turnID, status string, errorMessage ...string) error

SetTurnStatus patches a turn status. Use context.Background() when invoked from cancel path.

func (*Service) UserByUsername added in v0.2.2

func (s *Service) UserByUsername(ctx context.Context, username string) (string, error)

UserByUsername returns user id when available.

type UploadedAttachment

type UploadedAttachment struct {
	Name          string `json:"name"`
	Size          int    `json:"size,omitempty"`
	StagingFolder string `json:"stagingFolder,omitempty"`
	URI           string `json:"uri"`
	Mime          string `json:"mime,omitempty"`
}

UploadedAttachment mirrors Forge upload response structure.

Jump to

Keyboard shortcuts

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