feat: expand model tools and document handling

This commit is contained in:
lofyer
2026-08-11 19:52:58 +08:00
parent 71a8662690
commit 184180e618
50 changed files with 2537 additions and 747 deletions
+5 -3
View File
@@ -12,12 +12,13 @@ export type BuiltinMcpServerSummary = {
assignments: readonly RuntimeTarget[]
access: 'read' | 'mixed'
authorization: 'conversation-scoped'
requiresFeature?: 'magic-notes'
}
export const builtinMcpServers = [
{
id: 'knowledge-base',
name: '知识库 MCP',
name: '知识库',
description:
'列出并搜索当前对话明确选择的知识库,返回可核验的来源与证据引用。',
tools: [
@@ -38,7 +39,7 @@ export const builtinMcpServers = [
},
{
id: 'magic-notes',
name: '笔记 MCP',
name: '笔记',
description:
'读取全局魔法笔记,并在 Execute 模式下创建、修改或删除笔记与记录。',
tools: [
@@ -90,6 +91,7 @@ export const builtinMcpServers = [
],
assignments: ['model', 'opencode', 'continue'],
access: 'mixed',
authorization: 'conversation-scoped'
authorization: 'conversation-scoped',
requiresFeature: 'magic-notes'
}
] as const satisfies readonly BuiltinMcpServerSummary[]
+24 -1
View File
@@ -3,7 +3,7 @@ export type BuiltinModelToolSummary = {
displayName: string
description: string
access: 'read' | 'write'
group: 'filesystem' | 'browser'
group: 'filesystem' | 'browser' | 'web'
}
export const builtinModelTools = [
@@ -77,6 +77,22 @@ export const builtinModelTools = [
description: '截取当前可见页面区域、约 200KB 的有界 JPEG 图片。',
access: 'read',
group: 'browser'
},
{
name: 'web_search',
displayName: '联网搜索',
description:
'通过 Exa 托管 MCP 搜索公开网页,查询词会发送给第三方服务。',
access: 'read',
group: 'web'
},
{
name: 'web_fetch',
displayName: '读取网页',
description:
'通过 Exa 托管 MCP 读取公开 HTTP 或 HTTPS 网页的有界正文。',
access: 'read',
group: 'web'
}
] as const satisfies readonly BuiltinModelToolSummary[]
@@ -94,5 +110,12 @@ export const builtinModelToolGroups = [
description:
'启用“浏览器控制”后,在 Execute 模式下操作 GoodBuddy 隔离浏览器。',
tools: builtinModelTools.filter((tool) => tool.group === 'browser')
},
{
id: 'web',
name: '联网搜索',
description:
'启用后,直连模型可在 Ask 和 Execute 模式搜索并读取公开网页。',
tools: builtinModelTools.filter((tool) => tool.group === 'web')
}
] as const
+28
View File
@@ -303,10 +303,26 @@ export const mcpServerSummarySchema = z.discriminatedUnion('transport', [
])
export type McpServerSummary = z.infer<typeof mcpServerSummarySchema>
export const webSearchCapabilitySchema = z
.object({
provider: z.literal('exa'),
enabled: z.boolean(),
availableIn: z.tuple([z.literal('ask'), z.literal('execute')]),
tools: z.tuple([
z.literal('web_search'),
z.literal('web_fetch')
])
})
.strict()
export type WebSearchCapability = z.infer<
typeof webSearchCapabilitySchema
>
export const capabilitySnapshotSchema = z
.object({
skills: z.array(skillSummarySchema).max(256),
mcpServers: z.array(mcpServerSummarySchema).max(64),
webSearch: webSearchCapabilitySchema.optional(),
computerCapabilities: z
.array(computerCapabilityConfigSummarySchema)
.max(2)
@@ -336,3 +352,15 @@ export const mcpServerTestResultSchema = z
export type McpServerTestResult = z.infer<
typeof mcpServerTestResultSchema
>
export const webSearchTestResultSchema = z
.object({
provider: z.literal('exa'),
query: z.string().min(1).max(120),
durationMs: z.number().int().min(0),
preview: z.string().min(1).max(500)
})
.strict()
export type WebSearchTestResult = z.infer<
typeof webSearchTestResultSchema
>
+16 -1
View File
@@ -8,7 +8,8 @@ import type {
ComputerCapabilityId,
McpServerInput,
McpServerTestResult,
SkillImportKind
SkillImportKind,
WebSearchTestResult
} from './capability-contracts'
import {
assistantIdSchema,
@@ -580,6 +581,13 @@ export type RuntimeSettings = {
export type ContextAttachment = ConversationAttachment
export type ContextFileSelectionProgress = {
phase: 'reading' | 'parsing'
fileName: string
fileNumber: number
fileCount: number
}
export const maximumPastedImageBytes = 12 * 1024 * 1024
export const pastedImageInputSchema = z
@@ -1211,6 +1219,10 @@ export type DesktopApi = {
) => Promise<CapabilitySnapshot>
removeMcpServer: (serverId: string) => Promise<CapabilitySnapshot>
testMcpServer: (serverId: string) => Promise<McpServerTestResult>
setWebSearchEnabled?: (
enabled: boolean
) => Promise<CapabilitySnapshot>
testWebSearch?: () => Promise<WebSearchTestResult>
setComputerCapabilityEnabled?: (
capabilityId: ComputerCapabilityId,
enabled: boolean
@@ -1237,6 +1249,9 @@ export type DesktopApi = {
}
context: {
selectFiles: () => Promise<ContextAttachment[]>
onFileSelectionProgress: (
listener: (progress: ContextFileSelectionProgress) => void
) => () => void
addPastedImage: (
input: PastedImageInput
) => Promise<ContextAttachment>
+3
View File
@@ -123,6 +123,8 @@ export const ipcChannels = {
capabilitiesSaveMcp: 'capabilities:mcp:save',
capabilitiesRemoveMcp: 'capabilities:mcp:remove',
capabilitiesTestMcp: 'capabilities:mcp:test',
capabilitiesToggleWebSearch: 'capabilities:web-search:toggle',
capabilitiesTestWebSearch: 'capabilities:web-search:test',
capabilitiesToggleComputer: 'capabilities:computer:toggle',
capabilitiesConfigureComputer: 'capabilities:computer:configure',
capabilitiesDiagnoseComputer: 'capabilities:computer:diagnose',
@@ -131,6 +133,7 @@ export const ipcChannels = {
capabilitiesDefaultBrowserProfile: 'capabilities:browser-profile:default',
capabilitiesRemoveBrowserProfile: 'capabilities:browser-profile:remove',
contextSelectFiles: 'context:select-files',
contextFileSelectionProgress: 'context:file-selection-progress',
contextAddPastedImage: 'context:add-pasted-image',
contextCaptureScreen: 'context:capture-screen',
contextListWindows: 'context:list-windows',