feat(frontend): add wiki tool support and enhance agent tool icon mapping

- Implement `getWikiPageText` function to handle persisted slugs and JSON input for wiki page text retrieval.
- Update `getAgentToolIconName` to include mappings for `wiki_search` and `wiki_read_page` tools.
- Enhance tests to cover new functionality for wiki tools and ensure proper icon mapping in the agent stream display.
- Modify `AgentStreamDisplay` to utilize new wiki tool features and improve localization for wiki-related actions.
This commit is contained in:
wizardchen
2026-06-22 12:24:33 +08:00
committed by lyingbug
parent 0c3c866f0b
commit 483f507104
6 changed files with 65 additions and 3 deletions
@@ -5,6 +5,7 @@ import {
getKnowledgeSearchSummaryHtml,
getQueryText,
getRagPipelineStepTitle,
getWikiPageText,
} from './agent-tool-display.ts'
const t = (key, params) => {
@@ -22,6 +23,12 @@ test('getAgentToolIconName maps rag pipeline tools', () => {
assert.equal(getAgentToolIconName('knowledge_search'), 'data-search')
})
test('getAgentToolIconName maps Wiki tools to semantic search and reading icons', () => {
assert.equal(getAgentToolIconName('wiki_search'), 'search')
assert.equal(getAgentToolIconName('wiki_read_page'), 'file-search')
assert.equal(getAgentToolIconName('wiki_read_source_doc'), 'file-search')
})
test('getQueryText joins unique query strings', () => {
assert.equal(getQueryText({ query: 'foo', queries: ['foo', 'bar'] }), 'foo,bar')
})
@@ -35,6 +42,14 @@ test('getQueryText parses JSON-encoded queries string', () => {
)
})
test('getWikiPageText supports persisted slugs arrays', () => {
assert.equal(
getWikiPageText({ slugs: ['entity/知识助理', 'concept/API管理'] }),
'entity/知识助理、concept/API管理',
)
assert.equal(getWikiPageText('{"slug":"index"}'), 'index')
})
test('getKnowledgeSearchSummaryHtml includes file count when present', () => {
const html = getKnowledgeSearchSummaryHtml(t, {
results: [{}, {}],