Agent Charts
This commit is contained in:
+26
-1
@@ -11,6 +11,7 @@ import {
|
||||
runSubAgents,
|
||||
synthesizeFromAgents,
|
||||
} from './agents.js'
|
||||
import { chartIdsFromToolLog, mountChartEmbeds } from './chart-embed.js'
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
@@ -39,8 +40,9 @@ import {
|
||||
* saveSettings: (patch: object) => void,
|
||||
* getPeerLabel: () => string,
|
||||
* getCatalog?: () => Record<string, object>,
|
||||
* onOpenChart?: (id: string, ts?: number) => void,
|
||||
* onOpenChart?: (id: string, ts?: number, opts?: object) => void,
|
||||
* onOpenView?: (view: string) => void,
|
||||
* charts?: object,
|
||||
* log?: (msg: string) => void,
|
||||
* }} opts
|
||||
*/
|
||||
@@ -60,6 +62,7 @@ export function createQvacView(opts) {
|
||||
getCatalog: () => opts.getCatalog?.() || {},
|
||||
onOpenChart: opts.onOpenChart,
|
||||
onOpenView: opts.onOpenView,
|
||||
charts: opts.charts,
|
||||
confirmAction: (msg) => {
|
||||
try {
|
||||
return typeof confirm === 'function' ? confirm(msg) : true
|
||||
@@ -892,6 +895,28 @@ export function createQvacView(opts) {
|
||||
if (chips) chips.remove()
|
||||
assistantUi.div.appendChild(renderToolChips(toolLog))
|
||||
}
|
||||
// Live sparklines under the answer for chart-related tools
|
||||
const embedIds = chartIdsFromToolLog(toolLog)
|
||||
if (embedIds.length && assistantUi?.div && opts.manager?.request) {
|
||||
mountChartEmbeds(assistantUi.div, embedIds, {
|
||||
request: (m, a) => opts.manager.request(m, a || {}),
|
||||
catalog: opts.getCatalog?.() || {},
|
||||
onOpen: (id) => {
|
||||
opts.onOpenView?.('charts')
|
||||
if (opts.charts?.showCharts) {
|
||||
opts.charts.showCharts({
|
||||
charts: [id],
|
||||
pin: true,
|
||||
boardOnly: true,
|
||||
focus: id,
|
||||
openFocus: true,
|
||||
})
|
||||
} else {
|
||||
opts.onOpenChart?.(id)
|
||||
}
|
||||
},
|
||||
}).catch(() => {})
|
||||
}
|
||||
setStatus(result.mode === 'fallback' ? 'Ready (tools-only)' : 'Ready', 'ok')
|
||||
} catch (err) {
|
||||
const msg = err?.message || String(err)
|
||||
|
||||
Reference in New Issue
Block a user