chatluna-plugin-onebot-sandbox 1.0.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/LICENSE +21 -0
- package/README.md +20 -0
- package/client/app.tsx +306 -0
- package/client/chat/chat-pane.tsx +303 -0
- package/client/chat/composer.css +635 -0
- package/client/chat/composer.tsx +646 -0
- package/client/chat/details-panel.tsx +196 -0
- package/client/chat/emoji-picker.tsx +70 -0
- package/client/chat/extension-mark.tsx +16 -0
- package/client/chat/forward.tsx +257 -0
- package/client/chat/image-preview.tsx +93 -0
- package/client/chat/member-menu.tsx +64 -0
- package/client/chat/message-list.tsx +617 -0
- package/client/chat/messages.css +1018 -0
- package/client/chat/notifications.tsx +83 -0
- package/client/chat/reactions.tsx +52 -0
- package/client/chat/search-panel.tsx +231 -0
- package/client/chat/sidebar.tsx +424 -0
- package/client/chat/webqq-view.tsx +71 -0
- package/client/environment/avatar-picker.tsx +92 -0
- package/client/environment/create-popover.tsx +228 -0
- package/client/environment/directory-model.ts +63 -0
- package/client/environment/entity-dialog.css +383 -0
- package/client/environment/entity-dialog.tsx +442 -0
- package/client/environment/page.css +14 -0
- package/client/environment/page.tsx +280 -0
- package/client/i18n.ts +19 -0
- package/client/index.ts +17 -0
- package/client/locales/en.yml +617 -0
- package/client/locales/zh.yml +617 -0
- package/client/mcp/capability-catalog.tsx +277 -0
- package/client/mcp/credential-manager.tsx +257 -0
- package/client/onebot-debug/page.tsx +329 -0
- package/client/records/record-layout.tsx +429 -0
- package/client/records/records.css +259 -0
- package/client/settings/about.tsx +43 -0
- package/client/settings/draft.ts +47 -0
- package/client/settings/localize.ts +76 -0
- package/client/settings/page.tsx +210 -0
- package/client/settings/settings.css +47 -0
- package/client/shared/avatar.tsx +35 -0
- package/client/shared/confirm-dialog.tsx +44 -0
- package/client/shared/controls.css +17 -0
- package/client/shared/discard-confirm.tsx +45 -0
- package/client/shared/floating-panel.ts +40 -0
- package/client/shared/format-duration.ts +22 -0
- package/client/shared/format-time.ts +49 -0
- package/client/shared/glass.css +150 -0
- package/client/shared/implementation.ts +12 -0
- package/client/shared/overlay-scrollbar.css +45 -0
- package/client/shared/overlay-scrollbar.tsx +123 -0
- package/client/shared/use-element-width.ts +19 -0
- package/client/shared/use-retained.ts +12 -0
- package/client/test-call/page.tsx +260 -0
- package/client/test-space/agent-visuals.tsx +121 -0
- package/client/test-space/observe-overlay.tsx +42 -0
- package/client/test-space/overview.tsx +267 -0
- package/client/test-space/spaces.css +201 -0
- package/client/test-space/thumbnail-capture.ts +63 -0
- package/client/test-space/thumbnail-scale.ts +21 -0
- package/client/test-space/use-space-list.ts +35 -0
- package/client/test-space/zoom.ts +197 -0
- package/client/webqq/composer-draft-host.ts +578 -0
- package/client/webqq/composer-draft.ts +81 -0
- package/client/webqq/conversation-tree.ts +155 -0
- package/client/webqq/emoji-catalog.ts +78 -0
- package/client/webqq/fork-boundary.ts +28 -0
- package/client/webqq/forward-cluster.ts +20 -0
- package/client/webqq/forward-dialog-stack.ts +74 -0
- package/client/webqq/forward-preview.ts +40 -0
- package/client/webqq/friend-menu.ts +17 -0
- package/client/webqq/group-display.ts +18 -0
- package/client/webqq/group-menu.ts +25 -0
- package/client/webqq/mention.ts +4 -0
- package/client/webqq/message-capabilities.ts +37 -0
- package/client/webqq/message-cluster.ts +68 -0
- package/client/webqq/message-presentation.ts +197 -0
- package/client/webqq/message-reveal.ts +31 -0
- package/client/webqq/message-search-date.ts +40 -0
- package/client/webqq/message-selection.ts +85 -0
- package/client/webqq/notification-requests.ts +20 -0
- package/client/webqq/participant-presentation.ts +128 -0
- package/client/webqq/profile-card.ts +199 -0
- package/client/webqq/relationship-directory.ts +62 -0
- package/client/webqq/thinking-panel.ts +7 -0
- package/client/webqq/user-stack.ts +53 -0
- package/client/workspace/agent-overlay-effect.ts +238 -0
- package/client/workspace/context.tsx +117 -0
- package/client/workspace/overlay-host.tsx +299 -0
- package/client/workspace/profile-card.css +164 -0
- package/client/workspace/state.ts +28 -0
- package/client/workspace/store.ts +388 -0
- package/client/workspace/use-test-spaces.ts +21 -0
- package/dist/.vite/manifest.json +21 -0
- package/dist/app-63rfTh6w.js +85 -0
- package/dist/client.css +4 -0
- package/dist/client.js +1 -0
- package/lib/account-profile.d.ts +17 -0
- package/lib/account-profile.d.ts.map +1 -0
- package/lib/base-dir.d.ts +4 -0
- package/lib/base-dir.d.ts.map +1 -0
- package/lib/bot.d.ts +185 -0
- package/lib/bot.d.ts.map +1 -0
- package/lib/builtin-avatar-options.d.ts +11 -0
- package/lib/builtin-avatar-options.d.ts.map +1 -0
- package/lib/builtin-avatars.d.ts +6 -0
- package/lib/builtin-avatars.d.ts.map +1 -0
- package/lib/channel-assignee.d.ts +52 -0
- package/lib/channel-assignee.d.ts.map +1 -0
- package/lib/chatluna/conversation-lines.d.ts +46 -0
- package/lib/chatluna/conversation-lines.d.ts.map +1 -0
- package/lib/chatluna/runtime.d.ts +26 -0
- package/lib/chatluna/runtime.d.ts.map +1 -0
- package/lib/chatluna/state.d.ts +67 -0
- package/lib/chatluna/state.d.ts.map +1 -0
- package/lib/chatluna/thinking.d.ts +10 -0
- package/lib/chatluna/thinking.d.ts.map +1 -0
- package/lib/chatluna/tools.d.ts +36 -0
- package/lib/chatluna/tools.d.ts.map +1 -0
- package/lib/chatluna/wakeup.d.ts +143 -0
- package/lib/chatluna/wakeup.d.ts.map +1 -0
- package/lib/console-contract.d.ts +131 -0
- package/lib/console-contract.d.ts.map +1 -0
- package/lib/console.d.ts +31 -0
- package/lib/console.d.ts.map +1 -0
- package/lib/control-service.d.ts +425 -0
- package/lib/control-service.d.ts.map +1 -0
- package/lib/conversation-resolution.d.ts +157 -0
- package/lib/conversation-resolution.d.ts.map +1 -0
- package/lib/error-detail.d.ts +3 -0
- package/lib/error-detail.d.ts.map +1 -0
- package/lib/inbound-delivery.d.ts +156 -0
- package/lib/inbound-delivery.d.ts.map +1 -0
- package/lib/index.d.ts +76 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12834 -0
- package/lib/index.js.map +1 -0
- package/lib/lifecycle.d.ts +8 -0
- package/lib/lifecycle.d.ts.map +1 -0
- package/lib/mcp/arguments.d.ts +71 -0
- package/lib/mcp/arguments.d.ts.map +1 -0
- package/lib/mcp/call-records.d.ts +32 -0
- package/lib/mcp/call-records.d.ts.map +1 -0
- package/lib/mcp/http-api.d.ts +147 -0
- package/lib/mcp/http-api.d.ts.map +1 -0
- package/lib/mcp/page-cursor.d.ts +37 -0
- package/lib/mcp/page-cursor.d.ts.map +1 -0
- package/lib/mcp/server.d.ts +60 -0
- package/lib/mcp/server.d.ts.map +1 -0
- package/lib/mcp/service.d.ts +219 -0
- package/lib/mcp/service.d.ts.map +1 -0
- package/lib/mcp/tool-registry.d.ts +113 -0
- package/lib/mcp/tool-registry.d.ts.map +1 -0
- package/lib/mcp/types.d.ts +144 -0
- package/lib/mcp/types.d.ts.map +1 -0
- package/lib/media-storage.d.ts +33 -0
- package/lib/media-storage.d.ts.map +1 -0
- package/lib/message-capabilities.d.ts +78 -0
- package/lib/message-capabilities.d.ts.map +1 -0
- package/lib/onebot-debug.d.ts +115 -0
- package/lib/onebot-debug.d.ts.map +1 -0
- package/lib/onebot-message.d.ts +23 -0
- package/lib/onebot-message.d.ts.map +1 -0
- package/lib/onebot-profiles.d.ts +45 -0
- package/lib/onebot-profiles.d.ts.map +1 -0
- package/lib/persistence.d.ts +148 -0
- package/lib/persistence.d.ts.map +1 -0
- package/lib/random.d.ts +5 -0
- package/lib/random.d.ts.map +1 -0
- package/lib/record-store.d.ts +80 -0
- package/lib/record-store.d.ts.map +1 -0
- package/lib/relationship-actions.d.ts +157 -0
- package/lib/relationship-actions.d.ts.map +1 -0
- package/lib/scope-directory.d.ts +105 -0
- package/lib/scope-directory.d.ts.map +1 -0
- package/lib/settings.d.ts +33 -0
- package/lib/settings.d.ts.map +1 -0
- package/lib/test-spaces.d.ts +69 -0
- package/lib/test-spaces.d.ts.map +1 -0
- package/lib/types.d.ts +739 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/webui.d.ts +26 -0
- package/lib/webui.d.ts.map +1 -0
- package/package.json +112 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
ArrowRightIcon,
|
|
4
|
+
BoxIcon,
|
|
5
|
+
BracesIcon,
|
|
6
|
+
BotIcon,
|
|
7
|
+
CircleAlertIcon,
|
|
8
|
+
CpuIcon,
|
|
9
|
+
GitBranchIcon,
|
|
10
|
+
LinkIcon,
|
|
11
|
+
TagIcon,
|
|
12
|
+
} from 'lucide-react'
|
|
13
|
+
import {
|
|
14
|
+
Button,
|
|
15
|
+
Checkbox,
|
|
16
|
+
Input,
|
|
17
|
+
Select,
|
|
18
|
+
SelectContent,
|
|
19
|
+
SelectItem,
|
|
20
|
+
SelectTrigger,
|
|
21
|
+
SelectValue,
|
|
22
|
+
} from '@chatluna/ui-kit'
|
|
23
|
+
import type {
|
|
24
|
+
GetSandboxOneBotDebugRecordsInput,
|
|
25
|
+
SandboxConsoleOneBotDebugRecord,
|
|
26
|
+
SandboxDirectoryBot,
|
|
27
|
+
SandboxEntitySource,
|
|
28
|
+
} from '../../src/types'
|
|
29
|
+
import { buildSandboxBotDirectory } from '../environment/directory-model'
|
|
30
|
+
import { sourceName, useT } from '../i18n'
|
|
31
|
+
import {
|
|
32
|
+
FilterField,
|
|
33
|
+
JsonBlock,
|
|
34
|
+
MetaChips,
|
|
35
|
+
MetaList,
|
|
36
|
+
MetaRow,
|
|
37
|
+
RecordDetailHeader,
|
|
38
|
+
RecordDetailPane,
|
|
39
|
+
RecordItem,
|
|
40
|
+
RecordListPane,
|
|
41
|
+
RecordNotice,
|
|
42
|
+
RecordPage,
|
|
43
|
+
RecordSection,
|
|
44
|
+
RecordTag,
|
|
45
|
+
StatusBadge,
|
|
46
|
+
orderByTime,
|
|
47
|
+
useRecordRefresh,
|
|
48
|
+
type SortOrder,
|
|
49
|
+
} from '../records/record-layout'
|
|
50
|
+
import { SandboxAvatar } from '../shared/avatar'
|
|
51
|
+
import { useSandbox } from '../workspace/context'
|
|
52
|
+
import { errorText, invoke } from '../workspace/store'
|
|
53
|
+
import { useTestSpaces } from '../workspace/use-test-spaces'
|
|
54
|
+
import { implementationLabel } from '../shared/implementation'
|
|
55
|
+
|
|
56
|
+
type Direction = 'all' | 'action' | 'event'
|
|
57
|
+
|
|
58
|
+
interface Filters {
|
|
59
|
+
botKey: string
|
|
60
|
+
direction: Direction
|
|
61
|
+
action: string
|
|
62
|
+
requestedAction: string
|
|
63
|
+
errorsOnly: boolean
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const EMPTY_FILTERS: Filters = { botKey: 'all', direction: 'all', action: '', requestedAction: '', errorsOnly: false }
|
|
67
|
+
|
|
68
|
+
function sourceKey(source: SandboxEntitySource) {
|
|
69
|
+
return source.type === 'main' ? 'main' : `space:${source.spaceId}`
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function botKey(bot: SandboxDirectoryBot) {
|
|
73
|
+
return `${sourceKey(bot.source)}:${bot.id}`
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function recordKey(record: SandboxConsoleOneBotDebugRecord) {
|
|
77
|
+
return `${sourceKey(record.source)}:${record.id}`
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function countLargeValues(value: unknown): number {
|
|
81
|
+
if (!value || typeof value !== 'object') return 0
|
|
82
|
+
if (Reflect.get(value, 'kind') === 'large-value') return 1
|
|
83
|
+
return Object.values(value).reduce<number>((sum, item) => sum + countLargeValues(item), 0)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** OneBot 调试:被测插件经虚拟机器人发出的 action 与沙盒推送的原始事件,跨主环境与全部测试空间。 */
|
|
87
|
+
export function OneBotDebugPage() {
|
|
88
|
+
const t = useT()
|
|
89
|
+
const { view } = useSandbox()
|
|
90
|
+
const snapshot = view.workspace?.snapshot
|
|
91
|
+
const { spaces } = useTestSpaces()
|
|
92
|
+
const bots = React.useMemo(() => snapshot ? buildSandboxBotDirectory(snapshot, spaces) : [], [snapshot, spaces])
|
|
93
|
+
const [records, setRecords] = React.useState<SandboxConsoleOneBotDebugRecord[]>([])
|
|
94
|
+
const [detail, setDetail] = React.useState<SandboxConsoleOneBotDebugRecord>()
|
|
95
|
+
const [loading, setLoading] = React.useState(false)
|
|
96
|
+
const [detailLoading, setDetailLoading] = React.useState(false)
|
|
97
|
+
const [error, setError] = React.useState('')
|
|
98
|
+
const [filters, setFilters] = React.useState<Filters>(EMPTY_FILTERS)
|
|
99
|
+
const [order, setOrder] = React.useState<SortOrder>('desc')
|
|
100
|
+
const [filterOpen, setFilterOpen] = React.useState(false)
|
|
101
|
+
const [live, setLive] = React.useState(false)
|
|
102
|
+
|
|
103
|
+
const query = async (next: Filters = filters, nextOrder: SortOrder = order) => {
|
|
104
|
+
const input: GetSandboxOneBotDebugRecordsInput = {
|
|
105
|
+
botId: next.botKey === 'all' ? undefined : bots.find((bot) => botKey(bot) === next.botKey)?.id,
|
|
106
|
+
direction: next.direction === 'all' ? undefined : next.direction,
|
|
107
|
+
action: next.action.trim() || undefined,
|
|
108
|
+
requestedAction: next.requestedAction.trim() || undefined,
|
|
109
|
+
status: next.errorsOnly ? 'error' : undefined,
|
|
110
|
+
order: nextOrder,
|
|
111
|
+
}
|
|
112
|
+
setLoading(true)
|
|
113
|
+
try {
|
|
114
|
+
setRecords((await invoke('onebot-sandbox.debug-records', input)).records)
|
|
115
|
+
setError('')
|
|
116
|
+
} catch (failure) {
|
|
117
|
+
setError(errorText(failure, t('sandbox.debug.loadFailed')))
|
|
118
|
+
} finally {
|
|
119
|
+
setLoading(false)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const open = async (record: SandboxConsoleOneBotDebugRecord) => {
|
|
124
|
+
setDetailLoading(true)
|
|
125
|
+
try {
|
|
126
|
+
setDetail(await invoke('onebot-sandbox.debug-record', {
|
|
127
|
+
recordId: record.id,
|
|
128
|
+
includeLargeValues: true,
|
|
129
|
+
...(record.source.type === 'test-space' ? { spaceId: record.source.spaceId } : {}),
|
|
130
|
+
}))
|
|
131
|
+
setError('')
|
|
132
|
+
} catch (failure) {
|
|
133
|
+
setError(errorText(failure, t('sandbox.debug.detailFailed')))
|
|
134
|
+
} finally {
|
|
135
|
+
setDetailLoading(false)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const refresh = () => {
|
|
140
|
+
void query()
|
|
141
|
+
if (detail) void open(detail)
|
|
142
|
+
}
|
|
143
|
+
useRecordRefresh(live, refresh)
|
|
144
|
+
|
|
145
|
+
const update = (patch: Partial<Filters>, submit = false) => {
|
|
146
|
+
const next = { ...filters, ...patch }
|
|
147
|
+
setFilters(next)
|
|
148
|
+
if (submit) void query(next)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const active = filters.botKey !== 'all' || filters.direction !== 'all' || !!filters.action.trim() || !!filters.requestedAction.trim() || filters.errorsOnly
|
|
152
|
+
const summary = [
|
|
153
|
+
filters.botKey !== 'all' ? bots.find((bot) => botKey(bot) === filters.botKey)?.name ?? filters.botKey : '',
|
|
154
|
+
filters.direction !== 'all' ? t(`sandbox.debug.direction.${filters.direction}`) : '',
|
|
155
|
+
filters.action.trim(),
|
|
156
|
+
filters.requestedAction.trim(),
|
|
157
|
+
filters.errorsOnly ? t('sandbox.records.errorsOnly') : '',
|
|
158
|
+
].filter(Boolean).join(' · ') || t('sandbox.records.noFilter')
|
|
159
|
+
const botName = (record: SandboxConsoleOneBotDebugRecord) => bots.find((bot) => bot.id === record.botId && sourceKey(bot.source) === sourceKey(record.source))?.name ?? record.botId
|
|
160
|
+
const selected = detail ? recordKey(detail) : undefined
|
|
161
|
+
|
|
162
|
+
const botItems = [{ value: 'all', label: t('sandbox.debug.allBots') }, ...bots.map((bot) => ({ value: botKey(bot), label: `${bot.name} · ${bot.id} · ${sourceName(t, bot.source)}` }))]
|
|
163
|
+
const directionItems = (['all', 'action', 'event'] as const).map((value) => ({ value, label: t(`sandbox.debug.direction.${value}`) }))
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<RecordPage
|
|
167
|
+
title={t('sandbox.debug.title')}
|
|
168
|
+
description={t('sandbox.debug.description')}
|
|
169
|
+
loading={loading}
|
|
170
|
+
error={error}
|
|
171
|
+
live={live}
|
|
172
|
+
onLiveChange={setLive}
|
|
173
|
+
onRefresh={refresh}
|
|
174
|
+
clear={{
|
|
175
|
+
label: t('sandbox.debug.clear'),
|
|
176
|
+
title: t('sandbox.debug.clearTitle'),
|
|
177
|
+
description: t('sandbox.debug.clearDescription'),
|
|
178
|
+
disabled: !records.length,
|
|
179
|
+
onConfirm: async () => {
|
|
180
|
+
try {
|
|
181
|
+
await invoke('onebot-sandbox.clear-debug-records', {})
|
|
182
|
+
setDetail(undefined)
|
|
183
|
+
await query()
|
|
184
|
+
} catch (failure) {
|
|
185
|
+
setError(errorText(failure, t('sandbox.debug.clearFailed')))
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
}}
|
|
189
|
+
>
|
|
190
|
+
<RecordListPane
|
|
191
|
+
label={t('sandbox.records.list')}
|
|
192
|
+
order={order}
|
|
193
|
+
onToggleOrder={() => {
|
|
194
|
+
const next = order === 'desc' ? 'asc' : 'desc'
|
|
195
|
+
setOrder(next)
|
|
196
|
+
void query(filters, next)
|
|
197
|
+
}}
|
|
198
|
+
loading={loading}
|
|
199
|
+
empty={!records.length}
|
|
200
|
+
filter={{
|
|
201
|
+
active,
|
|
202
|
+
summary,
|
|
203
|
+
open: filterOpen,
|
|
204
|
+
onOpenChange: (next) => {
|
|
205
|
+
setFilterOpen(next)
|
|
206
|
+
if (!next) void query()
|
|
207
|
+
},
|
|
208
|
+
content: (
|
|
209
|
+
<>
|
|
210
|
+
<FilterField label={t('sandbox.debug.bot')}>
|
|
211
|
+
<Select value={filters.botKey} onValueChange={(value) => value && update({ botKey: value })} items={botItems}>
|
|
212
|
+
<SelectTrigger className="w-full"><SelectValue /></SelectTrigger>
|
|
213
|
+
<SelectContent className="sandbox-glass">
|
|
214
|
+
<SelectItem value="all">{t('sandbox.debug.allBots')}</SelectItem>
|
|
215
|
+
{bots.map((bot) => (
|
|
216
|
+
<SelectItem key={botKey(bot)} value={botKey(bot)}>
|
|
217
|
+
<SandboxAvatar kind="bot" name={bot.name} src={bot.avatar} className="size-5" badge={false} />
|
|
218
|
+
<span className="truncate">{bot.name} · {bot.id} · {sourceName(t, bot.source)}</span>
|
|
219
|
+
</SelectItem>
|
|
220
|
+
))}
|
|
221
|
+
</SelectContent>
|
|
222
|
+
</Select>
|
|
223
|
+
</FilterField>
|
|
224
|
+
<FilterField label={t('sandbox.debug.directionLabel')}>
|
|
225
|
+
<Select value={filters.direction} onValueChange={(value) => value && update({ direction: value as Direction })} items={directionItems}>
|
|
226
|
+
<SelectTrigger className="w-full"><SelectValue /></SelectTrigger>
|
|
227
|
+
<SelectContent className="sandbox-glass">
|
|
228
|
+
{directionItems.map((item) => <SelectItem key={item.value} value={item.value}>{item.label}</SelectItem>)}
|
|
229
|
+
</SelectContent>
|
|
230
|
+
</Select>
|
|
231
|
+
</FilterField>
|
|
232
|
+
<FilterField label={t('sandbox.debug.action')}>
|
|
233
|
+
<Input value={filters.action} placeholder="get_group_info" onChange={(event) => update({ action: event.target.value })} onKeyDown={(event) => event.key === 'Enter' && void query()} />
|
|
234
|
+
</FilterField>
|
|
235
|
+
<FilterField label={t('sandbox.debug.requestedAction')}>
|
|
236
|
+
<Input value={filters.requestedAction} placeholder="getGroupInfo" onChange={(event) => update({ requestedAction: event.target.value })} onKeyDown={(event) => event.key === 'Enter' && void query()} />
|
|
237
|
+
</FilterField>
|
|
238
|
+
<label className="flex items-center gap-2 text-xs">
|
|
239
|
+
<Checkbox checked={filters.errorsOnly} onCheckedChange={(checked) => update({ errorsOnly: checked === true }, true)} />
|
|
240
|
+
{t('sandbox.records.errorsOnly')}
|
|
241
|
+
</label>
|
|
242
|
+
<Button variant="outline" size="sm" onClick={() => {
|
|
243
|
+
setFilters(EMPTY_FILTERS)
|
|
244
|
+
void query(EMPTY_FILTERS)
|
|
245
|
+
}}>{t('sandbox.records.reset')}</Button>
|
|
246
|
+
</>
|
|
247
|
+
),
|
|
248
|
+
}}
|
|
249
|
+
>
|
|
250
|
+
{orderByTime(records, order, (left, right) => left.sequence - right.sequence).map((record) => (
|
|
251
|
+
<RecordItem
|
|
252
|
+
key={recordKey(record)}
|
|
253
|
+
active={recordKey(record) === selected}
|
|
254
|
+
onClick={() => void open(record)}
|
|
255
|
+
title={record.requestedAction}
|
|
256
|
+
status={record.status}
|
|
257
|
+
tag={record.direction.toUpperCase()}
|
|
258
|
+
time={record.createdAt}
|
|
259
|
+
duration={record.durationMs}
|
|
260
|
+
meta={[sourceName(t, record.source)]}
|
|
261
|
+
/>
|
|
262
|
+
))}
|
|
263
|
+
</RecordListPane>
|
|
264
|
+
<RecordDetailPane
|
|
265
|
+
label={t('sandbox.records.detail')}
|
|
266
|
+
loading={detailLoading}
|
|
267
|
+
scrollKey={selected}
|
|
268
|
+
header={detail && (
|
|
269
|
+
<RecordDetailHeader
|
|
270
|
+
title={detail.requestedAction}
|
|
271
|
+
time={detail.createdAt}
|
|
272
|
+
duration={detail.durationMs}
|
|
273
|
+
badges={<><StatusBadge status={detail.status} /><RecordTag>{detail.direction.toUpperCase()}</RecordTag></>}
|
|
274
|
+
/>
|
|
275
|
+
)}
|
|
276
|
+
>
|
|
277
|
+
{detail && <DebugDetail record={detail} botName={botName(detail)} />}
|
|
278
|
+
</RecordDetailPane>
|
|
279
|
+
</RecordPage>
|
|
280
|
+
)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** 详情正文;标题栏由页面交给 `RecordDetailPane` 的 `header`。 */
|
|
284
|
+
export function DebugDetail({ record, botName }: { record: SandboxConsoleOneBotDebugRecord, botName: string }) {
|
|
285
|
+
const t = useT()
|
|
286
|
+
const entities = Object.entries(record.entities).filter((entry): entry is [string, string] => Boolean(entry[1]))
|
|
287
|
+
const observation = record.conversationObservation
|
|
288
|
+
const isAction = record.direction === 'action'
|
|
289
|
+
return (
|
|
290
|
+
<>
|
|
291
|
+
{record.error && (
|
|
292
|
+
<RecordNotice icon={CircleAlertIcon} title={t('sandbox.records.diagnosis')} tone="destructive">
|
|
293
|
+
<span className="font-mono">{record.error.code}</span> · {record.error.message}
|
|
294
|
+
<span className="mt-0.5 block font-mono text-[11px]">trace {record.error.traceId}</span>
|
|
295
|
+
</RecordNotice>
|
|
296
|
+
)}
|
|
297
|
+
{observation && (
|
|
298
|
+
<RecordNotice icon={GitBranchIcon} title={t(`sandbox.debug.observation.${observation.kind}.title`)}>
|
|
299
|
+
{t(`sandbox.debug.observation.${observation.kind}.detail`, { event: observation.eventConversationId, actual: observation.conversationId })}
|
|
300
|
+
</RecordNotice>
|
|
301
|
+
)}
|
|
302
|
+
<MetaList>
|
|
303
|
+
<MetaRow icon={BotIcon} label={t('sandbox.debug.bot')} value={<>{botName} <span className="font-mono font-normal text-muted-foreground">{record.botId}</span></>} />
|
|
304
|
+
<MetaRow icon={BoxIcon} label={t('sandbox.debug.source')} value={sourceName(t, record.source)} />
|
|
305
|
+
<MetaRow icon={CpuIcon} label={t('sandbox.debug.implementation')} value={implementationLabel(record.implementation)} />
|
|
306
|
+
{record.action !== record.requestedAction && <MetaRow icon={ArrowRightIcon} label={t('sandbox.debug.action')} value={<span className="font-mono">{record.action}</span>} />}
|
|
307
|
+
{record.matchedAlias && <MetaRow icon={TagIcon} label={t('sandbox.debug.alias')} value={<span className="font-mono">{record.matchedAlias}</span>} />}
|
|
308
|
+
<MetaRow
|
|
309
|
+
icon={LinkIcon}
|
|
310
|
+
label={t('sandbox.debug.entities')}
|
|
311
|
+
wide
|
|
312
|
+
value={entities.length ? <MetaChips items={entities} /> : <span className="font-normal text-muted-foreground">{t('sandbox.debug.noEntities')}</span>}
|
|
313
|
+
/>
|
|
314
|
+
</MetaList>
|
|
315
|
+
{record.payload !== undefined && (
|
|
316
|
+
<RecordSection icon={BracesIcon} title={t(isAction ? 'sandbox.debug.input' : 'sandbox.debug.eventData')}>
|
|
317
|
+
<JsonBlock value={record.payload} />
|
|
318
|
+
{countLargeValues(record.payload) > 0 && <p className="text-[11px] text-muted-foreground">{t('sandbox.debug.folded', { count: countLargeValues(record.payload) })}</p>}
|
|
319
|
+
</RecordSection>
|
|
320
|
+
)}
|
|
321
|
+
{record.result !== undefined && (
|
|
322
|
+
<RecordSection icon={BracesIcon} title={t(isAction ? 'sandbox.debug.output' : 'sandbox.debug.handled')}>
|
|
323
|
+
<JsonBlock value={record.result} />
|
|
324
|
+
{countLargeValues(record.result) > 0 && <p className="text-[11px] text-muted-foreground">{t('sandbox.debug.folded', { count: countLargeValues(record.result) })}</p>}
|
|
325
|
+
</RecordSection>
|
|
326
|
+
)}
|
|
327
|
+
</>
|
|
328
|
+
)
|
|
329
|
+
}
|