bailinghub 0.5.0 → 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 -206
- 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_AUTH_API.en.md +25 -9
- package/docs/AGENT_AUTH_API.md +17 -5
- package/docs/AGENT_CLIENT_QUICKSTART.en.md +90 -18
- package/docs/AGENT_CLIENT_QUICKSTART.md +74 -16
- package/docs/AGENT_CONVERSATION_AUDIT.en.md +194 -0
- package/docs/AGENT_CONVERSATION_AUDIT.md +111 -0
- package/docs/CHANGELOG.en.md +23 -0
- package/docs/CHANGELOG.md +23 -0
- package/docs/INDEPENDENT_VALIDATION.en.md +4 -4
- package/docs/INDEPENDENT_VALIDATION.md +4 -4
- package/docs/README.en.md +7 -0
- package/docs/README.md +7 -0
- package/docs/RELEASE_NOTES_v0.5.1.en.md +45 -0
- package/docs/RELEASE_NOTES_v0.5.1.md +45 -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 +3 -0
- package/scripts/check-image-tags.sh +1 -1
- package/scripts/check-release-consistency.test.mjs +5 -5
- 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 +2 -0
- package/scripts/verify-github-repo.mjs +2 -0
- package/sql/057_agent_conversation_audit.sql +55 -0
- package/src/app/agent-conversation-audit.ts +30 -0
- package/src/app/oss-edition.ts +1 -0
- package/src/core/config/agent-direct-console-selection.test.ts +22 -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-auth-repository.test.ts +36 -0
- package/src/infrastructure/config/config-agent-auth-repository.ts +97 -0
- package/src/infrastructure/config/config-agent-client-runtime-repository.test.ts +38 -0
- package/src/infrastructure/config/config-agent-client-runtime-repository.ts +54 -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-agent-clients.test.ts +120 -0
- package/src/routes/admin-agent-clients.ts +161 -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 +6 -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-D4RRm5D1.js → Accounts-Ca_VnSu9.js} +1 -1
- package/web/console/assets/AgentClients-BPIvlLYY.js +1 -0
- package/web/console/assets/AgentClients-DsWADpzr.css +1 -0
- package/web/console/assets/{Approvals-CsTTKb8o.js → Approvals-CMvPWacY.js} +1 -1
- package/web/console/assets/{Audit-BzvZ7JZw.js → Audit-CIRqOCnL.js} +1 -1
- package/web/console/assets/{BrandLockup-CYcA93wh.js → BrandLockup-BrytmTTH.js} +1 -1
- package/web/console/assets/{Channels-DRQZggqM.js → Channels-CApxH2TB.js} +1 -1
- package/web/console/assets/{ChatEntries-BUB7BWKU.js → ChatEntries-CJon3bWJ.js} +1 -1
- package/web/console/assets/Clients-BSA1rlTB.js +3 -0
- package/web/console/assets/Clients-CNIVs7Qn.css +1 -0
- package/web/console/assets/{Cost-BZgFf1yM.js → Cost-BbhlQFP8.js} +1 -1
- package/web/console/assets/{Credentials-BTe2Q07j.js → Credentials-kqr1W0K7.js} +1 -1
- package/web/console/assets/{Diagnostics-WL-buYli.js → Diagnostics-Kljt9XTH.js} +1 -1
- package/web/console/assets/{Executors-CGZ-7Xmp.js → Executors-DnsB-Xz4.js} +1 -1
- package/web/console/assets/{HelpTip-CT07o3kB.js → HelpTip-i-KJhf5s.js} +1 -1
- package/web/console/assets/{Kb-VVw8oGsT.js → Kb-DLZSAFWP.js} +2 -2
- package/web/console/assets/{Login-rwvmBBPl.js → Login-DiTjPWmN.js} +1 -1
- package/web/console/assets/{Projects-CexaCEY1.js → Projects-CXcVCgCD.js} +1 -1
- package/web/console/assets/Routes-CXGl9SMM.css +1 -0
- package/web/console/assets/Routes-DN9_d9Po.js +124 -0
- package/web/console/assets/Runs-Cwbe6thL.js +3 -0
- package/web/console/assets/Runs-D8UmjP5G.css +1 -0
- package/web/console/assets/{Setup-Djh5yadQ.js → Setup-FqoCKmfZ.js} +1 -1
- package/web/console/assets/Shell-BEqpONiy.js +1 -0
- package/web/console/assets/Shell-D9Uw-fsa.css +1 -0
- package/web/console/assets/{StorageBuckets-CQBR41W1.js → StorageBuckets-CkORbYXY.js} +1 -1
- package/web/console/assets/{SystemSettings-DgnopekD.js → SystemSettings-gTQAazu7.js} +1 -1
- package/web/console/assets/{SystemStatus-Bj8-kPt2.js → SystemStatus-DAmUUNqO.js} +1 -1
- package/web/console/assets/{Targets-BAfCt_nH.js → Targets-CZmDcjsE.js} +1 -1
- package/web/console/assets/{Tools-xjd0NZdE.js → Tools-CIHInlHL.js} +1 -1
- package/web/console/assets/index-BkLbd7Cc.js +2 -0
- package/web/console/assets/{index-DZEQL_yy.js → index-QnmD7N7F.js} +1 -1
- package/web/console/assets/{request-DkNPOweH.js → request-r7GHVJzw.js} +1 -1
- package/web/console/assets/{schema-CgPWAu1_.js → schema-BVn_hB7M.js} +1 -1
- package/web/console/assets/{util-SiQC2MJh.js → util-4bN2dv7B.js} +1 -1
- package/web/console/assets/{vendor-element-D7WRzHhy.js → vendor-element-CZoEjZr8.js} +1 -1
- package/web/console/assets/vendor-mammoth-BUEEDX6A.js +231 -0
- package/web/console/index.html +2 -2
- package/web-admin/package-lock.json +3 -3
- package/web-admin/src/agent-direct-selection.ts +21 -0
- package/web-admin/src/components/ClientConversations.vue +244 -0
- package/web-admin/src/components/conversation-audit.ts +121 -0
- package/web-admin/src/layout/Shell.vue +1 -1
- package/web-admin/src/pages/AgentClients.vue +254 -0
- package/web-admin/src/pages/Clients.vue +4 -2
- package/web-admin/src/pages/Routes.vue +54 -5
- package/web-admin/src/pages/Runs.vue +73 -17
- package/web-admin/src/router.ts +2 -0
- package/web-admin/tests/conversation-audit.fixture.mjs +182 -0
- package/web-admin/tests/conversation-audit.test.mjs +93 -0
- package/web/console/assets/Clients-CQ_MonGL.css +0 -1
- package/web/console/assets/Clients-HhCyrxfz.js +0 -3
- package/web/console/assets/Routes-B9ZHbQAp.js +0 -124
- package/web/console/assets/Routes-BbkFpi6Y.css +0 -1
- package/web/console/assets/Runs-4zDD9VOC.css +0 -1
- package/web/console/assets/Runs-BzFNPTwD.js +0 -3
- package/web/console/assets/Shell-BVIjmoY8.css +0 -1
- package/web/console/assets/Shell-kn763smL.js +0 -1
- package/web/console/assets/index-DfJA7iJS.js +0 -2
- package/web/console/assets/vendor-mammoth-DvgsHdlx.js +0 -231
package/web/console/index.html
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
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
|
-
<link rel="modulepreload" crossorigin href="./assets/vendor-element-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="./assets/vendor-element-CZoEjZr8.js">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="./assets/index-Fi9gkGxV.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
@@ -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,21 @@
|
|
|
1
|
+
export const EXACT_OPERATION_ID_RE = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
2
|
+
|
|
3
|
+
export function mergeExactOperationIds(...groups: ReadonlyArray<ReadonlyArray<string>>): string[] {
|
|
4
|
+
const merged: string[] = [];
|
|
5
|
+
const seen = new Set<string>();
|
|
6
|
+
for (const group of groups) {
|
|
7
|
+
for (const raw of group) {
|
|
8
|
+
const operationId = String(raw).trim();
|
|
9
|
+
if (!EXACT_OPERATION_ID_RE.test(operationId) || seen.has(operationId)) continue;
|
|
10
|
+
seen.add(operationId);
|
|
11
|
+
merged.push(operationId);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return merged;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function includesAllCurrentOperationIds(selected: ReadonlyArray<string>, current: ReadonlyArray<string>): boolean {
|
|
18
|
+
if (!current.length) return false;
|
|
19
|
+
const selectedSet = new Set(selected);
|
|
20
|
+
return current.every((operationId) => selectedSet.has(operationId));
|
|
21
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -102,7 +102,7 @@ const menuRef = ref<{ open: (index: string) => void } | null>(null);
|
|
|
102
102
|
const ICONS: Record<string, unknown> = {
|
|
103
103
|
kb: markRaw(Collection), runs: markRaw(Tickets), executors: markRaw(Monitor), cost: markRaw(Coin), routes: markRaw(Connection), targets: markRaw(Cpu),
|
|
104
104
|
tools: markRaw(SetUp), approvals: markRaw(Stamp), chat: markRaw(ChatDotRound), channels: markRaw(Promotion), projects: markRaw(Folder),
|
|
105
|
-
clients: markRaw(Key), credentials: markRaw(Lock), storage: markRaw(Box), settings: markRaw(Brush), system: markRaw(InfoFilled), diagnostics: markRaw(Warning), accounts: markRaw(User), audit: markRaw(Document),
|
|
105
|
+
clients: markRaw(Key), 'agent-clients': markRaw(Connection), credentials: markRaw(Lock), storage: markRaw(Box), settings: markRaw(Brush), system: markRaw(InfoFilled), diagnostics: markRaw(Warning), accounts: markRaw(User), audit: markRaw(Document),
|
|
106
106
|
};
|
|
107
107
|
const GROUP_ORDER = ['场景配置', '接入入口', '能力装配', '运行', '基础资源', '系统管理'] as const;
|
|
108
108
|
const DEFAULT_OPEN_GROUPS = new Set<string>(['场景配置', '接入入口', '能力装配', '运行']);
|