bailinghub 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +146 -185
- package/README.md +135 -207
- package/THIRD_PARTY_NOTICES.md +6 -7
- package/assets/readme-demo-evidence.en-dark.svg +82 -0
- package/assets/readme-demo-evidence.en.svg +82 -0
- package/assets/readme-demo-evidence.zh-CN-dark.svg +82 -0
- package/assets/readme-demo-evidence.zh-CN.svg +82 -0
- package/assets/readme-entry-points.en-dark.svg +71 -0
- package/assets/readme-entry-points.en.svg +71 -0
- package/assets/readme-entry-points.zh-CN-dark.svg +71 -0
- package/assets/readme-entry-points.zh-CN.svg +71 -0
- package/assets/readme-product-overview.en-dark.svg +87 -0
- package/assets/readme-product-overview.en.svg +87 -0
- package/assets/readme-product-overview.zh-CN-dark.svg +87 -0
- package/assets/readme-product-overview.zh-CN.svg +87 -0
- package/docker-compose.images.yml +2 -2
- package/docs/AGENT_CLIENT_QUICKSTART.en.md +29 -8
- package/docs/AGENT_CLIENT_QUICKSTART.md +25 -6
- package/docs/AGENT_CONVERSATION_AUDIT.en.md +194 -0
- package/docs/AGENT_CONVERSATION_AUDIT.md +111 -0
- package/docs/CHANGELOG.en.md +11 -0
- package/docs/CHANGELOG.md +11 -0
- package/docs/INDEPENDENT_VALIDATION.en.md +4 -4
- package/docs/INDEPENDENT_VALIDATION.md +4 -4
- package/docs/README.en.md +5 -0
- package/docs/README.md +5 -0
- package/docs/RELEASE_NOTES_v0.6.0.en.md +51 -0
- package/docs/RELEASE_NOTES_v0.6.0.md +51 -0
- package/docs/user-guide/README.en.md +1 -0
- package/docs/user-guide/README.md +1 -0
- package/docs/user-guide/console-map.en.md +2 -0
- package/docs/user-guide/console-map.md +2 -1
- package/docs/user-guide/conversations.en.md +40 -0
- package/docs/user-guide/conversations.md +40 -0
- package/package.json +1 -1
- package/scripts/check-doc-links.mjs +2 -0
- package/scripts/check-image-tags.sh +1 -1
- package/scripts/check-release-consistency.test.mjs +2 -2
- package/scripts/e2e-console.mjs +89 -0
- package/scripts/generate-readme-assets.mjs +488 -7
- package/scripts/install.sh +1 -1
- package/scripts/publish-images.sh +1 -1
- package/scripts/release-audit.mjs +1 -0
- package/scripts/verify-github-repo.mjs +1 -0
- package/sql/057_agent_conversation_audit.sql +55 -0
- package/src/app/agent-conversation-audit.ts +30 -0
- package/src/core/runtime/agent-conversation-audit.test.ts +38 -0
- package/src/core/runtime/agent-conversation-audit.ts +159 -0
- package/src/infrastructure/config/config-agent-conversation-audit-repository.test.ts +146 -0
- package/src/infrastructure/config/config-agent-conversation-audit-repository.ts +262 -0
- package/src/infrastructure/config/configstore.ts +5 -0
- package/src/routes/admin-conversation-audit.ts +46 -0
- package/src/routes/admin-runtime.test.ts +38 -0
- package/src/routes/admin-runtime.ts +14 -3
- package/src/routes/admin.ts +3 -0
- package/src/routes/agent-api.ts +2 -0
- package/src/routes/agent-conversation-audit.test.ts +131 -0
- package/src/routes/agent-conversation-audit.ts +33 -0
- package/src/test-support/agent-conversation-audit-fixture.ts +123 -0
- package/web/console/assets/{Accounts-r10QUjLQ.js → Accounts-Ca_VnSu9.js} +1 -1
- package/web/console/assets/{AgentClients-UTTqbkjy.js → AgentClients-BPIvlLYY.js} +1 -1
- package/web/console/assets/{Approvals-BGKkYIya.js → Approvals-CMvPWacY.js} +1 -1
- package/web/console/assets/{Audit-CQmjOAoO.js → Audit-CIRqOCnL.js} +1 -1
- package/web/console/assets/{BrandLockup-BF_0pCa3.js → BrandLockup-BrytmTTH.js} +1 -1
- package/web/console/assets/{Channels-C4yZE67F.js → Channels-CApxH2TB.js} +1 -1
- package/web/console/assets/{ChatEntries-OqsqLjU6.js → ChatEntries-CJon3bWJ.js} +1 -1
- package/web/console/assets/{Clients-Dv3sv51C.js → Clients-BSA1rlTB.js} +1 -1
- package/web/console/assets/{Cost-C_-kiH59.js → Cost-BbhlQFP8.js} +1 -1
- package/web/console/assets/{Credentials-CPTEAiV6.js → Credentials-kqr1W0K7.js} +1 -1
- package/web/console/assets/{Diagnostics-O-NKFOeI.js → Diagnostics-Kljt9XTH.js} +1 -1
- package/web/console/assets/{Executors-GVIAiNgv.js → Executors-DnsB-Xz4.js} +1 -1
- package/web/console/assets/{Kb-BsCWkJI1.js → Kb-DLZSAFWP.js} +2 -2
- package/web/console/assets/{Login-VFjkHNMr.js → Login-DiTjPWmN.js} +1 -1
- package/web/console/assets/{Projects-Ds-sJwfy.js → Projects-CXcVCgCD.js} +1 -1
- package/web/console/assets/{Routes-Wwurw2UU.js → Routes-DN9_d9Po.js} +1 -1
- package/web/console/assets/Runs-Cwbe6thL.js +3 -0
- package/web/console/assets/Runs-D8UmjP5G.css +1 -0
- package/web/console/assets/{Setup-BLelw0_V.js → Setup-FqoCKmfZ.js} +1 -1
- package/web/console/assets/{Shell-CvaeK4j_.js → Shell-BEqpONiy.js} +1 -1
- package/web/console/assets/{StorageBuckets-Dv6u47yO.js → StorageBuckets-CkORbYXY.js} +1 -1
- package/web/console/assets/{SystemSettings-B9K7zaDU.js → SystemSettings-gTQAazu7.js} +1 -1
- package/web/console/assets/{SystemStatus-H-oKDo-y.js → SystemStatus-DAmUUNqO.js} +1 -1
- package/web/console/assets/{Targets-CCFhjPKf.js → Targets-CZmDcjsE.js} +1 -1
- package/web/console/assets/{Tools-D0H9xpFH.js → Tools-CIHInlHL.js} +1 -1
- package/web/console/assets/{index-CuoTgf6q.js → index-BkLbd7Cc.js} +2 -2
- package/web/console/assets/{index-DyX9Bz3V.js → index-QnmD7N7F.js} +1 -1
- package/web/console/assets/{request-F5lXa7Ro.js → request-r7GHVJzw.js} +1 -1
- package/web/console/assets/{schema-DUWaWqPn.js → schema-BVn_hB7M.js} +1 -1
- package/web/console/assets/vendor-mammoth-BUEEDX6A.js +231 -0
- package/web/console/index.html +1 -1
- package/web-admin/package-lock.json +3 -3
- package/web-admin/src/components/ClientConversations.vue +244 -0
- package/web-admin/src/components/conversation-audit.ts +121 -0
- package/web-admin/src/pages/Runs.vue +73 -17
- package/web-admin/tests/conversation-audit.fixture.mjs +182 -0
- package/web-admin/tests/conversation-audit.test.mjs +93 -0
- package/web/console/assets/Runs-4zDD9VOC.css +0 -1
- package/web/console/assets/Runs-DLPzXmSy.js +0 -3
- package/web/console/assets/vendor-mammoth-nXG51Cg7.js +0 -231
package/web/console/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>百灵中枢 · 控制台</title>
|
|
7
7
|
<style>html,body{background:#0a0b0d;color-scheme:dark}</style>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-BkLbd7Cc.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="./assets/vendor-vue-B2uhHUfE.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="./assets/vendor-element-CZoEjZr8.js">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="./assets/index-Fi9gkGxV.css">
|
|
@@ -1113,9 +1113,9 @@
|
|
|
1113
1113
|
}
|
|
1114
1114
|
},
|
|
1115
1115
|
"node_modules/@xmldom/xmldom": {
|
|
1116
|
-
"version": "0.8.
|
|
1117
|
-
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.
|
|
1118
|
-
"integrity": "sha512
|
|
1116
|
+
"version": "0.8.15",
|
|
1117
|
+
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.15.tgz",
|
|
1118
|
+
"integrity": "sha512-/5NV/vDALVFDXgLmfsy9TRCBlKwO2LNBFzpzvb9iIj+jR+eSc6DLYYvVOdivT/jm7MtU6TebYuRmzEOI7w40UA==",
|
|
1119
1119
|
"license": "MIT",
|
|
1120
1120
|
"engines": {
|
|
1121
1121
|
"node": ">=10.0.0"
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="auditConvo">
|
|
3
|
+
<aside class="auditRail" aria-label="客户端对话列表">
|
|
4
|
+
<div class="railHeading"><b>客户端完整对话</b><span class="muted">按最近更新排序</span></div>
|
|
5
|
+
<div v-loading="listLoading" class="conversationList">
|
|
6
|
+
<el-alert v-if="listError" :title="listError" type="error" :closable="false" />
|
|
7
|
+
<el-empty v-else-if="!listLoading && !conversations.length" :image-size="56" description="尚无客户端正文归档;历史记录可在「原授权记录」查看" />
|
|
8
|
+
<button v-for="item in conversations" :key="item.conversation_id" type="button" class="conversationItem"
|
|
9
|
+
:class="{ selected: currentId === item.conversation_id }" @click="emit('select', item.conversation_id)">
|
|
10
|
+
<div class="itemHeading"><b>{{ item.client_app_id }}</b><el-tag size="small" effect="plain" :type="statusType(item.last_turn_status)">{{ item.last_turn_status ? turnStatusLabel(item.last_turn_status) : auditStatusLabel(item.state) }}</el-tag></div>
|
|
11
|
+
<div class="conversationName mono">{{ item.client_conversation_id }}</div>
|
|
12
|
+
<div class="muted">已接收 {{ item.turn_count }} 轮 / {{ item.message_count }} 条消息 · {{ item.member_count }} 项授权</div>
|
|
13
|
+
<div class="muted itemTime">{{ fmtTime(item.updated_at, true) }}</div>
|
|
14
|
+
</button>
|
|
15
|
+
<div v-if="listMore" class="pager"><el-button link :loading="listMoreLoading" @click="loadMoreConversations">加载更多对话</el-button></div>
|
|
16
|
+
</div>
|
|
17
|
+
</aside>
|
|
18
|
+
|
|
19
|
+
<main ref="pane" v-loading="detailLoading" class="auditPane" aria-label="客户端对话正文与授权执行">
|
|
20
|
+
<el-alert v-if="detailError" :title="detailError" type="error" :closable="false" class="notice" />
|
|
21
|
+
<el-empty v-if="!conversation && !detailLoading && !detailError" :image-size="80" description="选择一条对话,查看客户端正文与每轮授权执行" />
|
|
22
|
+
<template v-if="conversation">
|
|
23
|
+
<header class="conversationHeader">
|
|
24
|
+
<div class="headerRow"><b>{{ conversation.client_app_id }}</b><el-tag size="small" effect="plain">{{ conversation.route_key }}</el-tag><el-tag size="small" effect="plain" :type="conversation.state === 'ready' ? 'success' : 'warning'">{{ auditStatusLabel(conversation.state) }}</el-tag></div>
|
|
25
|
+
<div class="mono conversationName">{{ conversation.client_conversation_id }}</div>
|
|
26
|
+
<div class="muted">已接收 {{ conversation.turn_count }} 轮 / {{ conversation.message_count }} 条消息 · {{ conversation.confirmed_count }}/{{ conversation.member_count }} 项授权已确认</div>
|
|
27
|
+
<div class="muted provenance">展示客户端已同步的可见文本,旧历史或未同步内容可能缺失。授权卡片链接中枢验证的执行记录;正文与执行结果分别展示,隐藏推理不在此记录。</div>
|
|
28
|
+
<div class="members"><el-tag v-for="member in members" :key="member.session_id" size="small" effect="plain" :type="member.confirmed ? 'info' : 'warning'">{{ member.display_label || '未命名授权' }}{{ member.confirmed ? '' : ' · 待确认' }}</el-tag></div>
|
|
29
|
+
</header>
|
|
30
|
+
<el-alert v-if="conversation.state !== 'ready'" title="授权成员尚未全部确认,对话归档尚未就绪。" type="warning" :closable="false" class="notice" />
|
|
31
|
+
<div class="loadedCount muted">已加载 {{ turns.length }} 轮、{{ loadedMessageCount }} 条消息({{ events.length }} 条归档事件)<span v-if="hasMore"> · 下方可继续加载</span></div>
|
|
32
|
+
<el-alert v-if="focusTurn && !turns.some(turn => turn.id === focusTurn)" title="目标轮次尚未加载,请继续加载后续记录。" type="info" :closable="false" class="notice" />
|
|
33
|
+
<el-empty v-if="!turns.length && !detailLoading" :image-size="56" description="尚未收到客户端正文或轮次记录" />
|
|
34
|
+
|
|
35
|
+
<section v-for="(turn, index) in turns" :key="turn.id" :data-turn-id="turn.id" class="auditTurn" :class="{ focused: focusTurn === turn.id }">
|
|
36
|
+
<div class="turnHeading"><b>第 {{ index + 1 }} 轮</b><span class="muted mono">{{ turn.id }}</span><el-tag size="small" effect="plain" :type="statusType(turn.end?.status)">{{ turn.end ? turnStatusLabel(turn.end.status) : '尚未收到轮次结束记录' }}</el-tag></div>
|
|
37
|
+
<div v-if="!turn.messages.some(message => message.kind === 'user_message')" class="missingText">本轮尚未收到用户正文。</div>
|
|
38
|
+
<template v-for="event in turn.events" :key="event.event_id">
|
|
39
|
+
<article v-if="event.kind === 'user_message' || event.kind === 'assistant_message'" class="auditMessage" :class="event.kind === 'user_message' ? 'userMessage' : 'assistantMessage'">
|
|
40
|
+
<div class="messageMeta muted">{{ event.kind === 'user_message' ? '用户' : '客户端助手' }} · {{ fmtTime(event.created_at, true) }}</div>
|
|
41
|
+
<div v-if="typeof event.content === 'string'" class="messageText">{{ event.content || '(空消息)' }}</div>
|
|
42
|
+
<div v-else class="messageText missingText">正文未上传或已不可用;不以授权执行摘要替代。</div>
|
|
43
|
+
</article>
|
|
44
|
+
</template>
|
|
45
|
+
<div v-if="turn.end && !turn.messages.some(message => message.kind === 'assistant_message')" class="missingText">本轮已结束,但未收到客户端助手正文。授权执行摘要不能替代完整答复。</div>
|
|
46
|
+
<div v-if="turn.runs.length" class="authorizationRuns">
|
|
47
|
+
<div class="muted runsHeading">本轮各授权执行 · {{ turn.runs.length }} 条关联记录</div>
|
|
48
|
+
<article v-for="run in turn.runs" :key="run.event_id" class="authorizationRun">
|
|
49
|
+
<div class="runHead"><b>{{ memberLabel(run.member_session_id) }}</b><el-tag size="small" effect="plain" :type="statusType(runTraces[run.run_id || '']?.data?.run.status)">{{ runTraces[run.run_id || '']?.data ? auditStatusLabel(runTraces[run.run_id || ''].data?.run.status) : '已关联执行' }}</el-tag></div>
|
|
50
|
+
<div class="muted mono runId">run: {{ run.run_id || '缺少执行标识' }}</div>
|
|
51
|
+
<div class="runActions"><el-button v-if="run.run_id && run.thread_id" size="small" plain :loading="runTraces[run.run_id]?.loading" @click="toggleRunTrace(run)">{{ runTraces[run.run_id]?.open ? '收起授权轨迹' : '查看授权轨迹' }}</el-button><el-button v-if="run.thread_id" size="small" link type="primary" @click="emit('open-thread', run.thread_id)">原授权记录</el-button><span v-if="!run.thread_id" class="missingText">缺少原授权记录关联,无法打开执行轨迹。</span></div>
|
|
52
|
+
<div v-if="run.run_id && runTraces[run.run_id]?.open" class="runTrace">
|
|
53
|
+
<el-alert v-if="runTraces[run.run_id].error" :title="runTraces[run.run_id].error" type="error" :closable="false" />
|
|
54
|
+
<template v-if="runTraces[run.run_id].data">
|
|
55
|
+
<div class="muted">以下是该授权的中枢执行轨迹,不是完整对话正文。</div>
|
|
56
|
+
<el-alert v-if="runTraces[run.run_id].data?.trace.summary?.partial" title="原执行接口返回的是部分工具轨迹,不代表全量。可继续从原授权记录排查。" type="warning" :closable="false" class="notice" />
|
|
57
|
+
<div v-for="invocation in runTraces[run.run_id].data?.invocations" :key="invocation.job_id" class="invocation"><b class="mono">{{ invocation.tool }}</b><span>{{ invocationStatus(invocation) }}</span><el-button link type="primary" size="small" @click="emit('open-job', invocation.job_id)">工具详情</el-button></div>
|
|
58
|
+
<el-timeline v-if="runTraces[run.run_id].data?.trace.events.length" class="executionTimeline">
|
|
59
|
+
<el-timeline-item v-for="(event, eventIndex) in runTraces[run.run_id].data?.trace.events" :key="eventIndex" :timestamp="fmtTime(event.ts, true)" placement="top">
|
|
60
|
+
<b>{{ event.title || event.event }}</b><div v-if="event.summary" class="muted">{{ event.summary }}</div>
|
|
61
|
+
<el-collapse v-if="event.detail && Object.keys(event.detail).length"><el-collapse-item title="事件详情"><pre class="eventDetail">{{ JSON.stringify(event.detail, null, 2) }}</pre></el-collapse-item></el-collapse>
|
|
62
|
+
</el-timeline-item>
|
|
63
|
+
</el-timeline>
|
|
64
|
+
<div v-else class="muted">该授权尚无可展示的执行事件。</div>
|
|
65
|
+
</template>
|
|
66
|
+
</div>
|
|
67
|
+
</article>
|
|
68
|
+
</div>
|
|
69
|
+
<div v-else class="muted noRuns">本轮尚无已关联的授权执行记录。</div>
|
|
70
|
+
</section>
|
|
71
|
+
<div v-if="hasMore" class="pager"><el-button :loading="moreLoading" @click="loadMoreEvents">加载后续记录</el-button><div class="muted">按原顺序继续加载;同一轮跨页记录会合并展示。</div></div>
|
|
72
|
+
<div v-else-if="events.length" class="pager muted">已加载当前全部已接收事件 · 旧历史或未同步内容可能缺失;刷新可获取后续上传内容</div>
|
|
73
|
+
</template>
|
|
74
|
+
</main>
|
|
75
|
+
</div>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<script setup lang="ts">
|
|
79
|
+
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue';
|
|
80
|
+
import { api } from '../request';
|
|
81
|
+
import { fmtTime } from '../util';
|
|
82
|
+
import { auditStatusLabel, groupAuditTurns, mergeAuditEvents } from './conversation-audit';
|
|
83
|
+
import type { AuditConversation, AuditMember, AuditEvent, AuditListPage, AuditDetailPage } from './conversation-audit';
|
|
84
|
+
|
|
85
|
+
const props = defineProps<{ selectedId?: string; focusTurn?: string }>();
|
|
86
|
+
const emit = defineEmits<{ select: [id: string]; 'open-thread': [id: number]; 'open-job': [id: string] }>();
|
|
87
|
+
interface Invocation { job_id: string; tool: string; state?: string | null; status: string; approval_status?: string | null }
|
|
88
|
+
interface RunTrace {
|
|
89
|
+
run: { status: string };
|
|
90
|
+
trace: { summary?: { partial?: boolean }; events: Array<{ ts: string; event: string; title?: string; summary?: string; detail?: Record<string, unknown> }> };
|
|
91
|
+
invocations: Invocation[];
|
|
92
|
+
}
|
|
93
|
+
interface RunTraceState { loading: boolean; open: boolean; data: RunTrace | null; error: string }
|
|
94
|
+
const LIST_PAGE = 50, EVENT_PAGE = 100;
|
|
95
|
+
const conversations = ref<AuditConversation[]>([]), listLoading = ref(false), listMoreLoading = ref(false), listMore = ref(false), listOffset = ref<number | null>(0), listError = ref('');
|
|
96
|
+
const currentId = ref(''), conversation = ref<AuditConversation | null>(null), members = ref<AuditMember[]>([]), events = ref<AuditEvent[]>([]);
|
|
97
|
+
const detailLoading = ref(false), moreLoading = ref(false), hasMore = ref(false), afterSequence = ref<number | null>(0), detailError = ref(''), pane = ref<HTMLElement | null>(null);
|
|
98
|
+
const runTraces = reactive<Record<string, RunTraceState>>({});
|
|
99
|
+
let listGeneration = 0, detailGeneration = 0;
|
|
100
|
+
const turns = computed(() => groupAuditTurns(events.value));
|
|
101
|
+
const loadedMessageCount = computed(() => events.value.filter(event => event.kind === 'user_message' || event.kind === 'assistant_message').length);
|
|
102
|
+
function statusType(status?: string | null): 'info' | 'success' | 'warning' | 'danger' {
|
|
103
|
+
if (status === 'completed' || status === 'executed' || status === 'ready') return 'success';
|
|
104
|
+
if (status === 'failed' || status === 'denied' || status === 'business_rejected') return 'danger';
|
|
105
|
+
if (status === 'running' || status === 'awaiting_approval') return 'warning';
|
|
106
|
+
return 'info';
|
|
107
|
+
}
|
|
108
|
+
function memberLabel(sessionId?: string): string { return members.value.find(member => member.session_id === sessionId)?.display_label || '未识别授权(保留原执行关联)'; }
|
|
109
|
+
function turnStatusLabel(status?: string | null): string {
|
|
110
|
+
if (status === 'completed') return '本轮已结束';
|
|
111
|
+
if (status === 'failed') return '本轮失败';
|
|
112
|
+
if (status === 'cancelled') return '本轮已取消';
|
|
113
|
+
return auditStatusLabel(status);
|
|
114
|
+
}
|
|
115
|
+
function invocationStatus(invocation: Invocation): string {
|
|
116
|
+
if (invocation.approval_status === 'pending') return '等待审批';
|
|
117
|
+
if (invocation.approval_status === 'denied') return '审批拒绝';
|
|
118
|
+
if (invocation.approval_status === 'approved' && invocation.state === 'awaiting_approval') return '已批准,等待客户端续执行';
|
|
119
|
+
return auditStatusLabel(invocation.state || invocation.status);
|
|
120
|
+
}
|
|
121
|
+
async function loadConversations(): Promise<void> {
|
|
122
|
+
const generation = ++listGeneration;
|
|
123
|
+
listLoading.value = true; listError.value = ''; listMoreLoading.value = false;
|
|
124
|
+
try {
|
|
125
|
+
const page = await api<AuditListPage>(`/admin/api/conversation-audits?limit=${LIST_PAGE}&offset=0`);
|
|
126
|
+
if (generation !== listGeneration) return;
|
|
127
|
+
conversations.value = page.items; listMore.value = page.has_more; listOffset.value = page.next_offset;
|
|
128
|
+
} catch (error) { if (generation === listGeneration) listError.value = (error as Error).message; }
|
|
129
|
+
finally { if (generation === listGeneration) listLoading.value = false; }
|
|
130
|
+
}
|
|
131
|
+
async function loadMoreConversations(): Promise<void> {
|
|
132
|
+
if (listLoading.value || listMoreLoading.value || !listMore.value || listOffset.value == null) return;
|
|
133
|
+
const generation = listGeneration;
|
|
134
|
+
listMoreLoading.value = true;
|
|
135
|
+
try {
|
|
136
|
+
const page = await api<AuditListPage>(`/admin/api/conversation-audits?limit=${LIST_PAGE}&offset=${listOffset.value}`);
|
|
137
|
+
if (generation !== listGeneration) return;
|
|
138
|
+
const rows = new Map(conversations.value.map(item => [item.conversation_id, item]));
|
|
139
|
+
for (const item of page.items) rows.set(item.conversation_id, item);
|
|
140
|
+
conversations.value = [...rows.values()]; listMore.value = page.has_more; listOffset.value = page.next_offset;
|
|
141
|
+
} catch (error) { if (generation === listGeneration) listError.value = (error as Error).message; }
|
|
142
|
+
finally { if (generation === listGeneration) listMoreLoading.value = false; }
|
|
143
|
+
}
|
|
144
|
+
function applyPage(page: AuditDetailPage): void {
|
|
145
|
+
conversation.value = page.conversation; members.value = page.members;
|
|
146
|
+
events.value = mergeAuditEvents(events.value, page.events); hasMore.value = page.has_more; afterSequence.value = page.next_after_sequence;
|
|
147
|
+
}
|
|
148
|
+
async function focusLoadedTurn(): Promise<void> {
|
|
149
|
+
if (!props.focusTurn) return;
|
|
150
|
+
await nextTick();
|
|
151
|
+
const target = [...(pane.value?.querySelectorAll<HTMLElement>('[data-turn-id]') ?? [])].find(element => element.dataset.turnId === props.focusTurn);
|
|
152
|
+
if (target && pane.value) pane.value.scrollTop += target.getBoundingClientRect().top - pane.value.getBoundingClientRect().top - 12;
|
|
153
|
+
}
|
|
154
|
+
async function openConversation(id: string): Promise<void> {
|
|
155
|
+
const generation = ++detailGeneration;
|
|
156
|
+
currentId.value = id; conversation.value = null; events.value = []; members.value = []; hasMore.value = false; afterSequence.value = 0;
|
|
157
|
+
detailLoading.value = true; moreLoading.value = false; detailError.value = '';
|
|
158
|
+
for (const key of Object.keys(runTraces)) delete runTraces[key];
|
|
159
|
+
try {
|
|
160
|
+
const page = await api<AuditDetailPage>(`/admin/api/conversation-audits/${encodeURIComponent(id)}?after_sequence=0&limit=${EVENT_PAGE}`);
|
|
161
|
+
if (generation !== detailGeneration) return;
|
|
162
|
+
applyPage(page); await nextTick(); if (pane.value) pane.value.scrollTop = 0; await focusLoadedTurn();
|
|
163
|
+
} catch (error) { if (generation === detailGeneration) detailError.value = (error as Error).message; }
|
|
164
|
+
finally { if (generation === detailGeneration) detailLoading.value = false; }
|
|
165
|
+
}
|
|
166
|
+
async function loadMoreEvents(): Promise<void> {
|
|
167
|
+
if (!currentId.value || detailLoading.value || moreLoading.value || !hasMore.value || afterSequence.value == null) return;
|
|
168
|
+
const generation = detailGeneration;
|
|
169
|
+
moreLoading.value = true; detailError.value = '';
|
|
170
|
+
try {
|
|
171
|
+
const page = await api<AuditDetailPage>(`/admin/api/conversation-audits/${encodeURIComponent(currentId.value)}?after_sequence=${afterSequence.value}&limit=${EVENT_PAGE}`);
|
|
172
|
+
if (generation !== detailGeneration) return;
|
|
173
|
+
applyPage(page); await focusLoadedTurn();
|
|
174
|
+
} catch (error) { if (generation === detailGeneration) detailError.value = (error as Error).message; }
|
|
175
|
+
finally { if (generation === detailGeneration) moreLoading.value = false; }
|
|
176
|
+
}
|
|
177
|
+
async function toggleRunTrace(run: AuditEvent): Promise<void> {
|
|
178
|
+
if (!run.run_id || !run.thread_id) return;
|
|
179
|
+
const existing = runTraces[run.run_id];
|
|
180
|
+
if (existing?.open) { existing.open = false; return; }
|
|
181
|
+
if (existing?.data) { existing.open = true; return; }
|
|
182
|
+
const generation = detailGeneration, id = run.run_id;
|
|
183
|
+
runTraces[id] = { loading: true, open: true, data: null, error: '' };
|
|
184
|
+
try {
|
|
185
|
+
const data = await api<RunTrace>(`/admin/api/threads/${run.thread_id}/agent-runs/${encodeURIComponent(id)}/trace`);
|
|
186
|
+
if (generation === detailGeneration) runTraces[id] = { loading: false, open: true, data, error: '' };
|
|
187
|
+
} catch (error) { if (generation === detailGeneration) runTraces[id] = { loading: false, open: true, data: null, error: `授权轨迹未能读取:${(error as Error).message}` }; }
|
|
188
|
+
}
|
|
189
|
+
async function refresh(): Promise<void> { await Promise.all([loadConversations(), currentId.value ? openConversation(currentId.value) : Promise.resolve()]); }
|
|
190
|
+
watch(() => props.selectedId, id => { if (id && id !== currentId.value) void openConversation(id); }, { immediate: true });
|
|
191
|
+
watch(() => props.focusTurn, () => { void focusLoadedTurn(); });
|
|
192
|
+
onMounted(() => { void loadConversations(); });
|
|
193
|
+
defineExpose({ refresh });
|
|
194
|
+
</script>
|
|
195
|
+
|
|
196
|
+
<style scoped>
|
|
197
|
+
.auditConvo { display: flex; height: calc(100vh - 270px); min-height: 470px; border: 1px solid var(--el-border-color); overflow: hidden; }
|
|
198
|
+
.muted { color: var(--el-text-color-secondary); font-size: 12px; }
|
|
199
|
+
.mono { font-family: var(--bz-mono, monospace); }
|
|
200
|
+
.auditRail { flex: 0 0 300px; width: 300px; min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--el-border-color); }
|
|
201
|
+
.railHeading { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-bottom: 1px solid var(--el-border-color-lighter); }
|
|
202
|
+
.conversationList { overflow-y: auto; flex: 1; }
|
|
203
|
+
.conversationItem { display: block; width: 100%; border: 0; border-bottom: 1px solid var(--el-border-color-lighter); padding: 14px; text-align: left; cursor: pointer; font: inherit; color: inherit; background: transparent; }
|
|
204
|
+
.conversationItem:hover { background: var(--el-fill-color-light); }
|
|
205
|
+
.conversationItem.selected { background: var(--el-color-primary-light-9); box-shadow: inset 3px 0 var(--el-color-primary); }
|
|
206
|
+
.conversationItem:focus-visible { outline: 2px solid var(--el-color-primary); outline-offset: -2px; }
|
|
207
|
+
.itemHeading, .headerRow, .turnHeading, .runHead, .runActions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
|
|
208
|
+
.itemHeading { justify-content: space-between; }
|
|
209
|
+
.conversationName { overflow-wrap: anywhere; font-size: 12px; line-height: 1.6; margin: 6px 0; }
|
|
210
|
+
.itemTime { margin-top: 5px; }
|
|
211
|
+
.auditPane { flex: 1; min-width: 0; overflow-y: auto; padding: 16px 20px; }
|
|
212
|
+
.conversationHeader { padding-bottom: 16px; border-bottom: 1px solid var(--el-border-color); }
|
|
213
|
+
.provenance { margin-top: 10px; line-height: 1.65; }
|
|
214
|
+
.members { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
|
|
215
|
+
.notice { margin: 12px 0; }
|
|
216
|
+
.loadedCount { margin: 16px 0; }
|
|
217
|
+
.auditTurn { padding: 0 0 24px; margin-bottom: 20px; border-bottom: 1px solid var(--el-border-color-lighter); }
|
|
218
|
+
.auditTurn.focused { outline: 1px solid var(--el-color-primary-light-5); outline-offset: 8px; }
|
|
219
|
+
.turnHeading { padding-bottom: 14px; }
|
|
220
|
+
.turnHeading .mono { overflow-wrap: anywhere; }
|
|
221
|
+
.auditMessage { width: fit-content; max-width: 88%; margin: 12px 0; }
|
|
222
|
+
.auditMessage.userMessage { margin-left: auto; }
|
|
223
|
+
.messageMeta { margin: 0 0 5px; }
|
|
224
|
+
.userMessage .messageMeta { text-align: right; }
|
|
225
|
+
.messageText { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.75; padding: 11px 14px; background: var(--el-fill-color-light); border: 1px solid var(--el-border-color-lighter); }
|
|
226
|
+
.userMessage .messageText { background: var(--el-color-primary-light-9); border-color: var(--el-color-primary-light-7); }
|
|
227
|
+
.missingText { color: var(--el-color-warning-dark-2); font-size: 12px; line-height: 1.65; }
|
|
228
|
+
.authorizationRuns { margin: 18px 0 0; border-left: 2px solid var(--el-border-color); padding-left: 12px; }
|
|
229
|
+
.runsHeading { margin-bottom: 8px; }
|
|
230
|
+
.authorizationRun { border: 1px solid var(--el-border-color-lighter); padding: 12px; margin-top: 8px; }
|
|
231
|
+
.runId { margin: 7px 0; overflow-wrap: anywhere; }
|
|
232
|
+
.runActions { margin-top: 8px; }
|
|
233
|
+
.runActions .el-button + .el-button { margin-left: 0; }
|
|
234
|
+
.runTrace { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--el-border-color); }
|
|
235
|
+
.invocation { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 0; font-size: 12px; border-bottom: 1px solid var(--el-border-color-lighter); }
|
|
236
|
+
.invocation .el-button { margin-left: auto; }
|
|
237
|
+
.executionTimeline { padding: 16px 0 0 4px; }
|
|
238
|
+
.eventDetail { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; font-size: 12px; }
|
|
239
|
+
.noRuns { margin-top: 14px; }
|
|
240
|
+
.pager { padding: 18px 10px; text-align: center; }
|
|
241
|
+
.pager .muted { margin-top: 8px; }
|
|
242
|
+
@media (max-width: 1000px) { .auditRail { width: 240px; flex-basis: 240px; } .auditPane { padding: 14px; } }
|
|
243
|
+
@media (max-width: 1000px) { .auditConvo { flex-direction: column; height: auto; min-height: 0; } .auditRail { width: 100%; flex-basis: auto; border-right: 0; max-height: 240px; border-bottom: 1px solid var(--el-border-color); } .auditPane { max-height: 75vh; min-height: 280px; } .auditMessage { max-width: 100%; } }
|
|
244
|
+
</style>
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
type AuditTurnStatus = 'running' | 'completed' | 'failed' | 'cancelled';
|
|
2
|
+
|
|
3
|
+
export interface AuditConversation {
|
|
4
|
+
conversation_id: string;
|
|
5
|
+
client_archive_id: string;
|
|
6
|
+
client_conversation_id: string;
|
|
7
|
+
client_app_id: string;
|
|
8
|
+
route_key: string;
|
|
9
|
+
state: 'enrolling' | 'ready';
|
|
10
|
+
member_count: number;
|
|
11
|
+
confirmed_count: number;
|
|
12
|
+
last_sequence: number;
|
|
13
|
+
message_count: number;
|
|
14
|
+
turn_count: number;
|
|
15
|
+
last_turn_status: AuditTurnStatus | null;
|
|
16
|
+
created_at: string;
|
|
17
|
+
updated_at: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AuditMember {
|
|
21
|
+
session_id: string;
|
|
22
|
+
display_label: string;
|
|
23
|
+
confirmed: boolean;
|
|
24
|
+
principal: { id: string; tenant?: string; roles: string[] };
|
|
25
|
+
on_behalf_of?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface AuditEvent {
|
|
29
|
+
event_id: string;
|
|
30
|
+
sequence: number;
|
|
31
|
+
client_turn_id: string;
|
|
32
|
+
kind: 'turn_start' | 'user_message' | 'assistant_message' | 'run_link' | 'turn_end';
|
|
33
|
+
content?: string;
|
|
34
|
+
run_id?: string;
|
|
35
|
+
member_session_id?: string;
|
|
36
|
+
thread_id?: number;
|
|
37
|
+
status?: AuditTurnStatus;
|
|
38
|
+
created_at: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface AuditListPage {
|
|
42
|
+
schema: string;
|
|
43
|
+
items: AuditConversation[];
|
|
44
|
+
has_more: boolean;
|
|
45
|
+
next_offset: number | null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface AuditDetailPage {
|
|
49
|
+
schema: string;
|
|
50
|
+
conversation: AuditConversation;
|
|
51
|
+
members: AuditMember[];
|
|
52
|
+
events: AuditEvent[];
|
|
53
|
+
has_more: boolean;
|
|
54
|
+
next_after_sequence: number | null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface AuditTurn {
|
|
58
|
+
id: string;
|
|
59
|
+
sequence: number;
|
|
60
|
+
events: AuditEvent[];
|
|
61
|
+
messages: AuditEvent[];
|
|
62
|
+
runs: AuditEvent[];
|
|
63
|
+
start?: AuditEvent;
|
|
64
|
+
end?: AuditEvent;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Events are immutable; repeated pages may fill gaps but cannot replace received text. */
|
|
68
|
+
export function mergeAuditEvents(current: readonly AuditEvent[], incoming: readonly AuditEvent[]): AuditEvent[] {
|
|
69
|
+
const events = new Map<string, AuditEvent>();
|
|
70
|
+
for (const event of [...current, ...incoming]) {
|
|
71
|
+
const existing = events.get(event.event_id);
|
|
72
|
+
if (!existing) {
|
|
73
|
+
events.set(event.event_id, { ...event });
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const received = Object.fromEntries(Object.entries(existing).filter(([, value]) => value !== undefined));
|
|
77
|
+
events.set(event.event_id, { ...event, ...received });
|
|
78
|
+
}
|
|
79
|
+
return [...events.values()].sort((left, right) => left.sequence - right.sequence ||
|
|
80
|
+
(left.event_id < right.event_id ? -1 : left.event_id > right.event_id ? 1 : 0));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Group the complete accumulated event list, including turns spanning multiple pages. */
|
|
84
|
+
export function groupAuditTurns(events: readonly AuditEvent[]): AuditTurn[] {
|
|
85
|
+
const turns = new Map<string, AuditTurn>();
|
|
86
|
+
for (const event of mergeAuditEvents([], events)) {
|
|
87
|
+
let turn = turns.get(event.client_turn_id);
|
|
88
|
+
if (!turn) {
|
|
89
|
+
turn = { id: event.client_turn_id, sequence: event.sequence, events: [], messages: [], runs: [] };
|
|
90
|
+
turns.set(event.client_turn_id, turn);
|
|
91
|
+
}
|
|
92
|
+
turn.events.push(event);
|
|
93
|
+
if (event.kind === 'user_message' || event.kind === 'assistant_message') turn.messages.push(event);
|
|
94
|
+
else if (event.kind === 'run_link') turn.runs.push(event);
|
|
95
|
+
else if (event.kind === 'turn_start' && !turn.start) turn.start = event;
|
|
96
|
+
else if (event.kind === 'turn_end') turn.end = event;
|
|
97
|
+
}
|
|
98
|
+
return [...turns.values()];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function auditStatusLabel(status?: string | null): string {
|
|
102
|
+
if (!status) return '—';
|
|
103
|
+
const labels: Record<string, string> = {
|
|
104
|
+
enrolling: '授权确认中',
|
|
105
|
+
ready: '已就绪',
|
|
106
|
+
running: '进行中',
|
|
107
|
+
completed: '已完成',
|
|
108
|
+
failed: '失败',
|
|
109
|
+
cancelled: '已取消',
|
|
110
|
+
executed: '执行成功',
|
|
111
|
+
business_rejected: '业务拒绝',
|
|
112
|
+
awaiting_approval: '等待审批',
|
|
113
|
+
denied: '审批拒绝',
|
|
114
|
+
rejected_before_dispatch: '派发前拦截',
|
|
115
|
+
reconciliation_required: '需要人工对账',
|
|
116
|
+
in_progress: '执行中',
|
|
117
|
+
preparing: '准备中',
|
|
118
|
+
context_ready: '上下文已就绪',
|
|
119
|
+
};
|
|
120
|
+
return Object.hasOwn(labels, status) ? labels[status] : status;
|
|
121
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<template #header>
|
|
4
4
|
<div style="display: flex; justify-content: space-between; align-items: center">
|
|
5
5
|
<span><b>任务</b> <HelpTip title="任务页是什么">
|
|
6
|
-
<p>「<b>会话</b
|
|
6
|
+
<p>「<b>会话</b>」展示客户端已同步的可见文本与每轮各授权执行,也保留原授权记录入口。旧历史或未同步内容可能缺失。</p>
|
|
7
7
|
<p>「<b>调度流</b>」按时间倒序审计<b>每一次派发</b>,点行看任务全详情(输入 / 组装上下文 / 工具 / 回复)。</p>
|
|
8
8
|
<p>「<b>追溯</b>」按 job_id、request_id、client_id、thread_id 或 principal_id 查单次任务完整生命周期,用于接入排障和审批/送达/工具调用对账。</p>
|
|
9
9
|
</HelpTip></span>
|
|
@@ -15,7 +15,16 @@
|
|
|
15
15
|
<!-- ============ 会话视图:把平铺的 job 还原成「一个人一条对话」(收件箱式主从) ============ -->
|
|
16
16
|
<el-tab-pane name="threads">
|
|
17
17
|
<template #label><span><el-icon style="vertical-align:-2px"><ChatLineRound /></el-icon> 会话</span></template>
|
|
18
|
-
<div class="
|
|
18
|
+
<div class="conversationViewSwitch">
|
|
19
|
+
<el-radio-group v-model="conversationView" size="small" @change="onConversationView">
|
|
20
|
+
<el-radio-button value="audit">客户端完整对话</el-radio-button>
|
|
21
|
+
<el-radio-button value="legacy">原授权记录</el-radio-button>
|
|
22
|
+
</el-radio-group>
|
|
23
|
+
<span class="muted">{{ conversationView === 'audit' ? '按客户端会话汇总正文;授权执行保持独立可追溯。' : '保留单授权、历史会话与业务接入记录;执行摘要不等于客户端完整答复。' }}</span>
|
|
24
|
+
</div>
|
|
25
|
+
<ClientConversations v-show="conversationView === 'audit'" ref="clientConversations" :selected-id="auditConversationId" :focus-turn="auditTurnId"
|
|
26
|
+
@select="selectAuditConversation" @open-thread="gotoThread" @open-job="openDetail({ job_id: $event })" />
|
|
27
|
+
<div v-show="conversationView === 'legacy'" class="convo">
|
|
19
28
|
<!-- 左:会话列表 -->
|
|
20
29
|
<div class="rail">
|
|
21
30
|
<el-input v-model="threadQ" size="default" placeholder="搜会话:身份 / 接入方 / 内容 / 路由" clearable class="railsearch">
|
|
@@ -29,7 +38,7 @@
|
|
|
29
38
|
<div class="trow1">
|
|
30
39
|
<el-tag v-if="partyVisible(t)" size="small" effect="plain" :type="partyType(t)">{{ partyLabel(t) }}</el-tag>
|
|
31
40
|
<span class="who mono" :title="identityTitle(t)">{{ whoLabel(t) }}</span>
|
|
32
|
-
<span class="tcount muted">{{ t.message_count }}
|
|
41
|
+
<span class="tcount muted">{{ t.message_count }} 条消息</span>
|
|
33
42
|
</div>
|
|
34
43
|
<div class="tprev muted">{{ t.last_preview || '(无内容)' }}</div>
|
|
35
44
|
<div class="tmeta muted"><span class="mono">{{ t.route_name }}</span> · {{ fmtTime(t.last_active_at, true) }}</div>
|
|
@@ -40,14 +49,14 @@
|
|
|
40
49
|
|
|
41
50
|
<!-- 右:完整对话(聊天记录)+ 逐轮执行轨迹 -->
|
|
42
51
|
<div ref="paneRef" class="pane" v-loading="threadDataLoading">
|
|
43
|
-
<el-empty v-if="!threadData && !threadDataLoading" :image-size="90" description="
|
|
52
|
+
<el-empty v-if="!threadData && !threadDataLoading" :image-size="90" description="选择左侧记录,查看该授权或业务入口保存的消息与轨迹" />
|
|
44
53
|
<template v-if="threadData">
|
|
45
54
|
<div class="paneHead">
|
|
46
55
|
<div class="ph1">
|
|
47
56
|
<el-tag v-if="partyVisible(threadData.thread)" size="small" effect="plain" :type="partyType(threadData.thread)">{{ partyLabel(threadData.thread) }}</el-tag>
|
|
48
57
|
<b class="mono" :title="identityTitle(threadData.thread)">{{ whoLabel(threadData.thread) }}</b>
|
|
49
58
|
<el-tag size="small" effect="plain" type="info" class="mono">{{ threadData.thread.route_name }}</el-tag>
|
|
50
|
-
<span class="muted">{{ threadData.thread.message_count }}
|
|
59
|
+
<span class="muted">{{ threadData.thread.message_count }} 条消息 · 最近 {{ fmtTime(threadData.thread.last_active_at, true) }}</span>
|
|
51
60
|
</div>
|
|
52
61
|
<div class="ph2 muted mono" :title="threadData.thread.scope_key">scope: {{ threadData.thread.scope_key }}</div>
|
|
53
62
|
</div>
|
|
@@ -83,6 +92,7 @@
|
|
|
83
92
|
<div v-if="isAgentTrace(traceKey(m))" class="agentTraceHint">
|
|
84
93
|
本地智能体负责理解、规划和工具选择;隐藏推理不会上传。以下只展示中枢可验证的运行边界、ACC 工具治理、审批与结果。
|
|
85
94
|
</div>
|
|
95
|
+
<el-button v-if="traces[traceKey(m)].detail.conversation_audit_id" size="small" plain type="primary" class="traceDetailBtn" @click="gotoAuditConversation(traces[traceKey(m)].detail.conversation_audit_id, traces[traceKey(m)].detail.client_turn_id)">查看客户端完整对话</el-button>
|
|
86
96
|
<div v-if="isAgentTrace(traceKey(m)) && traces[traceKey(m)].summary?.partial" class="agentTracePartial">
|
|
87
97
|
本轮工具记录超过单次展示上限,以下是已通过归属校验的部分轨迹,不代表全量。
|
|
88
98
|
</div>
|
|
@@ -111,7 +121,7 @@
|
|
|
111
121
|
</el-timeline-item>
|
|
112
122
|
</el-timeline>
|
|
113
123
|
<div v-else class="muted notrace">这一轮没有可展示的执行事件</div>
|
|
114
|
-
<div v-if="isAgentTrace(traceKey(m)) &&
|
|
124
|
+
<div v-if="isAgentTrace(traceKey(m)) && traces[traceKey(m)].summary?.tool_invocations === 0 && !traces[traceKey(m)].invocations.length" class="muted notrace">本轮未调用中枢治理工具。</div>
|
|
115
125
|
<el-button v-if="m.job_id" plain type="primary" size="small" class="traceDetailBtn" @click="openDetail({ job_id: m.job_id })">查看完整详情</el-button>
|
|
116
126
|
</template>
|
|
117
127
|
<div v-else-if="!traces[traceKey(m)]?.loading" class="muted">该轮详情已不可用(记录可能已清理)</div>
|
|
@@ -277,7 +287,8 @@
|
|
|
277
287
|
</div>
|
|
278
288
|
</div>
|
|
279
289
|
<div class="detailActions">
|
|
280
|
-
<el-button v-if="detail.
|
|
290
|
+
<el-button v-if="detail.conversation_audit_id" plain size="small" type="primary" @click="gotoAuditConversation(detail.conversation_audit_id, detail.client_turn_id)">客户端完整对话</el-button>
|
|
291
|
+
<el-button v-if="detail.thread_id" plain size="small" @click="gotoThread(detail.thread_id)">原会话记录</el-button>
|
|
281
292
|
<el-popconfirm v-if="canRerun" title="重跑该任务?将复用原始输入与参数重新执行。" width="260" @confirm="rerun">
|
|
282
293
|
<template #reference><el-button type="primary" size="small">重跑</el-button></template>
|
|
283
294
|
</el-popconfirm>
|
|
@@ -431,7 +442,7 @@
|
|
|
431
442
|
|
|
432
443
|
<script setup lang="ts">
|
|
433
444
|
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue';
|
|
434
|
-
import { useRoute } from 'vue-router';
|
|
445
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
435
446
|
import { ElMessage } from 'element-plus/es/components/message/index';
|
|
436
447
|
import { ChatLineRound, List, Search } from '@element-plus/icons-vue';
|
|
437
448
|
import { api } from '../request';
|
|
@@ -439,8 +450,10 @@ import { fmtTime } from '../util';
|
|
|
439
450
|
import { useMe } from '../store';
|
|
440
451
|
import RichText from '../components/RichText.vue';
|
|
441
452
|
import HelpTip from '../components/HelpTip.vue';
|
|
453
|
+
import ClientConversations from '../components/ClientConversations.vue';
|
|
442
454
|
|
|
443
455
|
const route = useRoute();
|
|
456
|
+
const router = useRouter();
|
|
444
457
|
|
|
445
458
|
type TraceSeverity = 'info' | 'warning' | 'error';
|
|
446
459
|
type TraceStage = 'launch' | 'context' | 'execution' | 'tool' | 'approval' | 'delivery' | 'summary' | 'recovery' | 'channel' | 'config' | 'system' | string;
|
|
@@ -512,6 +525,9 @@ interface DetailTraceGroup {
|
|
|
512
525
|
|
|
513
526
|
const s = useMe();
|
|
514
527
|
const activeTab = ref<'threads' | 'runs' | 'trace'>('threads');
|
|
528
|
+
const conversationView = ref<'audit' | 'legacy'>('audit');
|
|
529
|
+
const auditConversationId = ref(''), auditTurnId = ref('');
|
|
530
|
+
const clientConversations = ref<InstanceType<typeof ClientConversations> | null>(null);
|
|
515
531
|
const list = ref<any[]>([]);
|
|
516
532
|
const loading = ref(false);
|
|
517
533
|
// 调度流分页:服务端按 offset 取,前端「加载更多」累加。每页 RUNS_PAGE 条;满页即推断还有更多。
|
|
@@ -538,6 +554,7 @@ const threadQ = ref('');
|
|
|
538
554
|
const curThread = ref<number | null>(null);
|
|
539
555
|
const threadData = ref<{ thread: any; messages: ThreadMessage[] } | null>(null);
|
|
540
556
|
const threadDataLoading = ref(false);
|
|
557
|
+
let threadLoadGeneration = 0;
|
|
541
558
|
const paneRef = ref<HTMLElement | null>(null);
|
|
542
559
|
// 逐轮执行轨迹缓存:job:<id> / agent-run:<id> 分开命名,避免两类 UUID 语义混淆。
|
|
543
560
|
const traces = reactive<Record<string, ConversationTraceState>>({});
|
|
@@ -895,20 +912,25 @@ function scrollPaneToBottom(): void {
|
|
|
895
912
|
if (el) el.scrollTop = el.scrollHeight;
|
|
896
913
|
}
|
|
897
914
|
async function openThread(id: number): Promise<void> {
|
|
915
|
+
const generation = ++threadLoadGeneration;
|
|
898
916
|
curThread.value = id;
|
|
899
917
|
threadData.value = null; threadDataLoading.value = true;
|
|
900
918
|
// 切会话清空轨迹缓存(避免不同会话的 job 串台占内存)
|
|
901
919
|
for (const k of Object.keys(traces)) delete traces[k];
|
|
902
|
-
try {
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
920
|
+
try {
|
|
921
|
+
const data = await api<{ thread: any; messages: ThreadMessage[] }>('/admin/api/threads/' + id);
|
|
922
|
+
if (generation === threadLoadGeneration) threadData.value = data;
|
|
923
|
+
}
|
|
924
|
+
catch (e) { if (generation === threadLoadGeneration) ElMessage.error((e as Error).message); }
|
|
925
|
+
finally { if (generation === threadLoadGeneration) threadDataLoading.value = false; }
|
|
926
|
+
if (generation === threadLoadGeneration && threadData.value) {
|
|
906
927
|
await nextTick();
|
|
907
928
|
scrollPaneToBottom();
|
|
908
|
-
setTimeout(scrollPaneToBottom, 150); //
|
|
929
|
+
setTimeout(() => { if (generation === threadLoadGeneration) scrollPaneToBottom(); }, 150); // 图片/异步内容撑高后再贴底
|
|
909
930
|
}
|
|
910
931
|
}
|
|
911
932
|
async function toggleTrace(message: ThreadMessage): Promise<void> {
|
|
933
|
+
const generation = threadLoadGeneration;
|
|
912
934
|
const key = traceKey(message);
|
|
913
935
|
const cur = traces[key];
|
|
914
936
|
if (cur?.open) { cur.open = false; return; }
|
|
@@ -918,23 +940,30 @@ async function toggleTrace(message: ThreadMessage): Promise<void> {
|
|
|
918
940
|
try {
|
|
919
941
|
if (message.job_id) {
|
|
920
942
|
const t = await api<TracePayload>('/admin/api/runs/' + message.job_id + '/trace');
|
|
943
|
+
if (generation !== threadLoadGeneration) return;
|
|
921
944
|
traces[key] = { kind, open: true, loading: false, detail: t.job, events: normalizeTraceEvents(t), summary: t.trace.summary ?? null, invocations: [] };
|
|
922
945
|
} else if (message.agent_run_id && curThread.value) {
|
|
923
946
|
const t = await api<AgentRunTracePayload>(`/admin/api/threads/${curThread.value}/agent-runs/${message.agent_run_id}/trace`);
|
|
947
|
+
if (generation !== threadLoadGeneration) return;
|
|
924
948
|
traces[key] = { kind, open: true, loading: false, detail: t.run, events: t.trace.events, summary: t.trace.summary ?? null, invocations: t.invocations ?? [] };
|
|
925
949
|
} else {
|
|
926
950
|
throw new Error('该轮缺少可追溯标识');
|
|
927
951
|
}
|
|
928
952
|
} catch (e) {
|
|
953
|
+
if (generation !== threadLoadGeneration) return;
|
|
929
954
|
traces[key] = { kind, open: true, loading: false, detail: null, events: [], summary: null, invocations: [] };
|
|
930
955
|
ElMessage.error((e as Error).message);
|
|
931
956
|
}
|
|
932
957
|
}
|
|
933
958
|
function onTab(name: string): void {
|
|
934
|
-
if (name === 'threads' && !threadsLoaded.value) void loadThreads();
|
|
959
|
+
if (name === 'threads' && conversationView.value === 'legacy' && !threadsLoaded.value) void loadThreads();
|
|
960
|
+
}
|
|
961
|
+
function onConversationView(): void {
|
|
962
|
+
if (conversationView.value === 'legacy' && !threadsLoaded.value) void loadThreads();
|
|
935
963
|
}
|
|
936
964
|
function refresh(): void {
|
|
937
|
-
if (activeTab.value === 'threads'
|
|
965
|
+
if (activeTab.value === 'threads' && conversationView.value === 'audit') void clientConversations.value?.refresh();
|
|
966
|
+
else if (activeTab.value === 'threads') { void loadThreads(); if (curThread.value) void openThread(curThread.value); }
|
|
938
967
|
else if (activeTab.value === 'trace') { if (traceJobInput.value.trim()) void lookupJobTrace(); }
|
|
939
968
|
else void load();
|
|
940
969
|
}
|
|
@@ -1043,8 +1072,19 @@ async function copyTraceDebugReport(): Promise<void> {
|
|
|
1043
1072
|
function gotoThread(threadId: number): void {
|
|
1044
1073
|
detailOpen.value = false;
|
|
1045
1074
|
activeTab.value = 'threads';
|
|
1075
|
+
conversationView.value = 'legacy';
|
|
1046
1076
|
if (!threadsLoaded.value) void loadThreads();
|
|
1047
1077
|
void openThread(threadId);
|
|
1078
|
+
void router.replace({ query: { ...route.query, job: undefined, conversation: undefined, turn: undefined, thread: String(threadId) } });
|
|
1079
|
+
}
|
|
1080
|
+
function selectAuditConversation(id: string): void {
|
|
1081
|
+
gotoAuditConversation(id);
|
|
1082
|
+
}
|
|
1083
|
+
function gotoAuditConversation(id: string, turnId?: string): void {
|
|
1084
|
+
detailOpen.value = false;
|
|
1085
|
+
activeTab.value = 'threads'; conversationView.value = 'audit';
|
|
1086
|
+
auditConversationId.value = id; auditTurnId.value = turnId || '';
|
|
1087
|
+
void router.replace({ query: { ...route.query, job: undefined, thread: undefined, conversation: id, turn: turnId || undefined } });
|
|
1048
1088
|
}
|
|
1049
1089
|
async function rerun(): Promise<void> {
|
|
1050
1090
|
try {
|
|
@@ -1063,19 +1103,35 @@ async function openJobFromQuery(job: string): Promise<void> {
|
|
|
1063
1103
|
onMounted(async () => {
|
|
1064
1104
|
const job = String(route.query['job'] ?? ''); // 深链:审批意图页「看任务」直达详情 → 落调度流 + 开抽屉
|
|
1065
1105
|
const thr = String(route.query['thread'] ?? ''); // 深链:直达某会话
|
|
1106
|
+
const conversation = String(route.query['conversation'] ?? '');
|
|
1107
|
+
if (conversation) { auditConversationId.value = conversation; auditTurnId.value = String(route.query['turn'] ?? ''); }
|
|
1108
|
+
else if (thr) conversationView.value = 'legacy';
|
|
1066
1109
|
if (job) { activeTab.value = 'trace'; traceJobInput.value = job; }
|
|
1067
1110
|
await load(); // 调度流列表(始终拉,刷新/深链都用得上)
|
|
1068
|
-
if (activeTab.value === 'threads' && !threadsLoaded.value) await loadThreads();
|
|
1069
|
-
if (thr) void openThread(Number(thr));
|
|
1111
|
+
if (activeTab.value === 'threads' && conversationView.value === 'legacy' && !threadsLoaded.value) await loadThreads();
|
|
1112
|
+
if (thr && !conversation && /^\d+$/.test(thr)) void openThread(Number(thr));
|
|
1070
1113
|
if (job) await openJobFromQuery(job);
|
|
1071
1114
|
});
|
|
1072
1115
|
watch(() => route.query['job'], (v) => {
|
|
1073
1116
|
void openJobFromQuery(String(v ?? ''));
|
|
1074
1117
|
});
|
|
1118
|
+
watch(() => [route.query['conversation'], route.query['turn']], ([id, turn]) => {
|
|
1119
|
+
if (!id) return;
|
|
1120
|
+
activeTab.value = 'threads'; conversationView.value = 'audit';
|
|
1121
|
+
auditConversationId.value = String(id); auditTurnId.value = String(turn || '');
|
|
1122
|
+
});
|
|
1123
|
+
watch(() => route.query['thread'], (value) => {
|
|
1124
|
+
const id = String(value || '');
|
|
1125
|
+
if (!/^\d+$/.test(id) || (curThread.value === Number(id) && conversationView.value === 'legacy')) return;
|
|
1126
|
+
activeTab.value = 'threads'; conversationView.value = 'legacy';
|
|
1127
|
+
if (!threadsLoaded.value) void loadThreads();
|
|
1128
|
+
void openThread(Number(id));
|
|
1129
|
+
});
|
|
1075
1130
|
</script>
|
|
1076
1131
|
|
|
1077
1132
|
<style scoped>
|
|
1078
1133
|
.muted { color: var(--el-text-color-secondary); font-size: 12px; }
|
|
1134
|
+
.conversationViewSwitch { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
|
|
1079
1135
|
.dangerText { color: var(--el-color-danger); }
|
|
1080
1136
|
.warningText { color: var(--el-color-warning); }
|
|
1081
1137
|
.loadmore { text-align: center; padding: 12px 0 4px; }
|