Restore Ask workspace reads and output paging without granting write access, and let programming Subagents reuse their parent's browser page. Allocate browser resources only when used, keep Agent pages aligned with workbar tabs, recover released bindings, and remove unused automatic screenshot work. Preserve inherited Runtime selections during remote usage persistence and manual compression. Keep viable channel model fallbacks, display the actual scheduled-task mode and Harness model source, and avoid rediscovery delays when calling healthy MCP tools. Fix directory/history refresh, case-only renames, rename-aware commit diffs, and FastGPT probe success reporting. Add regression coverage and align feature documentation. The Agent-side connection timeout fix requires deploying an updated Agent; existing Ask read-only and Execute authorization boundaries remain unchanged. Final validation: 3839 tests passed, 66 skipped; typecheck, lint, development build, and diff checks passed. Isolated Electron UI/MCP workflows passed with a loopback model fixture. Current-source Linux x64 Host checks passed with three successful real model requests. Chromium loadURL rejection was not reproduced in the UI; released-binding recovery has automated coverage. Release note: 修复 Ask 读取项目文件、浏览器页面显示与恢复、文件管理及模型配置跟随中的不一致,并减少无用截图和 MCP 等待。定时任务显示实际工作模式,远程会话可正常保存继承 Runtime 的用量;远端连接超时修复需更新 Agent 后生效。
134 lines
5.5 KiB
TypeScript
134 lines
5.5 KiB
TypeScript
import { execFile } from 'node:child_process'
|
|
import { resolve } from 'node:path'
|
|
import { pathToFileURL } from 'node:url'
|
|
import { promisify } from 'node:util'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
type Fixture = {
|
|
status?: number
|
|
body?: unknown
|
|
raw?: string
|
|
error?: string
|
|
}
|
|
type ProviderReport = {
|
|
catalog: { success: boolean; failure?: string; count?: number }
|
|
retrievals: Array<{
|
|
searchMode: string
|
|
usingRerank?: boolean
|
|
success: boolean
|
|
failure?: string
|
|
count?: number
|
|
contentPresent?: boolean
|
|
}>
|
|
features: { searchModes: string[]; rerankProbed: boolean; rerankSucceeded: boolean }
|
|
operations: Array<{ name: string; status: number | 'failed' }>
|
|
}
|
|
|
|
const success = (list: unknown[] = []): Fixture => ({
|
|
body: { code: 200, data: { list } }
|
|
})
|
|
|
|
async function probe(
|
|
retrievalFixtures: Record<string, Fixture>,
|
|
catalog: Fixture = { body: { code: 200, data: [{ _id: 'fixture-dataset', type: 'dataset' }] } }
|
|
): Promise<ProviderReport> {
|
|
// Run the actual CLI with an entirely in-process fetch fixture. No server,
|
|
// credentials file, external provider, or real knowledge request is used.
|
|
const script = `
|
|
const fixtures = ${JSON.stringify(retrievalFixtures)};
|
|
const catalog = ${JSON.stringify(catalog)};
|
|
globalThis.fetch = async (url, init) => {
|
|
const path = new URL(url).pathname;
|
|
let fixture;
|
|
if (path.endsWith('/list')) fixture = catalog;
|
|
else if (path.endsWith('/detail')) fixture = {body: {code: 200, data: {}}};
|
|
else if (path.endsWith('/searchTest')) {
|
|
const input = JSON.parse(init.body);
|
|
fixture = fixtures[input.usingReRank ? 'rerank' : input.searchMode];
|
|
} else throw new Error('Unexpected fixture request');
|
|
if (!fixture) throw new Error('Missing fixture');
|
|
if (fixture.error) throw new DOMException('fixture request failure', fixture.error);
|
|
return new Response(fixture.raw ?? JSON.stringify(fixture.body), {
|
|
status: fixture.status ?? 200, headers: {'Content-Type': 'application/json'}
|
|
});
|
|
};
|
|
process.argv = [process.execPath, 'probe', '--provider=fastgpt', '--extended'];
|
|
await import(${JSON.stringify(pathToFileURL(resolve('scripts/external-knowledge-probe.mjs')).href)});
|
|
`
|
|
const { stdout } = await promisify(execFile)(
|
|
process.execPath, ['--input-type=module', '--eval', script],
|
|
{
|
|
env: {
|
|
...process.env,
|
|
GOODBUDDY_FASTGPT_BASE_URL: 'http://fixture.invalid',
|
|
GOODBUDDY_FASTGPT_API_KEY: 'fixture-only-key'
|
|
},
|
|
timeout: 10_000
|
|
}
|
|
)
|
|
expect(stdout).not.toContain('fixture-only-key')
|
|
expect(stdout).not.toContain('fixture.invalid')
|
|
expect(stdout).not.toContain('fixture-dataset')
|
|
return JSON.parse(stdout).providers[0] as ProviderReport
|
|
}
|
|
|
|
describe('FastGPT probe success evidence', () => {
|
|
it.each([
|
|
[{ status: 401, body: { code: 200, data: [] } }, 'http-error'],
|
|
[{ status: 500, body: { code: 200, data: { list: [] } } }, 'http-error'],
|
|
[{ body: { code: 403, data: { list: [] } } }, 'business-error'],
|
|
[{ body: { data: { list: [] } } }, 'business-error'],
|
|
[{ body: { code: 200, data: {} } }, 'invalid-shape'],
|
|
[{ body: { code: 200, data: { list: null } } }, 'invalid-shape'],
|
|
[{ raw: '{malformed' }, 'request-failed'],
|
|
[{ error: 'TimeoutError' }, 'request-failed'],
|
|
[{ error: 'TypeError' }, 'request-failed']
|
|
] as const)('does not advertise failed retrievals: %j', async (fixture, failure) => {
|
|
const report = await probe({
|
|
embedding: fixture, fullTextRecall: fixture, mixedRecall: fixture, rerank: fixture
|
|
})
|
|
expect(report.features).toEqual({
|
|
searchModes: [], rerankProbed: true, rerankSucceeded: false,
|
|
extensionQueryProbed: false
|
|
})
|
|
expect(report.retrievals).toHaveLength(4)
|
|
for (const retrieval of report.retrievals) {
|
|
expect(retrieval).toMatchObject({ success: false, failure })
|
|
expect(retrieval).not.toHaveProperty('count')
|
|
expect(retrieval).not.toHaveProperty('contentPresent')
|
|
}
|
|
})
|
|
|
|
it('distinguishes successful empty lists from failures and successful nonempty results', async () => {
|
|
const report = await probe({
|
|
embedding: success(),
|
|
fullTextRecall: { body: { code: 200, data: [] } },
|
|
mixedRecall: { body: { code: 500, data: { list: [] } } },
|
|
rerank: success([{ q: 'private fixture content', score: 0.9 }])
|
|
})
|
|
expect(report.features).toMatchObject({
|
|
searchModes: ['embedding', 'fullTextRecall'],
|
|
rerankProbed: true, rerankSucceeded: true
|
|
})
|
|
expect(report.retrievals[0]).toMatchObject({ success: true, count: 0, contentPresent: false })
|
|
expect(report.retrievals[1]).toMatchObject({ success: true, count: 0 })
|
|
expect(report.retrievals[2]).toMatchObject({ success: false, failure: 'business-error' })
|
|
expect(report.retrievals[3]).toMatchObject({ success: true, count: 1, contentPresent: true })
|
|
expect(JSON.stringify(report)).not.toContain('private fixture content')
|
|
})
|
|
|
|
it('does not claim an extended rerank probe when catalog discovery fails', async () => {
|
|
const report = await probe({}, {
|
|
status: 403,
|
|
body: { code: 200, data: [{ _id: 'fixture-dataset', type: 'dataset' }] }
|
|
})
|
|
expect(report.catalog).toMatchObject({ success: false, failure: 'http-error' })
|
|
expect(report.catalog).not.toHaveProperty('count')
|
|
expect(report.retrievals).toEqual([])
|
|
expect(report.features).toMatchObject({
|
|
searchModes: [], rerankProbed: false, rerankSucceeded: false
|
|
})
|
|
expect(report.operations).toHaveLength(1)
|
|
})
|
|
})
|