feat: add event stream workbench panel

这个提交存在于:
YokiiroBW 2026-07-05 16:23:47 +08:00
父节点 6e82b8d547
当前提交 9d59920e4f
共有 12 个文件被更改,包括 79 次插入 和 25 次删除

查看文件

@ -71,5 +71,6 @@ export const endpoints = {
errorLogs: "logs/errors",
integrationLogs: "logs/integrations",
auditLogs: "security/audit-logs",
eventStream: "events/stream",
webManifest: "web/manifest",
} as const

查看文件

@ -55,6 +55,20 @@ export interface AuditLog {
created_at: string
}
export interface EventStreamEvent {
event_id: string
event_type: string
data: Record<string, unknown>
created_at: string
}
export interface EventStreamResult {
content_type: string
events: EventStreamEvent[]
body: string
count: number
}
export interface LogBundle {
generation: GenerationLog[]
workflows: WorkflowLog[]

查看文件

@ -8,7 +8,7 @@ import type { ApiDialect, CapabilityProfile, RenderPlanValidationResult } from "
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 { EventStreamResult, 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"
@ -193,6 +193,8 @@ const text = {
workflowLogs: "\u5de5\u4f5c\u6d41",
integrationLogs: "\u96c6\u6210",
integrationEvents: "\u96c6\u6210\u4e8b\u4ef6",
eventStream: "\u4e8b\u4ef6\u6d41",
ssePreview: "SSE Preview",
auditLogs: "\u5ba1\u8ba1",
targetType: "TargetType",
actor: "\u64cd\u4f5c\u4eba",
@ -200,6 +202,7 @@ const text = {
emptyErrors: "\u6682\u65e0\u9519\u8bef",
emptyWorkflowLogs: "\u6682\u65e0\u5de5\u4f5c\u6d41\u65e5\u5fd7",
emptyIntegrationLogs: "\u6682\u65e0\u96c6\u6210\u65e5\u5fd7",
emptyEvents: "\u6682\u65e0\u4e8b\u4ef6",
emptyAuditLogs: "\u6682\u65e0\u5ba1\u8ba1\u65e5\u5fd7",
noErrorDetail: "\u65e0\u9519\u8bef\u8be6\u60c5",
reload: "\u91cd\u8f7d",
@ -266,6 +269,7 @@ 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 eventStream = ref<EventStreamResult | null>(null)
const signedMedia = ref<MediaSignResult | null>(null)
const settingsDraft = ref("")
const settingsImportDraft = ref("")
@ -350,6 +354,9 @@ const integrationEventFilters = ref({
action: "",
status: "",
})
const eventStreamFilters = ref({
event_type: "",
})
const auditFilters = ref({
action: "",
target_type: "",
@ -482,6 +489,7 @@ async function load() {
await loadWardrobe(profileData.items[0]?.profile_id)
await loadWorkflows(profileData.items[0]?.profile_id)
await loadLogs()
await loadEventStream()
} catch (err) {
error.value = err instanceof Error ? err.message : text.loadFailed
} finally {
@ -540,6 +548,10 @@ async function loadIntegrationEventLogs() {
)
}
async function loadEventStream() {
eventStream.value = await getJson<EventStreamResult>(endpoints.eventStream, compactQuery(eventStreamFilters.value, 20))
}
async function loadAuditLogs() {
logs.value.audit = await getJson<LogBundle["audit"]>(endpoints.auditLogs, {
action: auditFilters.value.action || undefined,
@ -2564,6 +2576,33 @@ function storageRootBytes(uriPrefix: string) {
<pre v-if="integrationEventLogs.length">{{ JSON.stringify(integrationEventLogs[0], null, 2) }}</pre>
</div>
<div class="list-view">
<header>
<h2>{{ text.eventStream }}</h2>
<span>{{ eventStream?.count ?? 0 }}</span>
</header>
<div class="form-grid">
<label>
<span>EventType</span>
<input v-model="eventStreamFilters.event_type" type="text" />
</label>
<button type="button" :disabled="Boolean(busy)" @click="loadEventStream">
{{ text.applyFilters }}
</button>
</div>
<ul>
<li v-for="item in eventStream?.events ?? []" :key="item.event_id">
<div>
<strong>{{ item.event_type }}</strong>
<small>{{ item.event_id }} / {{ item.created_at }}</small>
</div>
<span>{{ Object.keys(item.data).length }}</span>
</li>
<li v-if="!eventStream?.events.length" class="empty">{{ text.emptyEvents }}</li>
</ul>
<pre v-if="eventStream?.body">{{ eventStream.body }}</pre>
</div>
<div class="list-view">
<header>
<h2>{{ text.auditLogs }}</h2>

查看文件

@ -538,7 +538,7 @@ GET media/fetch?token=...
## 17. SSE
```http
GET events/stream
GET events/stream?event_type=&limit=50
```
事件样例:

查看文件

@ -889,7 +889,7 @@ GET /jobs
GET /jobs/{task_id}
POST /jobs/{task_id}/cancel
POST /jobs/{task_id}/retry
GET /events/stream
GET /events/stream?event_type=&limit=50
```
SSE 事件:

查看文件

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

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

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

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

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

查看文件

@ -1,3 +1,3 @@
<script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-BqwYfnoc.js"></script>
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-Bj4uvUaJ.css">
<script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-iAALmDfT.js"></script>
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-BJain7ke.css">
<div id="app"></div>