Help us shape the future of Go! Take the 2026 Go Developer Survey

manager

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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
	// SystemPromptVars 是渲染摘要 AgentProfile 系统提示词模板(pongo2)所需的变量。
	//
	// 与 RuntimeContextResolver 一致:这里只提供业务上下文事实(输出目录、输出文件等),
	// 真正的系统提示词由 AgentService 用 Profile 模板 + 这些变量渲染。
	SystemPromptVars map[string]any

	// WorkingDir 是 Agent 执行任务时的工作目录。
	WorkingDir string

	// ProjectID 是摘要所属对象(Analysis / AnalysisNode)归属的项目 ID,
	// 供 AISummaryWorker 回填到摘要记录。
	ProjectID int64
}

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,
	workflowRepo interfaces.WorkflowRepository,
	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

type AISummaryGenerateRequestEvent struct {
	OutboxID   int64
	RawPayload []byte
}

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 (*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

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 (*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) Describe added in v0.1.4

Describe 按 ContainerInstance ID 从运行时获取详情(docker inspect / kubectl describe)。

func (*ContainerManager) GetLogs

func (m *ContainerManager) GetLogs(ctx context.Context, id int64, tail int) (string, error)

func (*ContainerManager) GetMaxConcurrency

func (s *ContainerManager) GetMaxConcurrency() int

func (*ContainerManager) OnEvent

如果容器运行太快,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 CreateQueueStatus struct {
	ActiveCount    int64
	PendingCount   int64
	MaxConcurrency int
	MaxPending     int
}

type ImageManager

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

type OutboxCreateRequestEvent

type OutboxCreateRequestEvent struct {
	OutboxID   int64
	RawPayload []byte
}

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

type OutboxDeleteRequestEvent struct {
	OutboxID   int64
	RawPayload []byte
}

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 OutboxRecreateRequestEvent

type OutboxRecreateRequestEvent struct {
	OutboxID   int64
	RawPayload []byte
}

type OutboxStartRequestEvent

type OutboxStartRequestEvent struct {
	OutboxID   int64
	RawPayload []byte
}

OutboxStartRequestEvent is published to the event bus when a ContainerStartRequest outbox event is picked up.

type OutboxStopRequestEvent

type OutboxStopRequestEvent struct {
	OutboxID   int64
	RawPayload []byte
}

OutboxStopRequestEvent is published to the event bus when a ContainerStopRequest outbox event is picked up.

type RuntimeVariableSet added in v0.1.4

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

RuntimeVariableSet 是一组已求值的运行时变量,可派生扁平 map 或分类列表。

func (*RuntimeVariableSet) ByCategory added in v0.1.4

ByCategory 返回指定分类的变量,供前端分组展示。

func (*RuntimeVariableSet) List added in v0.1.4

List 返回全部变量(含元数据),供 API 返回。

func (*RuntimeVariableSet) ToMap added in v0.1.4

func (s *RuntimeVariableSet) ToMap() map[string]string

ToMap 派生扁平 map,供 ContainerRuntimeResolver 替换占位符,行为与原 setRuntimeVar 一致(跳过空值)。

Jump to

Keyboard shortcuts

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