Documentation
¶
Index ¶
- Constants
- func RunOutboxDispatcher(dispatcher *OutboxDispatcher)
- type AISummaryContent
- type AISummaryContentProvider
- type AISummaryEventHandler
- type AISummaryGenerateRequestEvent
- type AISummaryWorker
- type AgentProjectContextProvider
- type AppSessionEventHandler
- type ContainerCreateWorker
- type ContainerManager
- func (m *ContainerManager) CreateByTemplate(ctx context.Context, templateID int64, ownerType types.ContainerOwnerType, ...) (*types.ContainerInstance, error)
- func (m *ContainerManager) CreateQueueMaxPending() int
- func (m *ContainerManager) Delete(ctx context.Context, id int64) error
- func (m *ContainerManager) GetLogs(ctx context.Context, id int64, tail int) (string, error)
- func (s *ContainerManager) GetMaxConcurrency() int
- func (m *ContainerManager) OnEvent(e containerruntime.RuntimeEvent)
- func (m *ContainerManager) QueueStatus(ctx context.Context) (*CreateQueueStatus, error)
- func (m *ContainerManager) RecoverRuntimeMonitoring(ctx context.Context) (int, error)
- func (m *ContainerManager) RunRuntimeReconciler(ctx context.Context, interval time.Duration)
- func (m *ContainerManager) Start(ctx context.Context, id int64) error
- func (m *ContainerManager) Stop(ctx context.Context, id int64) error
- func (m *ContainerManager) StopByOwner(ctx context.Context, ownerType types.ContainerOwnerType, ownerID int64) error
- func (s *ContainerManager) TransitionContainerAndEnqueueOutbox(ctx context.Context, inst *types.ContainerInstance, to types.ContainerStatus, ...) error
- type ContainerRuntimeResolveInput
- type ContainerRuntimeResolver
- type CreateQueueStatus
- type ImageManager
- type OutboxCreateRequestEvent
- type OutboxDeleteRequestEvent
- type OutboxDispatcher
- type OutboxRecreateRequestEvent
- type OutboxStartRequestEvent
- type OutboxStopRequestEvent
Constants ¶
const ( // OutboxEventTypeCreateRequest is the outbox event type for container creation requests. OutboxEventTypeCreateRequest = "ContainerCreateRequest" // OutboxEventTypeStopRequest is the outbox event type for container stop requests. OutboxEventTypeStopRequest = "ContainerStopRequest" // OutboxEventTypeDeleteRequest is the outbox event type for container delete requests. OutboxEventTypeDeleteRequest = "ContainerDeleteRequest" // OutboxEventTypeStartRequest is the outbox event type for container start requests. OutboxEventTypeRecreateRequest = "AppSessionContainerRecreateRequest" OutboxEventTypeStartRequest = "ContainerStartRequest" )
const OutboxEventTypeAISummaryGenerateRequest = "AISummaryGenerateRequest"
OutboxEventTypeAISummaryGenerateRequest 是 AI 摘要生成请求的 outbox 事件类型。
Variables ¶
This section is empty.
Functions ¶
func RunOutboxDispatcher ¶
func RunOutboxDispatcher(dispatcher *OutboxDispatcher)
Types ¶
type AISummaryContent ¶ added in v0.1.2
type AISummaryContent struct {
// Title 是摘要标题的候选值。
Title string
// SystemPrompt 是交给 Agent 生成摘要时的系统提示词。
SystemPrompt string
// Text 是交给 Agent 生成摘要的原始内容(用户输入)。
Text string
WorkingDir string
}
AISummaryContent 是生成摘要所需的原始内容。
type AISummaryContentProvider ¶ added in v0.1.2
type AISummaryContentProvider interface {
Resolve(ctx context.Context, ownerType types.SummaryOwnerType, ownerID int64) (AISummaryContent, error)
}
AISummaryContentProvider 根据摘要所属对象解析用于生成摘要的原始内容。 当前基于 Analysis / AnalysisNode 的字段组装文本;后续可扩展为读取 实际 output 文件内容。
func NewAISummaryContentProvider ¶ added in v0.1.2
func NewAISummaryContentProvider(analysisRepo interfaces.AnalysisRepository, cfg *config.Config) AISummaryContentProvider
NewAISummaryContentProvider 创建 AISummaryContentProvider。 系统提示词优先读取配置 cfg.AISummary.SystemPrompt,未配置时回退到默认值。
type AISummaryEventHandler ¶ added in v0.1.2
type AISummaryEventHandler struct {
// contains filtered or unexported fields
}
AISummaryEventHandler 订阅 AISummaryStatusEvent,并将摘要状态变更推送给 所属项目用户,前端据此刷新 AISummaryPanel。
func NewAISummaryEventHandler ¶ added in v0.1.2
func NewAISummaryEventHandler(db *gorm.DB, analysisRepo interfaces.AnalysisRepository, projectRepo interfaces.ProjectRepository, hub *realtime.Hub) *AISummaryEventHandler
func (*AISummaryEventHandler) Handle ¶ added in v0.1.2
func (h *AISummaryEventHandler) Handle(evt event.Event)
type AISummaryGenerateRequestEvent ¶ added in v0.1.2
AISummaryGenerateRequestEvent is published to the event bus when an AISummaryGenerateRequest outbox event is picked up.
type AISummaryWorker ¶ added in v0.1.2
type AISummaryWorker struct {
// contains filtered or unexported fields
}
AISummaryWorker 订阅 AISummaryGenerateRequestEvent,异步执行 AI 摘要生成。
func NewAISummaryWorker ¶ added in v0.1.2
func NewAISummaryWorker( summaryRepo interfaces.AISummaryRepository, containerRepo interfaces.ContainerRepository, bus event.Bus, agentService *agent.AgentService, content AISummaryContentProvider, ) *AISummaryWorker
NewAISummaryWorker 创建 AISummaryWorker。
func (*AISummaryWorker) Handle ¶ added in v0.1.2
func (w *AISummaryWorker) Handle(evt event.Event)
Handle 分发事件到对应的处理逻辑。
type AgentProjectContextProvider ¶ added in v0.1.2
type AgentProjectContextProvider struct {
// contains filtered or unexported fields
}
AgentProjectContextProvider 实现 agent.ProjectContextProvider: 查询当前用户激活项目下已完成(status=done)的分析节点,以及项目关联的参考文献, 并格式化为注入上下文的文本。
采用实时查询而非写入 memory repo 的设计:analysis_nodes / project_literature 是领域状态的唯一数据源,状态在运行期间频繁变化,实时查询可保证注入内容始终最新。
func NewAgentProjectContextProvider ¶ added in v0.1.2
func NewAgentProjectContextProvider( projects interfaces.ProjectRepository, analyses interfaces.AnalysisRepository, cfg *config.Config, ) *AgentProjectContextProvider
NewAgentProjectContextProvider 创建项目上下文提供者。
func (*AgentProjectContextProvider) ProjectContext ¶ added in v0.1.2
func (p *AgentProjectContextProvider) ProjectContext(ctx context.Context, userID string) (string, error)
ProjectContext 实现 agent.ProjectContextProvider。
type AppSessionEventHandler ¶
type AppSessionEventHandler struct {
// contains filtered or unexported fields
}
AppSessionEventHandler listens for ContainerEvent on the event bus and synchronizes the corresponding AppSession status accordingly.
When a container transitions to creating/running/stopped/failed, this handler updates the owning AppSession's Status, StartedAt, and StoppedAt fields so that the AppSession reflects the actual container lifecycle.
Only containers with OwnerType == ContainerOwnerAppSession are processed; DAG nodes and services are ignored.
func NewAppSessionEventHandler ¶
func NewAppSessionEventHandler(repo interfaces.ContainerRepository, hub *realtime.Hub) *AppSessionEventHandler
func (*AppSessionEventHandler) Handle ¶
func (h *AppSessionEventHandler) Handle(evt event.Event)
type ContainerCreateWorker ¶
type ContainerCreateWorker struct {
// contains filtered or unexported fields
}
ContainerCreateWorker subscribes to OutboxCreateRequestEvent and ContainerEvent from the event bus. For creation requests it executes rt.Create + rt.Start, and updates the active create request count while the request is being handled.
func NewContainerCreateWorker ¶
func NewContainerCreateWorker( repo interfaces.ContainerRepository, projectRepo interfaces.ProjectRepository, analysisRepo interfaces.AnalysisRepository, workflowService interfaces.WorkflowService, reg *containerruntime.Registry, res ContainerRuntimeResolver, containerManager *ContainerManager, cfg *config.Config, ) *ContainerCreateWorker
NewContainerCreateWorker creates a new worker.
func (*ContainerCreateWorker) Handle ¶
func (w *ContainerCreateWorker) Handle(evt event.Event)
Handle dispatches events from the event bus. It handles four event types:
- OutboxCreateRequestEvent: executes deferred container creation
- OutboxStopRequestEvent: executes deferred container stop
- OutboxDeleteRequestEvent: executes deferred container delete
- OutboxStartRequestEvent: executes deferred container start
type ContainerManager ¶
type ContainerManager struct {
// contains filtered or unexported fields
}
func NewContainerManager ¶
func NewContainerManager( containerRepo interfaces.ContainerRepository, analysisRepo interfaces.AnalysisRepository, projectRepo interfaces.ProjectRepository, workflowService interfaces.WorkflowService, reg *containerruntime.Registry, bus event.Bus, res ContainerRuntimeResolver, img *ImageManager, cfg *config.Config, ) *ContainerManager
func (*ContainerManager) CreateByTemplate ¶
func (m *ContainerManager) CreateByTemplate( ctx context.Context, templateID int64, ownerType types.ContainerOwnerType, ownerID int64, name string, ) (*types.ContainerInstance, error)
return nil }
func (*ContainerManager) CreateQueueMaxPending ¶
func (m *ContainerManager) CreateQueueMaxPending() int
func (*ContainerManager) Delete ¶
func (m *ContainerManager) Delete(ctx context.Context, id int64) error
func (*ContainerManager) GetMaxConcurrency ¶
func (s *ContainerManager) GetMaxConcurrency() int
func (*ContainerManager) OnEvent ¶
func (m *ContainerManager) OnEvent(e containerruntime.RuntimeEvent)
如果容器运行太快,ContainerStarted与 ContainerExited可能会竞争
func (*ContainerManager) QueueStatus ¶
func (m *ContainerManager) QueueStatus(ctx context.Context) (*CreateQueueStatus, error)
func (*ContainerManager) RecoverRuntimeMonitoring ¶
func (m *ContainerManager) RecoverRuntimeMonitoring(ctx context.Context) (int, error)
func (*ContainerManager) RunRuntimeReconciler ¶
func (m *ContainerManager) RunRuntimeReconciler(ctx context.Context, interval time.Duration)
RunRuntimeReconciler periodically reconnects runtime monitoring.
func (*ContainerManager) Start ¶
func (m *ContainerManager) Start(ctx context.Context, id int64) error
func (*ContainerManager) Stop ¶
func (m *ContainerManager) Stop(ctx context.Context, id int64) error
func (*ContainerManager) StopByOwner ¶
func (m *ContainerManager) StopByOwner(ctx context.Context, ownerType types.ContainerOwnerType, ownerID int64) error
func (*ContainerManager) TransitionContainerAndEnqueueOutbox ¶
func (s *ContainerManager) TransitionContainerAndEnqueueOutbox(ctx context.Context, inst *types.ContainerInstance, to types.ContainerStatus, eventType string) error
type ContainerRuntimeResolveInput ¶
type ContainerRuntimeResolveInput struct {
Spec *types.ContainerSpec
Variables map[string]string
}
type ContainerRuntimeResolver ¶
type ContainerRuntimeResolver interface {
Resolve(ctx context.Context, in *ContainerRuntimeResolveInput) (*types.ContainerSpec, error)
}
func NewDefaultContainerRuntimeResolver ¶
func NewDefaultContainerRuntimeResolver() ContainerRuntimeResolver
type CreateQueueStatus ¶
type ImageManager ¶
type ImageManager struct {
// contains filtered or unexported fields
}
func NewImageManager ¶
func NewImageManager(repo interfaces.ContainerRepository, reg *containerruntime.Registry) *ImageManager
type OutboxCreateRequestEvent ¶
OutboxCreateRequestEvent is published to the event bus when a ContainerCreateRequest outbox event is picked up. Handlers that need to process deferred container creation subscribe to this.
type OutboxDeleteRequestEvent ¶
OutboxDeleteRequestEvent is published to the event bus when a ContainerDeleteRequest outbox event is picked up.
type OutboxDispatcher ¶
type OutboxDispatcher struct {
// contains filtered or unexported fields
}
func NewOutboxDispatcher ¶
func NewOutboxDispatcher(repo interfaces.ContainerRepository, bus event.Bus) *OutboxDispatcher
func (*OutboxDispatcher) Start ¶
func (d *OutboxDispatcher) Start(ctx context.Context)
type OutboxStartRequestEvent ¶
OutboxStartRequestEvent is published to the event bus when a ContainerStartRequest outbox event is picked up.
type OutboxStopRequestEvent ¶
OutboxStopRequestEvent is published to the event bus when a ContainerStopRequest outbox event is picked up.
Source Files
¶
- agent_project_context.go
- ai_summary_content_provider.go
- ai_summary_event_handler.go
- ai_summary_worker.go
- app_session_event_handler.go
- container_create_worker.go
- container_manager.go
- container_manager_runtime_reconciler.go
- container_runtime_resolver.go
- create_queue_status.go
- image_manager.go
- outbox_dispatcher.go