Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
114 lines
7.9 KiB
TypeScript
114 lines
7.9 KiB
TypeScript
import { contextBridge, ipcRenderer } from "electron";
|
|
import { IPC_CHANNELS } from "../shared/ipc";
|
|
import type { DesktopApi, RendererEvent } from "../shared/desktop-api";
|
|
|
|
function invoke<T>(channel: string, payload?: unknown): Promise<T> {
|
|
return ipcRenderer.invoke(channel, payload) as Promise<T>;
|
|
}
|
|
|
|
const api: DesktopApi = {
|
|
loadSnapshot: () => invoke(IPC_CHANNELS.loadSnapshot),
|
|
bootstrapOnboarding: (input) => invoke(IPC_CHANNELS.bootstrapOnboarding, input),
|
|
createOrganization: (input) => invoke(IPC_CHANNELS.createOrganization, input),
|
|
setActiveOrganization: (input) => invoke(IPC_CHANNELS.setActiveOrganization, input),
|
|
setUiPreferences: (input) => invoke(IPC_CHANNELS.setUiPreferences, input),
|
|
deleteOrganization: (input) => invoke(IPC_CHANNELS.deleteOrganization, input),
|
|
createAgent: (input) => invoke(IPC_CHANNELS.createAgent, input),
|
|
updateAgent: (input) => invoke(IPC_CHANNELS.updateAgent, input),
|
|
updateEmployeeProfile: (input) => invoke(IPC_CHANNELS.updateEmployeeProfile, input),
|
|
setAutonomousPaused: (input) => invoke(IPC_CHANNELS.setAutonomousPaused, input),
|
|
stopRun: (input) => invoke(IPC_CHANNELS.stopRun, input),
|
|
setIntegrationKey: (input) => invoke(IPC_CHANNELS.setIntegrationKey, input),
|
|
clearIntegrationKey: (input) => invoke(IPC_CHANNELS.clearIntegrationKey, input),
|
|
createTask: (input) => invoke(IPC_CHANNELS.createTask, input),
|
|
updateTask: (input) => invoke(IPC_CHANNELS.updateTask, input),
|
|
deleteTask: (input) => invoke(IPC_CHANNELS.deleteTask, input),
|
|
updateTaskStatus: (input) => invoke(IPC_CHANNELS.updateTaskStatus, input),
|
|
runTask: (input) => invoke(IPC_CHANNELS.runTask, input),
|
|
createGoal: (input) => invoke(IPC_CHANNELS.createGoal, input),
|
|
createProject: (input) => invoke(IPC_CHANNELS.createProject, input),
|
|
createWorkspace: (input) => invoke(IPC_CHANNELS.createWorkspace, input),
|
|
createDocument: (input) => invoke(IPC_CHANNELS.createDocument, input),
|
|
updateDocument: (input) => invoke(IPC_CHANNELS.updateDocument, input),
|
|
deleteDocument: (input) => invoke(IPC_CHANNELS.deleteDocument, input),
|
|
createKnowledgeEntry: (input) => invoke(IPC_CHANNELS.createKnowledgeEntry, input),
|
|
deleteKnowledgeEntry: (input) => invoke(IPC_CHANNELS.deleteKnowledgeEntry, input),
|
|
resumeGoal: (input) => invoke(IPC_CHANNELS.resumeGoal, input),
|
|
updateKnowledgeEntry: (input) => invoke(IPC_CHANNELS.updateKnowledgeEntry, input),
|
|
listDocumentVersions: (input) => invoke(IPC_CHANNELS.listDocumentVersions, input),
|
|
listKnowledgeRevisions: (input) => invoke(IPC_CHANNELS.listKnowledgeRevisions, input),
|
|
createAutomationRule: (input) => invoke(IPC_CHANNELS.createAutomationRule, input),
|
|
updateAutomationRule: (input) => invoke(IPC_CHANNELS.updateAutomationRule, input),
|
|
deleteAutomationRule: (input) => invoke(IPC_CHANNELS.deleteAutomationRule, input),
|
|
createMeeting: (input) => invoke(IPC_CHANNELS.createMeeting, input),
|
|
deleteMeeting: (input) => invoke(IPC_CHANNELS.deleteMeeting, input),
|
|
createSprint: (input) => invoke(IPC_CHANNELS.createSprint, input),
|
|
deleteSprint: (input) => invoke(IPC_CHANNELS.deleteSprint, input),
|
|
createApproval: (input) => invoke(IPC_CHANNELS.createApproval, input),
|
|
decideApproval: (input) => invoke(IPC_CHANNELS.decideApproval, input),
|
|
syncEmployeeIdentity: (input) => invoke(IPC_CHANNELS.syncEmployeeIdentity, input),
|
|
grantRole: (input) => invoke(IPC_CHANNELS.grantRole, input),
|
|
createChatSpace: (input) => invoke(IPC_CHANNELS.createChatSpace, input),
|
|
sendMessage: (input) => invoke(IPC_CHANNELS.sendMessage, input),
|
|
editMessage: (input) => invoke(IPC_CHANNELS.editMessage, input),
|
|
deleteMessage: (input) => invoke(IPC_CHANNELS.deleteMessage, input),
|
|
markChatSpaceRead: (input) => invoke(IPC_CHANNELS.markChatSpaceRead, input),
|
|
saveProviderCredential: (input) => invoke(IPC_CHANNELS.saveProviderCredential, input),
|
|
revokeProviderCredential: (input) => invoke(IPC_CHANNELS.revokeProviderCredential, input),
|
|
startProviderOAuth: (input) => invoke(IPC_CHANNELS.startProviderOAuth, input),
|
|
cancelProviderOAuth: (input) => invoke(IPC_CHANNELS.cancelProviderOAuth, input),
|
|
checkProviderHealth: (input) => invoke(IPC_CHANNELS.checkProviderHealth, input),
|
|
listProviderModels: (input) => invoke(IPC_CHANNELS.listProviderModels, input),
|
|
checkProviderModel: (input) => invoke(IPC_CHANNELS.checkProviderModel, input),
|
|
updateProviderPolicy: (input) => invoke(IPC_CHANNELS.updateProviderPolicy, input),
|
|
setProviderPrices: (input) => invoke(IPC_CHANNELS.setProviderPrices, input),
|
|
setGoalAuditor: (input) => invoke(IPC_CHANNELS.setGoalAuditor, input),
|
|
openExternalUrl: (url) => invoke(IPC_CHANNELS.openExternalUrl, url),
|
|
createProviderResponse: (input) => invoke(IPC_CHANNELS.createProviderResponse, input),
|
|
streamProviderResponse: (input) => invoke(IPC_CHANNELS.streamProviderResponse, input),
|
|
cancelProviderResponse: (input) => invoke(IPC_CHANNELS.cancelProviderResponse, input),
|
|
createSocialAccount: (input) => invoke(IPC_CHANNELS.createSocialAccount, input),
|
|
launchSocialLogin: (input) => invoke(IPC_CHANNELS.launchSocialLogin, input),
|
|
createScheduledPost: (input) => invoke(IPC_CHANNELS.createScheduledPost, input),
|
|
setScheduledPostState: (input) => invoke(IPC_CHANNELS.setScheduledPostState, input),
|
|
importFile: (input) => invoke(IPC_CHANNELS.importFile, input),
|
|
openFile: (input) => invoke(IPC_CHANNELS.openFile, input),
|
|
pickDirectory: () => invoke(IPC_CHANNELS.pickDirectory),
|
|
setFilePinned: (input) => invoke(IPC_CHANNELS.setFilePinned, input),
|
|
createMigrationReport: (input) => invoke(IPC_CHANNELS.createMigrationReport, input),
|
|
setFeatureFlag: (input) => invoke(IPC_CHANNELS.setFeatureFlag, input),
|
|
createComplianceExport: (input) => invoke(IPC_CHANNELS.createComplianceExport, input),
|
|
createLegalHold: (input) => invoke(IPC_CHANNELS.createLegalHold, input),
|
|
setLegalHoldState: (input) => invoke(IPC_CHANNELS.setLegalHoldState, input),
|
|
createRetentionFreeze: (input) => invoke(IPC_CHANNELS.createRetentionFreeze, input),
|
|
setRetentionFreezeState: (input) => invoke(IPC_CHANNELS.setRetentionFreezeState, input),
|
|
listConnectorCatalog: () => invoke(IPC_CHANNELS.listConnectorCatalog),
|
|
connectComposioToolkit: (input) => invoke(IPC_CHANNELS.connectComposioToolkit, input),
|
|
disconnectComposioToolkit: (input) => invoke(IPC_CHANNELS.disconnectComposioToolkit, input),
|
|
grantConnector: (input) => invoke(IPC_CHANNELS.grantConnector, input),
|
|
approvalDrifts: (input) => invoke(IPC_CHANNELS.approvalDrifts, input),
|
|
runRequests: (input) => invoke(IPC_CHANNELS.runRequests, input),
|
|
chatThreadHistory: (input) => invoke(IPC_CHANNELS.chatThreadHistory, input),
|
|
chatSpaceHistory: (input) => invoke(IPC_CHANNELS.chatSpaceHistory, input),
|
|
setTaskBlocked: (input) => invoke(IPC_CHANNELS.setTaskBlocked, input),
|
|
taskDeleteImpact: (input) => invoke(IPC_CHANNELS.taskDeleteImpact, input),
|
|
cancelQueuedRun: (input) => invoke(IPC_CHANNELS.cancelQueuedRun, input),
|
|
runHistory: (input) => invoke(IPC_CHANNELS.runHistory, input),
|
|
setGoalDueDate: (input) => invoke(IPC_CHANNELS.setGoalDueDate, input),
|
|
revokeConnector: (input) => invoke(IPC_CHANNELS.revokeConnector, input),
|
|
refreshComposioAccounts: (input) => invoke(IPC_CHANNELS.refreshComposioAccounts, input),
|
|
search: (input) => invoke(IPC_CHANNELS.search, input),
|
|
subscribe: (callback) => {
|
|
const listener = (_event: Electron.IpcRendererEvent, payload: RendererEvent) => callback(payload);
|
|
ipcRenderer.on(IPC_CHANNELS.rendererEvent, listener);
|
|
return () => ipcRenderer.removeListener(IPC_CHANNELS.rendererEvent, listener);
|
|
},
|
|
platform: process.platform as DesktopApi["platform"],
|
|
language: (process.argv.find((arg) => arg.startsWith("--app-language="))?.slice("--app-language=".length) === "zh" ? "zh" : "en") as DesktopApi["language"],
|
|
windowMinimize: () => invoke<void>(IPC_CHANNELS.windowMinimize),
|
|
windowMaximize: () => invoke<void>(IPC_CHANNELS.windowMaximize),
|
|
windowClose: () => invoke<void>(IPC_CHANNELS.windowClose),
|
|
};
|
|
|
|
contextBridge.exposeInMainWorld("agentCompany", api);
|