bailinghub 0.10.0 → 0.11.1
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/CONTRIBUTING.md +20 -0
- package/README.en.md +6 -6
- package/README.md +6 -6
- package/SECURITY.md +20 -0
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/docker-compose.images.yml +2 -2
- package/docs/AGENT_CONVERSATION_AUDIT.en.md +8 -2
- package/docs/AGENT_CONVERSATION_AUDIT.md +8 -1
- package/docs/CHANGELOG.en.md +29 -1
- package/docs/CHANGELOG.md +29 -1
- package/docs/IMPLEMENTATION_STATUS.en.md +12 -3
- package/docs/IMPLEMENTATION_STATUS.md +12 -3
- package/docs/INDEPENDENT_VALIDATION.en.md +4 -4
- package/docs/INDEPENDENT_VALIDATION.md +4 -4
- package/docs/MODEL_CONTINUATION.en.md +8 -0
- package/docs/MODEL_CONTINUATION.md +8 -0
- package/docs/MODEL_OUTPUT_BUDGET.en.md +1 -0
- package/docs/MODEL_OUTPUT_BUDGET.md +1 -0
- package/docs/README.en.md +6 -0
- package/docs/README.md +6 -0
- package/docs/RELEASE_NOTES_v0.10.1.en.md +41 -0
- package/docs/RELEASE_NOTES_v0.10.1.md +41 -0
- package/docs/RELEASE_NOTES_v0.11.0.en.md +19 -0
- package/docs/RELEASE_NOTES_v0.11.0.md +19 -0
- package/docs/RELEASE_NOTES_v0.11.1.en.md +25 -0
- package/docs/RELEASE_NOTES_v0.11.1.md +25 -0
- package/docs/UPGRADE_v0.10.1.en.md +66 -0
- package/docs/UPGRADE_v0.10.1.md +66 -0
- package/docs/UPGRADE_v0.11.0.en.md +24 -0
- package/docs/UPGRADE_v0.11.0.md +24 -0
- package/docs/UPGRADE_v0.11.1.en.md +28 -0
- package/docs/UPGRADE_v0.11.1.md +28 -0
- package/docs/security/GRC_EVIDENCE.md +54 -0
- package/docs/user-guide/console-map.md +2 -2
- package/package.json +5 -3
- package/scripts/check-doc-links.mjs +6 -0
- package/scripts/check-image-tags.sh +1 -1
- package/scripts/check-php-sdk-artifacts.mjs +152 -0
- package/scripts/check-php-sdk-artifacts.test.mjs +99 -0
- package/scripts/check-release-consistency.test.mjs +2 -2
- package/scripts/copy-acr-platform-image.sh +42 -0
- package/scripts/e2e-console-runtime-audit.mjs +7 -0
- package/scripts/e2e-console-troubleshooting-extra.mjs +4 -4
- package/scripts/e2e-console.mjs +90 -23
- package/scripts/install.sh +1 -1
- package/scripts/notification-console-test.mjs +2 -1
- package/scripts/publish-images.sh +1 -1
- package/scripts/release-audit.mjs +13 -1
- package/scripts/restore-ghcr-version.sh +48 -0
- package/scripts/sdk-declaration-contract-test.ts +34 -0
- package/scripts/sdk-p1-check.mjs +62 -26
- package/scripts/test-acr-platform-copy.sh +152 -0
- package/scripts/verify-github-repo.mjs +12 -0
- package/sdk/dotnet/Bailing.Connect/BailingConnect.cs +4 -4
- package/sdk/dotnet/README.md +8 -0
- package/sdk/dotnet/tests/Declaration/Declaration.csproj +11 -0
- package/sdk/dotnet/tests/Declaration/Program.cs +74 -0
- package/sdk/go/README.md +8 -0
- package/sdk/go/bailingconnect/connect.go +5 -5
- package/sdk/go/bailingconnect/declaration_test.go +107 -0
- package/sdk/java/README.md +13 -0
- package/sdk/java/src/main/java/com/bailing/connect/BailingConnect.java +4 -4
- package/sdk/java/tests/DeclarationTest.java +70 -0
- package/sdk/node/README.md +8 -0
- package/sdk/node/src/index.mjs +4 -4
- package/sdk/node/tests/declaration.test.mjs +41 -0
- package/sdk/php/README.md +16 -0
- package/sdk/php/src/Attributes/AiTool.php +4 -4
- package/sdk/php/src/SpecBuilder.php +8 -8
- package/sdk/php/tests/declaration-serialization.php +103 -0
- package/sdk/php7/README.md +14 -0
- package/sdk/php7/src/ToolDef.php +3 -3
- package/sdk/php7/src/ToolSpec.php +8 -13
- package/sdk/php7/tests/declaration-serialization.php +103 -0
- package/sdk/python/README.md +8 -0
- package/sdk/python/bailing_connect/__init__.py +6 -6
- package/sdk/python/tests/test_declaration.py +61 -0
- package/src/core/config/console-task-location.test.ts +12 -24
- package/src/core/contracts/explicit-capability-values.test.ts +62 -0
- package/src/core/contracts/openapi-tools.ts +2 -2
- package/src/core/contracts/tool-annotations.ts +4 -4
- package/src/core/runtime/credential-resolver.ts +3 -3
- package/src/infrastructure/config/config-agent-conversation-audit-repository.test.ts +29 -0
- package/src/infrastructure/config/config-agent-conversation-audit-repository.ts +142 -9
- package/src/infrastructure/config/config-conversation-feed.integration.test.ts +134 -0
- package/src/infrastructure/config/config-conversation-ledger.test.ts +47 -1
- package/src/infrastructure/config/config-conversation-ledger.ts +24 -8
- package/src/infrastructure/config/config-observability-ledger.ts +32 -4
- package/src/infrastructure/config/config-recent-jobs.integration.test.ts +45 -0
- package/src/infrastructure/config/configstore.ts +4 -4
- package/src/infrastructure/config/conversation-delivery-message.ts +12 -0
- package/src/modules/usage/contracts.ts +1 -0
- package/src/modules/usage/model-context.test.ts +106 -0
- package/src/modules/usage/model-context.ts +54 -0
- package/src/modules/usage/model-continuation.test.ts +27 -0
- package/src/modules/usage/provider.test.ts +40 -0
- package/src/modules/usage/provider.ts +21 -3
- package/src/modules/usage/repository.ts +2 -1
- package/src/routes/admin-conversation-audit.ts +20 -3
- package/src/routes/admin-history-cursor.ts +12 -0
- package/src/routes/admin-runtime.test.ts +47 -0
- package/src/routes/admin-runtime.ts +32 -3
- package/src/routes/admin-usage.ts +12 -1
- package/src/routes/admin.ts +6 -1
- package/src/routes/agent-conversation-audit.test.ts +47 -3
- package/src/test-support/agent-conversation-audit-fixture.ts +9 -1
- package/web/connect/bailing-connect-php.tgz +0 -0
- package/web/connect/bailing-connect-php7.tgz +0 -0
- package/web/console/assets/{Accounts-Dhyw-7wF.js → Accounts-B1Ne8Xx2.js} +1 -1
- package/web/console/assets/AgentClients-CiGQ-n2i.js +1 -0
- package/web/console/assets/AgentClients-xEIfsj7w.css +1 -0
- package/web/console/assets/AgentTasks-CaCeYv60.css +1 -0
- package/web/console/assets/AgentTasks-CylHZHHq.js +2 -0
- package/web/console/assets/{Approvals-CQx1YWxW.js → Approvals-wD4Iv80G.js} +1 -1
- package/web/console/assets/{Audit--QcdVlMh.js → Audit-BStlxkPw.js} +1 -1
- package/web/console/assets/{BrandLockup-DQcaW4Nt.js → BrandLockup-BAhrPnhy.js} +1 -1
- package/web/console/assets/Channels-DAlIgNxo.js +105 -0
- package/web/console/assets/Channels-WwRHFKJn.css +1 -0
- package/web/console/assets/ChatEntries-CPx-E9aJ.js +7 -0
- package/web/console/assets/ChatEntries-DALYfRDP.css +1 -0
- package/web/console/assets/Clients-gqNFusNW.css +1 -0
- package/web/console/assets/Clients-w97QPpFD.js +3 -0
- package/web/console/assets/Cost-CNDZaif-.css +1 -0
- package/web/console/assets/Cost-CxtN0mca.js +1 -0
- package/web/console/assets/Credentials-6c6aktzZ.css +1 -0
- package/web/console/assets/Credentials-BhpoH-hR.js +1 -0
- package/web/console/assets/{Diagnostics-CyoM1XrZ.js → Diagnostics-DnC-ODuy.js} +1 -1
- package/web/console/assets/Executors-CCTYuZf4.js +1 -0
- package/web/console/assets/Executors-CQ8iw3kK.css +1 -0
- package/web/console/assets/{HelpTip-DLlhaGQp.js → HelpTip-piedkqU-.js} +1 -1
- package/web/console/assets/Kb-CFCa-7LY.css +1 -0
- package/web/console/assets/Kb-DKp3mwWB.js +2 -0
- package/web/console/assets/Login-g_aZWHQd.js +1 -0
- package/web/console/assets/Login-krXZsvoF.css +1 -0
- package/web/console/assets/Projects-BexeaCxT.css +1 -0
- package/web/console/assets/Projects-DurExYV9.js +1 -0
- package/web/console/assets/Routes-CKoIjkCM.css +1 -0
- package/web/console/assets/Routes-CX7Q7bkz.js +138 -0
- package/web/console/assets/Runs-C48kdEwk.css +1 -0
- package/web/console/assets/Runs-CQKEDsrH.js +3 -0
- package/web/console/assets/Setup-CtWCXXpj.css +1 -0
- package/web/console/assets/Setup-DzI8rEAc.js +1 -0
- package/web/console/assets/Shell-BQ-g_O7K.js +1 -0
- package/web/console/assets/Shell-Y2fZK5LV.css +1 -0
- package/web/console/assets/StorageBuckets-CWxzIh0x.css +1 -0
- package/web/console/assets/StorageBuckets-DoZIzA7B.js +1 -0
- package/web/console/assets/SystemSettings-C3pFFzAQ.js +1 -0
- package/web/console/assets/SystemSettings-C5nv0K2a.css +1 -0
- package/web/console/assets/SystemStatus-Bbxu2dp4.css +1 -0
- package/web/console/assets/SystemStatus-BgekIK52.js +1 -0
- package/web/console/assets/Targets-CbLq7rgm.css +1 -0
- package/web/console/assets/Targets-DH1ZcK0J.js +1 -0
- package/web/console/assets/Tools-CMS1wVOm.js +5 -0
- package/web/console/assets/Tools-Qk1c5Rp8.css +1 -0
- package/web/console/assets/Usage-C0OkK7Jg.js +1 -0
- package/web/console/assets/Usage-Cue7CYnT.css +1 -0
- package/web/console/assets/UsageAccess-CHdWXvE8.js +1 -0
- package/web/console/assets/UsageAccess-nOa03hGb.css +1 -0
- package/web/console/assets/{UsageHelp-BmuiE1Ew.js → UsageHelp-BkIsuFUj.js} +1 -1
- package/web/console/assets/{console-location-Csv-xsnl.js → console-location-C_az_xHo.js} +1 -1
- package/web/console/assets/index-CbI5fbiD.js +2 -0
- package/web/console/assets/{index-B_5UfiTw.js → index-DwlsLKwM.js} +1 -1
- package/web/console/assets/request-WgSVj8ie.js +1 -0
- package/web/console/assets/{schema-o3mK4mid.js → schema-rb4T_2cj.js} +1 -1
- package/web/console/assets/task-page-location-BGxGar7H.js +1 -0
- package/web/console/assets/{use-list-location-cIPy2cKM.js → use-list-location-DeVfTTII.js} +1 -1
- package/web/console/assets/{use-unsaved-form-DScKD0h9.js → use-unsaved-form-B10XHC-n.js} +1 -1
- package/web/console/assets/{util-B40VqOwl.js → util-C0YJ70YU.js} +1 -1
- package/web/console/assets/{vendor-element-BT8tHCFk.js → vendor-element-BCC2kYn_.js} +7 -7
- package/web/console/assets/{vendor-mammoth-CVIXVxTN.js → vendor-mammoth-C7l0Q30g.js} +1 -1
- package/web/console/index.html +2 -2
- package/web-admin/package-lock.json +4 -4
- package/web-admin/package.json +1 -1
- package/web-admin/scripts/agent-task-control-smoke.mjs +26 -3
- package/web-admin/src/components/AgentSetupPanel.vue +19 -15
- package/web-admin/src/components/ChannelThread.vue +441 -0
- package/web-admin/src/components/ClientConversations.vue +397 -134
- package/web-admin/src/components/ConversationSourceTag.vue +24 -0
- package/web-admin/src/components/JobStatusTag.vue +18 -0
- package/web-admin/src/components/NotificationOutboxPanel.vue +5 -2
- package/web-admin/src/components/UsageServiceReferences.vue +6 -24
- package/web-admin/src/components/conversation-audit.ts +67 -2
- package/web-admin/src/components/conversation-reading-position.ts +27 -0
- package/web-admin/src/layout/Shell.vue +15 -17
- package/web-admin/src/onboarding-state.ts +5 -5
- package/web-admin/src/pages/AgentClients.vue +33 -27
- package/web-admin/src/pages/AgentTasks.vue +88 -43
- package/web-admin/src/pages/Channels.vue +15 -41
- package/web-admin/src/pages/ChatEntries.vue +13 -51
- package/web-admin/src/pages/Clients.vue +2 -2
- package/web-admin/src/pages/Cost.vue +10 -51
- package/web-admin/src/pages/Credentials.vue +1 -1
- package/web-admin/src/pages/Executors.vue +4 -3
- package/web-admin/src/pages/Kb.vue +4 -4
- package/web-admin/src/pages/Login.vue +7 -8
- package/web-admin/src/pages/Projects.vue +1 -1
- package/web-admin/src/pages/Routes.vue +46 -83
- package/web-admin/src/pages/Runs.vue +239 -567
- package/web-admin/src/pages/Setup.vue +20 -20
- package/web-admin/src/pages/StorageBuckets.vue +1 -1
- package/web-admin/src/pages/SystemSettings.vue +1 -2
- package/web-admin/src/pages/SystemStatus.vue +4 -6
- package/web-admin/src/pages/Targets.vue +0 -2
- package/web-admin/src/pages/Tools.vue +31 -22
- package/web-admin/src/pages/Usage.vue +110 -60
- package/web-admin/src/pages/UsageAccess.vue +2 -5
- package/web-admin/src/request.ts +5 -1
- package/web-admin/src/task-page-location.ts +6 -12
- package/web-admin/src/task-trace-presentation.ts +143 -0
- package/web-admin/tests/conversation-audit.test.mjs +23 -1
- package/web-admin/tests/model-context.browser.mjs +238 -0
- package/web-admin/tests/model-output-budget.browser.mjs +1 -0
- package/web/console/assets/AgentClients-BA0M26-I.css +0 -1
- package/web/console/assets/AgentClients-DWxb8-ko.js +0 -1
- package/web/console/assets/AgentTasks-DOyxANnx.css +0 -1
- package/web/console/assets/AgentTasks-DUHD4dzr.js +0 -2
- package/web/console/assets/Channels-DJJU3ksE.css +0 -1
- package/web/console/assets/Channels-cGS5WfQ-.js +0 -105
- package/web/console/assets/ChatEntries-BYpji27B.css +0 -1
- package/web/console/assets/ChatEntries-nh23Iz5O.js +0 -7
- package/web/console/assets/Clients-CX5EeYio.js +0 -3
- package/web/console/assets/Clients-CbZAou8E.css +0 -1
- package/web/console/assets/Cost-C6oQvz9P.css +0 -1
- package/web/console/assets/Cost-DOZfdNS9.js +0 -1
- package/web/console/assets/Credentials--aHs57yV.css +0 -1
- package/web/console/assets/Credentials-sy6W9Sac.js +0 -1
- package/web/console/assets/Executors-2Upi6bOS.css +0 -1
- package/web/console/assets/Executors-BQqqiFwt.js +0 -1
- package/web/console/assets/Kb-5R3ce4UU.js +0 -5
- package/web/console/assets/Kb-BM_PYi11.css +0 -1
- package/web/console/assets/Login-YKeUwdgo.js +0 -1
- package/web/console/assets/Login-xtPwDB5_.css +0 -1
- package/web/console/assets/Projects-DHwHrPT9.css +0 -1
- package/web/console/assets/Projects-Grgb6fOv.js +0 -1
- package/web/console/assets/Routes-DR_Yf02e.css +0 -1
- package/web/console/assets/Routes-DYgrXlRJ.js +0 -138
- package/web/console/assets/Runs-CwTddJJj.js +0 -3
- package/web/console/assets/Runs-D4FOvNfu.css +0 -1
- package/web/console/assets/Setup-Ca0b1d1-.css +0 -1
- package/web/console/assets/Setup-D_xUPNDq.js +0 -1
- package/web/console/assets/Shell-BTg8Vw_L.css +0 -1
- package/web/console/assets/Shell-Dfam2Uoj.js +0 -1
- package/web/console/assets/StorageBuckets-7QLBpV4a.css +0 -1
- package/web/console/assets/StorageBuckets-CP6e50wI.js +0 -1
- package/web/console/assets/SystemSettings-BRYKyJNa.js +0 -1
- package/web/console/assets/SystemSettings-HsXGx0aH.css +0 -1
- package/web/console/assets/SystemStatus-B-VfRsQd.css +0 -1
- package/web/console/assets/SystemStatus-CbPsDsGt.js +0 -1
- package/web/console/assets/Targets-1j4-g6rC.css +0 -1
- package/web/console/assets/Targets-C2LkR2AF.js +0 -1
- package/web/console/assets/Tools-C9HPJqJb.css +0 -1
- package/web/console/assets/Tools-C9JNJUS0.js +0 -2
- package/web/console/assets/Usage-D1Mv6vGY.js +0 -1
- package/web/console/assets/Usage-DMOzUsqh.css +0 -1
- package/web/console/assets/UsageAccess-77LmGCm6.js +0 -1
- package/web/console/assets/UsageAccess-C6ZGxEgJ.css +0 -1
- package/web/console/assets/index-MjZJEFIN.js +0 -2
- package/web/console/assets/request-rqm6MT0s.js +0 -1
- package/web/console/assets/task-page-location-DWiGtAln.js +0 -1
|
@@ -1,101 +1,149 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="auditConvo">
|
|
3
|
-
<aside class="auditRail" aria-label="
|
|
4
|
-
<div class="railHeading"
|
|
2
|
+
<div class="auditConvo" :class="{ hasSelection: !!selectedId || !!channelThread }">
|
|
3
|
+
<aside ref="rail" class="auditRail" aria-label="会话列表">
|
|
4
|
+
<div class="railHeading">
|
|
5
|
+
<div class="headingLine"><h3>最近会话</h3><el-select :model-value="activeSource" class="sourceFilter" aria-label="会话来源" size="small" @change="emit('change-source', $event)">
|
|
6
|
+
<el-option v-for="(label, key) in conversationSources" :key="key" :value="key" :label="label" />
|
|
7
|
+
</el-select></div>
|
|
8
|
+
<el-input v-model="query" clearable :prefix-icon="Search" aria-label="筛选已加载的会话" placeholder="筛选已加载的会话或编号" />
|
|
9
|
+
</div>
|
|
10
|
+
<div v-if="legacyFeed" class="legacyFeed muted">当前存储仅提供客户端会话列表,其他记录可从下方入口查看。</div>
|
|
5
11
|
<div v-loading="listLoading" class="conversationList">
|
|
6
12
|
<el-alert v-if="listError" :title="listError" type="error" :closable="false" />
|
|
7
|
-
<el-empty v-else-if="!listLoading && !
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
<
|
|
13
|
-
<
|
|
13
|
+
<el-empty v-else-if="!listLoading && !visibleConversations.length" :image-size="48"
|
|
14
|
+
:description="query.trim() ? '已加载的会话中没有匹配项' : '该渠道暂无已记录的会话'" />
|
|
15
|
+
<button v-for="item in visibleConversations" :key="feedKey(item)" type="button" class="conversationItem"
|
|
16
|
+
:aria-current="currentKey === feedKey(item) ? 'true' : undefined" @click="selectFeedItem(item)">
|
|
17
|
+
<span class="itemTop"><ConversationSourceTag :source="item.source" /><time class="muted">{{ fmtTime(item.updated_at) }}</time></span>
|
|
18
|
+
<strong class="itemTitle" :title="feedTitle(item)">{{ feedTitle(item) }}</strong>
|
|
19
|
+
<span class="itemMeta muted">
|
|
20
|
+
<span v-if="item.source_label && item.source_label !== conversationSources[item.source]" class="itemOrigin" :title="item.source_label">{{ item.source_label }}</span>
|
|
21
|
+
<span class="itemState">{{ item.turn_count != null ? `${item.turn_count} 轮 · ` : '' }}{{ item.message_count }} 条消息</span>
|
|
22
|
+
</span>
|
|
23
|
+
<span v-if="item.kind === 'audit' && ((item.state && item.state !== 'ready') || (item.last_turn_status && item.last_turn_status !== 'completed'))" class="itemState">
|
|
24
|
+
{{ item.state && item.state !== 'ready' ? auditStatusLabel(item.state) : turnStatusLabel(item.last_turn_status) }}
|
|
25
|
+
</span>
|
|
14
26
|
</button>
|
|
15
27
|
<div v-if="listMore" class="pager"><el-button link :loading="listMoreLoading" @click="loadMoreConversations">加载更多对话</el-button></div>
|
|
16
28
|
</div>
|
|
29
|
+
<button class="directoryEntry" type="button" @click="emit('open-directory')">
|
|
30
|
+
<el-icon><Collection /></el-icon><span>授权与接入记录</span><el-icon><ArrowRight /></el-icon>
|
|
31
|
+
</button>
|
|
17
32
|
</aside>
|
|
18
33
|
|
|
19
|
-
<main
|
|
34
|
+
<main v-if="currentThreadId" class="channelMain" aria-label="渠道会话详情">
|
|
35
|
+
<el-button class="backToList" link @click="emit('back-list')"><el-icon><ArrowLeft /></el-icon>最近会话</el-button>
|
|
36
|
+
<ChannelThread ref="channelPane" feed :thread-id="currentThreadId" :heading="selectedThread?.title || ''" :source="selectedThread?.source" @open-job="emit('open-job', $event)" @open-audit="(id, turn) => emit('open-audit', id, turn)" />
|
|
37
|
+
</main>
|
|
38
|
+
<main v-else ref="pane" v-loading="detailLoading" class="auditPane" aria-label="客户端对话正文与授权执行">
|
|
39
|
+
<el-button class="backToList" link @click="emit('back-list')"><el-icon><ArrowLeft /></el-icon>最近会话</el-button>
|
|
20
40
|
<el-alert v-if="detailError" :title="detailError" type="error" :closable="false" class="notice" />
|
|
21
|
-
<el-empty v-if="!conversation && !detailLoading && !detailError" :image-size="
|
|
41
|
+
<el-empty v-if="!conversation && !detailLoading && !detailError" :image-size="70" description="选择一条会话,查看对话与执行记录" />
|
|
22
42
|
<template v-if="conversation">
|
|
23
|
-
<header class="conversationHeader">
|
|
24
|
-
<div class="
|
|
25
|
-
<div class="
|
|
26
|
-
<div class="
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<div class="members">
|
|
30
|
-
<article v-for="member in memberCards" :key="member.session_id" class="memberCard" :data-member-session-id="member.session_id">
|
|
31
|
-
<el-tag size="small" effect="plain" :type="member.confirmed ? 'info' : 'warning'">{{ member.display_label || '未命名授权' }}{{ member.confirmed ? '' : ' · 待确认' }}</el-tag>
|
|
32
|
-
<div class="muted memberTarget"><span>系统:{{ member.context.systemLabel }}</span><span>路由:{{ member.context.routeLabel }}</span></div>
|
|
33
|
-
<div v-if="member.context.source === 'legacy_header'" class="missingText">旧记录:仅有归档头部信息,未单独记录成员系统与路由。</div>
|
|
34
|
-
<div class="muted mono memberSession">Session:{{ member.session_id }}</div>
|
|
35
|
-
</article>
|
|
43
|
+
<header class="conversationHeader" data-reading-header>
|
|
44
|
+
<div class="detailTitle"><ConversationSourceTag source="client" /><h2 :title="conversationTitle(conversation)">{{ conversationTitle(conversation) }}</h2></div>
|
|
45
|
+
<div class="headerMeta muted">{{ conversation.client_app_id }} · 最近更新 {{ fmtTime(conversation.updated_at, true) }} · 已接收 {{ conversation.turn_count }} 轮 / {{ conversation.message_count }} 条消息</div>
|
|
46
|
+
<div class="headerLinks">
|
|
47
|
+
<el-button link type="primary" @click="infoPanel = 'members'">关联授权({{ conversation.member_count }})</el-button>
|
|
48
|
+
<el-button link @click="infoPanel = 'archive'">归档信息</el-button>
|
|
36
49
|
</div>
|
|
37
50
|
</header>
|
|
38
51
|
<el-alert v-if="conversation.state !== 'ready'" title="授权成员尚未全部确认,对话归档尚未就绪。" type="warning" :closable="false" class="notice" />
|
|
39
|
-
<
|
|
40
|
-
<el-
|
|
41
|
-
<
|
|
42
|
-
|
|
52
|
+
<el-alert v-if="focusTurn && !turns.some(turn => turn.id === focusTurn)" :title="hasMore ? '目标轮次尚未加载,请继续加载后续记录。' : '当前已接收的记录中没有目标轮次。'" type="info" :closable="false" class="notice" />
|
|
53
|
+
<el-empty v-if="!turns.length && !detailLoading" :image-size="48" description="尚未收到客户端正文或轮次记录" />
|
|
54
|
+
<div v-if="beforeSequence != null" class="historyControl"><el-button link :loading="moreLoading" :disabled="detailLoading" @click="loadEarlierEvents">加载更早记录</el-button></div>
|
|
43
55
|
<section v-for="(turn, index) in turns" :key="turn.id" :data-turn-id="turn.id" class="auditTurn" :class="{ focused: focusTurn === turn.id }">
|
|
44
|
-
<div class="turnHeading"><
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
</
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
<div class="turnHeading"><h3 :title="turn.id">{{ beforeSequence == null ? `第 ${index + 1} 轮` : ('轮次 · ' + turn.id.slice(-8)) }}</h3>
|
|
57
|
+
<span class="muted" :class="{ attention: turn.end?.status === 'failed' }">{{ turn.end ? turnStatusLabel(turn.end.status) : beforeSequence != null && !turn.start ? '部分轮次记录' : '尚未收到轮次结束记录' }}</span>
|
|
58
|
+
<time class="muted">{{ fmtTime(turn.start?.created_at || turn.events[0]?.created_at, true) }}</time>
|
|
59
|
+
</div>
|
|
60
|
+
<div v-if="!turn.messages.some(message => message.kind === 'user_message')" class="missingText">{{ beforeSequence != null && !turn.start ? '本轮此前的内容可向前加载。' : '本轮尚未收到用户正文。' }}</div>
|
|
61
|
+
<article v-for="event in turn.messages" :key="event.event_id" :data-reading-id="event.event_id" class="auditMessage" :class="event.kind === 'user_message' ? 'userMessage' : 'assistantMessage'">
|
|
62
|
+
<span class="messageMeta"><strong class="actorName"><el-icon aria-hidden="true"><User v-if="event.kind === 'user_message'" /><ChatLineSquare v-else /></el-icon>{{ event.kind === 'user_message' ? '用户' : '客户端助手' }}</strong><time :datetime="event.created_at" :title="fmtTime(event.created_at, true)">{{ fmtTime(event.created_at, true).split(' ').pop() }}</time></span>
|
|
63
|
+
<div v-if="typeof event.content === 'string'" class="messageText">{{ event.content || '(空消息)' }}</div>
|
|
64
|
+
<div v-else class="messageText missingText">正文未上传或已不可用。</div>
|
|
65
|
+
</article>
|
|
66
|
+
<div v-if="turn.end && (beforeSequence == null || turn.start) && !turn.messages.some(message => message.kind === 'assistant_message')" class="missingText">本轮已结束,但未收到客户端助手正文。</div>
|
|
67
|
+
|
|
54
68
|
<div v-if="turn.runs.length" class="authorizationRuns">
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<el-
|
|
69
|
-
<
|
|
69
|
+
<article v-for="run in turn.runs" :key="run.event_id" class="authorizationRun" :data-run-id="run.run_id" :data-reading-id="run.event_id">
|
|
70
|
+
<div class="runHead">
|
|
71
|
+
<button v-if="run.run_id && run.thread_id" type="button" class="runToggle" :aria-expanded="!!runTraces[run.run_id]?.open"
|
|
72
|
+
@click="toggleRunTrace(run)">
|
|
73
|
+
<el-icon><ArrowDown v-if="runTraces[run.run_id]?.open" /><ArrowRight v-else /></el-icon>
|
|
74
|
+
<span class="muted">授权执行</span><strong>{{ memberLabel(run.member_session_id) }}</strong>
|
|
75
|
+
<span class="runState" :class="'state-' + (runSummaries[run.run_id]?.type || 'info')">{{ runSummaries[run.run_id]?.label || '查看轨迹' }}</span>
|
|
76
|
+
</button>
|
|
77
|
+
<span v-else class="unlinkedRun"><span class="muted">授权执行</span> {{ memberLabel(run.member_session_id) }}</span>
|
|
78
|
+
</div>
|
|
79
|
+
<p v-if="!run.thread_id" class="missingText">缺少原授权记录关联,无法打开执行轨迹。</p>
|
|
80
|
+
<div v-if="!run.thread_id || !run.run_id || runTraces[run.run_id]?.open" class="runTrace">
|
|
81
|
+
<div class="runActions">
|
|
82
|
+
<el-button v-if="run.thread_id" link type="primary" @click="emit('open-thread', run.thread_id)">原授权记录</el-button>
|
|
83
|
+
<details class="inlineMeta"><summary>执行标识</summary><div class="muted">系统:{{ memberContext(run.member_session_id).systemLabel }} · 路由:{{ memberContext(run.member_session_id).routeLabel }}</div>
|
|
84
|
+
<div class="mono">Session:{{ run.member_session_id || '未记录' }}</div><div class="mono">Run:{{ run.run_id || '未记录' }}</div><div class="mono">轮次:{{ turn.id }}</div>
|
|
85
|
+
</details>
|
|
86
|
+
</div>
|
|
87
|
+
<div v-if="memberContext(run.member_session_id).source === 'legacy_header'" class="missingText">旧记录:仅有归档头部信息,未单独记录成员系统与路由。</div>
|
|
88
|
+
<div v-else-if="memberContext(run.member_session_id).source === 'unavailable'" class="missingText">缺少授权成员的系统与路由信息,保留原执行关联。</div>
|
|
89
|
+
<span v-if="run.run_id && runTraces[run.run_id]?.loading" class="muted" role="status">正在读取执行轨迹…</span>
|
|
90
|
+
<el-alert v-if="run.run_id && runTraces[run.run_id]?.error" :title="runTraces[run.run_id].error" type="error" :closable="false" />
|
|
91
|
+
<template v-if="run.run_id && runTraces[run.run_id]?.data">
|
|
92
|
+
<el-alert v-if="runTraces[run.run_id].data?.trace.summary?.partial" title="当前只显示部分工具轨迹,可继续查看原授权记录。" type="warning" :closable="false" />
|
|
93
|
+
<div v-for="invocation in runTraces[run.run_id].data?.invocations" :key="invocation.job_id" class="invocation">
|
|
94
|
+
<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>
|
|
95
|
+
</div>
|
|
70
96
|
<el-timeline v-if="runTraces[run.run_id].data?.trace.events.length" class="executionTimeline">
|
|
71
97
|
<el-timeline-item v-for="(event, eventIndex) in runTraces[run.run_id].data?.trace.events" :key="eventIndex" :timestamp="fmtTime(event.ts, true)" placement="top">
|
|
72
98
|
<b>{{ event.title || event.event }}</b><div v-if="event.summary" class="muted">{{ event.summary }}</div>
|
|
73
99
|
<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>
|
|
74
100
|
</el-timeline-item>
|
|
75
101
|
</el-timeline>
|
|
76
|
-
<
|
|
102
|
+
<p v-else class="muted">该授权尚无可展示的执行事件。</p>
|
|
77
103
|
</template>
|
|
78
104
|
</div>
|
|
79
105
|
</article>
|
|
80
106
|
</div>
|
|
81
|
-
<
|
|
107
|
+
<p v-else-if="beforeSequence == null || turn.start" class="muted noRuns">本轮尚无已关联的授权执行记录。</p>
|
|
108
|
+
<details v-if="!turn.runs.length" class="inlineMeta"><summary>轮次标识</summary><span class="mono">{{ turn.id }}</span></details>
|
|
82
109
|
</section>
|
|
83
|
-
<
|
|
84
|
-
|
|
110
|
+
<footer class="pager muted">已加载 {{ turns.length }} 轮、{{ loadedMessageCount }} 条消息({{ events.length }} 条归档事件)<span v-if="!hasMore && beforeSequence == null"> · 旧历史或未同步内容可能缺失</span>
|
|
111
|
+
<div v-if="hasMore"><el-button :loading="moreLoading" @click="loadMoreEvents">加载后续记录</el-button></div>
|
|
112
|
+
</footer>
|
|
85
113
|
</template>
|
|
86
114
|
</main>
|
|
115
|
+
<el-drawer :model-value="!!infoPanel" :title="infoPanel === 'members' ? '关联授权' : '归档信息'" size="min(480px, 96vw)" append-to-body @update:model-value="infoPanel = null">
|
|
116
|
+
<template v-if="conversation">
|
|
117
|
+
<div v-if="infoPanel === 'members'">
|
|
118
|
+
<p>已确认 {{ conversation.confirmed_count }} / {{ conversation.member_count }} 项授权</p>
|
|
119
|
+
<article v-for="member in memberCards" :key="member.session_id" class="memberCard" :data-member-session-id="member.session_id">
|
|
120
|
+
<h3>{{ member.display_label || '未命名授权' }} <span class="muted">{{ member.confirmed ? '已确认' : '待确认' }}</span></h3>
|
|
121
|
+
<dl class="facts"><dt>系统</dt><dd>{{ member.context.systemLabel }}</dd><dt>路由</dt><dd>{{ member.context.routeLabel }}</dd><dt>Session</dt><dd class="mono">{{ member.session_id }}</dd></dl>
|
|
122
|
+
<p v-if="member.context.source === 'legacy_header'" class="missingText">旧记录:仅有归档头部信息,未单独记录成员系统与路由。</p>
|
|
123
|
+
</article>
|
|
124
|
+
</div>
|
|
125
|
+
<dl v-else class="facts"><dt>归档写入方</dt><dd>{{ conversation.client_app_id }}</dd><dt>写入路由</dt><dd>{{ conversation.route_key }}</dd>
|
|
126
|
+
<dt>客户端会话 ID</dt><dd class="mono">{{ conversation.client_conversation_id }}</dd><dt>客户端归档 ID</dt><dd class="mono">{{ conversation.client_archive_id || '未记录' }}</dd><dt>归档记录 ID</dt><dd class="mono">{{ conversation.conversation_id }}</dd>
|
|
127
|
+
<dt>归档状态</dt><dd>{{ auditStatusLabel(conversation.state) }}</dd><dt>最近更新</dt><dd>{{ fmtTime(conversation.updated_at, true) }}</dd>
|
|
128
|
+
</dl>
|
|
129
|
+
</template>
|
|
130
|
+
</el-drawer>
|
|
87
131
|
</div>
|
|
88
132
|
</template>
|
|
89
133
|
|
|
90
134
|
<script setup lang="ts">
|
|
91
|
-
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue';
|
|
135
|
+
import { computed, nextTick, onMounted, onBeforeUnmount, reactive, ref, watch } from 'vue';
|
|
136
|
+
import { ArrowDown, ArrowLeft, ArrowRight, Collection, Search, User, ChatLineSquare } from '@element-plus/icons-vue';
|
|
92
137
|
import { api } from '../request';
|
|
93
138
|
import { fmtTime } from '../util';
|
|
94
|
-
import
|
|
95
|
-
import
|
|
139
|
+
import ChannelThread from './ChannelThread.vue';
|
|
140
|
+
import ConversationSourceTag from './ConversationSourceTag.vue';
|
|
141
|
+
import { readingPosition, restoreReadingPosition } from './conversation-reading-position';
|
|
142
|
+
import { auditMemberContext, auditStatusLabel, groupAuditTurns, mergeAuditEvents, conversationSources, feedKey, feedTitle, readConversationSource } from './conversation-audit';
|
|
143
|
+
import type { AuditConversation, AuditMember, AuditEvent, AuditListPage, AuditDetailPage, ConversationFeedItem, ConversationFeedPage, ConversationSource } from './conversation-audit';
|
|
96
144
|
|
|
97
|
-
const props = defineProps<{ selectedId?: string; focusTurn?: string }>();
|
|
98
|
-
const emit = defineEmits<{ select: [id: string]; 'open-thread': [id: number]; 'open-job': [id: string] }>();
|
|
145
|
+
const props = defineProps<{ selectedId?: string; focusTurn?: string; channelThread?: number; source?: string }>();
|
|
146
|
+
const emit = defineEmits<{ select: [id: string]; 'select-channel': [id: number]; 'change-source': [source: ConversationSource]; 'open-audit': [id: string, turn?: string]; 'back-list': []; 'open-directory': []; 'open-thread': [id: number]; 'open-job': [id: string] }>();
|
|
99
147
|
interface Invocation { job_id: string; tool: string; state?: string | null; status: string; approval_status?: string | null }
|
|
100
148
|
interface RunTrace {
|
|
101
149
|
run: { status: string };
|
|
@@ -104,14 +152,37 @@ interface RunTrace {
|
|
|
104
152
|
}
|
|
105
153
|
interface RunTraceState { loading: boolean; open: boolean; data: RunTrace | null; error: string }
|
|
106
154
|
const LIST_PAGE = 50, EVENT_PAGE = 100;
|
|
107
|
-
const conversations = ref<
|
|
155
|
+
const conversations = ref<ConversationFeedItem[]>([]), listLoading = ref(false), listMoreLoading = ref(false), listMore = ref(false), listOffset = ref<number | null>(0), listError = ref('');
|
|
156
|
+
const query = ref('');
|
|
157
|
+
const activeSource = computed(() => readConversationSource(props.source));
|
|
158
|
+
const legacyFeed = ref(false);
|
|
159
|
+
const listCursor = ref<string | null>(null);
|
|
160
|
+
const channelPane = ref<InstanceType<typeof ChannelThread> | null>(null);
|
|
161
|
+
const currentThreadId = ref<number | null>(null);
|
|
162
|
+
const currentKey = computed(() => currentThreadId.value ? `thread:${currentThreadId.value}` : `audit:${currentId.value}`);
|
|
163
|
+
const selectedThread = computed(() => conversations.value.find(item => item.kind === 'thread' && item.thread_id === currentThreadId.value));
|
|
164
|
+
const rail = ref<HTMLElement | null>(null);
|
|
165
|
+
const infoPanel = ref<'archive' | 'members' | null>(null);
|
|
108
166
|
const currentId = ref(''), conversation = ref<AuditConversation | null>(null), members = ref<AuditMember[]>([]), events = ref<AuditEvent[]>([]);
|
|
109
167
|
const detailLoading = ref(false), moreLoading = ref(false), hasMore = ref(false), afterSequence = ref<number | null>(0), detailError = ref(''), pane = ref<HTMLElement | null>(null);
|
|
168
|
+
const beforeSequence = ref<number | null>(null);
|
|
110
169
|
const runTraces = reactive<Record<string, RunTraceState>>({});
|
|
111
170
|
let listGeneration = 0, detailGeneration = 0;
|
|
112
171
|
const turns = computed(() => groupAuditTurns(events.value));
|
|
113
172
|
const memberCards = computed(() => members.value.map(member => ({ ...member, context: auditMemberContext(member, conversation.value) })));
|
|
114
173
|
const loadedMessageCount = computed(() => events.value.filter(event => event.kind === 'user_message' || event.kind === 'assistant_message').length);
|
|
174
|
+
function conversationTitle(item: AuditConversation): string {
|
|
175
|
+
if (item.first_user_preview?.trim()) return item.first_user_preview.trim();
|
|
176
|
+
const id = item.client_conversation_id;
|
|
177
|
+
return `${item.client_app_id} · ${id.length > 12 ? '…' + id.slice(-12) : id}`;
|
|
178
|
+
}
|
|
179
|
+
const visibleConversations = computed(() => {
|
|
180
|
+
const text = query.value.trim().toLowerCase();
|
|
181
|
+
if (!text) return conversations.value;
|
|
182
|
+
return conversations.value.filter(item =>
|
|
183
|
+
[item.title, item.source_label, conversationSources[item.source], String(item.thread_id ?? ''), item.client_conversation_id, item.conversation_id, item.client_app_id, item.route_key]
|
|
184
|
+
.some(value => value?.toLowerCase().includes(text)));
|
|
185
|
+
});
|
|
115
186
|
function statusType(status?: string | null): 'info' | 'success' | 'warning' | 'danger' {
|
|
116
187
|
if (status === 'completed' || status === 'executed' || status === 'ready') return 'success';
|
|
117
188
|
if (status === 'failed' || status === 'denied' || status === 'business_rejected') return 'danger';
|
|
@@ -132,130 +203,322 @@ function invocationStatus(invocation: Invocation): string {
|
|
|
132
203
|
if (invocation.approval_status === 'approved' && invocation.state === 'awaiting_approval') return '已批准,等待客户端续执行';
|
|
133
204
|
return auditStatusLabel(invocation.state || invocation.status);
|
|
134
205
|
}
|
|
206
|
+
const runSummaries = computed(() => Object.fromEntries(
|
|
207
|
+
Object.entries(runTraces).map(([id, state]) => [id, summarizeTrace(state)]),
|
|
208
|
+
));
|
|
209
|
+
function summarizeTrace(state: RunTraceState): { label: string; type: string } {
|
|
210
|
+
if (state.loading) return { label: '读取中…', type: 'info' };
|
|
211
|
+
const trace = state.data;
|
|
212
|
+
if (!trace) return { label: '读取失败', type: 'danger' };
|
|
213
|
+
if (trace.trace.summary?.partial) return { label: '部分轨迹', type: 'warning' };
|
|
214
|
+
if (trace.invocations.length === 1) {
|
|
215
|
+
const inv = trace.invocations[0];
|
|
216
|
+
const state = inv.approval_status === 'pending' ? 'awaiting_approval' : inv.approval_status === 'denied' ? 'denied' : inv.state || inv.status;
|
|
217
|
+
return { label: invocationStatus(inv), type: statusType(state) };
|
|
218
|
+
}
|
|
219
|
+
if (trace.invocations.length > 1) {
|
|
220
|
+
const pending = trace.invocations.filter(inv => inv.approval_status === 'pending').length;
|
|
221
|
+
return pending ? { label: `${pending} 项等待审批`, type: 'warning' }
|
|
222
|
+
: { label: `${trace.invocations.length} 项工具调用`, type: 'info' };
|
|
223
|
+
}
|
|
224
|
+
return { label: '运行:' + auditStatusLabel(trace.run.status), type: 'info' };
|
|
225
|
+
}
|
|
226
|
+
async function fetchFeed(offset: number, source: ConversationSource, cursor?: string | null): Promise<ConversationFeedPage & { legacy?: boolean }> {
|
|
227
|
+
const params = new URLSearchParams({ source, limit: String(LIST_PAGE) });
|
|
228
|
+
if (cursor) params.set('cursor', cursor);
|
|
229
|
+
else params.set('offset', String(offset));
|
|
230
|
+
try { return await api<ConversationFeedPage>('/admin/api/conversation-audits/feed?' + params); }
|
|
231
|
+
catch (error) {
|
|
232
|
+
if (!(error instanceof Error) || error.message !== 'conversation_feed_unavailable') throw error;
|
|
233
|
+
if (source !== 'all' && source !== 'client') throw new Error('当前存储未提供此渠道的会话列表,请打开下方“授权与接入记录”。');
|
|
234
|
+
const page = await api<AuditListPage>(`/admin/api/conversation-audits?limit=${LIST_PAGE}&offset=${offset}`);
|
|
235
|
+
return { ...page, legacy: true, items: page.items.map(row => ({ ...row, kind: 'audit', source: 'client', thread_id: null, title: row.first_user_preview || null, source_label: row.client_app_id })) };
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function selectFeedItem(item: ConversationFeedItem): void {
|
|
239
|
+
if (feedKey(item) === currentKey.value && !props.focusTurn) {
|
|
240
|
+
if (item.kind === 'thread') channelPane.value?.scrollToLatest();
|
|
241
|
+
else restoreReadingPosition(pane.value, null, true);
|
|
242
|
+
}
|
|
243
|
+
if (item.kind === 'audit' && item.conversation_id) emit('select', item.conversation_id);
|
|
244
|
+
else if (item.kind === 'thread' && item.thread_id) emit('select-channel', item.thread_id);
|
|
245
|
+
}
|
|
246
|
+
function openFeedItem(item: ConversationFeedItem): void {
|
|
247
|
+
if (item.kind === 'thread' && item.thread_id) showChannel(item.thread_id);
|
|
248
|
+
else if (item.kind === 'audit' && item.conversation_id) void openConversation(item.conversation_id);
|
|
249
|
+
}
|
|
250
|
+
function showChannel(id: number): void {
|
|
251
|
+
if (currentThreadId.value === id) return;
|
|
252
|
+
resetSelection();
|
|
253
|
+
currentThreadId.value = id;
|
|
254
|
+
}
|
|
255
|
+
function resetSelection(): void {
|
|
256
|
+
++detailGeneration;
|
|
257
|
+
currentThreadId.value = null; currentId.value = ''; conversation.value = null; infoPanel.value = null;
|
|
258
|
+
events.value = []; members.value = []; hasMore.value = false; afterSequence.value = 0; beforeSequence.value = null;
|
|
259
|
+
detailError.value = ''; detailLoading.value = false; moreLoading.value = false;
|
|
260
|
+
for (const key of Object.keys(runTraces)) delete runTraces[key];
|
|
261
|
+
}
|
|
135
262
|
async function loadConversations(): Promise<void> {
|
|
136
263
|
const generation = ++listGeneration;
|
|
137
264
|
listLoading.value = true; listError.value = ''; listMoreLoading.value = false;
|
|
138
265
|
try {
|
|
139
|
-
const page = await
|
|
266
|
+
const page = await fetchFeed(0, activeSource.value);
|
|
140
267
|
if (generation !== listGeneration) return;
|
|
141
|
-
conversations.value = page.items; listMore.value = page.has_more; listOffset.value = page.next_offset;
|
|
268
|
+
legacyFeed.value = !!page.legacy; conversations.value = page.items; listMore.value = page.has_more; listOffset.value = page.next_offset; listCursor.value = page.next_cursor ?? null;
|
|
269
|
+
if (!props.selectedId && !props.channelThread && !currentId.value && !currentThreadId.value && page.items.length && window.matchMedia('(min-width: 901px)').matches) {
|
|
270
|
+
openFeedItem(page.items[0]);
|
|
271
|
+
}
|
|
142
272
|
} catch (error) { if (generation === listGeneration) listError.value = (error as Error).message; }
|
|
143
273
|
finally { if (generation === listGeneration) listLoading.value = false; }
|
|
144
274
|
}
|
|
145
275
|
async function loadMoreConversations(): Promise<void> {
|
|
146
|
-
if (listLoading.value || listMoreLoading.value || !listMore.value || listOffset.value == null) return;
|
|
276
|
+
if (listLoading.value || listMoreLoading.value || !listMore.value || (!listCursor.value && listOffset.value == null)) return;
|
|
147
277
|
const generation = listGeneration;
|
|
148
278
|
listMoreLoading.value = true;
|
|
149
279
|
try {
|
|
150
|
-
const page = await
|
|
280
|
+
const page = await fetchFeed(listOffset.value ?? conversations.value.length, activeSource.value, listCursor.value);
|
|
151
281
|
if (generation !== listGeneration) return;
|
|
152
|
-
const rows = new Map(conversations.value.map(item => [item
|
|
153
|
-
for (const item of page.items) rows.set(item
|
|
154
|
-
conversations.value = [...rows.values()]; listMore.value = page.has_more; listOffset.value = page.next_offset;
|
|
282
|
+
const rows = new Map(conversations.value.map(item => [feedKey(item), item]));
|
|
283
|
+
for (const item of page.items) rows.set(feedKey(item), item);
|
|
284
|
+
conversations.value = [...rows.values()]; listMore.value = page.has_more; listOffset.value = page.next_offset; listCursor.value = page.next_cursor ?? null; listError.value = '';
|
|
155
285
|
} catch (error) { if (generation === listGeneration) listError.value = (error as Error).message; }
|
|
156
286
|
finally { if (generation === listGeneration) listMoreLoading.value = false; }
|
|
157
287
|
}
|
|
158
288
|
function applyPage(page: AuditDetailPage): void {
|
|
159
289
|
conversation.value = page.conversation; members.value = page.members;
|
|
160
|
-
events.value = mergeAuditEvents(events.value, page.events); hasMore.value = page.has_more; afterSequence.value = page.next_after_sequence;
|
|
290
|
+
events.value = mergeAuditEvents(events.value, page.events); hasMore.value = page.has_more === true; afterSequence.value = page.next_after_sequence ?? null;
|
|
161
291
|
}
|
|
162
292
|
async function focusLoadedTurn(): Promise<void> {
|
|
163
293
|
if (!props.focusTurn) return;
|
|
164
294
|
await nextTick();
|
|
165
295
|
const target = [...(pane.value?.querySelectorAll<HTMLElement>('[data-turn-id]') ?? [])].find(element => element.dataset.turnId === props.focusTurn);
|
|
166
|
-
if (target && pane.value)
|
|
296
|
+
if (target && pane.value) {
|
|
297
|
+
const header = pane.value.querySelector('header');
|
|
298
|
+
pane.value.scrollTop += target.getBoundingClientRect().top - pane.value.getBoundingClientRect().top - (header?.clientHeight ?? 0) - 10;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function readEvents(id: string, query: string) {
|
|
302
|
+
return api<AuditDetailPage>(`/admin/api/conversation-audits/${encodeURIComponent(id)}?${query}&limit=${EVENT_PAGE}`);
|
|
303
|
+
}
|
|
304
|
+
function priorCursor(page: AuditDetailPage): number | null {
|
|
305
|
+
return page.has_earlier && page.next_before_sequence != null ? page.next_before_sequence : null;
|
|
167
306
|
}
|
|
168
|
-
async function openConversation(id: string): Promise<void> {
|
|
307
|
+
async function openConversation(id: string, locate = false): Promise<void> {
|
|
169
308
|
const generation = ++detailGeneration;
|
|
170
|
-
|
|
309
|
+
const same = currentId.value === id && !!conversation.value;
|
|
310
|
+
const firstLoaded = same && !locate ? events.value[0]?.sequence : undefined;
|
|
311
|
+
const lastLoaded = same && !locate ? events.value.at(-1)?.sequence : undefined;
|
|
312
|
+
currentThreadId.value = null; currentId.value = id;
|
|
313
|
+
if (!same) {
|
|
314
|
+
conversation.value = null; events.value = []; members.value = []; hasMore.value = false; afterSequence.value = 0;
|
|
315
|
+
beforeSequence.value = null; infoPanel.value = null;
|
|
316
|
+
}
|
|
171
317
|
detailLoading.value = true; moreLoading.value = false; detailError.value = '';
|
|
172
|
-
for (const key of Object.
|
|
318
|
+
for (const [key, state] of Object.entries(runTraces)) {
|
|
319
|
+
if (!same || state.loading) delete runTraces[key];
|
|
320
|
+
}
|
|
321
|
+
try {
|
|
322
|
+
const target = props.focusTurn;
|
|
323
|
+
let page = await readEvents(id, target ? 'after_sequence=0' : 'tail=1');
|
|
324
|
+
if (generation !== detailGeneration) return;
|
|
325
|
+
let before = priorCursor(page);
|
|
326
|
+
let windowEvents = page.events;
|
|
327
|
+
// Keep the history already opened by the reader when refreshing the newest page.
|
|
328
|
+
while (!target && firstLoaded != null && before != null && before > firstLoaded) {
|
|
329
|
+
const older = await readEvents(id, 'before_sequence=' + before);
|
|
330
|
+
if (generation !== detailGeneration) return;
|
|
331
|
+
const next = priorCursor(older);
|
|
332
|
+
if (next != null && next >= before) throw new Error('归档分页位置未能核对');
|
|
333
|
+
windowEvents = [...older.events, ...windowEvents];
|
|
334
|
+
before = next;
|
|
335
|
+
}
|
|
336
|
+
if (target) {
|
|
337
|
+
// Trace links open at their turn. Refreshing the same link keeps later pages the reader already opened.
|
|
338
|
+
let found = windowEvents.some(event => event.client_turn_id === target);
|
|
339
|
+
while (page.has_more && (!found || (lastLoaded != null && (windowEvents.at(-1)?.sequence ?? 0) < lastLoaded))) {
|
|
340
|
+
const cursor = page.next_after_sequence;
|
|
341
|
+
if (cursor == null) throw new Error('归档分页位置未能核对');
|
|
342
|
+
page = await readEvents(id, 'after_sequence=' + cursor);
|
|
343
|
+
if (generation !== detailGeneration) return;
|
|
344
|
+
if (page.has_more && (page.next_after_sequence == null || page.next_after_sequence <= cursor)) throw new Error('归档分页位置未能核对');
|
|
345
|
+
windowEvents = windowEvents.concat(page.events);
|
|
346
|
+
found ||= page.events.some(event => event.client_turn_id === target);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
const position = same && !locate ? readingPosition(pane.value) : null;
|
|
350
|
+
events.value = [];
|
|
351
|
+
applyPage({ ...page, events: windowEvents }); beforeSequence.value = before;
|
|
352
|
+
await nextTick();
|
|
353
|
+
if (generation !== detailGeneration) return;
|
|
354
|
+
if (target && (locate || !same)) await focusLoadedTurn();
|
|
355
|
+
else restoreReadingPosition(pane.value, position, true);
|
|
356
|
+
} catch (error) {
|
|
357
|
+
if (generation === detailGeneration) detailError.value = (same ? '刷新未成功,以下为上次读取的记录。' : '') + (error as Error).message;
|
|
358
|
+
} finally { if (generation === detailGeneration) detailLoading.value = false; }
|
|
359
|
+
}
|
|
360
|
+
async function loadEarlierEvents(): Promise<void> {
|
|
361
|
+
const before = beforeSequence.value;
|
|
362
|
+
if (!currentId.value || detailLoading.value || moreLoading.value || before == null) return;
|
|
363
|
+
const generation = detailGeneration;
|
|
364
|
+
moreLoading.value = true; detailError.value = '';
|
|
173
365
|
try {
|
|
174
|
-
const page = await
|
|
366
|
+
const page = await readEvents(currentId.value, 'before_sequence=' + before);
|
|
175
367
|
if (generation !== detailGeneration) return;
|
|
176
|
-
|
|
368
|
+
const cursor = priorCursor(page);
|
|
369
|
+
if (cursor != null && cursor >= before) throw new Error('归档分页位置未能核对');
|
|
370
|
+
const position = readingPosition(pane.value);
|
|
371
|
+
events.value = mergeAuditEvents(events.value, page.events);
|
|
372
|
+
beforeSequence.value = cursor;
|
|
373
|
+
await nextTick();
|
|
374
|
+
if (generation === detailGeneration) restoreReadingPosition(pane.value, position, false);
|
|
177
375
|
} catch (error) { if (generation === detailGeneration) detailError.value = (error as Error).message; }
|
|
178
|
-
finally { if (generation === detailGeneration)
|
|
376
|
+
finally { if (generation === detailGeneration) moreLoading.value = false; }
|
|
179
377
|
}
|
|
180
378
|
async function loadMoreEvents(): Promise<void> {
|
|
181
379
|
if (!currentId.value || detailLoading.value || moreLoading.value || !hasMore.value || afterSequence.value == null) return;
|
|
182
380
|
const generation = detailGeneration;
|
|
183
381
|
moreLoading.value = true; detailError.value = '';
|
|
184
382
|
try {
|
|
185
|
-
const page = await
|
|
186
|
-
if (generation
|
|
187
|
-
applyPage(page); await focusLoadedTurn();
|
|
383
|
+
const page = await readEvents(currentId.value, 'after_sequence=' + afterSequence.value);
|
|
384
|
+
if (generation === detailGeneration) applyPage(page);
|
|
188
385
|
} catch (error) { if (generation === detailGeneration) detailError.value = (error as Error).message; }
|
|
189
386
|
finally { if (generation === detailGeneration) moreLoading.value = false; }
|
|
190
387
|
}
|
|
191
388
|
async function toggleRunTrace(run: AuditEvent): Promise<void> {
|
|
192
389
|
if (!run.run_id || !run.thread_id) return;
|
|
193
390
|
const existing = runTraces[run.run_id];
|
|
391
|
+
if (existing?.loading) { existing.open = !existing.open; return; }
|
|
194
392
|
if (existing?.open) { existing.open = false; return; }
|
|
195
393
|
if (existing?.data) { existing.open = true; return; }
|
|
196
394
|
const generation = detailGeneration, id = run.run_id;
|
|
197
395
|
runTraces[id] = { loading: true, open: true, data: null, error: '' };
|
|
198
396
|
try {
|
|
199
397
|
const data = await api<RunTrace>(`/admin/api/threads/${run.thread_id}/agent-runs/${encodeURIComponent(id)}/trace`);
|
|
200
|
-
if (generation === detailGeneration) runTraces[id] = { loading: false, open: true, data, error: '' };
|
|
201
|
-
} catch (error) { if (generation === detailGeneration) runTraces[id] = { loading: false, open: true, data: null, error: `授权轨迹未能读取:${(error as Error).message}` }; }
|
|
398
|
+
if (generation === detailGeneration) runTraces[id] = { loading: false, open: runTraces[id]?.open ?? true, data, error: '' };
|
|
399
|
+
} catch (error) { if (generation === detailGeneration) runTraces[id] = { loading: false, open: runTraces[id]?.open ?? true, data: null, error: `授权轨迹未能读取:${(error as Error).message}` }; }
|
|
400
|
+
}
|
|
401
|
+
async function refresh(): Promise<void> {
|
|
402
|
+
await Promise.all([loadConversations(), currentThreadId.value ? channelPane.value?.refresh() : currentId.value ? openConversation(currentId.value) : undefined]);
|
|
202
403
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
404
|
+
watch(() => [props.selectedId, props.channelThread, activeSource.value, props.focusTurn] as const, async ([id, thread, source, turn], previous) => {
|
|
405
|
+
const changedSource = !!previous && previous[2] !== source;
|
|
406
|
+
if (changedSource) {
|
|
407
|
+
resetSelection(); conversations.value = []; listMore.value = false; listOffset.value = 0; listCursor.value = null; legacyFeed.value = false; query.value = '';
|
|
408
|
+
void loadConversations();
|
|
409
|
+
}
|
|
410
|
+
if (id && (id !== currentId.value || turn !== previous?.[3])) await openConversation(id, true);
|
|
411
|
+
else if (thread) showChannel(thread);
|
|
412
|
+
else if (!id && !thread && previous && (previous[0] || previous[1]) && !changedSource) {
|
|
413
|
+
infoPanel.value = null;
|
|
414
|
+
await nextTick();
|
|
415
|
+
if (window.matchMedia('(max-width: 900px)').matches) {
|
|
416
|
+
const target = rail.value?.querySelector<HTMLElement>('[aria-current="true"]') || rail.value?.querySelector<HTMLInputElement>('input');
|
|
417
|
+
target?.focus({ preventScroll: true });
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}, { immediate: true });
|
|
421
|
+
onBeforeUnmount(() => { ++detailGeneration; ++listGeneration; });
|
|
206
422
|
onMounted(() => { void loadConversations(); });
|
|
207
423
|
defineExpose({ refresh });
|
|
208
424
|
</script>
|
|
209
425
|
|
|
210
426
|
<style scoped>
|
|
211
|
-
.auditConvo { display:
|
|
427
|
+
.auditConvo { display: grid; grid-template-columns: clamp(235px, 22vw, 310px) minmax(0, 1fr); height: max(480px, calc(100dvh - 258px)); border: 1px solid var(--el-border-color); }
|
|
428
|
+
h2, h3, p { margin: 0; }
|
|
429
|
+
h2 { font-size: 19px; line-height: 1.5; overflow-wrap: anywhere; }
|
|
430
|
+
h3 { font-size: 14px; }
|
|
212
431
|
.muted { color: var(--el-text-color-secondary); font-size: 12px; }
|
|
213
|
-
.mono { font-family: var(--bz-mono
|
|
214
|
-
.auditRail {
|
|
215
|
-
.railHeading {
|
|
216
|
-
.
|
|
217
|
-
.
|
|
218
|
-
.
|
|
219
|
-
.
|
|
220
|
-
.
|
|
221
|
-
.
|
|
222
|
-
.
|
|
223
|
-
.
|
|
224
|
-
.
|
|
225
|
-
.
|
|
226
|
-
.
|
|
227
|
-
.
|
|
228
|
-
.
|
|
229
|
-
.
|
|
230
|
-
.
|
|
231
|
-
.
|
|
232
|
-
.
|
|
233
|
-
.
|
|
234
|
-
|
|
235
|
-
.
|
|
236
|
-
.
|
|
237
|
-
.
|
|
238
|
-
.
|
|
239
|
-
.
|
|
432
|
+
.mono { font-family: var(--bz-mono); overflow-wrap: anywhere; }
|
|
433
|
+
.auditRail { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--el-border-color); }
|
|
434
|
+
.railHeading { padding: 14px 14px 12px; }
|
|
435
|
+
.headingLine, .itemMeta, .turnHeading, .runHead, .runActions, .headerLinks, .invocation { display: flex; align-items: center; gap: 8px; }
|
|
436
|
+
.sourceFilter { width: 99px; }
|
|
437
|
+
.channelMain { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
|
|
438
|
+
.legacyFeed { padding: 2px 14px 8px; }
|
|
439
|
+
.headingLine { justify-content: space-between; margin-bottom: 9px; }
|
|
440
|
+
.conversationList { flex: 1; overflow: auto; }
|
|
441
|
+
.conversationItem, .directoryEntry, .runToggle { font: inherit; color: inherit; text-align: left; background: transparent; border: 0; cursor: pointer; }
|
|
442
|
+
.conversationItem { width: 100%; display: block; padding: 12px 14px; border-bottom: 1px solid var(--el-border-color-lighter); }
|
|
443
|
+
.conversationItem:hover, .directoryEntry:hover, .runToggle:hover { background: var(--el-fill-color-light); }
|
|
444
|
+
.conversationItem[aria-current=true] { background: var(--el-color-primary-light-9); }
|
|
445
|
+
.conversationItem[aria-current=true] .itemTitle { color: var(--el-color-primary); }
|
|
446
|
+
.conversationItem:focus-visible, .directoryEntry:focus-visible, .runToggle:focus-visible { outline: 2px solid var(--el-color-primary); outline-offset: -2px; }
|
|
447
|
+
.itemTitle { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-size: 14px; }
|
|
448
|
+
.itemTop, .detailTitle { display: flex; align-items: center; gap: 8px; }
|
|
449
|
+
.itemTop { justify-content: space-between; margin-bottom: 5px; }
|
|
450
|
+
.itemMeta { margin-top: 4px; }
|
|
451
|
+
.itemState { flex-shrink: 0; }
|
|
452
|
+
.itemMeta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
453
|
+
time { flex-shrink: 0; font-variant-numeric: tabular-nums; }
|
|
454
|
+
.itemState { font-size: 12px; color: var(--el-text-color-secondary); }
|
|
455
|
+
.directoryEntry { width: 100%; display: flex; align-items: center; gap: 8px; padding: 13px 14px; font-weight: 600; border-top: 1px solid var(--el-border-color); }
|
|
456
|
+
.directoryEntry .el-icon:last-child { margin-left: auto; }
|
|
457
|
+
.auditPane { --pane-inset: clamp(16px, 2vw, 32px); min-width: 0; overflow: auto; padding: 0 var(--pane-inset); }
|
|
458
|
+
.backToList { display: none; }
|
|
459
|
+
.conversationHeader { position: sticky; top: 0; z-index: 1; background: var(--el-bg-color); padding: 12px var(--pane-inset) 9px; margin-inline: calc(-1 * var(--pane-inset)); border-bottom: 1px solid var(--el-border-color); }
|
|
460
|
+
.headerMeta { margin: 5px 0; overflow-wrap: anywhere; }
|
|
461
|
+
.headerLinks, .runActions, .invocation { flex-wrap: wrap; }
|
|
462
|
+
.headerLinks .el-button + .el-button { margin-left: 4px; }
|
|
463
|
+
.auditTurn { padding: 16px 0; border-bottom: 1px solid var(--el-border-color-lighter); }
|
|
464
|
+
.auditTurn.focused .turnHeading h3 { color: var(--el-color-primary); }
|
|
465
|
+
.turnHeading { flex-wrap: wrap; margin-bottom: 10px; }
|
|
466
|
+
.turnHeading time { margin-left: auto; }
|
|
467
|
+
.detailTitle h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
|
|
468
|
+
.historyControl { text-align: center; padding: 6px; }
|
|
469
|
+
.auditMessage { width: fit-content; max-width: 88%; margin-block: 10px; }
|
|
470
|
+
.userMessage { margin-left: auto; }
|
|
471
|
+
.messageMeta, .actorName { display: flex; align-items: center; gap: 5px; }
|
|
472
|
+
.messageMeta { gap: 9px; margin-bottom: 4px; }
|
|
473
|
+
.userMessage .messageMeta { justify-content: flex-end; }
|
|
474
|
+
.actorName { font-size: 12px; color: var(--el-text-color-primary); }
|
|
475
|
+
.messageMeta time { font-size: 11px; color: var(--el-text-color-secondary); }
|
|
476
|
+
.messageText { border: 1px solid var(--el-border-color-lighter); background: var(--el-fill-color-light); padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.65; }
|
|
240
477
|
.userMessage .messageText { background: var(--el-color-primary-light-9); border-color: var(--el-color-primary-light-7); }
|
|
241
|
-
.
|
|
242
|
-
.
|
|
243
|
-
.
|
|
244
|
-
.
|
|
245
|
-
.
|
|
246
|
-
.
|
|
247
|
-
.
|
|
248
|
-
.
|
|
249
|
-
.
|
|
250
|
-
.
|
|
251
|
-
.
|
|
252
|
-
.
|
|
478
|
+
.authorizationRuns { margin: 12px 0 0; }
|
|
479
|
+
.authorizationRun { border: 1px solid var(--el-border-color); }
|
|
480
|
+
.authorizationRun + .authorizationRun { margin-top: 6px; }
|
|
481
|
+
.runHead { background: var(--el-fill-color-lighter); }
|
|
482
|
+
.runToggle, .unlinkedRun { min-width: 0; flex: 1; display: flex; align-items: baseline; gap: 8px; padding: 9px 10px; font-size: 13px; overflow-wrap: anywhere; }
|
|
483
|
+
.runToggle .el-icon { align-self: center; }
|
|
484
|
+
.runToggle .muted { flex-shrink: 0; }
|
|
485
|
+
.runState { margin-left: auto; align-self: center; flex-shrink: 0; font-size: 12px; }
|
|
486
|
+
.state-success { color: var(--el-color-success); }
|
|
487
|
+
.state-warning, .missingText { color: var(--el-color-warning); }
|
|
488
|
+
.state-danger, .attention { color: var(--el-color-danger); }
|
|
489
|
+
.state-info { color: var(--el-text-color-secondary); }
|
|
490
|
+
.missingText, .noRuns { font-size: 12px; padding: 5px 0; }
|
|
491
|
+
.authorizationRun > .missingText { padding: 5px 10px; }
|
|
492
|
+
.runTrace { padding: 10px; border-top: 1px solid var(--el-border-color-lighter); }
|
|
493
|
+
.runActions { align-items: baseline; gap: 8px 18px; }
|
|
494
|
+
.inlineMeta { color: var(--el-text-color-secondary); font-size: 12px; overflow-wrap: anywhere; }
|
|
495
|
+
.inlineMeta summary { cursor: pointer; }
|
|
496
|
+
.inlineMeta[open] > summary { margin-bottom: 5px; }
|
|
497
|
+
.invocation { padding: 8px 0; border-bottom: 1px solid var(--el-border-color-lighter); }
|
|
253
498
|
.invocation .el-button { margin-left: auto; }
|
|
254
|
-
.executionTimeline {
|
|
255
|
-
.eventDetail { white-space: pre-wrap; overflow-wrap: anywhere;
|
|
256
|
-
.
|
|
257
|
-
.pager {
|
|
258
|
-
.
|
|
259
|
-
|
|
260
|
-
|
|
499
|
+
.executionTimeline { margin: 10px 0; padding-left: 12px; }
|
|
500
|
+
.eventDetail { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
501
|
+
.pager { text-align: center; padding: 12px; }
|
|
502
|
+
.pager .el-button { margin-top: 4px; }
|
|
503
|
+
.notice { margin: 8px 0; }
|
|
504
|
+
.memberCard { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--el-border-color); }
|
|
505
|
+
.facts { display: grid; grid-template-columns: max-content minmax(0,1fr); gap: 10px 14px; margin: 12px 0; }
|
|
506
|
+
.facts dt { color: var(--el-text-color-secondary); }
|
|
507
|
+
.facts dd { margin: 0; overflow-wrap: anywhere; }
|
|
508
|
+
@media (max-width: 900px) {
|
|
509
|
+
.auditConvo { display: flex; flex-direction: column; min-width: 0; }
|
|
510
|
+
.auditRail, .auditPane { height: 100%; border-right: 0; }
|
|
511
|
+
.auditConvo.hasSelection .auditRail, .auditConvo:not(.hasSelection) .auditPane, .auditConvo:not(.hasSelection) .channelMain { display: none; }
|
|
512
|
+
.channelMain { flex: 1; }
|
|
513
|
+
.backToList { display: inline-flex; margin-top: 10px; }
|
|
514
|
+
.conversationHeader { padding-top: 6px; }
|
|
515
|
+
.auditPane { --pane-inset: 12px; }
|
|
516
|
+
.authorizationRuns { margin-left: 0; }
|
|
517
|
+
}
|
|
518
|
+
@media (max-width: 550px) {
|
|
519
|
+
.auditConvo { height: max(355px, calc(100dvh - 235px)); }
|
|
520
|
+
.turnHeading time { font-size: 11px; }
|
|
521
|
+
.runHead { flex-wrap: wrap; gap: 0; }
|
|
522
|
+
.runToggle { flex-wrap: wrap; }
|
|
523
|
+
}
|
|
261
524
|
</style>
|