@@ -10,8 +10,12 @@ import type { PromptPreset } from "./settings-store";
1010import type { LocalGgufModel , GpuBackend } from "./llamacpp-manager" ;
1111import type { ScheduledTask } from "./scheduled-tasks-store" ;
1212import type { LocalRuntimeStatus } from "./local-server-manager" ;
13+ import type { PythonEnvironmentStatus } from "./python-runtime-manager" ;
14+ import type { ChatSession } from "./sessions-store" ;
15+ import type { Project } from "./projects-store" ;
16+ import type { DownloadJob } from "./download-jobs-store" ;
1317
14- interface ToolExecuteResult {
18+ export interface ToolExecuteResult {
1519 result ?: unknown ;
1620 error ?: string ;
1721}
@@ -22,49 +26,49 @@ interface ToolExecuteResult {
2226// listener if it doesn't).
2327const terminalListeners = new Map < string , { data : ( ...args : unknown [ ] ) => void ; exit : ( ...args : unknown [ ] ) => void } > ( ) ;
2428
25- interface ScreenSourceInfo {
29+ export interface ScreenSourceInfo {
2630 id : string ;
2731 name : string ;
2832 thumbnailDataUrl : string ;
2933}
3034
31- interface ScreenCaptureResult {
35+ export interface ScreenCaptureResult {
3236 dataBase64 ?: string ;
3337 mimeType ?: string ;
3438 error ?: string ;
3539}
3640
37- interface FigmaFetchResult {
41+ export interface FigmaFetchResult {
3842 result ?: { dataBase64 : string ; mimeType : string ; name : string } ;
3943 error ?: string ;
4044}
4145
42- interface OcrResult {
46+ export interface OcrResult {
4347 text ?: string ;
4448 error ?: string ;
4549}
4650
47- interface HfSearchResult {
51+ export interface HfSearchResult {
4852 results ?: { id : string ; downloads : number ; likes : number ; tags : string [ ] } [ ] ;
4953 error ?: string ;
5054}
5155
52- interface HfListFilesResult {
56+ export interface HfListFilesResult {
5357 files ?: { path : string ; sizeBytes : number | null } [ ] ;
5458 error ?: string ;
5559}
5660
57- interface HfDownloadProgress {
61+ export interface HfDownloadProgress {
5862 receivedBytes : number ;
5963 totalBytes : number | null ;
6064}
6165
62- interface HfDownloadResult {
66+ export interface HfDownloadResult {
6367 path ?: string ;
6468 error ?: string ;
6569}
6670
67- interface McpConnectResult {
71+ export interface McpConnectResult {
6872 tools ?: { name : string ; description ?: string ; inputSchema ?: Record < string , unknown > } [ ] ;
6973 error ?: string ;
7074}
@@ -73,7 +77,7 @@ function randomId(): string {
7377 return Math . random ( ) . toString ( 36 ) . slice ( 2 ) ;
7478}
7579
76- contextBridge . exposeInMainWorld ( " api" , {
80+ export const api = {
7781 ollama : {
7882 status : ( ) => ipcRenderer . invoke ( "ollama:status" ) ,
7983 start : ( ) => ipcRenderer . invoke ( "ollama:start" ) ,
@@ -104,14 +108,14 @@ contextBridge.exposeInMainWorld("api", {
104108
105109 localBackends : {
106110 getStatuses : ( ) : Promise < LocalRuntimeStatus [ ] > => ipcRenderer . invoke ( "localBackends:getStatuses" ) ,
107- start : ( backend : "mlx" | "rocm" | "vllm" , model : string ) => ipcRenderer . invoke ( "localBackends:start" , { backend, model } ) ,
111+ start : ( backend : "mlx" | "rocm" | "vllm" , model : string ) : Promise < string > => ipcRenderer . invoke ( "localBackends:start" , { backend, model } ) ,
108112 stop : ( backend : "mlx" | "rocm" | "vllm" ) => ipcRenderer . invoke ( "localBackends:stop" , backend ) ,
109- restart : ( backend : "mlx" | "rocm" | "vllm" , model : string ) => ipcRenderer . invoke ( "localBackends:restart" , { backend, model } ) ,
113+ restart : ( backend : "mlx" | "rocm" | "vllm" , model : string ) : Promise < string > => ipcRenderer . invoke ( "localBackends:restart" , { backend, model } ) ,
110114 unload : ( backend : "mlx" | "rocm" | "vllm" ) => ipcRenderer . invoke ( "localBackends:unload" , backend ) ,
111115 } ,
112116
113117 pythonRuntimes : {
114- getStatuses : ( ) => ipcRenderer . invoke ( "pythonRuntimes:getStatuses" ) ,
118+ getStatuses : ( ) : Promise < PythonEnvironmentStatus [ ] > => ipcRenderer . invoke ( "pythonRuntimes:getStatuses" ) ,
115119 } ,
116120
117121 chat : {
@@ -152,8 +156,26 @@ contextBridge.exposeInMainWorld("api", {
152156 get : ( id : string ) => ipcRenderer . invoke ( "sessions:get" , id ) ,
153157 create : ( model : string | null , projectId ?: string | null ) =>
154158 ipcRenderer . invoke ( "sessions:create" , { model, projectId : projectId ?? null } ) ,
155- update : ( id : string , partial : Record < string , unknown > ) =>
156- ipcRenderer . invoke ( "sessions:update" , { id, partial } ) ,
159+ update : (
160+ id : string ,
161+ partial : Partial <
162+ Pick <
163+ ChatSession ,
164+ | "title"
165+ | "model"
166+ | "messages"
167+ | "params"
168+ | "projectId"
169+ | "systemPrompt"
170+ | "agentMode"
171+ | "agentWorkspace"
172+ | "planSteps"
173+ | "contextSummary"
174+ | "contextSummaryThroughIndex"
175+ | "tags"
176+ >
177+ >
178+ ) => ipcRenderer . invoke ( "sessions:update" , { id, partial } ) ,
157179 delete : ( id : string ) => ipcRenderer . invoke ( "sessions:delete" , id ) ,
158180 clearAll : ( ) => ipcRenderer . invoke ( "sessions:clearAll" ) ,
159181 } ,
@@ -216,7 +238,7 @@ contextBridge.exposeInMainWorld("api", {
216238
217239 downloads : {
218240 list : ( ) => ipcRenderer . invoke ( "downloads:list" ) ,
219- create : ( input : { modelId : string ; filename : string ; expectedBytes : number ; backend ?: string } ) => ipcRenderer . invoke ( "downloads:create" , input ) ,
241+ create : ( input : { modelId : string ; filename : string ; expectedBytes : number ; backend ?: "automatic" | DownloadJob [ "backend" ] } ) => ipcRenderer . invoke ( "downloads:create" , input ) ,
220242 pause : ( id : string ) => ipcRenderer . invoke ( "downloads:pause" , id ) ,
221243 resume : ( id : string ) => ipcRenderer . invoke ( "downloads:resume" , id ) ,
222244 retry : ( id : string ) => ipcRenderer . invoke ( "downloads:retry" , id ) ,
@@ -262,7 +284,7 @@ contextBridge.exposeInMainWorld("api", {
262284 projects : {
263285 list : ( ) => ipcRenderer . invoke ( "projects:list" ) ,
264286 create : ( name : string ) => ipcRenderer . invoke ( "projects:create" , name ) ,
265- update : ( id : string , partial : Record < string , unknown > ) =>
287+ update : ( id : string , partial : Partial < Pick < Project , "name" | "instructions" | "params" > > ) =>
266288 ipcRenderer . invoke ( "projects:update" , { id, partial } ) ,
267289 delete : ( id : string ) => ipcRenderer . invoke ( "projects:delete" , id ) ,
268290 } ,
@@ -364,4 +386,6 @@ contextBridge.exposeInMainWorld("api", {
364386 . finally ( ( ) => ipcRenderer . removeListener ( channel , listener ) ) ;
365387 } ,
366388 } ,
367- } ) ;
389+ } ;
390+
391+ contextBridge . exposeInMainWorld ( "api" , api ) ;
0 commit comments