dsh-agent-control-center 0.1.0 → 0.3.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/CHANGELOG.md +116 -0
- package/README.md +217 -83
- package/README.zh.md +159 -58
- package/client.js +7660 -2005
- package/cordis.patch.yml +5 -0
- package/docs/01-CONTRACT.md +3 -2
- package/docs/05-ACCEPTANCE-EVIDENCE.md +81 -0
- package/docs/06-UX-OPTIMIZATION.md +57 -0
- package/docs/07-GUIDE.md +327 -0
- package/docs/08-COMPATIBILITY.md +202 -0
- package/docs/09-ARCHITECTURE.md +333 -0
- package/docs/ROADMAP.md +448 -0
- package/index.js +67 -2
- package/lib/core/cache.js +277 -0
- package/lib/core/compat.js +877 -0
- package/lib/core/errors.js +14 -1
- package/lib/core/http.js +22 -0
- package/lib/core/index.js +53 -2
- package/lib/core/paths.js +6 -0
- package/lib/core/registry.js +21 -5
- package/lib/core/util.js +4 -1
- package/lib/modules/a-agents.js +104 -4
- package/lib/modules/b-tools.js +169 -26
- package/lib/modules/f-diagnostics.js +109 -17
- package/lib/modules/g-templates.js +18 -0
- package/lib/modules/i-recovery.js +84 -23
- package/lib/modules/j-instruction.js +624 -0
- package/lib/modules/k-export.js +540 -0
- package/package.json +1 -1
- package/scripts/release.mjs +81 -0
- package/scripts/verify.mjs +12 -0
- package/src/client/app.js +684 -118
- package/src/client/i18n/agents.js +96 -0
- package/src/client/i18n/common.js +36 -0
- package/src/client/i18n/diagnostics.js +52 -0
- package/src/client/i18n/export.js +174 -0
- package/src/client/i18n/instruction.js +236 -0
- package/src/client/i18n/meta.js +72 -0
- package/src/client/i18n/overview.js +38 -0
- package/src/client/i18n/recovery.js +66 -0
- package/src/client/i18n/sessions.js +64 -0
- package/src/client/i18n/templates.js +88 -0
- package/src/client/i18n/tools.js +96 -0
- package/src/client/i18n/usage.js +42 -0
- package/src/client/kernel.js +327 -40
- package/src/client/pages/agents.js +637 -354
- package/src/client/pages/diagnostics.js +526 -177
- package/src/client/pages/export.js +664 -0
- package/src/client/pages/instruction.js +648 -0
- package/src/client/pages/meta.js +553 -193
- package/src/client/pages/overview.js +255 -34
- package/src/client/pages/recovery.js +332 -131
- package/src/client/pages/sessions.js +470 -307
- package/src/client/pages/templates.js +691 -381
- package/src/client/pages/tools.js +559 -206
- package/src/client/pages/usage.js +235 -57
|
@@ -1,11 +1,62 @@
|
|
|
1
1
|
/* Tools page — read-only registry inventory with the three status layers
|
|
2
|
-
* (registered / visible to the selected Agent / called in history).
|
|
3
|
-
*
|
|
2
|
+
* (registered / visible to the selected Agent / called in history).
|
|
3
|
+
*
|
|
4
|
+
* Interaction rules kept here:
|
|
5
|
+
* - The inventory is filterable and never calls a probe.
|
|
6
|
+
* - A tool row is one button (`aria-expanded`) that opens the detail card;
|
|
7
|
+
* `/` focuses the search field and Esc collapses the open detail.
|
|
8
|
+
* - Every unavailable block shows its reason instead of a 0.
|
|
9
|
+
* - Schema text and evidence rows are copyable, so a report can quote them. */
|
|
4
10
|
(function toolsPage() {
|
|
5
|
-
/* Layout only: the host scrolls the content column, so
|
|
6
|
-
* height/overflow. Colors/typography come from the shared acc-* classes. */
|
|
11
|
+
/* Layout only: the host scrolls the content column, so the page never takes
|
|
12
|
+
* over height/overflow. Colors/typography come from the shared acc-* classes. */
|
|
7
13
|
const PAGE_STYLE = { display: 'flex', flexDirection: 'column', gap: '12px', padding: '8px 0' }
|
|
8
14
|
const STACK_STYLE = { display: 'flex', flexDirection: 'column', gap: '12px' }
|
|
15
|
+
const CLAMP_STYLE = { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', display: 'inline-block', maxWidth: '260px' }
|
|
16
|
+
|
|
17
|
+
/** Host prose is folded in the English UI; ASCII host text stays inline. */
|
|
18
|
+
function hostInline(text, t, mappingKey) {
|
|
19
|
+
const raw = text === null || text === undefined ? '' : String(text)
|
|
20
|
+
if (raw.length === 0) return ''
|
|
21
|
+
if (mappingKey !== undefined) {
|
|
22
|
+
const mapped = ACC.l10n.host(mappingKey, raw)
|
|
23
|
+
if (mapped.length > 0) return mapped
|
|
24
|
+
}
|
|
25
|
+
if (ACC.l10n.lang() === 'en' && ACC.l10n.hasCjk(raw)) return ''
|
|
26
|
+
return raw
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** @param {{ text: unknown, t: Function }} props */
|
|
30
|
+
function RawFold(props) {
|
|
31
|
+
return ACC.l10n.raw(props.t('tools.rawHostText'), props.text)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Collapsed explanation block so the inventory stays on the first screen. */
|
|
35
|
+
function InfoPanel(props) {
|
|
36
|
+
const [open, setOpen] = ACC.useState(false)
|
|
37
|
+
return h(
|
|
38
|
+
'div',
|
|
39
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: '4px' } },
|
|
40
|
+
h(
|
|
41
|
+
'button',
|
|
42
|
+
{
|
|
43
|
+
type: 'button',
|
|
44
|
+
onClick: () => setOpen((value) => !value),
|
|
45
|
+
'aria-expanded': open,
|
|
46
|
+
style: { display: 'flex', alignItems: 'center', gap: '6px', padding: 0, border: 0, background: 'transparent', color: 'inherit', font: 'inherit', fontSize: '11px', cursor: 'pointer', textAlign: 'left' },
|
|
47
|
+
},
|
|
48
|
+
h('span', { 'aria-hidden': 'true' }, open ? '▾' : '▸'),
|
|
49
|
+
h('span', { className: 'acc-muted' }, `${props.t('tools.aboutTitle')} - ${props.t('tools.aboutSummary')}`),
|
|
50
|
+
),
|
|
51
|
+
open
|
|
52
|
+
? h(
|
|
53
|
+
'ul',
|
|
54
|
+
{ style: { margin: 0, paddingLeft: '18px', display: 'flex', flexDirection: 'column', gap: '2px', fontSize: '11px', color: 'var(--dsw-alias-label-secondary, #61666b)' } },
|
|
55
|
+
props.items.map((text, index) => h('li', { key: String(index) }, text)),
|
|
56
|
+
)
|
|
57
|
+
: null,
|
|
58
|
+
)
|
|
59
|
+
}
|
|
9
60
|
|
|
10
61
|
/** @param {string} value @param {Function} t */
|
|
11
62
|
function statusBadge(value, t) {
|
|
@@ -14,12 +65,31 @@
|
|
|
14
65
|
return h(C.Badge, { tone, title: String(value) }, label)
|
|
15
66
|
}
|
|
16
67
|
|
|
68
|
+
/**
|
|
69
|
+
* A named layer badge ("✓ registered" / "✗ visible") so three yes/no badges
|
|
70
|
+
* in a row stay distinguishable without hovering.
|
|
71
|
+
* @param {{ label: string, value: string, t: Function }} props
|
|
72
|
+
*/
|
|
73
|
+
function layerBadge(props) {
|
|
74
|
+
const tone = props.value === 'yes' ? 'success' : props.value === 'no' ? 'neutral' : 'warn'
|
|
75
|
+
const glyph = props.value === 'yes' ? '✓' : props.value === 'no' ? '✗' : '?'
|
|
76
|
+
const text = props.value === 'yes' ? props.t('tools.yes') : props.value === 'no' ? props.t('tools.no') : props.value === 'unknown' ? props.t('tools.unknown') : props.t('common.unavailable')
|
|
77
|
+
return h(C.Badge, { tone, title: `${props.label}: ${text}` }, `${glyph} ${props.label}`)
|
|
78
|
+
}
|
|
79
|
+
|
|
17
80
|
/** @param {unknown} rate @param {Function} t */
|
|
18
|
-
function
|
|
19
|
-
if (rate === null || typeof rate !== 'object') return
|
|
81
|
+
function rateValue(rate) {
|
|
82
|
+
if (rate === null || typeof rate !== 'object') return null
|
|
20
83
|
const source = /** @type {Record<string, any>} */ (rate)
|
|
21
|
-
if (source.available === true && typeof source.value === 'number') return
|
|
22
|
-
return
|
|
84
|
+
if (source.available === true && typeof source.value === 'number') return source.value
|
|
85
|
+
return null
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** @param {unknown} rate @param {Function} t */
|
|
89
|
+
function rateText(rate, t) {
|
|
90
|
+
const value = rateValue(rate)
|
|
91
|
+
if (value === null) return String(t('common.unavailable'))
|
|
92
|
+
return `${(value * 100).toFixed(1)}%`
|
|
23
93
|
}
|
|
24
94
|
|
|
25
95
|
/** @param {number | null | undefined} value */
|
|
@@ -29,20 +99,82 @@
|
|
|
29
99
|
return `${(value / 1000).toFixed(2)} s`
|
|
30
100
|
}
|
|
31
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Share of one cluster inside the failed calls of the window, rendered as a
|
|
104
|
+
* bar with the exact numbers in its text alternative.
|
|
105
|
+
* @param {{ count: number, total: number, t: Function }} props
|
|
106
|
+
*/
|
|
107
|
+
function RatioBar(props) {
|
|
108
|
+
const total = props.total > 0 ? props.total : 0
|
|
109
|
+
const ratio = total === 0 ? 0 : Math.min(1, props.count / total)
|
|
110
|
+
const percent = total === 0 ? '0' : (ratio * 100).toFixed(0)
|
|
111
|
+
const label = props.t('tools.clusterShare', { count: props.count, percent })
|
|
112
|
+
return h(
|
|
113
|
+
'div',
|
|
114
|
+
{ style: { display: 'flex', alignItems: 'center', gap: '8px', minWidth: '150px' } },
|
|
115
|
+
h(
|
|
116
|
+
'div',
|
|
117
|
+
{ className: 'acc-bar', role: 'img', 'aria-label': label, title: label, style: { flex: '1 1 auto' } },
|
|
118
|
+
h('div', { className: 'acc-bar-fill is-danger', style: { width: `${Math.round(ratio * 100)}%` } }),
|
|
119
|
+
),
|
|
120
|
+
h('span', { className: 'acc-muted', style: { fontVariantNumeric: 'tabular-nums' } }, `${percent}%`),
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Copy one block of evidence text; feedback is inline, not a toast. */
|
|
125
|
+
function CopyButton(props) {
|
|
126
|
+
const [state, setState] = ACC.useState('idle')
|
|
127
|
+
const copy = ACC.useCallback(() => {
|
|
128
|
+
const text = String(props.text || '')
|
|
129
|
+
const finish = (next) => setState(next)
|
|
130
|
+
if (text.length === 0) {
|
|
131
|
+
finish('failed')
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
|
135
|
+
navigator.clipboard.writeText(text).then(() => finish('done'), () => finish('failed'))
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
finish('failed')
|
|
139
|
+
}, [props.text])
|
|
140
|
+
ACC.useEffect(() => {
|
|
141
|
+
if (state === 'idle') return undefined
|
|
142
|
+
const timer = setTimeout(() => setState('idle'), 1800)
|
|
143
|
+
return () => clearTimeout(timer)
|
|
144
|
+
}, [state])
|
|
145
|
+
const label = state === 'done' ? props.t('tools.copied') : state === 'failed' ? props.t('tools.copyFailed') : props.label || props.t('tools.copy')
|
|
146
|
+
return h(C.Btn, { tone: 'ghost', onClick: copy, title: label, 'aria-live': 'polite' }, label)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Esc collapses the open detail panel while it is open. */
|
|
150
|
+
function useEscape(active, onEscape) {
|
|
151
|
+
ACC.useEffect(() => {
|
|
152
|
+
if (!active) return undefined
|
|
153
|
+
const handler = (event) => {
|
|
154
|
+
if (event.key !== 'Escape') return
|
|
155
|
+
event.stopPropagation()
|
|
156
|
+
onEscape()
|
|
157
|
+
}
|
|
158
|
+
document.addEventListener('keydown', handler)
|
|
159
|
+
return () => document.removeEventListener('keydown', handler)
|
|
160
|
+
}, [active, onEscape])
|
|
161
|
+
}
|
|
162
|
+
|
|
32
163
|
/** @param {{ value: unknown, onOpen: Function, t: Function }} props */
|
|
33
164
|
function SourceBadge(props) {
|
|
34
165
|
const source = props.value || {}
|
|
35
166
|
const tone = source.kind === 'mcp' ? 'info' : source.kind === 'global' ? 'neutral' : source.kind === 'scoped' ? 'warn' : 'neutral'
|
|
36
167
|
const label = source.kind === 'mcp' ? `MCP${source.server ? ` · ${source.server}` : ''}` : source.kind === 'global' ? props.t('tools.sourceGlobal') : source.kind === 'scoped' ? props.t('tools.sourceScoped') : props.t('tools.sourceUnknown')
|
|
37
|
-
return h(C.Badge, { tone, title:
|
|
168
|
+
return h(C.Badge, { tone, title: hostInline(source.basis, props.t) || undefined }, label)
|
|
38
169
|
}
|
|
39
170
|
|
|
40
|
-
/** @param {{ detail: any, t: Function }} props */
|
|
171
|
+
/** @param {{ detail: any, t: Function, onClose: Function }} props */
|
|
41
172
|
function DetailBody(props) {
|
|
42
|
-
const { detail, t } = props
|
|
173
|
+
const { detail, t, onClose } = props
|
|
43
174
|
const definition = detail.definition || {}
|
|
44
175
|
const history = detail.history || {}
|
|
45
176
|
const checks = detail.checks || {}
|
|
177
|
+
const status = detail.status || {}
|
|
46
178
|
const clusters = Array.isArray(history.errorClusters) ? history.errorClusters : []
|
|
47
179
|
const samples = Array.isArray(history.failureSamples) ? history.failureSamples : []
|
|
48
180
|
const agents = Array.isArray(detail.visibility && detail.visibility.agents) ? detail.visibility.agents : []
|
|
@@ -50,77 +182,114 @@
|
|
|
50
182
|
const parameters = detail.schema && detail.schema.parameters
|
|
51
183
|
const outputSchema = detail.schema && detail.schema.outputSchema
|
|
52
184
|
const issues = Array.isArray(definition.issues) ? definition.issues : []
|
|
185
|
+
const failures = typeof history.failures === 'number' ? history.failures : 0
|
|
186
|
+
const clusterMax = clusters.reduce((max, cluster) => Math.max(max, Number(cluster.count) || 0), 0)
|
|
187
|
+
const schemaText = parameters === null || parameters === undefined ? '' : String(parameters.text || '')
|
|
53
188
|
|
|
54
189
|
return h(
|
|
55
190
|
'div',
|
|
56
|
-
{ style:
|
|
57
|
-
h(C.Notice, { tone: 'info' }, t('tools.probeNotice')),
|
|
58
|
-
h(
|
|
59
|
-
C.Card,
|
|
60
|
-
{ title: t('tools.detailChecks') },
|
|
61
|
-
definition.available === false
|
|
62
|
-
? h(C.Notice, { tone: 'warn' }, String(definition.reason || ''))
|
|
63
|
-
: h(C.KeyValues, {
|
|
64
|
-
items: [
|
|
65
|
-
{ label: t('tools.definitionComplete'), value: statusBadge(definition.definitionComplete === true ? 'yes' : 'no', t) },
|
|
66
|
-
{ label: t('tools.schemaParsable'), value: statusBadge(definition.schemaParsable === true ? 'yes' : 'no', t) },
|
|
67
|
-
{ label: t('tools.executablePresent'), value: statusBadge(definition.hasExecute === true ? 'yes' : 'no', t) },
|
|
68
|
-
{ label: t('tools.nameUnique'), value: statusBadge(checks.nameUnique === true ? 'yes' : checks.nameUnique === false ? 'no' : 'unknown', t) },
|
|
69
|
-
{ label: t('tools.parameterCount'), value: String(definition.parameterCount === undefined ? '—' : definition.parameterCount) },
|
|
70
|
-
{ label: t('tools.definitionTimeout'), value: definition.timeoutMs === null || definition.timeoutMs === undefined ? '—' : msText(definition.timeoutMs) },
|
|
71
|
-
{ label: t('tools.shadowedIn'), value: Array.isArray(checks.shadowedIn) && checks.shadowedIn.length > 0 ? checks.shadowedIn.join(', ') : t('common.none') },
|
|
72
|
-
],
|
|
73
|
-
}),
|
|
74
|
-
issues.length === 0
|
|
75
|
-
? h(C.Notice, { tone: 'success' }, t('tools.noIssues'))
|
|
76
|
-
: h(C.Table, {
|
|
77
|
-
columns: [
|
|
78
|
-
{ key: 'code', label: t('tools.issueCode'), render: (row) => h('span', { className: 'acc-mono' }, row.code) },
|
|
79
|
-
{ key: 'message', label: t('tools.issueMessage') },
|
|
80
|
-
],
|
|
81
|
-
rows: issues,
|
|
82
|
-
rowKey: 'code',
|
|
83
|
-
}),
|
|
84
|
-
),
|
|
85
|
-
h(
|
|
86
|
-
C.Card,
|
|
87
|
-
{ title: t('tools.statusTitle') },
|
|
88
|
-
h(C.KeyValues, {
|
|
89
|
-
items: [
|
|
90
|
-
{ label: t('tools.registered'), value: statusBadge(detail.status.registered === 'yes' ? 'yes' : 'no', t) },
|
|
91
|
-
{ label: t('tools.registeredWhere'), value: Array.isArray(detail.registeredWhere) && detail.registeredWhere.length > 0 ? detail.registeredWhere.join(', ') : '—' },
|
|
92
|
-
{ label: t('tools.visible'), value: statusBadge(detail.status.visibleToCurrentAgent, t) },
|
|
93
|
-
{ label: t('tools.called'), value: statusBadge(detail.status.called, t) },
|
|
94
|
-
{ label: t('tools.source'), value: h(SourceBadge, { value: detail.source, t }) },
|
|
95
|
-
{ label: t('tools.visibilityBasis'), value: String((detail.visibility && detail.visibility.basis) || '') },
|
|
96
|
-
],
|
|
97
|
-
}),
|
|
98
|
-
detail.visibility && detail.visibility.currentAgent && detail.visibility.currentAgent.available === false
|
|
99
|
-
? h(C.Notice, { tone: 'warn' }, `${t('tools.noAgent')} ${String(detail.visibility.currentAgent.reason || '')}`)
|
|
100
|
-
: null,
|
|
101
|
-
),
|
|
191
|
+
{ style: STACK_STYLE },
|
|
102
192
|
h(
|
|
103
|
-
|
|
104
|
-
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
rows: agents,
|
|
115
|
-
rowKey: 'id',
|
|
116
|
-
}),
|
|
193
|
+
'div',
|
|
194
|
+
{ className: 'acc-row', style: { justifyContent: 'space-between' } },
|
|
195
|
+
h(
|
|
196
|
+
'div',
|
|
197
|
+
{ className: 'acc-row' },
|
|
198
|
+
statusBadge(status.registered, t),
|
|
199
|
+
statusBadge(status.visibleToCurrentAgent, t),
|
|
200
|
+
statusBadge(status.called, t),
|
|
201
|
+
h(SourceBadge, { value: detail.source, t }),
|
|
202
|
+
),
|
|
203
|
+
h(C.Btn, { tone: 'ghost', onClick: onClose, title: t('tools.closeDetailHint') }, t('tools.closeDetail')),
|
|
117
204
|
),
|
|
118
|
-
h(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
205
|
+
h(C.Notice, { tone: 'info' }, t('tools.probeNotice')),
|
|
206
|
+
h('h4', { className: 'acc-section-title' }, t('tools.sectionStatus')),
|
|
207
|
+
h(C.KeyValues, {
|
|
208
|
+
items: [
|
|
209
|
+
{ label: t('tools.registeredWhere'), value: Array.isArray(detail.registeredWhere) && detail.registeredWhere.length > 0 ? detail.registeredWhere.join(', ') : '—' },
|
|
210
|
+
{
|
|
211
|
+
label: t('tools.visibilityBasis'),
|
|
212
|
+
value: h(
|
|
213
|
+
'div',
|
|
214
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: '2px' } },
|
|
215
|
+
h('span', null, hostInline(detail.visibility && detail.visibility.basis, t, 'tools.basisGeneric')),
|
|
216
|
+
h(RawFold, { text: detail.visibility && detail.visibility.basis, t }),
|
|
217
|
+
),
|
|
218
|
+
},
|
|
219
|
+
{ label: t('tools.conditional'), value: detail.conditional === true ? t('tools.conditionalTool') : detail.conditional === false ? t('tools.unconditionalTool') : t('common.unknown') },
|
|
220
|
+
],
|
|
221
|
+
}),
|
|
222
|
+
detail.visibility && detail.visibility.currentAgent && detail.visibility.currentAgent.available === false
|
|
223
|
+
? h(C.Notice, { tone: 'warn' }, `${t('tools.noAgent')} ${String(detail.visibility.currentAgent.reason || '')}`)
|
|
224
|
+
: null,
|
|
225
|
+
h('h4', { className: 'acc-section-title' }, t('tools.sectionDefinition')),
|
|
226
|
+
definition.available === false
|
|
227
|
+
? h(C.Notice, { tone: 'warn' }, hostInline(definition.reason, t, 'tools.definitionUnavailable'), h(RawFold, { text: definition.reason, t }))
|
|
228
|
+
: h(C.KeyValues, {
|
|
229
|
+
items: [
|
|
230
|
+
{ label: t('tools.definitionComplete'), value: statusBadge(definition.definitionComplete === true ? 'yes' : 'no', t) },
|
|
231
|
+
{ label: t('tools.schemaParsable'), value: statusBadge(definition.schemaParsable === true ? 'yes' : 'no', t) },
|
|
232
|
+
{ label: t('tools.executablePresent'), value: statusBadge(definition.hasExecute === true ? 'yes' : 'no', t) },
|
|
233
|
+
{ label: t('tools.nameUnique'), value: statusBadge(checks.nameUnique === true ? 'yes' : checks.nameUnique === false ? 'no' : 'unknown', t) },
|
|
234
|
+
{ label: t('tools.parameterCount'), value: String(definition.parameterCount === undefined ? '—' : definition.parameterCount) },
|
|
235
|
+
{ label: t('tools.definitionTimeout'), value: definition.timeoutMs === null || definition.timeoutMs === undefined ? '—' : msText(definition.timeoutMs) },
|
|
236
|
+
{ label: t('tools.shadowedIn'), value: Array.isArray(checks.shadowedIn) && checks.shadowedIn.length > 0 ? checks.shadowedIn.join(', ') : t('common.none') },
|
|
237
|
+
],
|
|
238
|
+
}),
|
|
239
|
+
issues.length === 0
|
|
240
|
+
? h(C.Notice, { tone: 'success' }, t('tools.noIssues'))
|
|
241
|
+
: h(C.Table, {
|
|
242
|
+
columns: [
|
|
243
|
+
{ key: 'code', label: t('tools.issueCode'), render: (row) => h('span', { className: 'acc-mono' }, row.code) },
|
|
244
|
+
{
|
|
245
|
+
key: 'message',
|
|
246
|
+
label: t('tools.issueMessage'),
|
|
247
|
+
render: (row) =>
|
|
248
|
+
h(
|
|
249
|
+
'div',
|
|
250
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: '2px' } },
|
|
251
|
+
h('span', { title: String(row.message || '') }, hostInline(row.message, t, `tools.issue.${row.code}`)),
|
|
252
|
+
h(RawFold, { text: row.message, t }),
|
|
253
|
+
),
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
rows: issues,
|
|
257
|
+
rowKey: 'code',
|
|
258
|
+
}),
|
|
259
|
+
h('h4', { className: 'acc-section-title' }, t('tools.sectionVisibility')),
|
|
260
|
+
agents.length === 0
|
|
261
|
+
? h(C.Empty, { title: t('tools.noAgents'), hint: t('tools.noAgentsHint') })
|
|
262
|
+
: h(C.Table, {
|
|
263
|
+
columns: [
|
|
264
|
+
{
|
|
265
|
+
key: 'id',
|
|
266
|
+
label: t('tools.agent'),
|
|
267
|
+
render: (row) =>
|
|
268
|
+
h(
|
|
269
|
+
'div',
|
|
270
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: '1px' } },
|
|
271
|
+
h('span', { className: 'acc-mono' }, String(row.id)),
|
|
272
|
+
h(
|
|
273
|
+
'span',
|
|
274
|
+
{ className: 'acc-muted', style: { fontSize: '11px', ...CLAMP_STYLE, maxWidth: '180px' }, title: String(row.basis || '') },
|
|
275
|
+
row.visible === true
|
|
276
|
+
? row.conditional === true ? t('tools.conditionalTool') : row.conditional === false ? t('tools.unconditionalTool') : t('common.unknown')
|
|
277
|
+
: String(row.basis || '—'),
|
|
278
|
+
),
|
|
279
|
+
),
|
|
280
|
+
},
|
|
281
|
+
{ key: 'visible', label: t('tools.visible'), render: (row) => (row.available === false ? h(C.Badge, { tone: 'warn', title: String(row.reason || '') }, t('common.unavailable')) : statusBadge(row.visible === true ? 'yes' : 'no', t)) },
|
|
282
|
+
],
|
|
283
|
+
rows: agents,
|
|
284
|
+
rowKey: 'id',
|
|
285
|
+
}),
|
|
286
|
+
presets.length === 0
|
|
287
|
+
? null
|
|
288
|
+
: h(
|
|
289
|
+
'div',
|
|
290
|
+
{ style: STACK_STYLE },
|
|
291
|
+
h('div', { className: 'acc-muted' }, `${t('tools.visibilityPresets')} · ${presets.length}`),
|
|
292
|
+
h(C.Table, {
|
|
124
293
|
columns: [
|
|
125
294
|
{ key: 'id', label: t('tools.preset'), render: (row) => h('span', { className: 'acc-mono' }, String(row.id)) },
|
|
126
295
|
{ key: 'visible', label: t('tools.visible'), render: (row) => (row.available === false ? h(C.Badge, { tone: 'warn', title: String(row.reason || '') }, t('common.unavailable')) : statusBadge(row.visible === true ? 'yes' : 'no', t)) },
|
|
@@ -128,76 +297,150 @@
|
|
|
128
297
|
rows: presets,
|
|
129
298
|
rowKey: 'id',
|
|
130
299
|
}),
|
|
131
|
-
|
|
132
|
-
h(
|
|
133
|
-
|
|
134
|
-
{
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
300
|
+
),
|
|
301
|
+
h('h4', { className: 'acc-section-title' }, t('tools.sectionHistory')),
|
|
302
|
+
history.available === false
|
|
303
|
+
? h(C.Notice, { tone: 'warn' }, `${t('tools.historyUnavailable')} ${hostInline(history.reason, t, 'tools.historyUnavailableReason')}`, h(RawFold, { text: history.reason, t }))
|
|
304
|
+
: h(
|
|
305
|
+
'div',
|
|
306
|
+
{ style: STACK_STYLE },
|
|
307
|
+
h(C.KeyValues, {
|
|
308
|
+
items: [
|
|
309
|
+
{ label: t('tools.calls'), value: String(history.calls) },
|
|
310
|
+
{ label: t('tools.successes'), value: String(history.successes) },
|
|
311
|
+
{ label: t('tools.failures'), value: String(history.failures) },
|
|
312
|
+
{ label: t('tools.unpaired'), value: h('span', { title: t('tools.unpairedHint') }, String(history.unpaired)) },
|
|
313
|
+
{ label: t('tools.successRate'), value: rateText(history.successRate, t) },
|
|
314
|
+
{ label: t('tools.lastCall'), value: history.lastCallAt ? ACC.fmt.dateTime(history.lastCallAt) : '—' },
|
|
315
|
+
{
|
|
316
|
+
label: t('tools.duration'),
|
|
317
|
+
value: history.duration && history.duration.available === true ? `${t('tools.durationMedian')} ${msText(history.duration.medianMs)}` : String(t('common.unavailable')),
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
}),
|
|
321
|
+
history.duration && history.duration.available === true
|
|
322
|
+
? h(
|
|
323
|
+
C.Notice,
|
|
324
|
+
{ tone: 'info' },
|
|
325
|
+
`${t('tools.durationSamples')} ${history.duration.samples} · ${t('tools.durationAvg')} ${msText(history.duration.avgMs)} · ${t('tools.durationMax')} ${msText(history.duration.maxMs)}`,
|
|
326
|
+
h(RawFold, { text: history.duration.basis, t }),
|
|
327
|
+
)
|
|
328
|
+
: h(C.Notice, { tone: 'warn' }, String((history.duration && history.duration.reason) || t('tools.durationUnavailable'))),
|
|
329
|
+
history.errorState && history.errorState.available === false
|
|
330
|
+
? h(C.Notice, { tone: 'info' }, `${t('tools.historyNoErrorState')} ${hostInline(history.errorState.reason, t, 'tools.errorStateReason')}`, h(RawFold, { text: history.errorState.reason, t }))
|
|
331
|
+
: null,
|
|
332
|
+
),
|
|
333
|
+
history.available === false
|
|
334
|
+
? null
|
|
335
|
+
: h(
|
|
336
|
+
'div',
|
|
337
|
+
{ style: STACK_STYLE },
|
|
338
|
+
h('div', { className: 'acc-row', style: { justifyContent: 'space-between' } },
|
|
339
|
+
h('h4', { className: 'acc-section-title' }, t('tools.errorDistribution')),
|
|
340
|
+
h('span', { className: 'acc-muted' }, t('tools.errorsTotal', { count: failures })),
|
|
341
|
+
),
|
|
342
|
+
clusters.length === 0
|
|
343
|
+
? h(C.Notice, { tone: 'success' }, t('tools.noErrors'))
|
|
344
|
+
: h(
|
|
345
|
+
'div',
|
|
346
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: '6px' } },
|
|
347
|
+
h(
|
|
348
|
+
'div',
|
|
349
|
+
{ className: 'acc-row', style: { gap: '6px', fontSize: '11px' } },
|
|
350
|
+
h('span', { className: 'acc-muted', style: { flex: '1 1 auto' } }, t('tools.cluster')),
|
|
351
|
+
h('span', { className: 'acc-muted', style: { flex: '0 0 auto' } }, `${t('tools.clusterCount')} · ${t('tools.clusterShareLabel')}`),
|
|
352
|
+
),
|
|
353
|
+
clusters.map((cluster) =>
|
|
354
|
+
h(
|
|
355
|
+
'div',
|
|
356
|
+
{
|
|
357
|
+
key: String(cluster.key),
|
|
358
|
+
style: { display: 'flex', flexDirection: 'column', gap: '3px', padding: '6px 8px', border: '.5px solid var(--dsw-alias-border-l2, rgba(0,0,0,.1))', borderRadius: 'var(--dsw-radius-sm, 8px)' },
|
|
359
|
+
},
|
|
360
|
+
h(
|
|
361
|
+
'div',
|
|
362
|
+
{ style: { display: 'flex', alignItems: 'baseline', gap: '6px', minWidth: 0 } },
|
|
363
|
+
h('span', { className: 'acc-mono', style: { ...CLAMP_STYLE, maxWidth: '150px' }, title: String(cluster.key) }, String(cluster.key)),
|
|
364
|
+
h('span', { className: 'acc-muted', style: { fontSize: '11px' } }, String(cluster.kind)),
|
|
365
|
+
h('span', { className: 'acc-grow' }),
|
|
366
|
+
h('span', { style: { fontVariantNumeric: 'tabular-nums', fontSize: '12px' } }, ACC.fmt.num(Number(cluster.count) || 0)),
|
|
367
|
+
),
|
|
368
|
+
h(RatioBar, { count: Number(cluster.count) || 0, total: Math.max(failures, clusterMax), t }),
|
|
369
|
+
h(
|
|
370
|
+
'div',
|
|
371
|
+
{ className: 'acc-muted', style: { fontSize: '11px', display: 'flex', flexWrap: 'wrap', gap: '6px' } },
|
|
372
|
+
h('span', null, cluster.lastAt ? ACC.l10n.dateTime(cluster.lastAt, t) : '—'),
|
|
373
|
+
hostInline(cluster.example, t).length > 0
|
|
374
|
+
? h('span', { style: { ...CLAMP_STYLE, maxWidth: '210px' }, title: String(cluster.example) }, hostInline(cluster.example, t))
|
|
375
|
+
: null,
|
|
376
|
+
h(RawFold, { text: cluster.example, t }),
|
|
377
|
+
),
|
|
378
|
+
),
|
|
379
|
+
),
|
|
380
|
+
),
|
|
381
|
+
h(
|
|
138
382
|
'div',
|
|
139
|
-
{ style:
|
|
140
|
-
h(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
{ label: t('tools.successRate'), value: rateText(history.successRate, t) },
|
|
147
|
-
{ label: t('tools.lastCall'), value: history.lastCallAt ? ACC.fmt.dateTime(history.lastCallAt) : '—' },
|
|
148
|
-
{ label: t('tools.duration'), value: history.duration && history.duration.available === true ? `${t('tools.durationMedian')} ${msText(history.duration.medianMs)}` : String(t('common.unavailable')) },
|
|
149
|
-
],
|
|
383
|
+
{ className: 'acc-row', style: { justifyContent: 'space-between' } },
|
|
384
|
+
h('h4', { className: 'acc-section-title' }, t('tools.failureSamples')),
|
|
385
|
+
h(CopyButton, {
|
|
386
|
+
text: samples.map((sample) => `${sample.at ? new Date(Number(sample.at)).toISOString() : ''}\t${sample.tool}\t${sample.summary}`).join('\n'),
|
|
387
|
+
t,
|
|
388
|
+
label: t('tools.copySamples'),
|
|
389
|
+
ariaLabel: t('tools.copySamplesAria'),
|
|
150
390
|
}),
|
|
151
|
-
history.duration && history.duration.available === true
|
|
152
|
-
? h(C.Notice, { tone: 'info' }, `${t('tools.durationSamples')} ${history.duration.samples} · ${t('tools.durationAvg')} ${msText(history.duration.avgMs)} · ${t('tools.durationMax')} ${msText(history.duration.maxMs)} · ${String(history.duration.basis || '')}`)
|
|
153
|
-
: h(C.Notice, { tone: 'warn' }, String((history.duration && history.duration.reason) || t('tools.durationUnavailable'))),
|
|
154
|
-
history.errorState && history.errorState.available === false
|
|
155
|
-
? h(C.Notice, { tone: 'warn' }, String(history.errorState.reason || ''))
|
|
156
|
-
: null,
|
|
157
|
-
h('h4', { className: 'acc-card-title' }, t('tools.errorDistribution')),
|
|
158
|
-
clusters.length === 0
|
|
159
|
-
? h(C.Notice, { tone: 'success' }, t('tools.noErrors'))
|
|
160
|
-
: h(C.Table, {
|
|
161
|
-
columns: [
|
|
162
|
-
{ key: 'key', label: t('tools.cluster'), render: (row) => h('span', { className: 'acc-mono' }, String(row.key)) },
|
|
163
|
-
{ key: 'kind', label: t('tools.clusterKind'), render: (row) => String(row.kind) },
|
|
164
|
-
{ key: 'count', label: t('tools.clusterCount'), align: 'right', render: (row) => String(row.count) },
|
|
165
|
-
{ key: 'lastAt', label: t('tools.clusterLast'), render: (row) => (row.lastAt ? ACC.fmt.dateTime(row.lastAt) : '—') },
|
|
166
|
-
{ key: 'example', label: t('tools.clusterExample') },
|
|
167
|
-
],
|
|
168
|
-
rows: clusters,
|
|
169
|
-
rowKey: 'key',
|
|
170
|
-
}),
|
|
171
|
-
h('h4', { className: 'acc-card-title' }, t('tools.failureSamples')),
|
|
172
|
-
samples.length === 0
|
|
173
|
-
? h(C.Notice, { tone: 'info' }, t('tools.noSamples'))
|
|
174
|
-
: h(C.Table, {
|
|
175
|
-
columns: [
|
|
176
|
-
{ key: 'at', label: t('tools.sampleTime'), render: (row) => (row.at ? ACC.fmt.dateTime(row.at) : '—') },
|
|
177
|
-
{ key: 'tool', label: t('tools.sampleTool'), render: (row) => h('span', { className: 'acc-mono' }, String(row.tool)) },
|
|
178
|
-
{ key: 'summary', label: t('tools.sampleError') },
|
|
179
|
-
],
|
|
180
|
-
rows: samples,
|
|
181
|
-
rowKey: 'at',
|
|
182
|
-
}),
|
|
183
391
|
),
|
|
184
|
-
|
|
392
|
+
h(C.Notice, { tone: 'info' }, t('tools.redactionNote')),
|
|
393
|
+
samples.length === 0
|
|
394
|
+
? h(C.Notice, { tone: 'info' }, t('tools.noSamples'))
|
|
395
|
+
: h(C.Table, {
|
|
396
|
+
columns: [
|
|
397
|
+
{
|
|
398
|
+
key: 'at',
|
|
399
|
+
label: t('tools.sampleTime'),
|
|
400
|
+
render: (row) =>
|
|
401
|
+
h(
|
|
402
|
+
'div',
|
|
403
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: '1px' } },
|
|
404
|
+
h('span', { style: { fontSize: '11px' } }, row.at ? ACC.l10n.dateTime(row.at, t) : '—'),
|
|
405
|
+
h('span', { className: 'acc-mono', style: { fontSize: '11px' } }, String(row.tool)),
|
|
406
|
+
),
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
key: 'summary',
|
|
410
|
+
label: t('tools.sampleError'),
|
|
411
|
+
render: (row) =>
|
|
412
|
+
h(
|
|
413
|
+
'div',
|
|
414
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: '2px' } },
|
|
415
|
+
hostInline(row.summary, t).length > 0
|
|
416
|
+
? h('span', { style: { maxWidth: '190px', display: 'inline-block' }, title: String(row.summary || '') }, hostInline(row.summary, t))
|
|
417
|
+
: h('span', { className: 'acc-muted', style: { fontSize: '11px' } }, t('tools.sampleFolded')),
|
|
418
|
+
h(RawFold, { text: row.summary, t }),
|
|
419
|
+
),
|
|
420
|
+
},
|
|
421
|
+
],
|
|
422
|
+
rows: samples,
|
|
423
|
+
rowKey: 'at',
|
|
424
|
+
}),
|
|
425
|
+
),
|
|
185
426
|
h(
|
|
186
|
-
|
|
187
|
-
{
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
: h(
|
|
191
|
-
'div',
|
|
192
|
-
{ style: STACK_STYLE },
|
|
193
|
-
h('div', { className: 'acc-muted' }, `${t('tools.parameters')} · ${parameters.bytes === undefined ? '' : ACC.fmt.bytes(parameters.bytes)}`),
|
|
194
|
-
h(C.Code, { text: String(parameters.text || '') }),
|
|
195
|
-
parameters.truncated ? h(C.Notice, { tone: 'warn' }, t('tools.schemaTruncated')) : null,
|
|
196
|
-
outputSchema === null || outputSchema === undefined
|
|
197
|
-
? null
|
|
198
|
-
: h('div', { style: STACK_STYLE }, h('div', { className: 'acc-muted' }, t('tools.outputSchema')), h(C.Code, { text: String(outputSchema.text || '') })),
|
|
199
|
-
),
|
|
427
|
+
'div',
|
|
428
|
+
{ className: 'acc-row', style: { justifyContent: 'space-between' } },
|
|
429
|
+
h('h4', { className: 'acc-section-title' }, t('tools.schema')),
|
|
430
|
+
parameters === null || parameters === undefined ? null : h(CopyButton, { text: schemaText, t, label: t('tools.copySchema') }),
|
|
200
431
|
),
|
|
432
|
+
parameters === null || parameters === undefined
|
|
433
|
+
? h(C.Notice, { tone: 'warn' }, t('tools.schemaUnavailable'))
|
|
434
|
+
: h(
|
|
435
|
+
'div',
|
|
436
|
+
{ style: STACK_STYLE },
|
|
437
|
+
h('div', { className: 'acc-muted' }, `${t('tools.parameters')} · ${parameters.bytes === undefined ? '' : ACC.fmt.bytes(parameters.bytes)}`),
|
|
438
|
+
h(C.Code, { text: schemaText }),
|
|
439
|
+
parameters.truncated ? h(C.Notice, { tone: 'warn' }, t('tools.schemaTruncated')) : null,
|
|
440
|
+
outputSchema === null || outputSchema === undefined
|
|
441
|
+
? null
|
|
442
|
+
: h('div', { style: STACK_STYLE }, h('div', { className: 'acc-muted' }, t('tools.outputSchema')), h(C.Code, { text: String(outputSchema.text || '') })),
|
|
443
|
+
),
|
|
201
444
|
)
|
|
202
445
|
}
|
|
203
446
|
|
|
@@ -210,33 +453,68 @@
|
|
|
210
453
|
const [sourceFilter, setSourceFilter] = ACC.useState('all')
|
|
211
454
|
const [onlyIssues, setOnlyIssues] = ACC.useState(false)
|
|
212
455
|
const [selected, setSelected] = ACC.useState('')
|
|
456
|
+
const searchRef = ACC.useRef(null)
|
|
213
457
|
|
|
214
|
-
|
|
458
|
+
// One-shot bypass flags: the first load may use the cache, an explicit
|
|
459
|
+
// Refresh must see fresh host state.
|
|
460
|
+
const forceList = ACC.useRef(false)
|
|
461
|
+
const forceDetail = ACC.useRef(false)
|
|
462
|
+
const list = ACC.useAsync((context) => {
|
|
463
|
+
const refresh = forceList.current
|
|
464
|
+
forceList.current = false
|
|
465
|
+
return ACC.api('tools.list', { days, agentId: agentId.length > 0 ? agentId : undefined, includePresets: true, ...(refresh ? { refresh: true } : {}) }, context)
|
|
466
|
+
}, [days, agentId])
|
|
215
467
|
const detail = ACC.useAsync(
|
|
216
|
-
(context) =>
|
|
468
|
+
(context) => {
|
|
469
|
+
if (selected.length === 0) return Promise.resolve(null)
|
|
470
|
+
const refresh = forceDetail.current
|
|
471
|
+
forceDetail.current = false
|
|
472
|
+
return ACC.api('tools.detail', { name: selected, days, agentId: agentId.length > 0 ? agentId : undefined, ...(refresh ? { refresh: true } : {}) }, context)
|
|
473
|
+
},
|
|
217
474
|
[selected, days, agentId],
|
|
218
475
|
)
|
|
219
476
|
|
|
477
|
+
useEscape(selected.length > 0, ACC.useCallback(() => setSelected(''), []))
|
|
478
|
+
ACC.useEffect(() => {
|
|
479
|
+
const onKey = (event) => {
|
|
480
|
+
if (event.key !== '/' || event.metaKey || event.ctrlKey || event.altKey) return
|
|
481
|
+
const tag = event.target && event.target.tagName ? String(event.target.tagName).toLowerCase() : ''
|
|
482
|
+
if (tag === 'input' || tag === 'textarea' || tag === 'select') return
|
|
483
|
+
event.preventDefault()
|
|
484
|
+
if (searchRef.current) searchRef.current.focus()
|
|
485
|
+
}
|
|
486
|
+
document.addEventListener('keydown', onKey)
|
|
487
|
+
return () => document.removeEventListener('keydown', onKey)
|
|
488
|
+
}, [])
|
|
489
|
+
|
|
220
490
|
if (list.status === 'loading') return h(C.Loading, { label: t('common.loading') })
|
|
221
491
|
if (list.status === 'error') return h(C.ErrorBox, { error: list.error, onRetry: list.reload, label: t('tools.loadFailed') })
|
|
222
492
|
const data = list.data
|
|
223
493
|
if (data.available === false) {
|
|
224
|
-
return h(C.Empty, {
|
|
494
|
+
return h(C.Empty, {
|
|
495
|
+
title: t('tools.registryUnavailable'),
|
|
496
|
+
hint: String(data.reason || ''),
|
|
497
|
+
action: h(C.Btn, { onClick: list.reload }, t('common.retry')),
|
|
498
|
+
})
|
|
225
499
|
}
|
|
226
500
|
const registry = data.registry || {}
|
|
227
501
|
const history = data.history || {}
|
|
228
502
|
const items = Array.isArray(data.items) ? data.items : []
|
|
229
503
|
const liveAgents = Array.isArray(registry.liveAgents) ? registry.liveAgents : []
|
|
504
|
+
const hasFilters = search.length > 0 || sourceFilter !== 'all' || onlyIssues
|
|
230
505
|
const filtered = items.filter((item) => {
|
|
231
506
|
if (search.length > 0 && !String(item.name).toLowerCase().includes(search.toLowerCase())) return false
|
|
232
507
|
if (sourceFilter !== 'all' && item.source && item.source.kind !== sourceFilter) return false
|
|
233
|
-
if (onlyIssues
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return false
|
|
508
|
+
if (onlyIssues) {
|
|
509
|
+
const issues = item.checks && Array.isArray(item.checks.issues) ? item.checks.issues : []
|
|
510
|
+
if (!issues.some((issue) => issue.code !== 'description_missing')) return false
|
|
237
511
|
}
|
|
238
512
|
return true
|
|
239
513
|
})
|
|
514
|
+
const registeredCount = items.filter((item) => item.status && item.status.registered === 'yes').length
|
|
515
|
+
const visibleCount = items.filter((item) => item.status && item.status.visibleToCurrentAgent === 'yes').length
|
|
516
|
+
const calledCount = items.filter((item) => item.status && item.status.called === 'yes').length
|
|
517
|
+
const currentAgent = data.currentAgent && data.currentAgent.available === true ? String(data.currentAgent.id) : String((data.currentAgent && data.currentAgent.reason) || t('common.unavailable'))
|
|
240
518
|
|
|
241
519
|
return h(
|
|
242
520
|
'div',
|
|
@@ -244,39 +522,47 @@
|
|
|
244
522
|
h(
|
|
245
523
|
C.Card,
|
|
246
524
|
{
|
|
247
|
-
title: t('tools.
|
|
525
|
+
title: t('tools.listTitle'),
|
|
248
526
|
subtitle: t('tools.subtitle'),
|
|
249
|
-
actions: h(C.Btn, {
|
|
527
|
+
actions: [h(C.Btn, {
|
|
528
|
+
key: 'r',
|
|
529
|
+
onClick: () => {
|
|
530
|
+
forceList.current = true
|
|
531
|
+
if (selected.length > 0) forceDetail.current = true
|
|
532
|
+
list.reload()
|
|
533
|
+
if (selected.length > 0) detail.reload()
|
|
534
|
+
},
|
|
535
|
+
ariaLabel: t('tools.refreshList'),
|
|
536
|
+
}, t('common.refresh'))],
|
|
250
537
|
},
|
|
251
|
-
h(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
),
|
|
267
|
-
h(
|
|
268
|
-
C.Card,
|
|
269
|
-
{ title: t('tools.listTitle') },
|
|
538
|
+
h(
|
|
539
|
+
'div',
|
|
540
|
+
{ className: 'acc-row', 'aria-label': t('tools.registrySummary') },
|
|
541
|
+
h(C.Badge, { tone: 'neutral' }, t('tools.registryBadge', { count: registry.globalCount === undefined ? '—' : registry.globalCount })),
|
|
542
|
+
h(C.Badge, { tone: 'neutral' }, t('tools.liveAgentBadge', { count: liveAgents.length })),
|
|
543
|
+
h(C.Badge, { tone: data.currentAgent && data.currentAgent.available === true ? 'info' : 'warn', title: String((data.currentAgent && data.currentAgent.reason) || '') }, `${t('tools.currentAgent')}: ${currentAgent}`),
|
|
544
|
+
h(C.Badge, { tone: 'neutral' }, `${data.window ? String(data.window.days) : '—'} ${t('tools.daysUnit')}`),
|
|
545
|
+
h(
|
|
546
|
+
C.Badge,
|
|
547
|
+
{ tone: history.available === true ? (history.empty === true ? 'neutral' : 'success') : 'warn' },
|
|
548
|
+
history.available === true
|
|
549
|
+
? `${t('tools.scanned')} ${history.scannedSessions}`
|
|
550
|
+
: String(history.reason || t('common.unavailable')),
|
|
551
|
+
),
|
|
552
|
+
),
|
|
270
553
|
h(
|
|
271
554
|
C.Toolbar,
|
|
272
|
-
|
|
555
|
+
{ className: 'acc-row' },
|
|
273
556
|
h('input', {
|
|
557
|
+
ref: searchRef,
|
|
274
558
|
className: 'acc-select',
|
|
275
559
|
type: 'search',
|
|
276
560
|
placeholder: t('tools.searchPlaceholder'),
|
|
277
561
|
value: search,
|
|
278
562
|
onChange: (event) => setSearch(event.target.value),
|
|
563
|
+
onKeyDown: (event) => { if (event.key === 'Escape') setSearch('') },
|
|
279
564
|
'aria-label': t('tools.search'),
|
|
565
|
+
style: { minWidth: '180px' },
|
|
280
566
|
}),
|
|
281
567
|
h(
|
|
282
568
|
'select',
|
|
@@ -296,66 +582,132 @@
|
|
|
296
582
|
),
|
|
297
583
|
h(
|
|
298
584
|
'select',
|
|
299
|
-
{ className: 'acc-select', value: agentId, onChange: (event) => setAgentId(event.target.value), 'aria-label': t('tools.agent') },
|
|
585
|
+
{ className: 'acc-select', value: agentId, onChange: (event) => setAgentId(event.target.value), 'aria-label': t('tools.agent'), title: t('tools.agent') },
|
|
300
586
|
h('option', { value: '' }, t('tools.agentAuto')),
|
|
301
587
|
liveAgents.map((agent) => h('option', { key: String(agent.id), value: String(agent.id) }, String(agent.id))),
|
|
302
588
|
),
|
|
303
589
|
h(
|
|
304
590
|
'label',
|
|
305
|
-
{ className: 'acc-row' },
|
|
591
|
+
{ className: 'acc-row', style: { cursor: 'pointer' } },
|
|
306
592
|
h('input', { type: 'checkbox', checked: onlyIssues, onChange: (event) => setOnlyIssues(event.target.checked) }),
|
|
307
593
|
h('span', { className: 'acc-muted' }, t('tools.onlyIssues')),
|
|
308
594
|
),
|
|
595
|
+
hasFilters
|
|
596
|
+
? h(C.Btn, { tone: 'ghost', onClick: () => { setSearch(''); setSourceFilter('all'); setOnlyIssues(false) } }, t('tools.clearFilters'))
|
|
597
|
+
: null,
|
|
309
598
|
),
|
|
599
|
+
h(
|
|
600
|
+
'div',
|
|
601
|
+
{ className: 'acc-row', style: { justifyContent: 'space-between' } },
|
|
602
|
+
h('span', { className: 'acc-muted' }, t('tools.resultsCount', { shown: filtered.length, total: items.length })),
|
|
603
|
+
h(
|
|
604
|
+
'span',
|
|
605
|
+
{ className: 'acc-muted' },
|
|
606
|
+
t('tools.layersSummary', { registered: registeredCount, visible: visibleCount, called: calledCount }),
|
|
607
|
+
),
|
|
608
|
+
),
|
|
609
|
+
h(InfoPanel, { t, items: [t('tools.statusLegend'), t('tools.probeNotice'), t('tools.hostNotesFold')] }),
|
|
610
|
+
history.available === false
|
|
611
|
+
? h(
|
|
612
|
+
'div',
|
|
613
|
+
{ className: 'acc-muted', style: { fontSize: '11px', display: 'flex', flexDirection: 'column', gap: '2px' } },
|
|
614
|
+
h('span', null, `${t('tools.historyUnavailable')} ${hostInline(history.reason, t, 'tools.historyUnavailableReason')}`),
|
|
615
|
+
h(RawFold, { text: `${String(history.reason || '')}\n${String(history.hint || '')}`, t }),
|
|
616
|
+
)
|
|
617
|
+
: h(
|
|
618
|
+
'div',
|
|
619
|
+
{ className: 'acc-muted', style: { fontSize: '11px' } },
|
|
620
|
+
history.empty === true
|
|
621
|
+
? `${t('tools.historyEmpty')} - ${t('tools.scanned')} ${history.scannedSessions}`
|
|
622
|
+
: `${t('tools.historyAvailable')} - ${t('tools.scanned')} ${history.scannedSessions} - ${t('tools.calls')} ${history.totals ? history.totals.calls : 0} - ${t('tools.failures')} ${history.totals ? history.totals.failures : 0}${history.truncated ? ` - ${t('tools.historyTruncated')}` : ''}`,
|
|
623
|
+
),
|
|
310
624
|
filtered.length === 0
|
|
311
|
-
? h(C.Empty, {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
625
|
+
? h(C.Empty, {
|
|
626
|
+
title: items.length === 0 ? t('tools.empty') : t('tools.filterEmpty'),
|
|
627
|
+
hint: items.length === 0 ? t('tools.emptyHint') : t('tools.filterEmptyHint'),
|
|
628
|
+
action: items.length === 0
|
|
629
|
+
? h(C.Btn, { onClick: list.reload }, t('common.retry'))
|
|
630
|
+
: h(C.Btn, { onClick: () => { setSearch(''); setSourceFilter('all'); setOnlyIssues(false) } }, t('tools.clearFilters')),
|
|
631
|
+
})
|
|
632
|
+
: h(
|
|
633
|
+
'div',
|
|
634
|
+
{ style: { display: 'flex', flexDirection: 'column' } },
|
|
635
|
+
filtered.map((row) => {
|
|
636
|
+
const isOpen = row.name === selected
|
|
637
|
+
const issues = row.checks && Array.isArray(row.checks.issues) ? row.checks.issues.filter((issue) => issue.code !== 'description_missing') : []
|
|
638
|
+
return h(
|
|
639
|
+
'button',
|
|
640
|
+
{
|
|
641
|
+
key: row.name,
|
|
642
|
+
type: 'button',
|
|
643
|
+
'aria-expanded': isOpen,
|
|
644
|
+
'aria-label': `${isOpen ? t('tools.collapseDetail') : t('tools.expandDetail')}: ${row.name}`,
|
|
645
|
+
title: isOpen ? t('tools.collapseDetail') : t('tools.expandDetail'),
|
|
646
|
+
onClick: () => setSelected(isOpen ? '' : row.name),
|
|
647
|
+
style: {
|
|
648
|
+
display: 'flex',
|
|
649
|
+
flexDirection: 'column',
|
|
650
|
+
alignItems: 'stretch',
|
|
651
|
+
gap: '4px',
|
|
652
|
+
padding: '8px 10px',
|
|
653
|
+
border: 0,
|
|
654
|
+
borderBottom: '0.5px solid var(--dsw-alias-border-l2, rgba(0,0,0,.1))',
|
|
655
|
+
background: isOpen ? 'var(--dsw-alias-interactive-bg-hover, rgba(38,49,72,.06))' : 'transparent',
|
|
656
|
+
color: 'inherit',
|
|
657
|
+
font: 'inherit',
|
|
658
|
+
textAlign: 'left',
|
|
659
|
+
cursor: 'pointer',
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
h(
|
|
663
|
+
'span',
|
|
664
|
+
{ style: { display: 'flex', alignItems: 'center', gap: '6px', minWidth: 0 } },
|
|
665
|
+
h('span', { 'aria-hidden': 'true' }, isOpen ? '▾' : '▸'),
|
|
666
|
+
h('span', { className: 'acc-mono', style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, String(row.name)),
|
|
667
|
+
h('span', { className: 'acc-grow' }),
|
|
668
|
+
issues.length > 0 ? h(C.Badge, { tone: 'warn', title: t('tools.issueCount') }, `${t('tools.issueCount')} ${issues.length}`) : null,
|
|
669
|
+
row.source ? h(SourceBadge, { value: row.source, t }) : null,
|
|
670
|
+
),
|
|
671
|
+
h(
|
|
672
|
+
'span',
|
|
673
|
+
{ style: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: '6px', paddingLeft: '18px' } },
|
|
674
|
+
h(layerBadge, { label: t('tools.registeredShort'), value: row.status.registered, t }),
|
|
675
|
+
h(layerBadge, { label: t('tools.visibleShort'), value: row.status.visibleToCurrentAgent, t }),
|
|
676
|
+
h(layerBadge, { label: t('tools.calledShort'), value: row.status.called, t }),
|
|
318
677
|
h(
|
|
319
|
-
'
|
|
320
|
-
{
|
|
321
|
-
|
|
678
|
+
'span',
|
|
679
|
+
{ className: 'acc-muted', style: { fontSize: '11px' } },
|
|
680
|
+
row.history && row.history.available === true
|
|
681
|
+
? `${t('tools.calls')} ${ACC.fmt.num(row.history.calls)} · ${t('tools.successRate')} ${rateText(row.history.successRate, t)}`
|
|
682
|
+
: t('tools.historyUnavailableShort'),
|
|
322
683
|
),
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
{ key: 'called', label: t('tools.called'), render: (row) => statusBadge(row.status.called, t) },
|
|
328
|
-
{ key: 'calls', label: t('tools.calls'), align: 'right', render: (row) => (row.history && row.history.available === true ? String(row.history.calls) : String(t('common.unavailable'))) },
|
|
329
|
-
{ key: 'rate', label: t('tools.successRate'), align: 'right', render: (row) => rateText(row.history ? row.history.successRate : null, t) },
|
|
330
|
-
{
|
|
331
|
-
key: 'issues',
|
|
332
|
-
label: t('tools.issueCount'),
|
|
333
|
-
align: 'right',
|
|
334
|
-
render: (row) => {
|
|
335
|
-
const issues = row.checks && Array.isArray(row.checks.issues) ? row.checks.issues.filter((issue) => issue.code !== 'description_missing') : []
|
|
336
|
-
return issues.length === 0 ? '—' : String(issues.length)
|
|
337
|
-
},
|
|
338
|
-
},
|
|
339
|
-
],
|
|
340
|
-
rows: filtered,
|
|
341
|
-
rowKey: 'name',
|
|
342
|
-
}),
|
|
684
|
+
),
|
|
685
|
+
)
|
|
686
|
+
}),
|
|
687
|
+
),
|
|
343
688
|
h(C.Truncated, { truncated: data.truncated === true, label: `${t('tools.truncatedList')} · ${t('tools.registryCount')} ${registry.globalCount === undefined ? '' : registry.globalCount}` }),
|
|
344
689
|
h('div', { className: 'acc-muted' }, t('tools.selectHint')),
|
|
345
|
-
Array.isArray(data.notes) && data.notes.length > 0
|
|
690
|
+
Array.isArray(data.notes) && data.notes.length > 0
|
|
691
|
+
? h(
|
|
692
|
+
'div',
|
|
693
|
+
{ className: 'acc-muted', style: { fontSize: '11px', display: 'flex', flexDirection: 'column', gap: '2px' } },
|
|
694
|
+
h('span', null, t('tools.hostNotesFold')),
|
|
695
|
+
h(RawFold, { text: data.notes.join('\n'), t }),
|
|
696
|
+
)
|
|
697
|
+
: null,
|
|
346
698
|
),
|
|
347
699
|
selected.length === 0
|
|
348
700
|
? null
|
|
349
701
|
: h(
|
|
350
702
|
C.Card,
|
|
351
|
-
{ title: `${t('tools.detailTitle')} · ${selected}`, actions: h(C.Btn, { tone: 'ghost', onClick: () => setSelected('') }, t('
|
|
703
|
+
{ title: `${t('tools.detailTitle')} · ${selected}`, actions: h(C.Btn, { tone: 'ghost', onClick: () => setSelected(''), title: t('tools.closeDetailHint') }, t('tools.closeDetail')) },
|
|
352
704
|
detail.status === 'loading'
|
|
353
705
|
? h(C.Loading, { label: t('common.loading') })
|
|
354
706
|
: detail.status === 'error'
|
|
355
707
|
? h(C.ErrorBox, { error: detail.error, onRetry: detail.reload, label: t('tools.detailFailed') })
|
|
356
708
|
: detail.data === null
|
|
357
709
|
? h(C.Empty, { title: t('tools.detailEmpty') })
|
|
358
|
-
: h(DetailBody, { detail: detail.data, t }),
|
|
710
|
+
: h(DetailBody, { detail: detail.data, t, onClose: () => setSelected('') }),
|
|
359
711
|
),
|
|
360
712
|
)
|
|
361
713
|
}
|
|
@@ -364,6 +716,7 @@
|
|
|
364
716
|
id: 'tools',
|
|
365
717
|
titleKey: 'nav.tools',
|
|
366
718
|
order: 20,
|
|
719
|
+
group: 'insight',
|
|
367
720
|
render: (props) => h(ToolsPage, props),
|
|
368
721
|
})
|
|
369
722
|
})()
|