Files
moteva/server/internal/domain/design/agent.go
T
root 44406b72db Initial commit: img-infinite-canvas AI design workbench MVP
Moteva-style AI design workbench replica. Home prompt creates a project;
the project page provides an infinite canvas with node drag, zoom/pan,
a design chat panel, history replay, image asset upload, and project
save/regenerate.

- Backend: go-zero, DDD layering, sqlc/pgx, optional PostgreSQL; memory
  or Redis cache; asynq job queue; MinIO/S3/R2/OSS object storage;
  sky-valley/pi agent runtime adapter.
- Frontend: Next.js App Router + Vite artifact build, TypeScript, i18n,
  shadcn/ui components, auth (OTP/Turnstile/Google/WeChat).
- Deploy: Docker Compose and k3s manifests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-07 23:15:37 +08:00

285 lines
6.1 KiB
Go

package design
import "context"
type AgentRequest struct {
Project Project
Prompt string
Mode string
ImageModel string
ImageSize string
Messages []AgentChatMessage
Memory AgentMemory
TaskPlan AgentTaskPlan
}
type AgentContent struct {
Type string
Text string
TextSource string
ImageURL string
ImageWidth int64
ImageHeight int64
}
type AgentChatMessage struct {
Role string
Contents []AgentContent
}
type AgentToolConfig struct {
PreferToolCategories map[string][]string
}
type AgentChatRequest struct {
Messages []AgentChatMessage
ToolConfig AgentToolConfig
ThreadID string
ThreadIDType int64
EnableMultimodalInput int64
EnableWebSearch bool
ImageModel string
ImageSize string
Mode string
}
type AgentThread struct {
ThreadID string
Status string
ThreadIDType int64
Project Project
}
type AgentThreadSummary struct {
AgentThreadID string
CoverImageURL string
Text string
ThreadIDType int64
UpdateTimestamp int64
}
type GeneratorTaskInputArgs struct {
AspectRatio string
Image []string
ImageURL string
Prompt string
Resolution string
SrcBox *NormalizedBox
DstBox *NormalizedBox
}
type GeneratorTaskSubmitRequest struct {
CID string
ProjectID string
GeneratorName string
InputArgs GeneratorTaskInputArgs
}
type GeneratorTaskPriceDetail struct {
BasePrice int64
ExtInfoForUnitCount string
GeneratorName string
InputArgs GeneratorTaskInputArgs
OutputArgs string
SearchKey string
TimeVariantPeriod string
TotalPrice int64
UnitCount int64
UnitName string
UnitPrice int64
}
type GeneratorTaskDisableUnlimitedPrice struct {
Balance int64
Price int64
PriceDetail GeneratorTaskPriceDetail
DisableUnlimited bool
}
type GeneratorTaskQueueInfo struct {
InQueue bool
Position int64
TotalQueueCount int64
EstimatedEndTime string
RemainingTimeSeconds int64
DisableUnlimitedPrice GeneratorTaskDisableUnlimitedPrice
}
type GeneratorTaskArtifactMetadata struct {
ArtifactID string
Format string
Height int64
Label string
NodeID string
NodeName string
SizeBytes int64
Width int64
}
type GeneratorTaskArtifact struct {
Type string
Content string
Metadata GeneratorTaskArtifactMetadata
}
type GeneratorTask struct {
GeneratorTaskID string
GeneratorName string
Status string
OriginalInputArgs GeneratorTaskInputArgs
QueueInfo GeneratorTaskQueueInfo
Artifacts []GeneratorTaskArtifact
Project Project
}
type ImageVectorizationRequest struct {
ImageDataURL string
Prompt string
Title string
Width int64
Height int64
}
type ImageVectorization struct {
SVG string
Width int64
Height int64
}
type ImageVectorizer interface {
VectorizeImage(ctx context.Context, req ImageVectorizationRequest) (ImageVectorization, error)
}
type AgentPlan struct {
Message Message
GeneratedNodes []Node
Connections []Connection
}
type AgentImageGenerationResult struct {
Index int
Node Node
}
type AgentTaskPlanRequest struct {
Project Project
Prompt string
Mode string
Messages []AgentChatMessage
Memory AgentMemory
WebSearchEnabled bool
}
type AgentImageTask struct {
Title string `json:"title"`
Brief string `json:"brief"`
}
type AgentTaskPlan struct {
Intent string
Reason string
UserFacingResponse string
ShouldSearch bool
SearchQuery string
SearchReason string
ImageCount int
ImageTasks []AgentImageTask
}
type AgentDecisionRequest struct {
Project Project
Prompt string
Mode string
Messages []AgentChatMessage
Memory AgentMemory
}
type AgentDecision struct {
Intent string
Reason string
}
type AgentConversationRequest struct {
Project Project
Prompt string
Mode string
Messages []AgentChatMessage
Memory AgentMemory
TaskPlan AgentTaskPlan
}
type AgentImageSummaryRequest struct {
Project Project
Prompt string
Mode string
ImageURL string
Memory AgentMemory
}
type AgentImagePromptRequest struct {
Project Project
Prompt string
Mode string
Messages []AgentChatMessage
Memory AgentMemory
TaskPlan AgentTaskPlan
}
type AgentImagePrompt struct {
Prompt string
Title string
}
type AgentResearchDecisionRequest struct {
Project Project
Prompt string
Mode string
Messages []AgentChatMessage
Memory AgentMemory
}
type AgentResearchDecision struct {
ShouldSearch bool
Query string
Reason string
}
type CreativeAgent interface {
Decide(ctx context.Context, req AgentDecisionRequest) (AgentDecision, error)
Respond(ctx context.Context, req AgentConversationRequest) (string, error)
SummarizeImage(ctx context.Context, req AgentImageSummaryRequest) (string, error)
BuildImagePrompt(ctx context.Context, req AgentImagePromptRequest) (AgentImagePrompt, error)
}
type ResearchDecider interface {
DecideResearch(ctx context.Context, req AgentResearchDecisionRequest) (AgentResearchDecision, error)
}
type AgentTaskPlanner interface {
PlanAgentTask(ctx context.Context, req AgentTaskPlanRequest) (AgentTaskPlan, error)
}
type AgentPlanningNarrator interface {
StreamPlanNarration(ctx context.Context, req AgentTaskPlanRequest, onDelta func(delta string) error) (string, error)
}
type StreamingCreativeAgent interface {
CreativeAgent
StreamRespond(ctx context.Context, req AgentConversationRequest, onDelta func(delta string) error) (string, error)
}
type AgentReplay struct {
ProjectID string
Messages []Message
}
type AgentRunner interface {
Plan(ctx context.Context, req AgentRequest) (AgentPlan, error)
Replay(ctx context.Context, project Project) (AgentReplay, error)
}
type IncrementalAgentRunner interface {
AgentRunner
PlanIncremental(ctx context.Context, req AgentRequest, onResult func(AgentImageGenerationResult) error) (AgentPlan, error)
}