astrbot_plugin_imagestudio/frontend/standalone-web/src/App.vue

3099 行
102 KiB
Vue

<script setup lang="ts">
import { computed, onMounted, ref } from "vue"
import { endpoints } from "../../shared/api/endpoints"
import { getJson, postJson, request } from "../../shared/api/client"
import type { UiBootstrap } from "../../shared/types/bootstrap"
import type { DashboardSummary } from "../../shared/types/dashboard"
import type { ApiDialect, CapabilityProfile, RenderPlanValidationResult } from "../../shared/types/discovery"
import type { GenerationImage, NodeGenerateResult } from "../../shared/types/image"
import type { DailyOutfitResult } from "../../shared/types/integration"
import type { GenerationJob, JobListResult } from "../../shared/types/job"
import type { LogBundle } from "../../shared/types/logs"
import type { Material, MaterialCategory, MaterialListResult } from "../../shared/types/material"
import type { CharacterProfile, ProfileListResult, QuickProfileDraftResult } from "../../shared/types/profile"
import type { ReviewResult } from "../../shared/types/review"
import type {
CurrentSettings,
DiffSettingsResult,
ExportSettingsResult,
ImportSettingsResult,
ReloadSettingsResult,
RollbackSettingsResult,
SaveSettingsResult,
SettingsSchema,
SettingsSnapshot,
ValidateSettingsResult,
} from "../../shared/types/settings"
import type { MediaSignResult, StorageStatus } from "../../shared/types/storage"
import type { WardrobeItem, WardrobeMatchResult } from "../../shared/types/wardrobe"
import type {
ProfileWorkflow,
WorkflowBranch,
WorkflowDetail,
WorkflowHistoryEntry,
WorkflowNode,
} from "../../shared/types/workflow"
type ViewKey =
| "dashboard"
| "profiles"
| "workflows"
| "materials"
| "wardrobe"
| "jobs"
| "discovery"
| "logs"
| "settings"
const text = {
waiting: "\u7b49\u5f85\u64cd\u4f5c",
loading: "\u52a0\u8f7d\u4e2d...",
loadFailed: "\u52a0\u8f7d\u5931\u8d25",
refresh: "\u5237\u65b0",
complete: "\u5b8c\u6210",
failed: "\u5931\u8d25",
noProfile: "\u672a\u9009\u62e9\u89d2\u8272",
noTags: "\u65e0\u6807\u7b7e",
noImage: "\u672a\u7ed1\u5b9a\u56fe\u7247",
create: "\u65b0\u5efa",
quickDraft: "\u5feb\u901f\u8349\u7a3f",
archive: "\u5f52\u6863",
start: "\u542f\u52a8",
generate: "\u751f\u6210",
adopt: "\u91c7\u7eb3",
select: "\u9009\u62e9",
unselect: "\u53d6\u9009",
recognize: "\u8bc6\u522b",
confirm: "\u786e\u8ba4",
edit: "\u7f16\u8f91",
update: "\u66f4\u65b0",
name: "\u540d\u79f0",
identity: "\u8eab\u4efd",
personality: "\u6027\u683c",
hairColor: "\u53d1\u8272",
hairstyle: "\u53d1\u578b",
eyeColor: "\u773c\u8272",
description: "\u63cf\u8ff0",
basePrompt: "\u57fa\u7840\u63d0\u793a\u8bcd",
appearancePrompt: "\u5916\u89c2\u63d0\u793a\u8bcd",
stylePrompt: "\u98ce\u683c\u63d0\u793a\u8bcd",
negativePrompt: "\u53cd\u5411\u63d0\u793a\u8bcd",
imageUri: "\u56fe\u7247 URI",
tags: "\u6807\u7b7e",
category: "\u5206\u7c7b",
allCategories: "\u5168\u90e8\u5206\u7c7b",
materialCreated: "\u7d20\u6750\u5df2\u521b\u5efa",
materialUpdated: "\u7d20\u6750\u5df2\u66f4\u65b0",
materialUploaded: "\u7d20\u6750\u5df2\u767b\u8bb0\u4e0a\u4f20",
materialArchived: "\u7d20\u6750\u5df2\u5f52\u6863",
upload: "\u4e0a\u4f20\u767b\u8bb0",
filename: "\u6587\u4ef6\u540d",
contentType: "Content-Type",
importToWardrobe: "\u52a0\u5165\u8863\u6a71",
delete: "\u5220\u9664",
wardrobeCategory: "\u8863\u6a71\u5206\u7c7b",
season: "\u5b63\u8282",
style: "\u98ce\u683c",
selectMaterial: "\u9009\u62e9\u7d20\u6750",
wardrobeImported: "\u8863\u6a71\u6761\u76ee\u5df2\u52a0\u5165",
wardrobeDeleted: "\u8863\u6a71\u6761\u76ee\u5df2\u5220\u9664",
dailyOutfit: "\u6bcf\u65e5\u7a7f\u642d",
categories: "\u5206\u7c7b",
mood: "\u5fc3\u60c5",
weather: "\u5929\u6c14",
keywords: "\u5173\u952e\u8bcd",
outfitGenerated: "\u6bcf\u65e5\u7a7f\u642d\u5df2\u751f\u6210",
dashboard: "\u8fd0\u884c\u6982\u89c8",
profiles: "\u89d2\u8272",
workflows: "\u5de5\u4f5c\u6d41",
materials: "\u7d20\u6750\u5e93",
wardrobe: "\u89d2\u8272\u8863\u6a71",
jobs: "\u4efb\u52a1\u961f\u5217",
discovery: "\u80fd\u529b\u63a2\u6d4b",
logs: "\u65e5\u5fd7\u5ba1\u8ba1",
settings: "\u8bbe\u7f6e",
profileList: "\u89d2\u8272\u5217\u8868",
profileCreated: "\u89d2\u8272\u5df2\u521b\u5efa",
profileUpdated: "\u89d2\u8272\u5df2\u66f4\u65b0",
profileDeleted: "\u89d2\u8272\u5df2\u5220\u9664",
emptyProfiles: "\u6682\u65e0\u89d2\u8272",
workflowList: "\u5de5\u4f5c\u6d41\u5217\u8868",
workflowType: "\u5de5\u4f5c\u6d41\u7c7b\u578b",
workflowCreated: "\u5de5\u4f5c\u6d41\u5df2\u521b\u5efa",
emptyWorkflows: "\u6682\u65e0\u5de5\u4f5c\u6d41",
nodes: "\u8282\u70b9",
nodeKey: "NodeKey",
nodeTitle: "\u8282\u70b9\u6807\u9898",
nodeType: "\u8282\u70b9\u7c7b\u578b",
status: "\u72b6\u6001",
nodeCreated: "\u8282\u70b9\u5df2\u521b\u5efa",
nodeUpdated: "\u8282\u70b9\u5df2\u66f4\u65b0",
nodeQueued: "\u8282\u70b9\u5df2\u91cd\u65b0\u5165\u961f",
nodeCompleted: "\u8282\u70b9\u5df2\u5b8c\u6210",
images: "\u56fe\u7247",
branches: "\u5206\u652f",
branchName: "\u5206\u652f\u540d",
switchBranch: "\u5207\u6362\u5206\u652f",
history: "\u5386\u53f2",
review: "\u8bc4\u5ba1",
reviewResult: "\u8bc4\u5ba1\u7ed3\u679c",
emptyImages: "\u6682\u65e0\u56fe\u7247",
emptyHistory: "\u6682\u65e0\u5386\u53f2",
modelRoute: "\u6a21\u578b\u8def\u7531",
prompt: "\u63d0\u793a\u8bcd",
generationQueued: "\u751f\u6210\u5df2\u5165\u961f",
branchCreated: "\u5206\u652f\u5df2\u521b\u5efa",
imageArchived: "\u56fe\u7247\u5df2\u5f52\u6863",
imageDeleted: "\u56fe\u7247\u5df2\u5220\u9664",
currentBranch: "\u5f53\u524d\u5206\u652f",
materialCategories: "\u7d20\u6750\u5206\u7c7b",
categoryType: "\u5206\u7c7b\u7c7b\u578b",
sortOrder: "\u6392\u5e8f",
categoryCreated: "\u5206\u7c7b\u5df2\u521b\u5efa",
categoryUpdated: "\u5206\u7c7b\u5df2\u66f4\u65b0",
categoryDeleted: "\u5206\u7c7b\u5df2\u5220\u9664",
materialItems: "\u7d20\u6750\u6761\u76ee",
emptyCategories: "\u6682\u65e0\u5206\u7c7b",
emptyMaterials: "\u6682\u65e0\u7d20\u6750",
pendingConfirm: "\u5f85\u786e\u8ba4",
signFirstImage: "\u7b7e\u540d\u9996\u56fe",
noSignableMaterial: "\u6ca1\u6709\u53ef\u7b7e\u540d\u7684\u7d20\u6750\u56fe\u7247",
signMaterial: "\u7b7e\u540d\u7d20\u6750",
match: "\u5339\u914d",
matchWardrobe: "\u8863\u6a71\u5339\u914d",
emptyWardrobe: "\u6682\u65e0\u8863\u6a71\u6761\u76ee",
moveFailed: "\u5931\u8d25\u8f6c\u6b7b\u4fe1",
retryDead: "\u91cd\u8bd5\u6b7b\u4fe1",
retry: "\u91cd\u8bd5",
cancel: "\u53d6\u6d88",
filter: "\u7b5b\u9009",
applyFilters: "\u5e94\u7528\u7b5b\u9009",
detail: "\u8be6\u60c5",
jobDetail: "\u4efb\u52a1\u8be6\u60c5",
allStatuses: "\u5168\u90e8\u72b6\u6001",
allProfiles: "\u5168\u90e8\u89d2\u8272",
allWorkflows: "\u5168\u90e8\u5de5\u4f5c\u6d41",
emptyJobs: "\u6682\u65e0\u4efb\u52a1",
dialects: "\u534f\u8bae\u65b9\u8a00",
safeProbe: "\u5b89\u5168\u63a2\u6d4b",
probeProvider: "\u63a2\u6d4b Provider",
capabilityProfiles: "\u80fd\u529b\u6863\u6848",
renderPlan: "RenderPlan",
validatePlan: "\u6821\u9a8c\u8ba1\u5212",
provider: "Provider",
model: "Model",
requiredCapabilities: "\u6240\u9700\u80fd\u529b",
validationStatus: "\u6821\u9a8c\u72b6\u6001",
support: "\u652f\u6301",
unsupported: "\u4e0d\u652f\u6301",
unconfirmed: "\u5f85\u786e\u8ba4",
emptyCapabilities: "\u6682\u65e0\u80fd\u529b\u6863\u6848",
generationLogs: "\u751f\u6210\u65e5\u5fd7",
errorLogs: "\u9519\u8bef",
workflowLogs: "\u5de5\u4f5c\u6d41",
integrationLogs: "\u96c6\u6210",
integrationEvents: "\u96c6\u6210\u4e8b\u4ef6",
auditLogs: "\u5ba1\u8ba1",
targetType: "TargetType",
actor: "\u64cd\u4f5c\u4eba",
emptyGenerationLogs: "\u6682\u65e0\u751f\u6210\u65e5\u5fd7",
emptyErrors: "\u6682\u65e0\u9519\u8bef",
emptyWorkflowLogs: "\u6682\u65e0\u5de5\u4f5c\u6d41\u65e5\u5fd7",
emptyIntegrationLogs: "\u6682\u65e0\u96c6\u6210\u65e5\u5fd7",
emptyAuditLogs: "\u6682\u65e0\u5ba1\u8ba1\u65e5\u5fd7",
noErrorDetail: "\u65e0\u9519\u8bef\u8be6\u60c5",
reload: "\u91cd\u8f7d",
validate: "\u6821\u9a8c",
diff: "\u5bf9\u6bd4",
save: "\u4fdd\u5b58",
reset: "\u91cd\u7f6e",
exportRedacted: "\u5bfc\u51fa\u8131\u654f\u914d\u7f6e",
exportSettings: "\u5bfc\u51fa\u8bbe\u7f6e",
exportDone: "\u5bfc\u51fa\u8bbe\u7f6e\u5b8c\u6210\uff0c\u914d\u7f6e\u5df2\u8131\u654f",
importSettings: "\u5bfc\u5165\u8bbe\u7f6e",
importDone: "\u8bbe\u7f6e\u5df2\u5bfc\u5165",
importDraftInvalid: "\u5bfc\u5165 JSON \u683c\u5f0f\u65e0\u6548",
snapshots: "\u914d\u7f6e\u5feb\u7167",
loadSnapshots: "\u52a0\u8f7d\u5feb\u7167",
loadSnapshot: "\u67e5\u770b\u5feb\u7167",
snapshotPreview: "\u5feb\u7167\u9884\u89c8",
rollback: "\u56de\u6eda",
rollbackDone: "\u914d\u7f6e\u5df2\u56de\u6eda",
settingsEditor: "\u914d\u7f6e\u7f16\u8f91",
settingsDraftInvalid: "\u914d\u7f6e JSON \u683c\u5f0f\u65e0\u6548",
settingsSaved: "\u8bbe\u7f6e\u5df2\u4fdd\u5b58",
validationResult: "\u6821\u9a8c\u7ed3\u679c",
diffResult: "\u53d8\u66f4\u5bf9\u6bd4",
storage: "\u5b58\u50a8",
running: "\u8fd0\u884c",
} as const
const navItems: Array<{ key: ViewKey; label: string }> = [
{ key: "dashboard", label: "\u6982\u89c8" },
{ key: "profiles", label: text.profiles },
{ key: "workflows", label: text.workflows },
{ key: "materials", label: "\u7d20\u6750" },
{ key: "wardrobe", label: "\u8863\u6a71" },
{ key: "jobs", label: "\u961f\u5217" },
{ key: "discovery", label: "\u63a2\u6d4b" },
{ key: "logs", label: "\u65e5\u5fd7" },
{ key: "settings", label: text.settings },
]
const viewKeys = navItems.map((item) => item.key)
const activeView = ref<ViewKey>(initialView())
const bootstrap = ref<UiBootstrap | null>(null)
const dashboard = ref<DashboardSummary | null>(null)
const profiles = ref<ProfileListResult | null>(null)
const workflows = ref<ProfileWorkflow[]>([])
const workflowDetail = ref<WorkflowDetail | null>(null)
const workflowBranches = ref<WorkflowBranch[]>([])
const workflowHistory = ref<WorkflowHistoryEntry[]>([])
const reviewResult = ref<ReviewResult | null>(null)
const selectedNodeId = ref("")
const nodeImages = ref<GenerationImage[]>([])
const nodeGenerateResult = ref<NodeGenerateResult | null>(null)
const jobs = ref<JobListResult | null>(null)
const selectedJob = ref<GenerationJob | null>(null)
const settingsSchema = ref<SettingsSchema | null>(null)
const currentSettings = ref<CurrentSettings | null>(null)
const storage = ref<StorageStatus | null>(null)
const materialCategories = ref<MaterialCategory[]>([])
const materials = ref<MaterialListResult | null>(null)
const wardrobe = ref<WardrobeItem[]>([])
const dialects = ref<ApiDialect[]>([])
const capabilities = ref<CapabilityProfile[]>([])
const wardrobeMatch = ref<WardrobeMatchResult | null>(null)
const logs = ref<LogBundle>({ generation: [], workflows: [], errors: [], integrations: [], audit: [] })
const integrationEventLogs = ref<LogBundle["integrations"]>([])
const signedMedia = ref<MediaSignResult | null>(null)
const settingsDraft = ref("")
const settingsImportDraft = ref("")
const settingsSnapshots = ref<SettingsSnapshot[]>([])
const settingsSnapshotDetail = ref<SettingsSnapshot | null>(null)
const settingsExportResult = ref<ExportSettingsResult | null>(null)
const settingsValidation = ref<ValidateSettingsResult | null>(null)
const settingsDiff = ref<DiffSettingsResult | null>(null)
const profileDraft = ref({
name: "",
identity: "",
personality: "",
hair_color: "",
hairstyle: "",
eye_color: "",
style: "",
clothing_keywords: "",
description: "",
})
const quickProfileDraft = ref<QuickProfileDraftResult | null>(null)
const profileEditDraft = ref({
profile_id: "",
name: "",
description: "",
base_prompt: "",
appearance_prompt: "",
style_prompt: "",
negative_prompt: "",
default_model_route: "",
})
const workflowDraft = ref({
display_name: "",
workflow_type: "single_image",
})
const branchDraft = ref({
branch_name: "",
})
const nodeDraft = ref({
node_id: "",
node_key: "",
title: "",
description: "",
node_type: "generation",
status: "pending",
prompt: "",
negative_prompt: "",
model_route: "",
})
const nodeGenerateDraft = ref({
model_route: "",
prompt: "",
negative_prompt: "",
})
const jobFilters = ref({
status: "",
profile_id: "",
workflow_id: "",
})
const generationLogFilters = ref({
status: "",
profile_id: "",
workflow_id: "",
node_id: "",
})
const workflowLogFilters = ref({
workflow_id: "",
action: "",
node_id: "",
branch_name: "",
})
const errorLogFilters = ref({
source: "",
status: "",
})
const integrationLogFilters = ref({
integration_name: "",
action: "",
status: "",
})
const integrationEventFilters = ref({
integration_name: "",
action: "",
status: "",
})
const auditFilters = ref({
action: "",
target_type: "",
actor_id: "",
})
const materialDraft = ref({
material_id: "",
display_name: "",
image_uri: "",
tags: "",
category_id: "",
prompt: "",
negative_prompt: "",
})
const materialUploadDraft = ref({
display_name: "",
filename: "",
content_type: "image/png",
image_uri: "",
category_id: "",
})
const categoryDraft = ref({
category_id: "",
name: "",
category_type: "material",
sort_order: 0,
})
const wardrobeDraft = ref({
material_id: "",
wardrobe_category: "top",
tags: "",
season: "",
style: "",
})
const dailyOutfitDraft = ref({
categories: "top,bottom,dress,shoes,accessory",
mood: "",
weather: "",
keywords: "",
})
const dailyOutfitResult = ref<DailyOutfitResult | null>(null)
const renderPlanDraft = ref({
provider_id: "",
model_id: "",
required_capabilities: "text_to_image",
})
const renderPlanValidation = ref<RenderPlanValidationResult | null>(null)
const lastOperation = ref("")
const loading = ref(true)
const busy = ref("")
const error = ref("")
const selectedProfileId = computed(() => profiles.value?.items[0]?.profile_id ?? "")
const selectedProfileName = computed(() => profiles.value?.items[0]?.name ?? text.noProfile)
const queueTotal = computed(() => {
const queue = dashboard.value?.queue
return queue ? queue.pending + queue.running + queue.failed + queue.dead_letter : 0
})
const pendingRecognition = computed(
() => materials.value?.items.filter((item) => item.recognition_status !== "confirmed").length ?? 0,
)
const confirmedMaterials = computed(() =>
(materials.value?.items ?? []).filter((item) => item.recognition_status === "confirmed"),
)
const selectedNode = computed(() => workflowDetail.value?.nodes.find((node) => node.node_id === selectedNodeId.value) ?? null)
const taskStatuses = ["created", "queued", "running", "completed", "succeeded", "failed", "cancelled", "dead_letter"]
const activeTitle = computed(() => {
const titles: Record<ViewKey, string> = {
dashboard: text.dashboard,
profiles: text.profiles,
workflows: text.workflows,
materials: text.materials,
wardrobe: text.wardrobe,
jobs: text.jobs,
discovery: text.discovery,
logs: text.logs,
settings: text.settings,
}
return titles[activeView.value]
})
onMounted(load)
function initialView(): ViewKey {
const requested = new URLSearchParams(window.location.search).get("view")
return viewKeys.includes(requested as ViewKey) ? (requested as ViewKey) : "dashboard"
}
async function load() {
loading.value = true
error.value = ""
try {
const [
bootstrapData,
dashboardData,
profileData,
jobData,
schemaData,
settingsData,
storageData,
categoryData,
materialData,
dialectData,
capabilityData,
] = await Promise.all([
getJson<UiBootstrap>(endpoints.uiBootstrap),
getJson<DashboardSummary>(endpoints.dashboardSummary),
getJson<ProfileListResult>(endpoints.profiles, { page: 1, page_size: 20 }),
getJson<JobListResult>(endpoints.jobs, { page: 1, page_size: 20 }),
getJson<SettingsSchema>(endpoints.settingsSchema),
getJson<CurrentSettings>(endpoints.settingsCurrent),
getJson<StorageStatus>(endpoints.storageStatus),
getJson<MaterialCategory[]>(endpoints.materialCategories),
getJson<MaterialListResult>(endpoints.materials, { page: 1, page_size: 24 }),
getJson<ApiDialect[]>(endpoints.apiDiscoveryDialects),
getJson<CapabilityProfile[]>(endpoints.apiDiscoveryCapabilities),
])
bootstrap.value = bootstrapData
dashboard.value = dashboardData
profiles.value = profileData
jobs.value = jobData
settingsSchema.value = schemaData
currentSettings.value = settingsData
resetSettingsDraft(settingsData.config)
storage.value = storageData
materialCategories.value = categoryData
materials.value = materialData
dialects.value = dialectData
capabilities.value = capabilityData
await loadWardrobe(profileData.items[0]?.profile_id)
await loadWorkflows(profileData.items[0]?.profile_id)
await loadLogs()
} catch (err) {
error.value = err instanceof Error ? err.message : text.loadFailed
} finally {
loading.value = false
}
}
async function loadLogs() {
const [generation, workflows, errors, integrations, integrationEvents, audit] = await Promise.allSettled([
getJson<LogBundle["generation"]>(endpoints.generationLogs, compactQuery(generationLogFilters.value, 12)),
getJson<LogBundle["workflows"]>(endpoints.workflowLogs, compactQuery(workflowLogFilters.value, 12)),
getJson<LogBundle["errors"]>(endpoints.errorLogs, compactQuery(errorLogFilters.value, 12)),
getJson<LogBundle["integrations"]>(endpoints.integrationLogs, compactQuery(integrationLogFilters.value, 12)),
getJson<LogBundle["integrations"]>(endpoints.integrationEventLogs, compactQuery(integrationEventFilters.value, 20)),
getJson<LogBundle["audit"]>(endpoints.auditLogs, { limit: 12 }),
])
logs.value = {
generation: settledValue(generation),
workflows: settledValue(workflows),
errors: settledValue(errors),
integrations: settledValue(integrations),
audit: settledValue(audit),
}
integrationEventLogs.value = settledValue(integrationEvents)
}
async function loadGenerationLogs() {
logs.value.generation = await getJson<LogBundle["generation"]>(
endpoints.generationLogs,
compactQuery(generationLogFilters.value, 20),
)
}
async function loadWorkflowLogs() {
logs.value.workflows = await getJson<LogBundle["workflows"]>(
endpoints.workflowLogs,
compactQuery(workflowLogFilters.value, 20),
)
}
async function loadErrorLogs() {
logs.value.errors = await getJson<LogBundle["errors"]>(endpoints.errorLogs, compactQuery(errorLogFilters.value, 20))
}
async function loadIntegrationLogs() {
logs.value.integrations = await getJson<LogBundle["integrations"]>(
endpoints.integrationLogs,
compactQuery(integrationLogFilters.value, 20),
)
}
async function loadIntegrationEventLogs() {
integrationEventLogs.value = await getJson<LogBundle["integrations"]>(
endpoints.integrationEventLogs,
compactQuery(integrationEventFilters.value, 20),
)
}
async function loadAuditLogs() {
logs.value.audit = await getJson<LogBundle["audit"]>(endpoints.auditLogs, {
action: auditFilters.value.action || undefined,
target_type: auditFilters.value.target_type || undefined,
actor_id: auditFilters.value.actor_id || undefined,
limit: 20,
})
}
function settledValue<T>(result: PromiseSettledResult<T[]>): T[] {
return result.status === "fulfilled" ? result.value : []
}
function compactQuery(values: Record<string, string>, limit: number) {
const query: Record<string, string | number | undefined> = { limit }
for (const [key, value] of Object.entries(values)) {
const normalized = value.trim()
query[key] = normalized || undefined
}
return query
}
async function loadJobs() {
jobs.value = await getJson<JobListResult>(endpoints.jobs, {
status: jobFilters.value.status || undefined,
profile_id: jobFilters.value.profile_id || undefined,
workflow_id: jobFilters.value.workflow_id || undefined,
page: 1,
page_size: 20,
})
}
async function loadWardrobe(profileId?: string) {
if (!profileId) {
wardrobe.value = []
return
}
wardrobe.value = await getJson<WardrobeItem[]>(endpoints.wardrobe(profileId))
}
async function loadWorkflows(profileId?: string) {
if (!profileId) {
workflows.value = []
workflowDetail.value = null
workflowBranches.value = []
workflowHistory.value = []
selectedNodeId.value = ""
nodeImages.value = []
return
}
workflows.value = await getJson<ProfileWorkflow[]>(endpoints.profileWorkflows(profileId))
const retainedWorkflowId = workflowDetail.value?.workflow.workflow_id
const workflowId = workflows.value.some((workflow) => workflow.workflow_id === retainedWorkflowId)
? retainedWorkflowId
: workflows.value[0]?.workflow_id
if (workflowId) {
await loadWorkflowDetail(workflowId)
} else {
workflowDetail.value = null
}
}
async function loadWorkflowDetail(workflowId: string) {
const detail = await getJson<WorkflowDetail>(endpoints.workflow(workflowId))
workflowDetail.value = detail
const retainedNodeId = selectedNodeId.value
const nodeId = detail.nodes.some((node) => node.node_id === retainedNodeId)
? retainedNodeId
: detail.workflow.current_node_id || detail.nodes[0]?.node_id
if (nodeId) {
await loadNodeImages(nodeId)
} else {
selectedNodeId.value = ""
nodeImages.value = []
}
await loadWorkflowExtras(workflowId)
}
async function loadNodeImages(nodeId: string) {
selectedNodeId.value = nodeId
nodeImages.value = await getJson<GenerationImage[]>(endpoints.nodeImages(nodeId))
}
async function loadWorkflowExtras(workflowId: string) {
const [branches, history] = await Promise.all([
getJson<WorkflowBranch[]>(endpoints.workflowBranches(workflowId)),
getJson<WorkflowHistoryEntry[]>(endpoints.workflowHistory(workflowId)),
])
workflowBranches.value = branches
workflowHistory.value = history
}
async function refreshSelectedWorkflow() {
const workflowId = workflowDetail.value?.workflow.workflow_id
if (workflowId) {
await loadWorkflowDetail(workflowId)
}
}
async function runOperation(label: string, action: () => Promise<unknown>, refresh = true) {
busy.value = label
error.value = ""
try {
const result = await action()
lastOperation.value = `${label}${text.complete}`
if (label === text.exportSettings) {
lastOperation.value = `${text.exportDone}: ${Boolean((result as ExportSettingsResult).redacted)}`
}
if (refresh) {
await load()
}
} catch (err) {
error.value = err instanceof Error ? err.message : `${label}${text.failed}`
} finally {
busy.value = ""
}
}
function retryJob(taskId: string) {
return runOperation(text.retry, () => postJson(endpoints.jobRetry(taskId)))
}
function cancelJob(taskId: string) {
return runOperation(text.cancel, () => postJson(endpoints.jobCancel(taskId)))
}
function loadJobDetail(taskId: string) {
return runOperation(
text.detail,
async () => {
selectedJob.value = await getJson<GenerationJob>(endpoints.job(taskId))
return selectedJob.value
},
false,
)
}
function resetProfileDraft() {
profileDraft.value = {
name: "",
identity: "",
personality: "",
hair_color: "",
hairstyle: "",
eye_color: "",
style: "",
clothing_keywords: "",
description: "",
}
quickProfileDraft.value = null
}
function createQuickProfileDraft() {
return runOperation(
text.quickDraft,
async () => {
quickProfileDraft.value = await postJson<QuickProfileDraftResult>(endpoints.quickProfileDraft, {
questionnaire: {
name: profileDraft.value.name,
identity: profileDraft.value.identity,
personality: splitCsv(profileDraft.value.personality),
hair_color: profileDraft.value.hair_color,
hairstyle: profileDraft.value.hairstyle,
eye_color: profileDraft.value.eye_color,
style: profileDraft.value.style,
clothing_keywords: splitCsv(profileDraft.value.clothing_keywords),
},
})
return quickProfileDraft.value
},
false,
)
}
function createProfileFromDraft() {
const preview = quickProfileDraft.value?.profile_preview
return runOperation(
text.create,
async () => {
const profile = await postJson<CharacterProfile>(endpoints.profiles, {
name: preview?.name || profileDraft.value.name,
description: profileDraft.value.description,
base_prompt: preview?.base_prompt,
appearance_prompt: preview?.appearance_prompt,
style_prompt: preview?.style_prompt,
negative_prompt: preview?.negative_prompt,
})
resetProfileDraft()
lastOperation.value = text.profileCreated
return profile
},
)
}
function deleteProfile(profileId: string) {
return runOperation(
text.delete,
async () => {
const profile = await request<CharacterProfile>(endpoints.profile(profileId), { method: "DELETE" })
lastOperation.value = text.profileDeleted
return profile
},
)
}
function resetProfileEditDraft() {
profileEditDraft.value = {
profile_id: "",
name: "",
description: "",
base_prompt: "",
appearance_prompt: "",
style_prompt: "",
negative_prompt: "",
default_model_route: "",
}
}
function editProfileDraft(profile: CharacterProfile) {
profileEditDraft.value = {
profile_id: profile.profile_id,
name: profile.name,
description: profile.description ?? "",
base_prompt: profile.base_prompt ?? "",
appearance_prompt: profile.appearance_prompt ?? "",
style_prompt: profile.style_prompt ?? "",
negative_prompt: profile.negative_prompt ?? "",
default_model_route: profile.default_model_route ?? "",
}
}
function updateProfileDraft() {
if (!profileEditDraft.value.profile_id) return Promise.resolve()
return runOperation(
text.update,
async () => {
const profile = await request<CharacterProfile>(endpoints.profile(profileEditDraft.value.profile_id), {
method: "PUT",
body: {
name: profileEditDraft.value.name,
description: profileEditDraft.value.description || undefined,
base_prompt: profileEditDraft.value.base_prompt || undefined,
appearance_prompt: profileEditDraft.value.appearance_prompt || undefined,
style_prompt: profileEditDraft.value.style_prompt || undefined,
negative_prompt: profileEditDraft.value.negative_prompt || undefined,
default_model_route: profileEditDraft.value.default_model_route || undefined,
},
})
resetProfileEditDraft()
lastOperation.value = text.profileUpdated
return profile
},
)
}
function createWorkflow() {
const profileId = selectedProfileId.value
if (!profileId) return Promise.resolve()
return runOperation(
text.create,
async () => {
const workflow = await postJson<WorkflowDetail>(endpoints.profileWorkflows(profileId), {
display_name: workflowDraft.value.display_name,
workflow_type: workflowDraft.value.workflow_type,
})
workflowDraft.value.display_name = ""
workflowDetail.value = workflow
lastOperation.value = text.workflowCreated
return workflow
},
)
}
function startWorkflow(workflowId: string) {
return runOperation(text.start, () => postJson<ProfileWorkflow>(endpoints.workflowStart(workflowId)))
}
function cancelWorkflow(workflowId: string) {
return runOperation(text.cancel, () => postJson<ProfileWorkflow>(endpoints.workflowCancel(workflowId)))
}
function archiveWorkflow(workflowId: string) {
return runOperation(text.archive, () => postJson<ProfileWorkflow>(endpoints.workflowArchive(workflowId)))
}
function createWorkflowBranch() {
const workflow = workflowDetail.value?.workflow
if (!workflow || !branchDraft.value.branch_name) return Promise.resolve()
return runOperation(
text.branches,
async () => {
const branch = await postJson<WorkflowBranch>(endpoints.workflowBranches(workflow.workflow_id), {
branch_name: branchDraft.value.branch_name,
base_branch_name: workflow.current_branch,
base_node_id: selectedNodeId.value || workflow.current_node_id,
copy_nodes: true,
})
branchDraft.value.branch_name = ""
await refreshSelectedWorkflow()
lastOperation.value = text.branchCreated
return branch
},
false,
)
}
function switchWorkflowBranch(branchName: string) {
const workflowId = workflowDetail.value?.workflow.workflow_id
if (!workflowId) return Promise.resolve()
return runOperation(
text.switchBranch,
async () => {
const workflow = await postJson<ProfileWorkflow>(endpoints.workflowSwitchBranch(workflowId), {
branch_name: branchName,
})
await refreshSelectedWorkflow()
return workflow
},
false,
)
}
function resetNodeDraft() {
nodeDraft.value = {
node_id: "",
node_key: "",
title: "",
description: "",
node_type: "generation",
status: "pending",
prompt: "",
negative_prompt: "",
model_route: "",
}
}
function editNodeDraft(node: WorkflowNode) {
nodeDraft.value = {
node_id: node.node_id,
node_key: node.node_key,
title: node.title,
description: node.description ?? "",
node_type: node.node_type,
status: node.status,
prompt: node.prompt ?? "",
negative_prompt: node.negative_prompt ?? "",
model_route: node.model_route ?? "",
}
}
function saveNodeDraft() {
const workflowId = workflowDetail.value?.workflow.workflow_id
if (!workflowId || !nodeDraft.value.node_key || !nodeDraft.value.title) return Promise.resolve()
const payload = {
node_key: nodeDraft.value.node_key,
title: nodeDraft.value.title,
description: nodeDraft.value.description || undefined,
node_type: nodeDraft.value.node_type || "generation",
status: nodeDraft.value.status || "pending",
prompt: nodeDraft.value.prompt || undefined,
negative_prompt: nodeDraft.value.negative_prompt || undefined,
model_route: nodeDraft.value.model_route || undefined,
}
if (nodeDraft.value.node_id) {
return runOperation(
text.update,
async () => {
const node = await request<WorkflowNode>(endpoints.node(nodeDraft.value.node_id), {
method: "PUT",
body: payload,
})
resetNodeDraft()
await refreshSelectedWorkflow()
lastOperation.value = text.nodeUpdated
return node
},
false,
)
}
return runOperation(
text.create,
async () => {
const node = await postJson<WorkflowNode>(endpoints.workflowNodes(workflowId), payload)
resetNodeDraft()
await refreshSelectedWorkflow()
lastOperation.value = text.nodeCreated
return node
},
false,
)
}
function reviewWorkflow() {
const workflowId = workflowDetail.value?.workflow.workflow_id
if (!workflowId) return Promise.resolve()
return runOperation(
text.review,
async () => {
reviewResult.value = await getJson<ReviewResult>(endpoints.workflowReview(workflowId))
return reviewResult.value
},
false,
)
}
function reviewSelectedNode() {
const nodeId = selectedNodeId.value
if (!nodeId) return Promise.resolve()
return runOperation(
text.review,
async () => {
reviewResult.value = await getJson<ReviewResult>(endpoints.nodeReview(nodeId))
return reviewResult.value
},
false,
)
}
function generateSelectedNode() {
const nodeId = selectedNodeId.value
if (!nodeId) return Promise.resolve()
return runOperation(
text.generate,
async () => {
nodeGenerateResult.value = await postJson<NodeGenerateResult>(endpoints.nodeGenerate(nodeId), {
model_route: nodeGenerateDraft.value.model_route || undefined,
prompt: nodeGenerateDraft.value.prompt || undefined,
negative_prompt: nodeGenerateDraft.value.negative_prompt || undefined,
})
await refreshSelectedWorkflow()
lastOperation.value = text.generationQueued
return nodeGenerateResult.value
},
false,
)
}
function retryNode(nodeId: string) {
return runOperation(
text.retry,
async () => {
const result = await postJson<Record<string, unknown>>(endpoints.nodeRetry(nodeId))
await refreshSelectedWorkflow()
lastOperation.value = text.nodeQueued
return result
},
false,
)
}
function completeNode(nodeId: string) {
return runOperation(
text.complete,
async () => {
const node = await postJson<WorkflowNode>(endpoints.nodeComplete(nodeId))
await refreshSelectedWorkflow()
lastOperation.value = text.nodeCompleted
return node
},
false,
)
}
function selectNodeImage(imageId: string) {
const nodeId = selectedNodeId.value
if (!nodeId) return Promise.resolve()
return runOperation(
text.select,
async () => {
const image = await postJson<GenerationImage>(endpoints.nodeSelectImage(nodeId), { image_id: imageId })
await refreshSelectedWorkflow()
return image
},
false,
)
}
function adoptNodeImage(imageId: string) {
const nodeId = selectedNodeId.value
if (!nodeId) return Promise.resolve()
return runOperation(
text.adopt,
async () => {
const history = await postJson<Record<string, unknown>>(endpoints.nodeAdoptImage(nodeId), {
image_id: imageId,
title: selectedNode.value?.title,
})
await refreshSelectedWorkflow()
return history
},
false,
)
}
function unselectImage(imageId: string) {
return runOperation(
text.unselect,
async () => {
const image = await postJson<GenerationImage>(endpoints.imageUnselect(imageId))
await refreshSelectedWorkflow()
return image
},
false,
)
}
function archiveImage(imageId: string) {
return runOperation(
text.archive,
async () => {
const image = await postJson<GenerationImage>(endpoints.imageArchive(imageId))
await refreshSelectedWorkflow()
lastOperation.value = text.imageArchived
return image
},
false,
)
}
function deleteImage(imageId: string) {
return runOperation(
text.delete,
async () => {
const image = await request<GenerationImage>(endpoints.image(imageId), { method: "DELETE" })
await refreshSelectedWorkflow()
lastOperation.value = text.imageDeleted
return image
},
false,
)
}
function moveFailedJobs() {
return runOperation(text.moveFailed, () => postJson(endpoints.jobDeadLetterMoveFailed, { limit: 20 }))
}
function retryDeadLetters() {
return runOperation(text.retryDead, () => postJson(endpoints.jobDeadLetterRetry, { limit: 20 }))
}
function safeProbeModel() {
const dialect = dialects.value[0]?.dialect ?? "unknown"
return runOperation(text.safeProbe, () =>
postJson<CapabilityProfile>(endpoints.apiDiscoveryProbeModel, {
provider_id: "local-preview",
model_id: "metadata-only",
dialect,
capabilities: { supports: ["text_to_image"] },
}),
)
}
function safeProbeProvider() {
const dialect = dialects.value[0]?.dialect ?? "unknown"
return runOperation(text.probeProvider, () =>
postJson<CapabilityProfile>(endpoints.apiDiscoveryProbeProvider, {
provider_id: renderPlanDraft.value.provider_id || "local-preview",
model_id: renderPlanDraft.value.model_id || "metadata-only",
dialect,
capabilities: { supports: splitCsv(renderPlanDraft.value.required_capabilities) },
}),
)
}
function validateRenderPlan() {
return runOperation(
text.validatePlan,
async () => {
renderPlanValidation.value = await postJson<RenderPlanValidationResult>(endpoints.apiDiscoveryValidateRenderPlan, {
provider_id: renderPlanDraft.value.provider_id,
model_id: renderPlanDraft.value.model_id,
required_capabilities: splitCsv(renderPlanDraft.value.required_capabilities),
})
return renderPlanValidation.value
},
false,
)
}
function setCapabilityStatus(profile: CapabilityProfile, status: CapabilityProfile["status"]) {
return runOperation(text.discovery, () =>
postJson<CapabilityProfile>(endpoints.apiDiscoveryManualOverride, {
provider_id: profile.provider_id,
model_id: profile.model_id,
dialect: profile.dialect,
status,
capabilities: profile.capabilities,
}),
)
}
function matchWardrobe() {
const profileId = selectedProfileId.value
if (!profileId) return Promise.resolve()
return runOperation(
text.matchWardrobe,
async () => {
wardrobeMatch.value = await postJson<WardrobeMatchResult>(endpoints.wardrobeMatch(profileId), {
tags: ["daily"],
})
return wardrobeMatch.value
},
false,
)
}
function resetWardrobeDraft() {
wardrobeDraft.value = {
material_id: "",
wardrobe_category: "top",
tags: "",
season: "",
style: "",
}
}
function importWardrobeMaterial() {
const profileId = selectedProfileId.value
if (!profileId) return Promise.resolve()
return runOperation(
text.importToWardrobe,
async () => {
const item = await postJson<WardrobeItem>(endpoints.wardrobeImportMaterial(profileId), {
material_id: wardrobeDraft.value.material_id,
wardrobe_category: wardrobeDraft.value.wardrobe_category,
tags: splitCsv(wardrobeDraft.value.tags),
season: wardrobeDraft.value.season || undefined,
style: wardrobeDraft.value.style || undefined,
})
resetWardrobeDraft()
lastOperation.value = text.wardrobeImported
return item
},
)
}
function deleteWardrobeItem(wardrobeItemId: string) {
const profileId = selectedProfileId.value
if (!profileId) return Promise.resolve()
return runOperation(
text.delete,
async () => {
const item = await request<WardrobeItem>(endpoints.wardrobeItem(profileId, wardrobeItemId), { method: "DELETE" })
lastOperation.value = text.wardrobeDeleted
return item
},
)
}
function requestDailyOutfit() {
const profileId = selectedProfileId.value
if (!profileId) return Promise.resolve()
return runOperation(
text.dailyOutfit,
async () => {
dailyOutfitResult.value = await postJson<DailyOutfitResult>(endpoints.privateCompanionDailyOutfit, {
profile_id: profileId,
categories: splitCsv(dailyOutfitDraft.value.categories),
mood: dailyOutfitDraft.value.mood,
weather: dailyOutfitDraft.value.weather,
keywords: splitCsv(dailyOutfitDraft.value.keywords),
request_source: "astrbot_plugin_private_companion",
})
lastOperation.value = text.outfitGenerated
return dailyOutfitResult.value
},
false,
)
}
function reloadSettings() {
return runOperation(
text.reload,
async () => {
const result = await postJson<ReloadSettingsResult>(endpoints.settingsReload)
currentSettings.value = { config_path: currentSettings.value?.config_path ?? "***PATH***", config: result.config }
resetSettingsDraft(result.config)
return result
},
false,
)
}
function exportSettings() {
return runOperation(
text.exportSettings,
async () => {
settingsExportResult.value = await getJson<ExportSettingsResult>(endpoints.settingsExport)
return settingsExportResult.value
},
false,
)
}
function resetSettingsDraft(config = currentSettings.value?.config ?? {}) {
settingsDraft.value = JSON.stringify(config, null, 2)
settingsValidation.value = null
settingsDiff.value = null
}
function parseSettingsDraft() {
try {
const config = JSON.parse(settingsDraft.value) as Record<string, unknown>
if (!config || Array.isArray(config) || typeof config !== "object") {
throw new Error(text.settingsDraftInvalid)
}
return config
} catch (err) {
throw new Error(err instanceof Error ? err.message : text.settingsDraftInvalid)
}
}
function parseSettingsImportDraft() {
try {
const config = JSON.parse(settingsImportDraft.value) as Record<string, unknown>
if (!config || Array.isArray(config) || typeof config !== "object") {
throw new Error(text.importDraftInvalid)
}
return config
} catch (err) {
throw new Error(err instanceof Error ? err.message : text.importDraftInvalid)
}
}
function validateSettingsDraft() {
return runOperation(
text.validate,
async () => {
settingsValidation.value = await postJson<ValidateSettingsResult>(endpoints.settingsValidate, {
config: parseSettingsDraft(),
})
return settingsValidation.value
},
false,
)
}
function diffSettingsDraft() {
return runOperation(
text.diff,
async () => {
settingsDiff.value = await postJson<DiffSettingsResult>(endpoints.settingsDiff, {
config: parseSettingsDraft(),
})
return settingsDiff.value
},
false,
)
}
function saveSettingsDraft() {
return runOperation(
text.save,
async () => {
const result = await postJson<SaveSettingsResult>(endpoints.settingsSave, {
config: parseSettingsDraft(),
})
currentSettings.value = { config_path: currentSettings.value?.config_path ?? "***PATH***", config: result.config }
resetSettingsDraft(result.config)
lastOperation.value = text.settingsSaved
return result
},
false,
)
}
function importSettingsDraft() {
return runOperation(
text.importSettings,
async () => {
const result = await postJson<ImportSettingsResult>(endpoints.settingsImport, {
config: parseSettingsImportDraft(),
})
currentSettings.value = { config_path: currentSettings.value?.config_path ?? "***PATH***", config: result.config }
resetSettingsDraft(result.config)
settingsImportDraft.value = ""
lastOperation.value = text.importDone
return result
},
false,
)
}
function loadSettingsSnapshots() {
return runOperation(
text.loadSnapshots,
async () => {
settingsSnapshots.value = await getJson<SettingsSnapshot[]>(endpoints.settingsSnapshots, { limit: 20 })
settingsSnapshotDetail.value = settingsSnapshots.value[0] ?? null
return settingsSnapshots.value
},
false,
)
}
function loadSettingsSnapshot(snapshotId: string) {
return runOperation(
text.loadSnapshot,
async () => {
settingsSnapshotDetail.value = await getJson<SettingsSnapshot>(endpoints.settingsSnapshot(snapshotId))
return settingsSnapshotDetail.value
},
false,
)
}
function rollbackSettingsSnapshot(snapshotId: string) {
return runOperation(
text.rollback,
async () => {
const result = await postJson<RollbackSettingsResult>(endpoints.settingsRollback, { snapshot_id: snapshotId })
currentSettings.value = { config_path: currentSettings.value?.config_path ?? "***PATH***", config: result.config }
resetSettingsDraft(result.config)
await loadSettingsSnapshots()
lastOperation.value = text.rollbackDone
return result
},
false,
)
}
function signFirstMaterial() {
const uri = materials.value?.items.find((item) => item.image_uri?.startsWith("storage://"))?.image_uri
if (!uri) {
lastOperation.value = text.noSignableMaterial
return Promise.resolve()
}
return runOperation(
text.signMaterial,
async () => {
signedMedia.value = await getJson<MediaSignResult>(endpoints.mediaSign, { uri })
return signedMedia.value
},
false,
)
}
function signMediaUri(uri?: string | null) {
if (!uri?.startsWith("storage://")) {
lastOperation.value = text.noSignableMaterial
return Promise.resolve()
}
return runOperation(
text.signMaterial,
async () => {
signedMedia.value = await getJson<MediaSignResult>(endpoints.mediaSign, { uri })
return signedMedia.value
},
false,
)
}
function resetCategoryDraft() {
categoryDraft.value = {
category_id: "",
name: "",
category_type: "material",
sort_order: 0,
}
}
function editCategoryDraft(category: MaterialCategory) {
categoryDraft.value = {
category_id: category.category_id,
name: category.name,
category_type: category.category_type,
sort_order: category.sort_order,
}
}
function saveCategoryDraft() {
const payload = {
name: categoryDraft.value.name,
category_type: categoryDraft.value.category_type,
sort_order: Number(categoryDraft.value.sort_order) || 0,
}
if (categoryDraft.value.category_id) {
return runOperation(
text.update,
async () => {
const category = await request<MaterialCategory>(endpoints.materialCategory(categoryDraft.value.category_id), {
method: "PUT",
body: payload,
})
resetCategoryDraft()
lastOperation.value = text.categoryUpdated
return category
},
)
}
return runOperation(
text.create,
async () => {
const category = await postJson<MaterialCategory>(endpoints.materialCategories, payload)
resetCategoryDraft()
lastOperation.value = text.categoryCreated
return category
},
)
}
function deleteCategory(categoryId: string) {
return runOperation(
text.delete,
async () => {
const category = await request<MaterialCategory>(endpoints.materialCategory(categoryId), { method: "DELETE" })
if (categoryDraft.value.category_id === categoryId) {
resetCategoryDraft()
}
lastOperation.value = text.categoryDeleted
return category
},
)
}
function resetMaterialDraft() {
materialDraft.value = {
material_id: "",
display_name: "",
image_uri: "",
tags: "",
category_id: "",
prompt: "",
negative_prompt: "",
}
}
function createMaterialDraft() {
const payload = {
display_name: materialDraft.value.display_name,
image_uri: materialDraft.value.image_uri || undefined,
thumbnail_uri: materialDraft.value.image_uri || undefined,
category_id: materialDraft.value.category_id || undefined,
tags: splitCsv(materialDraft.value.tags),
prompt: materialDraft.value.prompt || undefined,
negative_prompt: materialDraft.value.negative_prompt || undefined,
recognition_status: materialDraft.value.image_uri ? "pending_recognition" : "pending_upload",
}
if (materialDraft.value.material_id) {
return runOperation(
text.update,
async () => {
const material = await request<Material>(endpoints.material(materialDraft.value.material_id), {
method: "PUT",
body: payload,
})
resetMaterialDraft()
lastOperation.value = text.materialUpdated
return material
},
)
}
return runOperation(
text.create,
async () => {
const material = await postJson<Material>(endpoints.materials, payload)
resetMaterialDraft()
lastOperation.value = text.materialCreated
return material
},
)
}
function editMaterialDraft(material: Material) {
materialDraft.value = {
material_id: material.material_id,
display_name: material.display_name,
image_uri: material.image_uri ?? "",
tags: material.tags.join(", "),
category_id: material.category_id ?? "",
prompt: material.prompt ?? "",
negative_prompt: material.negative_prompt ?? "",
}
}
function resetMaterialUploadDraft() {
materialUploadDraft.value = {
display_name: "",
filename: "",
content_type: "image/png",
image_uri: "",
category_id: "",
}
}
function uploadMaterialDraft() {
return runOperation(
text.upload,
async () => {
const material = await postJson<Material>(endpoints.materialUpload, {
display_name: materialUploadDraft.value.display_name || undefined,
filename: materialUploadDraft.value.filename || undefined,
content_type: materialUploadDraft.value.content_type || undefined,
image_uri: materialUploadDraft.value.image_uri,
category_id: materialUploadDraft.value.category_id || undefined,
})
resetMaterialUploadDraft()
lastOperation.value = text.materialUploaded
return material
},
)
}
function recognizeMaterial(materialId: string) {
return runOperation(text.recognize, () => postJson<Material>(endpoints.materialRecognize(materialId)))
}
function confirmMaterial(material: Material) {
return runOperation(text.confirm, () =>
postJson<Material>(endpoints.materialConfirm(material.material_id), {
display_name: material.display_name,
prompt: material.prompt,
negative_prompt: material.negative_prompt,
tags: material.tags,
}),
)
}
function archiveMaterial(materialId: string) {
return runOperation(
text.archive,
async () => {
const material = await request<Material>(endpoints.material(materialId), { method: "DELETE" })
lastOperation.value = text.materialArchived
return material
},
)
}
function splitCsv(value: string) {
return value
.split(",")
.map((item) => item.trim())
.filter(Boolean)
}
function formatBytes(value = 0) {
if (value < 1024) return `${value} B`
if (value < 1024 * 1024) return `${(value / 1024).toFixed(1)} KB`
if (value < 1024 * 1024 * 1024) return `${(value / 1024 / 1024).toFixed(1)} MB`
return `${(value / 1024 / 1024 / 1024).toFixed(1)} GB`
}
function storageRootBytes(uriPrefix: string) {
return storage.value?.roots.find((root) => root.uri_prefix === uriPrefix)?.bytes ?? 0
}
</script>
<template>
<main class="web-shell">
<aside class="sidebar">
<div class="brand">
<strong>{{ bootstrap?.display_name ?? "ImageStudio" }}</strong>
<span>{{ bootstrap?.dashboard_user ?? "AstrBot" }}</span>
</div>
<nav>
<button
v-for="item in navItems"
:key="item.key"
type="button"
:class="{ active: activeView === item.key }"
@click="activeView = item.key"
>
{{ item.label }}
</button>
</nav>
</aside>
<section class="workspace">
<header class="topbar">
<div>
<h1>{{ activeTitle }}</h1>
<p>{{ dashboard?.plugin_status ?? "loading" }} / {{ lastOperation || text.waiting }}</p>
</div>
<div class="actions">
<button type="button" :disabled="Boolean(busy)" @click="load">
{{ busy || text.refresh }}
</button>
</div>
</header>
<section v-if="error" class="notice error">{{ error }}</section>
<section v-else-if="loading" class="notice">{{ text.loading }}</section>
<template v-else>
<section v-if="activeView === 'dashboard'" class="dashboard-grid">
<article>
<span>{{ text.profiles }}</span>
<strong>{{ dashboard?.active_profiles ?? 0 }}</strong>
</article>
<article>
<span>{{ text.jobs }}</span>
<strong>{{ queueTotal }}</strong>
</article>
<article>
<span>{{ text.materials }}</span>
<strong>{{ materials?.total ?? 0 }}</strong>
</article>
<article>
<span>{{ text.storage }}</span>
<strong>{{ formatBytes(storage?.total_bytes ?? dashboard?.storage.total_bytes) }}</strong>
</article>
</section>
<section v-if="activeView === 'profiles'" class="list-view">
<header>
<h2>{{ text.profileList }}</h2>
<span>{{ profiles?.total ?? 0 }}</span>
</header>
<div class="form-grid">
<label>
<span>{{ text.name }}</span>
<input v-model="profileDraft.name" type="text" />
</label>
<label>
<span>{{ text.identity }}</span>
<input v-model="profileDraft.identity" type="text" />
</label>
<label>
<span>{{ text.personality }}</span>
<input v-model="profileDraft.personality" type="text" placeholder="calm, brave" />
</label>
<label>
<span>{{ text.hairColor }}</span>
<input v-model="profileDraft.hair_color" type="text" />
</label>
<label>
<span>{{ text.hairstyle }}</span>
<input v-model="profileDraft.hairstyle" type="text" />
</label>
<label>
<span>{{ text.eyeColor }}</span>
<input v-model="profileDraft.eye_color" type="text" />
</label>
<label>
<span>{{ text.stylePrompt }}</span>
<input v-model="profileDraft.style" type="text" />
</label>
<label>
<span>{{ text.tags }}</span>
<input v-model="profileDraft.clothing_keywords" type="text" placeholder="white blouse, ribbon" />
</label>
<label class="wide-field">
<span>{{ text.description }}</span>
<input v-model="profileDraft.description" type="text" />
</label>
<button type="button" :disabled="Boolean(busy) || !profileDraft.name" @click="createQuickProfileDraft">
{{ text.quickDraft }}
</button>
<button type="button" :disabled="Boolean(busy) || !profileDraft.name" @click="createProfileFromDraft">
{{ text.create }}
</button>
</div>
<pre v-if="quickProfileDraft">{{ JSON.stringify(quickProfileDraft, null, 2) }}</pre>
<div v-if="profileEditDraft.profile_id" class="form-grid">
<label>
<span>{{ text.name }}</span>
<input v-model="profileEditDraft.name" type="text" />
</label>
<label>
<span>{{ text.provider }}</span>
<input v-model="profileEditDraft.default_model_route" type="text" />
</label>
<label class="wide-field">
<span>{{ text.description }}</span>
<input v-model="profileEditDraft.description" type="text" />
</label>
<label class="wide-field">
<span>{{ text.basePrompt }}</span>
<input v-model="profileEditDraft.base_prompt" type="text" />
</label>
<label class="wide-field">
<span>{{ text.appearancePrompt }}</span>
<input v-model="profileEditDraft.appearance_prompt" type="text" />
</label>
<label class="wide-field">
<span>{{ text.stylePrompt }}</span>
<input v-model="profileEditDraft.style_prompt" type="text" />
</label>
<label class="wide-field">
<span>{{ text.negativePrompt }}</span>
<input v-model="profileEditDraft.negative_prompt" type="text" />
</label>
<button type="button" :disabled="Boolean(busy) || !profileEditDraft.name" @click="updateProfileDraft">
{{ text.update }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="resetProfileEditDraft">{{ text.reset }}</button>
</div>
<ul>
<li v-for="profile in profiles?.items ?? []" :key="profile.profile_id">
<div>
<strong>{{ profile.name }}</strong>
<small>{{ profile.profile_id }}</small>
</div>
<div class="inline-actions">
<span class="badge">{{ profile.status }}</span>
<button type="button" :disabled="Boolean(busy)" @click="editProfileDraft(profile)">
{{ text.edit }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="deleteProfile(profile.profile_id)">
{{ text.delete }}
</button>
</div>
</li>
<li v-if="!profiles?.items.length" class="empty">{{ text.emptyProfiles }}</li>
</ul>
</section>
<section v-if="activeView === 'workflows'" class="split-view">
<div class="list-view">
<header>
<h2>{{ selectedProfileName }}</h2>
<span>{{ workflows.length }}</span>
</header>
<div class="form-grid">
<label>
<span>{{ text.name }}</span>
<input v-model="workflowDraft.display_name" type="text" />
</label>
<label>
<span>{{ text.workflowType }}</span>
<select v-model="workflowDraft.workflow_type">
<option value="single_image">single_image</option>
<option value="character_gradual">character_gradual</option>
<option value="character_fast">character_fast</option>
<option value="quick_profile">quick_profile</option>
</select>
</label>
<button
type="button"
:disabled="Boolean(busy) || !selectedProfileId || !workflowDraft.display_name"
@click="createWorkflow"
>
{{ text.create }}
</button>
</div>
<ul>
<li v-for="workflow in workflows" :key="workflow.workflow_id">
<div>
<strong>{{ workflow.display_name }}</strong>
<small>{{ workflow.workflow_type }} / {{ workflow.workflow_id }}</small>
</div>
<div class="inline-actions">
<span class="badge">{{ workflow.status }}</span>
<button type="button" :disabled="Boolean(busy)" @click="loadWorkflowDetail(workflow.workflow_id)">
{{ text.nodes }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="startWorkflow(workflow.workflow_id)">
{{ text.start }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="cancelWorkflow(workflow.workflow_id)">
{{ text.cancel }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="archiveWorkflow(workflow.workflow_id)">
{{ text.archive }}
</button>
</div>
</li>
<li v-if="!workflows.length" class="empty">{{ text.emptyWorkflows }}</li>
</ul>
<section v-if="workflowDetail" class="editor-panel">
<header>
<h2>{{ text.branches }}</h2>
<span>{{ workflowBranches.length }}</span>
</header>
<div class="form-grid">
<label>
<span>{{ text.branchName }}</span>
<input v-model="branchDraft.branch_name" type="text" placeholder="alt_pose" />
</label>
<button
type="button"
:disabled="Boolean(busy) || !branchDraft.branch_name"
@click="createWorkflowBranch"
>
{{ text.create }}
</button>
</div>
<ul>
<li v-for="branch in workflowBranches" :key="branch.branch_id">
<div>
<strong>{{ branch.branch_name }}</strong>
<small>{{ branch.base_branch_name ?? "main" }} / {{ branch.status }}</small>
</div>
<button type="button" :disabled="Boolean(busy)" @click="switchWorkflowBranch(branch.branch_name)">
{{ text.switchBranch }}
</button>
</li>
</ul>
</section>
</div>
<div class="list-view">
<header>
<h2>{{ text.nodes }}</h2>
<div class="inline-actions">
<span>{{ workflowDetail?.workflow.current_branch ?? "main" }}</span>
<button type="button" :disabled="Boolean(busy) || !workflowDetail" @click="reviewWorkflow">
{{ text.review }}
</button>
</div>
</header>
<div class="form-grid">
<label>
<span>{{ text.nodeKey }}</span>
<input v-model="nodeDraft.node_key" type="text" />
</label>
<label>
<span>{{ text.nodeTitle }}</span>
<input v-model="nodeDraft.title" type="text" />
</label>
<label>
<span>{{ text.nodeType }}</span>
<input v-model="nodeDraft.node_type" type="text" />
</label>
<label>
<span>{{ text.status }}</span>
<input v-model="nodeDraft.status" type="text" />
</label>
<label class="wide-field">
<span>{{ text.description }}</span>
<input v-model="nodeDraft.description" type="text" />
</label>
<label class="wide-field">
<span>{{ text.prompt }}</span>
<input v-model="nodeDraft.prompt" type="text" />
</label>
<label class="wide-field">
<span>{{ text.negativePrompt }}</span>
<input v-model="nodeDraft.negative_prompt" type="text" />
</label>
<label>
<span>{{ text.modelRoute }}</span>
<input v-model="nodeDraft.model_route" type="text" />
</label>
<button type="button" :disabled="Boolean(busy) || !nodeDraft.node_key || !nodeDraft.title" @click="saveNodeDraft">
{{ nodeDraft.node_id ? text.update : text.create }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="resetNodeDraft">{{ text.reset }}</button>
</div>
<div class="form-grid">
<label>
<span>{{ text.modelRoute }}</span>
<input v-model="nodeGenerateDraft.model_route" type="text" placeholder="image_low" />
</label>
<label>
<span>{{ text.prompt }}</span>
<input v-model="nodeGenerateDraft.prompt" type="text" />
</label>
<label class="wide-field">
<span>{{ text.negativePrompt }}</span>
<input v-model="nodeGenerateDraft.negative_prompt" type="text" />
</label>
<button type="button" :disabled="Boolean(busy) || !selectedNodeId" @click="generateSelectedNode">
{{ text.generate }}
</button>
<button type="button" :disabled="Boolean(busy) || !selectedNodeId" @click="reviewSelectedNode">
{{ text.review }}
</button>
</div>
<ul>
<li v-for="node in workflowDetail?.nodes ?? []" :key="node.node_id">
<div>
<strong>{{ node.title }}</strong>
<small>{{ node.node_key }} / {{ node.node_id }}</small>
</div>
<div class="inline-actions">
<span>{{ node.branch_name }}</span>
<span class="badge">{{ node.status }}</span>
<button type="button" :disabled="Boolean(busy)" @click="editNodeDraft(node)">
{{ text.edit }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="retryNode(node.node_id)">
{{ text.retry }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="completeNode(node.node_id)">
{{ text.complete }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="loadNodeImages(node.node_id)">
{{ text.images }}
</button>
</div>
</li>
<li v-if="!workflowDetail?.nodes.length" class="empty">{{ text.emptyWorkflows }}</li>
</ul>
<ul>
<li v-for="image in nodeImages" :key="image.image_id">
<div>
<strong>{{ image.image_id }}</strong>
<small>{{ image.thumbnail_uri ?? image.image_uri }}</small>
</div>
<div class="inline-actions">
<span v-if="image.is_selected" class="badge">{{ text.select }}</span>
<button
type="button"
:disabled="Boolean(busy) || image.is_selected || image.is_archived"
@click="selectNodeImage(image.image_id)"
>
{{ text.select }}
</button>
<button
type="button"
:disabled="Boolean(busy) || image.is_archived"
@click="adoptNodeImage(image.image_id)"
>
{{ text.adopt }}
</button>
<button
type="button"
:disabled="Boolean(busy) || !(image.thumbnail_uri ?? image.image_uri).startsWith('storage://')"
@click="signMediaUri(image.thumbnail_uri ?? image.image_uri)"
>
{{ text.signMaterial }}
</button>
<button
type="button"
:disabled="Boolean(busy) || !image.is_selected"
@click="unselectImage(image.image_id)"
>
{{ text.unselect }}
</button>
<button
type="button"
:disabled="Boolean(busy) || image.is_archived"
@click="archiveImage(image.image_id)"
>
{{ text.archive }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="deleteImage(image.image_id)">
{{ text.delete }}
</button>
</div>
</li>
<li v-if="!nodeImages.length" class="empty">{{ text.emptyImages }}</li>
</ul>
<pre v-if="signedMedia">{{ JSON.stringify(signedMedia, null, 2) }}</pre>
<pre v-if="nodeGenerateResult">{{ JSON.stringify(nodeGenerateResult, null, 2) }}</pre>
<section class="editor-panel">
<header>
<h2>{{ text.history }}</h2>
<span>{{ workflowHistory.length }}</span>
</header>
<ul>
<li v-for="entry in workflowHistory" :key="entry.history_id">
<div>
<strong>{{ entry.action }}</strong>
<small>{{ entry.title ?? entry.node_id ?? entry.workflow_id }}</small>
</div>
<span>{{ entry.branch_name }}</span>
</li>
<li v-if="!workflowHistory.length" class="empty">{{ text.emptyHistory }}</li>
</ul>
</section>
<section v-if="reviewResult" class="editor-panel">
<header>
<h2>{{ text.reviewResult }}</h2>
<span>{{ reviewResult.passed ? text.support : text.unsupported }}</span>
</header>
<pre>{{ JSON.stringify(reviewResult, null, 2) }}</pre>
</section>
<pre v-if="workflowDetail">{{ JSON.stringify(workflowDetail.workflow, null, 2) }}</pre>
</div>
</section>
<section v-if="activeView === 'materials'" class="split-view">
<div class="list-view">
<header>
<h2>{{ text.materialCategories }}</h2>
<span>{{ materialCategories.length }}</span>
</header>
<div class="form-grid">
<label>
<span>{{ text.name }}</span>
<input v-model="categoryDraft.name" type="text" />
</label>
<label>
<span>{{ text.categoryType }}</span>
<input v-model="categoryDraft.category_type" type="text" />
</label>
<label>
<span>{{ text.sortOrder }}</span>
<input v-model.number="categoryDraft.sort_order" type="number" />
</label>
<button type="button" :disabled="Boolean(busy) || !categoryDraft.name" @click="saveCategoryDraft">
{{ categoryDraft.category_id ? text.update : text.create }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="resetCategoryDraft">{{ text.reset }}</button>
</div>
<ul>
<li v-for="category in materialCategories" :key="category.category_id">
<div>
<strong>{{ category.name }}</strong>
<small>{{ category.category_type }}</small>
</div>
<div class="inline-actions">
<span>{{ category.sort_order }}</span>
<button type="button" :disabled="Boolean(busy)" @click="editCategoryDraft(category)">
{{ text.edit }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="deleteCategory(category.category_id)">
{{ text.delete }}
</button>
</div>
</li>
<li v-if="!materialCategories.length" class="empty">{{ text.emptyCategories }}</li>
</ul>
</div>
<div class="list-view">
<header>
<h2>{{ text.materialItems }}</h2>
<div class="inline-actions">
<span>{{ pendingRecognition }} {{ text.pendingConfirm }}</span>
<button type="button" :disabled="Boolean(busy)" @click="signFirstMaterial">
{{ text.signFirstImage }}
</button>
</div>
</header>
<div class="form-grid">
<label>
<span>{{ text.name }}</span>
<input v-model="materialDraft.display_name" type="text" />
</label>
<label>
<span>{{ text.imageUri }}</span>
<input v-model="materialDraft.image_uri" type="text" placeholder="storage://materials/example.png" />
</label>
<label>
<span>{{ text.category }}</span>
<select v-model="materialDraft.category_id">
<option value="">{{ text.allCategories }}</option>
<option
v-for="category in materialCategories"
:key="category.category_id"
:value="category.category_id"
>
{{ category.name }}
</option>
</select>
</label>
<label>
<span>{{ text.tags }}</span>
<input v-model="materialDraft.tags" type="text" placeholder="daily, top" />
</label>
<label>
<span>{{ text.prompt }}</span>
<input v-model="materialDraft.prompt" type="text" />
</label>
<label>
<span>{{ text.negativePrompt }}</span>
<input v-model="materialDraft.negative_prompt" type="text" />
</label>
<button type="button" :disabled="Boolean(busy) || !materialDraft.display_name" @click="createMaterialDraft">
{{ materialDraft.material_id ? text.update : text.create }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="resetMaterialDraft">{{ text.reset }}</button>
</div>
<ul>
<li v-for="material in materials?.items ?? []" :key="material.material_id">
<div>
<strong>{{ material.display_name }}</strong>
<small>{{ material.image_uri ?? text.noImage }}</small>
</div>
<div class="inline-actions">
<span class="badge">{{ material.recognition_status }}</span>
<button type="button" :disabled="Boolean(busy)" @click="editMaterialDraft(material)">
{{ text.edit }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="recognizeMaterial(material.material_id)">
{{ text.recognize }}
</button>
<button
type="button"
:disabled="Boolean(busy) || material.recognition_status === 'confirmed'"
@click="confirmMaterial(material)"
>
{{ text.confirm }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="archiveMaterial(material.material_id)">
{{ text.archive }}
</button>
</div>
</li>
<li v-if="!materials?.items.length" class="empty">{{ text.emptyMaterials }}</li>
</ul>
<div class="form-grid">
<label>
<span>{{ text.name }}</span>
<input v-model="materialUploadDraft.display_name" type="text" />
</label>
<label>
<span>{{ text.filename }}</span>
<input v-model="materialUploadDraft.filename" type="text" />
</label>
<label>
<span>{{ text.contentType }}</span>
<input v-model="materialUploadDraft.content_type" type="text" />
</label>
<label>
<span>{{ text.imageUri }}</span>
<input v-model="materialUploadDraft.image_uri" type="text" placeholder="storage://materials/upload.png" />
</label>
<label>
<span>{{ text.category }}</span>
<select v-model="materialUploadDraft.category_id">
<option value="">{{ text.allCategories }}</option>
<option
v-for="category in materialCategories"
:key="category.category_id"
:value="category.category_id"
>
{{ category.name }}
</option>
</select>
</label>
<button type="button" :disabled="Boolean(busy) || !materialUploadDraft.image_uri" @click="uploadMaterialDraft">
{{ text.upload }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="resetMaterialUploadDraft">{{ text.reset }}</button>
</div>
<pre v-if="signedMedia">{{ JSON.stringify(signedMedia, null, 2) }}</pre>
</div>
</section>
<section v-if="activeView === 'wardrobe'" class="list-view">
<header>
<h2>{{ selectedProfileName }}</h2>
<button type="button" :disabled="!selectedProfileId || Boolean(busy)" @click="matchWardrobe">
{{ text.match }}
</button>
</header>
<div class="form-grid">
<label>
<span>{{ text.selectMaterial }}</span>
<select v-model="wardrobeDraft.material_id">
<option value="">{{ text.selectMaterial }}</option>
<option v-for="material in confirmedMaterials" :key="material.material_id" :value="material.material_id">
{{ material.display_name }}
</option>
</select>
</label>
<label>
<span>{{ text.wardrobeCategory }}</span>
<input v-model="wardrobeDraft.wardrobe_category" type="text" />
</label>
<label>
<span>{{ text.tags }}</span>
<input v-model="wardrobeDraft.tags" type="text" placeholder="daily, top" />
</label>
<label>
<span>{{ text.season }}</span>
<input v-model="wardrobeDraft.season" type="text" />
</label>
<label>
<span>{{ text.style }}</span>
<input v-model="wardrobeDraft.style" type="text" />
</label>
<button
type="button"
:disabled="Boolean(busy) || !selectedProfileId || !wardrobeDraft.material_id || !wardrobeDraft.wardrobe_category"
@click="importWardrobeMaterial"
>
{{ text.importToWardrobe }}
</button>
</div>
<ul>
<li v-for="item in wardrobe" :key="item.wardrobe_item_id">
<div>
<strong>{{ item.wardrobe_category }}</strong>
<small>{{ item.material_id }} / {{ item.tags.join(", ") || text.noTags }}</small>
</div>
<div class="inline-actions">
<span>{{ item.usage_count }}</span>
<button type="button" :disabled="Boolean(busy)" @click="deleteWardrobeItem(item.wardrobe_item_id)">
{{ text.delete }}
</button>
</div>
</li>
<li v-if="!wardrobe.length" class="empty">{{ text.emptyWardrobe }}</li>
</ul>
<pre v-if="wardrobeMatch">{{ JSON.stringify(wardrobeMatch, null, 2) }}</pre>
<div class="form-grid">
<label>
<span>{{ text.categories }}</span>
<input v-model="dailyOutfitDraft.categories" type="text" />
</label>
<label>
<span>{{ text.mood }}</span>
<input v-model="dailyOutfitDraft.mood" type="text" />
</label>
<label>
<span>{{ text.weather }}</span>
<input v-model="dailyOutfitDraft.weather" type="text" />
</label>
<label>
<span>{{ text.keywords }}</span>
<input v-model="dailyOutfitDraft.keywords" type="text" />
</label>
<button type="button" :disabled="Boolean(busy) || !selectedProfileId" @click="requestDailyOutfit">
{{ text.dailyOutfit }}
</button>
</div>
<pre v-if="dailyOutfitResult">{{ JSON.stringify(dailyOutfitResult, null, 2) }}</pre>
</section>
<section v-if="activeView === 'jobs'" class="list-view">
<header>
<h2>{{ text.jobs }}</h2>
<div class="inline-actions">
<button type="button" :disabled="Boolean(busy)" @click="moveFailedJobs">{{ text.moveFailed }}</button>
<button type="button" :disabled="Boolean(busy)" @click="retryDeadLetters">{{ text.retryDead }}</button>
</div>
</header>
<div class="form-grid">
<label>
<span>Status</span>
<select v-model="jobFilters.status">
<option value="">{{ text.allStatuses }}</option>
<option v-for="status in taskStatuses" :key="status" :value="status">{{ status }}</option>
</select>
</label>
<label>
<span>{{ text.profiles }}</span>
<select v-model="jobFilters.profile_id">
<option value="">{{ text.allProfiles }}</option>
<option v-for="profile in profiles?.items ?? []" :key="profile.profile_id" :value="profile.profile_id">
{{ profile.name }}
</option>
</select>
</label>
<label>
<span>{{ text.workflows }}</span>
<select v-model="jobFilters.workflow_id">
<option value="">{{ text.allWorkflows }}</option>
<option v-for="workflow in workflows" :key="workflow.workflow_id" :value="workflow.workflow_id">
{{ workflow.display_name }}
</option>
</select>
</label>
<button type="button" :disabled="Boolean(busy)" @click="loadJobs">{{ text.filter }}</button>
</div>
<ul>
<li v-for="job in jobs?.items ?? []" :key="job.task_id">
<div>
<strong>{{ job.task_id }}</strong>
<small>{{ job.task_type }} / {{ job.progress }}%</small>
</div>
<div class="inline-actions">
<span class="badge">{{ job.status }}</span>
<button v-if="['failed', 'dead_letter', 'cancelled'].includes(job.status)" type="button" @click="retryJob(job.task_id)">
{{ text.retry }}
</button>
<button v-if="!['completed', 'succeeded', 'cancelled'].includes(job.status)" type="button" @click="cancelJob(job.task_id)">
{{ text.cancel }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="loadJobDetail(job.task_id)">
{{ text.detail }}
</button>
</div>
</li>
<li v-if="!jobs?.items.length" class="empty">{{ text.emptyJobs }}</li>
</ul>
<section v-if="selectedJob" class="editor-panel">
<header>
<h2>{{ text.jobDetail }}</h2>
<span>{{ selectedJob.status }}</span>
</header>
<pre>{{ JSON.stringify(selectedJob, null, 2) }}</pre>
</section>
</section>
<section v-if="activeView === 'discovery'" class="split-view">
<div class="list-view">
<header>
<h2>{{ text.dialects }}</h2>
<div class="inline-actions">
<button type="button" :disabled="Boolean(busy)" @click="safeProbeProvider">{{ text.probeProvider }}</button>
<button type="button" :disabled="Boolean(busy)" @click="safeProbeModel">{{ text.safeProbe }}</button>
</div>
</header>
<ul>
<li v-for="dialect in dialects" :key="dialect.dialect">
<div>
<strong>{{ dialect.label }}</strong>
<small>{{ dialect.capabilities.join(", ") || text.unconfirmed }}</small>
</div>
<span>{{ dialect.dialect }}</span>
</li>
</ul>
<div class="form-grid">
<label>
<span>{{ text.provider }}</span>
<input v-model="renderPlanDraft.provider_id" type="text" placeholder="local-preview" />
</label>
<label>
<span>{{ text.model }}</span>
<input v-model="renderPlanDraft.model_id" type="text" placeholder="metadata-only" />
</label>
<label>
<span>{{ text.requiredCapabilities }}</span>
<input v-model="renderPlanDraft.required_capabilities" type="text" placeholder="text_to_image" />
</label>
<button
type="button"
:disabled="Boolean(busy) || !renderPlanDraft.provider_id || !renderPlanDraft.model_id"
@click="validateRenderPlan"
>
{{ text.validatePlan }}
</button>
</div>
<pre v-if="renderPlanValidation">{{ JSON.stringify(renderPlanValidation, null, 2) }}</pre>
</div>
<div class="list-view">
<header>
<h2>{{ text.capabilityProfiles }}</h2>
<span>{{ capabilities.length }}</span>
</header>
<ul>
<li v-for="profile in capabilities" :key="profile.capability_profile_id">
<div>
<strong>{{ profile.provider_id }} / {{ profile.model_id }}</strong>
<small>{{ profile.dialect }}</small>
</div>
<div class="inline-actions">
<span class="badge">{{ profile.status }}</span>
<button type="button" :disabled="Boolean(busy)" @click="setCapabilityStatus(profile, 'confirmed_supported')">
{{ text.support }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="setCapabilityStatus(profile, 'confirmed_unsupported')">
{{ text.unsupported }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="setCapabilityStatus(profile, 'unconfirmed')">
{{ text.unconfirmed }}
</button>
</div>
</li>
<li v-if="!capabilities.length" class="empty">{{ text.emptyCapabilities }}</li>
</ul>
</div>
</section>
<section v-if="activeView === 'logs'" class="logs-view">
<div class="split-view">
<div class="list-view">
<header>
<h2>{{ text.generationLogs }}</h2>
<span>{{ logs.generation.length }}</span>
</header>
<div class="form-grid">
<label>
<span>{{ text.status }}</span>
<select v-model="generationLogFilters.status">
<option value="">{{ text.allStatuses }}</option>
<option v-for="status in taskStatuses" :key="`gen-${status}`" :value="status">{{ status }}</option>
</select>
</label>
<label>
<span>ProfileId</span>
<input v-model="generationLogFilters.profile_id" type="text" />
</label>
<label>
<span>WorkflowId</span>
<input v-model="generationLogFilters.workflow_id" type="text" />
</label>
<label>
<span>NodeId</span>
<input v-model="generationLogFilters.node_id" type="text" />
</label>
<button type="button" :disabled="Boolean(busy)" @click="loadGenerationLogs">
{{ text.applyFilters }}
</button>
</div>
<ul>
<li v-for="item in logs.generation" :key="item.task_id">
<div>
<strong>{{ item.task_id }}</strong>
<small>{{ item.status }} / {{ item.progress }}%</small>
</div>
<span>{{ item.created_at }}</span>
</li>
<li v-if="!logs.generation.length" class="empty">{{ text.emptyGenerationLogs }}</li>
</ul>
</div>
<div class="list-view">
<header>
<h2>{{ text.errorLogs }}</h2>
<span>{{ logs.errors.length }}</span>
</header>
<div class="form-grid">
<label>
<span>Source</span>
<select v-model="errorLogFilters.source">
<option value="">All</option>
<option value="generation_task">generation_task</option>
<option value="integration">integration</option>
</select>
</label>
<label>
<span>{{ text.status }}</span>
<input v-model="errorLogFilters.status" type="text" />
</label>
<button type="button" :disabled="Boolean(busy)" @click="loadErrorLogs">
{{ text.applyFilters }}
</button>
</div>
<ul>
<li v-for="item in logs.errors" :key="`${item.source}-${item.id}`">
<div>
<strong>{{ item.source }}</strong>
<small>{{ item.error_message ?? text.noErrorDetail }}</small>
</div>
<span class="badge">{{ item.status }}</span>
</li>
<li v-if="!logs.errors.length" class="empty">{{ text.emptyErrors }}</li>
</ul>
</div>
</div>
<div class="split-view">
<div class="list-view">
<header>
<h2>{{ text.workflowLogs }}</h2>
<span>{{ logs.workflows.length }}</span>
</header>
<div class="form-grid">
<label>
<span>WorkflowId</span>
<input v-model="workflowLogFilters.workflow_id" type="text" />
</label>
<label>
<span>Action</span>
<input v-model="workflowLogFilters.action" type="text" />
</label>
<label>
<span>NodeId</span>
<input v-model="workflowLogFilters.node_id" type="text" />
</label>
<label>
<span>{{ text.currentBranch }}</span>
<input v-model="workflowLogFilters.branch_name" type="text" />
</label>
<button type="button" :disabled="Boolean(busy)" @click="loadWorkflowLogs">
{{ text.applyFilters }}
</button>
</div>
<ul>
<li v-for="item in logs.workflows" :key="item.history_id">
<div>
<strong>{{ item.action }}</strong>
<small>{{ item.title ?? item.workflow_id }}</small>
</div>
<span>{{ item.branch_name ?? "main" }}</span>
</li>
<li v-if="!logs.workflows.length" class="empty">{{ text.emptyWorkflowLogs }}</li>
</ul>
</div>
<div class="list-view">
<header>
<h2>{{ text.integrationLogs }}</h2>
<span>{{ logs.integrations.length }}</span>
</header>
<div class="form-grid">
<label>
<span>Integration</span>
<input v-model="integrationLogFilters.integration_name" type="text" />
</label>
<label>
<span>Action</span>
<input v-model="integrationLogFilters.action" type="text" />
</label>
<label>
<span>{{ text.status }}</span>
<input v-model="integrationLogFilters.status" type="text" />
</label>
<button type="button" :disabled="Boolean(busy)" @click="loadIntegrationLogs">
{{ text.applyFilters }}
</button>
</div>
<ul>
<li v-for="item in logs.integrations" :key="item.integration_log_id">
<div>
<strong>{{ item.integration_name }}</strong>
<small>{{ item.action }}</small>
</div>
<span class="badge">{{ item.status }}</span>
</li>
<li v-if="!logs.integrations.length" class="empty">{{ text.emptyIntegrationLogs }}</li>
</ul>
</div>
</div>
<div class="list-view">
<header>
<h2>{{ text.integrationEvents }}</h2>
<span>{{ integrationEventLogs.length }}</span>
</header>
<div class="form-grid">
<label>
<span>Integration</span>
<input v-model="integrationEventFilters.integration_name" type="text" />
</label>
<label>
<span>Action</span>
<input v-model="integrationEventFilters.action" type="text" />
</label>
<label>
<span>{{ text.status }}</span>
<input v-model="integrationEventFilters.status" type="text" />
</label>
<button type="button" :disabled="Boolean(busy)" @click="loadIntegrationEventLogs">
{{ text.applyFilters }}
</button>
</div>
<ul>
<li v-for="item in integrationEventLogs" :key="`event-${item.integration_log_id}`">
<div>
<strong>{{ item.integration_name }}</strong>
<small>{{ item.action }} / {{ item.created_at }}</small>
</div>
<span class="badge">{{ item.status }}</span>
</li>
<li v-if="!integrationEventLogs.length" class="empty">{{ text.emptyIntegrationLogs }}</li>
</ul>
<pre v-if="integrationEventLogs.length">{{ JSON.stringify(integrationEventLogs[0], null, 2) }}</pre>
</div>
<div class="list-view">
<header>
<h2>{{ text.auditLogs }}</h2>
<span>{{ logs.audit.length }}</span>
</header>
<div class="form-grid">
<label>
<span>Action</span>
<input v-model="auditFilters.action" type="text" />
</label>
<label>
<span>{{ text.targetType }}</span>
<input v-model="auditFilters.target_type" type="text" />
</label>
<label>
<span>{{ text.actor }}</span>
<input v-model="auditFilters.actor_id" type="text" />
</label>
<button type="button" :disabled="Boolean(busy)" @click="loadAuditLogs">{{ text.filter }}</button>
</div>
<ul>
<li v-for="item in logs.audit" :key="item.audit_id">
<div>
<strong>{{ item.action }}</strong>
<small>{{ item.actor_type }} / {{ item.target_type }} / {{ item.target_id }}</small>
</div>
<span>{{ item.created_at }}</span>
</li>
<li v-if="!logs.audit.length" class="empty">{{ text.emptyAuditLogs }}</li>
</ul>
</div>
</section>
<section v-if="activeView === 'settings'" class="settings-view">
<div class="toolbar">
<button type="button" :disabled="Boolean(busy)" @click="reloadSettings">{{ text.reload }}</button>
<button type="button" :disabled="Boolean(busy)" @click="resetSettingsDraft()">{{ text.reset }}</button>
<button type="button" :disabled="Boolean(busy)" @click="validateSettingsDraft">{{ text.validate }}</button>
<button type="button" :disabled="Boolean(busy)" @click="diffSettingsDraft">{{ text.diff }}</button>
<button type="button" :disabled="Boolean(busy)" @click="saveSettingsDraft">{{ text.save }}</button>
<button type="button" :disabled="Boolean(busy)" @click="exportSettings">{{ text.exportRedacted }}</button>
<button type="button" :disabled="Boolean(busy)" @click="loadSettingsSnapshots">{{ text.loadSnapshots }}</button>
</div>
<div class="settings-sections">
<article v-for="section in settingsSchema?.sections ?? []" :key="section.key">
<h2>{{ section.title }}</h2>
<span>{{ section.fields.length }}</span>
</article>
</div>
<section class="editor-panel">
<header>
<h2>{{ text.settingsEditor }}</h2>
<span>{{ currentSettings?.config_path ?? "***PATH***" }}</span>
</header>
<textarea v-model="settingsDraft" spellcheck="false" />
</section>
<section class="editor-panel">
<header>
<h2>{{ text.importSettings }}</h2>
<button type="button" :disabled="Boolean(busy) || !settingsImportDraft" @click="importSettingsDraft">
{{ text.importSettings }}
</button>
</header>
<textarea v-model="settingsImportDraft" spellcheck="false" />
</section>
<section class="editor-panel">
<header>
<h2>{{ text.snapshots }}</h2>
<span>{{ settingsSnapshots.length }}</span>
</header>
<ul>
<li v-for="snapshot in settingsSnapshots" :key="snapshot.snapshot_id">
<div>
<strong>{{ snapshot.reason }}</strong>
<small>{{ snapshot.snapshot_id }} / {{ snapshot.created_at }}</small>
</div>
<div class="inline-actions">
<button type="button" :disabled="Boolean(busy)" @click="loadSettingsSnapshot(snapshot.snapshot_id)">
{{ text.loadSnapshot }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="rollbackSettingsSnapshot(snapshot.snapshot_id)">
{{ text.rollback }}
</button>
</div>
</li>
</ul>
</section>
<section v-if="settingsSnapshotDetail" class="editor-panel">
<header>
<h2>{{ text.snapshotPreview }}</h2>
<span>{{ settingsSnapshotDetail.snapshot_id }}</span>
</header>
<pre>{{ JSON.stringify(settingsSnapshotDetail.config, null, 2) }}</pre>
</section>
<div class="split-view">
<div class="list-view">
<header>
<h2>{{ text.validationResult }}</h2>
<span>{{ settingsValidation?.valid ?? "-" }}</span>
</header>
<pre>{{ JSON.stringify(settingsValidation ?? {}, null, 2) }}</pre>
</div>
<div class="list-view">
<header>
<h2>{{ text.diffResult }}</h2>
<span>{{ settingsDiff?.changes.length ?? 0 }}</span>
</header>
<pre>{{ JSON.stringify(settingsDiff ?? {}, null, 2) }}</pre>
</div>
</div>
<section v-if="settingsExportResult" class="editor-panel">
<header>
<h2>{{ text.exportSettings }}</h2>
<span>{{ settingsExportResult.redacted }}</span>
</header>
<pre>{{ JSON.stringify(settingsExportResult.config, null, 2) }}</pre>
</section>
</section>
</template>
</section>
<aside class="inspector">
<h2>{{ text.running }}</h2>
<dl>
<div>
<dt>Pending</dt>
<dd>{{ dashboard?.queue.pending ?? 0 }}</dd>
</div>
<div>
<dt>Running</dt>
<dd>{{ dashboard?.queue.running ?? 0 }}</dd>
</div>
<div>
<dt>Failed</dt>
<dd>{{ dashboard?.queue.failed ?? 0 }}</dd>
</div>
<div>
<dt>Dead</dt>
<dd>{{ dashboard?.queue.dead_letter ?? 0 }}</dd>
</div>
</dl>
<h2>{{ text.storage }}</h2>
<dl>
<div>
<dt>Images</dt>
<dd>{{ formatBytes(storageRootBytes("storage://images/")) }}</dd>
</div>
<div>
<dt>Materials</dt>
<dd>{{ formatBytes(storageRootBytes("storage://materials/")) }}</dd>
</div>
</dl>
</aside>
</main>
</template>
<style scoped>
.web-shell {
box-sizing: border-box;
display: grid;
grid-template-columns: 220px minmax(0, 1fr) 260px;
min-height: 100vh;
color: #1b2430;
background: #f5f6f8;
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.sidebar,
.inspector {
background: #ffffff;
}
.sidebar {
border-right: 1px solid #d9e0e8;
padding: 20px;
}
.inspector {
border-left: 1px solid #d9e0e8;
padding: 20px;
}
.brand {
display: grid;
gap: 4px;
margin-bottom: 24px;
}
.brand strong {
font-size: 19px;
}
.brand span,
p,
dt,
.empty,
small {
color: #667085;
}
nav {
display: grid;
gap: 6px;
}
button {
min-height: 36px;
border: 1px solid #c7d0da;
border-radius: 6px;
color: #1b2430;
background: #ffffff;
font: inherit;
text-align: center;
cursor: pointer;
}
button:disabled {
cursor: wait;
opacity: 0.62;
}
nav button {
border-color: transparent;
background: transparent;
text-align: left;
padding: 0 10px;
}
button.active {
border-color: #b8d8cf;
color: #164f43;
background: #e5f4ef;
}
.workspace {
min-width: 0;
padding: 24px;
}
.topbar,
.list-view header,
.toolbar,
.inline-actions {
display: flex;
gap: 12px;
align-items: center;
}
.topbar,
.list-view header {
justify-content: space-between;
}
.actions,
.inline-actions {
flex-wrap: wrap;
justify-content: flex-end;
}
.topbar button,
.toolbar button,
.list-view header button,
.inline-actions button {
padding: 0 14px;
}
h1,
h2,
p,
dl,
dd {
margin: 0;
}
h1 {
min-height: 30px;
font-size: 26px;
}
h2 {
font-size: 15px;
}
.notice,
article,
.list-view,
.editor-panel,
pre {
border: 1px solid #d9e0e8;
border-radius: 8px;
background: #ffffff;
}
.notice {
margin-top: 18px;
padding: 14px;
}
.error {
border-color: #f0b4b4;
color: #8a1f1f;
background: #fff7f7;
}
.dashboard-grid,
.split-view {
display: grid;
gap: 12px;
margin-top: 18px;
}
.dashboard-grid {
grid-template-columns: repeat(4, minmax(130px, 1fr));
}
.split-view {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
article {
display: grid;
gap: 8px;
padding: 16px;
}
article span {
color: #667085;
font-size: 13px;
}
article strong {
font-size: 24px;
}
.list-view,
.logs-view,
.settings-view {
margin-top: 18px;
}
.split-view .list-view,
.logs-view .list-view {
margin-top: 0;
}
.list-view {
padding: 16px;
}
.editor-panel {
display: grid;
gap: 12px;
margin-top: 12px;
padding: 16px;
}
.editor-panel header {
display: flex;
justify-content: space-between;
gap: 12px;
min-width: 0;
}
textarea {
box-sizing: border-box;
width: 100%;
min-height: 300px;
resize: vertical;
border: 1px solid #c7d0da;
border-radius: 6px;
padding: 12px;
color: #1b2430;
background: #fbfcfd;
font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
.form-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
margin-top: 14px;
padding: 12px;
border: 1px solid #eef1f5;
border-radius: 8px;
background: #fbfcfd;
}
label {
display: grid;
gap: 5px;
min-width: 0;
}
label span {
color: #667085;
font-size: 12px;
}
.wide-field {
grid-column: 1 / -1;
}
input,
select {
box-sizing: border-box;
width: 100%;
min-height: 34px;
border: 1px solid #c7d0da;
border-radius: 6px;
padding: 0 10px;
color: #1b2430;
background: #ffffff;
font: inherit;
}
ul {
display: grid;
gap: 10px;
margin: 14px 0 0;
padding: 0;
list-style: none;
}
li {
display: flex;
justify-content: space-between;
gap: 12px;
min-width: 0;
padding: 10px 0;
border-top: 1px solid #eef1f5;
}
li:first-child {
border-top: 0;
}
li > div {
display: grid;
gap: 3px;
min-width: 0;
}
li strong,
li span,
li small {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.badge {
align-self: center;
max-width: 180px;
border-radius: 999px;
padding: 4px 9px;
color: #1f4d62;
background: #e5f1f7;
font-size: 12px;
}
.toolbar {
justify-content: flex-start;
margin: 18px 0 12px;
}
.settings-sections {
display: grid;
grid-template-columns: repeat(3, minmax(120px, 1fr));
gap: 12px;
}
pre {
overflow: auto;
max-height: 420px;
margin: 12px 0 0;
padding: 14px;
font-size: 12px;
line-height: 1.5;
}
dl {
display: grid;
gap: 12px;
margin: 14px 0 24px;
}
dl div {
display: flex;
justify-content: space-between;
}
@media (max-width: 1160px) {
.web-shell {
grid-template-columns: 190px minmax(0, 1fr);
}
.inspector {
display: none;
}
}
@media (max-width: 820px) {
.web-shell {
grid-template-columns: 1fr;
}
.sidebar {
border-right: 0;
border-bottom: 1px solid #d9e0e8;
}
nav {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
nav button {
text-align: center;
}
.dashboard-grid,
.split-view,
.settings-sections {
grid-template-columns: 1fr;
}
.topbar,
.list-view header {
align-items: flex-start;
flex-direction: column;
}
}
</style>