Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名) - 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块) - docreader proto 描述符采用等长替换,保持序列化字节布局有效 - Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像 - 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
135 lines
5.1 KiB
JavaScript
135 lines
5.1 KiB
JavaScript
import assert from 'node:assert/strict'
|
||
import test from 'node:test'
|
||
import { getAgentToolIconName } from './agent-tool-icons.ts'
|
||
import {
|
||
getKnowledgeSearchSummaryHtml,
|
||
getQueryText,
|
||
getRagPipelineStepTitle,
|
||
getWikiPageText,
|
||
} from './agent-tool-display.ts'
|
||
|
||
const t = (key, params) => {
|
||
if (key === 'agentStream.search.foundResultsFromFiles') {
|
||
return `found ${params?.count} from ${params?.files} files`
|
||
}
|
||
if (key === 'agentStream.search.candidatesBelowThreshold') {
|
||
return `matched ${params?.count}, none relevant`
|
||
}
|
||
if (key === 'agentStream.ragPipeline.searchingWithQuery') {
|
||
return `searching ${params?.query}`
|
||
}
|
||
return key
|
||
}
|
||
|
||
test('getAgentToolIconName maps rag pipeline tools', () => {
|
||
assert.equal(getAgentToolIconName('query_understand'), 'ai-search')
|
||
assert.equal(getAgentToolIconName('knowledge_search'), 'data-search')
|
||
})
|
||
|
||
test('getAgentToolIconName maps the consolidated knowledge tools and their retired names alike', () => {
|
||
assert.equal(getAgentToolIconName('search_knowledge'), 'data-search')
|
||
assert.equal(getAgentToolIconName('search_knowledge', 'web'), 'internet')
|
||
assert.equal(getAgentToolIconName('read_document'), 'file-search')
|
||
assert.equal(getAgentToolIconName('list_documents'), 'file-search')
|
||
assert.equal(getAgentToolIconName('list_knowledge_chunks'), 'file-search')
|
||
assert.equal(getAgentToolIconName('get_document_info'), 'file-search')
|
||
})
|
||
|
||
test('getAgentToolIconName maps sandbox shell tools to the terminal icon', () => {
|
||
assert.equal(getAgentToolIconName('shell_exec'), 'terminal')
|
||
})
|
||
|
||
test('getAgentToolIconName maps skill and sandbox file tools', () => {
|
||
assert.equal(getAgentToolIconName('read_file'), 'file')
|
||
assert.equal(getAgentToolIconName('read_skill'), 'file')
|
||
assert.equal(getAgentToolIconName('list_sandbox_files'), 'folder')
|
||
assert.equal(getAgentToolIconName('read_sandbox_file'), 'file')
|
||
assert.equal(getAgentToolIconName('execute_skill_script'), 'code')
|
||
})
|
||
|
||
test('getAgentToolIconName maps operation and product-doc tools', () => {
|
||
assert.equal(getAgentToolIconName('find_operations'), 'task')
|
||
assert.equal(getAgentToolIconName('run_operation'), 'terminal')
|
||
assert.equal(getAgentToolIconName('search_academy_docs'), 'search')
|
||
assert.equal(getAgentToolIconName('read_academy_doc'), 'file')
|
||
})
|
||
|
||
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')
|
||
})
|
||
|
||
test('getQueryText parses JSON-encoded queries string', () => {
|
||
assert.equal(
|
||
getQueryText({
|
||
queries: '["合力天胜游泳俱乐部介绍", "合力天胜游泳训练机构", "合力天胜游泳队"]',
|
||
}),
|
||
'合力天胜游泳俱乐部介绍,合力天胜游泳训练机构,合力天胜游泳队',
|
||
)
|
||
})
|
||
|
||
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: [{}, {}],
|
||
kb_counts: { a: 1, b: 2 },
|
||
})
|
||
assert.match(html, /found <strong>2<\/strong> from <strong>2<\/strong> files/)
|
||
})
|
||
|
||
// Candidates that all fell below the relevance threshold never reached the
|
||
// answer, so the row must not read like a plain empty search: the difference
|
||
// points at the threshold rather than at the knowledge base.
|
||
test('getKnowledgeSearchSummaryHtml distinguishes filtered candidates from an empty search', () => {
|
||
assert.match(
|
||
getKnowledgeSearchSummaryHtml(t, { count: 0, candidate_count: 10 }),
|
||
/matched <strong>10<\/strong>, none relevant/,
|
||
)
|
||
assert.equal(
|
||
getKnowledgeSearchSummaryHtml(t, { count: 0, candidate_count: 0 }),
|
||
'agentStream.search.noResults',
|
||
)
|
||
})
|
||
|
||
test('getRagPipelineStepTitle uses query-aware search labels', () => {
|
||
const title = getRagPipelineStepTitle(t, {
|
||
tool_name: 'knowledge_search',
|
||
pending: true,
|
||
arguments: { query: '讯飞开放平台' },
|
||
})
|
||
assert.equal(title, 'searching 讯飞开放平台')
|
||
})
|
||
|
||
test('getRagPipelineStepTitle uses web labels when search_source is web', () => {
|
||
const title = getRagPipelineStepTitle(t, {
|
||
tool_name: 'knowledge_search',
|
||
pending: false,
|
||
success: true,
|
||
arguments: { search_source: 'web' },
|
||
})
|
||
assert.equal(title, 'agentStream.toolStatus.webSearch')
|
||
})
|
||
|
||
test('getRagPipelineStepTitle uses attachment parsing labels', () => {
|
||
assert.equal(
|
||
getRagPipelineStepTitle(t, { tool_name: 'attachment_parsing', pending: true }),
|
||
'agentStream.toolStatus.attachmentParsing',
|
||
)
|
||
assert.equal(
|
||
getRagPipelineStepTitle(t, { tool_name: 'attachment_parsing', pending: false, success: true }),
|
||
'agentStream.toolStatus.attachmentParsingDone',
|
||
)
|
||
})
|