feat: add workflow management workbench

这个提交存在于:
YokiiroBW 2026-07-05 13:46:58 +08:00
父节点 e7ef2f0508
当前提交 d108b9d175
共有 13 个文件被更改,包括 244 次插入 和 39 次删除

查看文件

@ -35,6 +35,9 @@ ROUTES: tuple[RouteSpec, ...] = (
RouteSpec("POST", "profiles/{profile_id}/workflows", "backend.routes.workflow_routes.create_profile_workflow", "write"),
RouteSpec("GET", "workflows/{workflow_id}", "backend.routes.workflow_routes.get_workflow", "read"),
RouteSpec("PUT", "workflows/{workflow_id}", "backend.routes.workflow_routes.update_workflow", "write"),
RouteSpec("POST", "workflows/{workflow_id}/start", "backend.routes.workflow_routes.start_workflow", "write"),
RouteSpec("POST", "workflows/{workflow_id}/cancel", "backend.routes.workflow_routes.cancel_workflow", "write"),
RouteSpec("POST", "workflows/{workflow_id}/archive", "backend.routes.workflow_routes.archive_workflow", "write"),
RouteSpec("GET", "workflows/{workflow_id}/nodes", "backend.routes.node_routes.list_workflow_nodes", "read"),
RouteSpec("POST", "workflows/{workflow_id}/nodes", "backend.routes.node_routes.create_workflow_node", "write"),
RouteSpec("GET", "workflows/{workflow_id}/branches", "backend.routes.branch_routes.list_workflow_branches", "read"),

查看文件

@ -6,6 +6,12 @@ export const endpoints = {
profiles: "profiles",
profile: (profileId: string) => `profiles/${profileId}`,
quickProfileDraft: "profiles/quick-draft",
profileWorkflows: (profileId: string) => `profiles/${profileId}/workflows`,
workflow: (workflowId: string) => `workflows/${workflowId}`,
workflowStart: (workflowId: string) => `workflows/${workflowId}/start`,
workflowCancel: (workflowId: string) => `workflows/${workflowId}/cancel`,
workflowArchive: (workflowId: string) => `workflows/${workflowId}/archive`,
workflowNodes: (workflowId: string) => `workflows/${workflowId}/nodes`,
jobs: "jobs",
jobCancel: (taskId: string) => `jobs/${taskId}/cancel`,
jobRetry: (taskId: string) => `jobs/${taskId}/retry`,

查看文件

@ -0,0 +1,39 @@
export interface ProfileWorkflow {
workflow_id: string
profile_id: string
workflow_type: string
display_name: string
mode?: string | null
status: string
current_node_id?: string | null
current_branch: string
session_key?: string | null
metadata: Record<string, unknown>
created_at: string
updated_at: string
}
export interface WorkflowNode {
node_id: string
workflow_id: string
node_key: string
title: string
description?: string | null
step_name?: string | null
node_type: string
status: string
branch_name: string
prompt?: string | null
negative_prompt?: string | null
model_route?: string | null
selected_image_id?: string | null
sort_order: number
metadata: Record<string, unknown>
created_at: string
updated_at: string
}
export interface WorkflowDetail {
workflow: ProfileWorkflow
nodes: WorkflowNode[]
}

查看文件

@ -21,8 +21,18 @@ import type {
} from "../../shared/types/settings"
import type { MediaSignResult, StorageStatus } from "../../shared/types/storage"
import type { WardrobeItem, WardrobeMatchResult } from "../../shared/types/wardrobe"
import type { ProfileWorkflow, WorkflowDetail } from "../../shared/types/workflow"
type ViewKey = "dashboard" | "profiles" | "materials" | "wardrobe" | "jobs" | "discovery" | "logs" | "settings"
type ViewKey =
| "dashboard"
| "profiles"
| "workflows"
| "materials"
| "wardrobe"
| "jobs"
| "discovery"
| "logs"
| "settings"
const text = {
waiting: "\u7b49\u5f85\u64cd\u4f5c",
@ -37,6 +47,7 @@ const text = {
create: "\u65b0\u5efa",
quickDraft: "\u5feb\u901f\u8349\u7a3f",
archive: "\u5f52\u6863",
start: "\u542f\u52a8",
recognize: "\u8bc6\u522b",
confirm: "\u786e\u8ba4",
name: "\u540d\u79f0",
@ -72,6 +83,7 @@ const text = {
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",
@ -82,6 +94,12 @@ const text = {
profileCreated: "\u89d2\u8272\u5df2\u521b\u5efa",
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",
currentBranch: "\u5f53\u524d\u5206\u652f",
materialCategories: "\u7d20\u6750\u5206\u7c7b",
materialItems: "\u7d20\u6750\u6761\u76ee",
emptyCategories: "\u6682\u65e0\u5206\u7c7b",
@ -142,6 +160,7 @@ const text = {
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" },
@ -154,6 +173,8 @@ const activeView = ref<ViewKey>("dashboard")
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 jobs = ref<JobListResult | null>(null)
const settingsSchema = ref<SettingsSchema | null>(null)
const currentSettings = ref<CurrentSettings | null>(null)
@ -181,6 +202,10 @@ const profileDraft = ref({
description: "",
})
const quickProfileDraft = ref<QuickProfileDraftResult | null>(null)
const workflowDraft = ref({
display_name: "",
workflow_type: "single_image",
})
const materialDraft = ref({
display_name: "",
image_uri: "",
@ -228,6 +253,7 @@ 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,
@ -282,6 +308,7 @@ async function load() {
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
@ -319,6 +346,28 @@ async function loadWardrobe(profileId?: string) {
wardrobe.value = await getJson<WardrobeItem[]>(endpoints.wardrobe(profileId))
}
async function loadWorkflows(profileId?: string) {
if (!profileId) {
workflows.value = []
workflowDetail.value = null
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) {
workflowDetail.value = await getJson<WorkflowDetail>(endpoints.workflow(workflowId))
}
async function runOperation(label: string, action: () => Promise<unknown>, refresh = true) {
busy.value = label
error.value = ""
@ -414,6 +463,36 @@ function deleteProfile(profileId: string) {
)
}
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 moveFailedJobs() {
return runOperation(text.moveFailed, () => postJson(endpoints.jobDeadLetterMoveFailed, { limit: 20 }))
}
@ -829,6 +908,81 @@ function storageRootBytes(uriPrefix: string) {
</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>
</div>
<div class="list-view">
<header>
<h2>{{ text.nodes }}</h2>
<span>{{ workflowDetail?.workflow.current_branch ?? "main" }}</span>
</header>
<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>
</div>
</li>
<li v-if="!workflowDetail?.nodes.length" class="empty">{{ text.emptyWorkflows }}</li>
</ul>
<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>

文件差异因一行或多行过长而隐藏

文件差异因一行或多行过长而隐藏

查看文件

@ -1,3 +1,3 @@
<script type="module" crossorigin src="/assets/index-DxDyhkQX.js"></script>
<script type="module" crossorigin src="/assets/index-b8CM27h2.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-KxvCyOGk.css">
<div id="app"></div>

查看文件

@ -20,6 +20,9 @@ class RouteRegistryTests(unittest.TestCase):
self.assertIn(("GET", "materials/{material_id}"), keys)
self.assertIn(("DELETE", "profiles/{profile_id}/wardrobe/{wardrobe_item_id}"), keys)
self.assertIn(("GET", "integrations/logs"), keys)
self.assertIn(("POST", "workflows/{workflow_id}/start"), keys)
self.assertIn(("POST", "workflows/{workflow_id}/cancel"), keys)
self.assertIn(("POST", "workflows/{workflow_id}/archive"), keys)
self.assertEqual(len(routes), len(ROUTES))
def test_webui_adapter_manifest_includes_api_routes(self):

文件差异因一行或多行过长而隐藏

文件差异因一行或多行过长而隐藏

文件差异因一行或多行过长而隐藏

文件差异因一行或多行过长而隐藏

查看文件

@ -1,3 +1,3 @@
<script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-CMIPJ6y1.js"></script>
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-DJ-aUUSl.css">
<script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-DnBfG3sU.js"></script>
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-BoTUhgnW.css">
<div id="app"></div>