feat: 接入 pi 原生能力——Usage Card、思考等级切换、压缩与分支摘要
This commit is contained in:
@@ -141,6 +141,43 @@ export function registerIpc(): AgentService {
|
||||
return pass(() => service.logoutProvider(providerId))
|
||||
})
|
||||
|
||||
// ---- 思考等级 / 压缩 / 分支摘要(pi 原生能力) ----
|
||||
ipcMain.handle('thinking:set', (_event, level: unknown) => {
|
||||
if (typeof level !== 'string') throw new Error('invalid thinking level')
|
||||
return pass(() => service.setThinkingLevel(level as never))
|
||||
})
|
||||
|
||||
ipcMain.handle('session:compact', (_event, instructions: unknown) => {
|
||||
if (instructions !== undefined && instructions !== null && typeof instructions !== 'string') {
|
||||
throw new Error('invalid compaction instructions')
|
||||
}
|
||||
return pass(() => service.compactSession(instructions || undefined))
|
||||
})
|
||||
|
||||
ipcMain.handle('session:compact:abort', () => pass(() => service.abortCompaction()))
|
||||
|
||||
ipcMain.handle('session:autoCompact', (_event, enabled: unknown) => {
|
||||
if (typeof enabled !== 'boolean') throw new Error('invalid flag')
|
||||
return pass(() => service.setAutoCompactionEnabled(enabled))
|
||||
})
|
||||
|
||||
ipcMain.handle('session:forkPoints', () => pass(() => service.listForkPoints()))
|
||||
|
||||
ipcMain.handle('session:navigate', (_event, entryId: unknown, options: unknown) => {
|
||||
if (typeof entryId !== 'string' || !entryId.trim()) throw new Error('invalid entry id')
|
||||
const o = (options ?? {}) as { summarize?: unknown; customInstructions?: unknown }
|
||||
if (o.summarize !== undefined && typeof o.summarize !== 'boolean') throw new Error('invalid navigate options')
|
||||
if (o.customInstructions !== undefined && typeof o.customInstructions !== 'string') {
|
||||
throw new Error('invalid navigate options')
|
||||
}
|
||||
return pass(() =>
|
||||
service.navigateTree(entryId, {
|
||||
...(o.summarize === true ? { summarize: true } : {}),
|
||||
...(typeof o.customInstructions === 'string' ? { customInstructions: o.customInstructions } : {})
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
// ---- 应用设置 ----
|
||||
ipcMain.handle('settings:get', () => service.getSettings())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user