Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/electron/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ for (const key of Object.keys(process.env)) {

import { createApplicationMenu } from './menu'
import { registerIpcHandlers } from './ipc'
import { initAgentProfiles } from './lib/agent-profile-service'
import { createTray, destroyTray } from './tray'
import { initializeRuntime } from './lib/runtime-init'
import { seedDefaultSkills } from './lib/config-paths'
Expand Down Expand Up @@ -232,6 +233,9 @@ app.whenReady().then(async () => {
const menu = createApplicationMenu()
Menu.setApplicationMenu(menu)

// 初始化 Agent Profile(确保预置通用助手存在)
initAgentProfiles()

// Register IPC handlers
registerIpcHandlers()

Expand Down
62 changes: 62 additions & 0 deletions apps/electron/src/main/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import type {
WeChatConfig,
WeChatBridgeState,
SDKMessage,
WorkspaceCapabilitiesSummary,
} from '@proma/shared'
import type { UserProfile, AppSettings } from '../types'
import { getRuntimeStatus, getGitRepoStatus } from './lib/runtime-init'
Expand Down Expand Up @@ -164,6 +165,14 @@ import {
attachWorkspaceDirectory,
detachWorkspaceDirectory,
} from './lib/agent-workspace-manager'
import {
listAgentProfiles,
getAgentProfile,
createAgentProfile,
updateAgentProfile,
deleteAgentProfile,
} from './lib/agent-profile-service'
import type { AgentProfile, AgentProfileCreateInput, AgentProfileUpdateInput } from '@proma/shared'
import { getMemoryConfig, setMemoryConfig } from './lib/memory-service'
import { getAllToolInfos } from './lib/chat-tool-registry'
import { updateToolState, updateToolCredentials, getToolCredentials, addCustomTool, deleteCustomTool } from './lib/chat-tool-config'
Expand Down Expand Up @@ -996,6 +1005,58 @@ export function registerIpcHandlers(): void {
}
)

// ===== Agent Profile 管理 =====

ipcMain.handle(
AGENT_IPC_CHANNELS.LIST_PROFILES,
async (): Promise<AgentProfile[]> => {
return listAgentProfiles()
}
)

ipcMain.handle(
AGENT_IPC_CHANNELS.GET_PROFILE,
async (_, id: string): Promise<AgentProfile | null> => {
return getAgentProfile(id)
}
)

ipcMain.handle(
AGENT_IPC_CHANNELS.CREATE_PROFILE,
async (_, input: AgentProfileCreateInput): Promise<AgentProfile> => {
return createAgentProfile(input)
}
)

ipcMain.handle(
AGENT_IPC_CHANNELS.UPDATE_PROFILE,
async (_, id: string, input: AgentProfileUpdateInput): Promise<AgentProfile | null> => {
return updateAgentProfile(id, input)
}
)

ipcMain.handle(
AGENT_IPC_CHANNELS.DELETE_PROFILE,
async (_, id: string): Promise<boolean> => {
return deleteAgentProfile(id)
}
)

// ===== 获取所有工作区的能力汇总 =====

ipcMain.handle(
AGENT_IPC_CHANNELS.LIST_ALL_CAPABILITIES,
async (): Promise<WorkspaceCapabilitiesSummary[]> => {
const workspaces = listAgentWorkspaces()
return workspaces.map((ws) => ({
workspaceId: ws.id,
workspaceName: ws.name,
workspaceSlug: ws.slug,
capabilities: getWorkspaceCapabilities(ws.slug),
}))
}
)

// 发送 Agent 消息(触发 Agent SDK 流式响应)
ipcMain.handle(
AGENT_IPC_CHANNELS.SEND_MESSAGE,
Expand Down Expand Up @@ -2325,6 +2386,7 @@ export function registerIpcHandlers(): void {
mode: input.mode,
text: input.text,
files: input.files,
agentProfileId: input.agentProfileId,
})
mainWin.show()
mainWin.focus()
Expand Down
Loading