MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / registerIpc

Function registerIpc

desktop/main.mjs:387–439  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

385}
386
387function registerIpc() {
388 ipcMain.handle('claw:desktop:get-bootstrap', async () => {
389 const appInfo = await loadProductMeta()
390 return {
391 isDesktop: true,
392 upstreamApiKey: await getSecret('upstreamApiKey'),
393 encryptionAvailable: safeStorage.isEncryptionAvailable(),
394 appInfo,
395 }
396 })
397
398 ipcMain.handle('claw:desktop:set-secret', async (_event, payload) => {
399 await setSecret(payload.key, payload.value)
400 return { ok: true }
401 })
402
403 ipcMain.handle('claw:desktop:pick-directory', async () => {
404 const result = await dialog.showOpenDialog({
405 properties: ['openDirectory', 'createDirectory'],
406 })
407 return result.canceled ? null : result.filePaths[0]
408 })
409
410 ipcMain.handle('claw:desktop:pick-file', async (_event, payload) => {
411 const result = await dialog.showOpenDialog({
412 properties: ['openFile'],
413 filters: payload?.filters || [],
414 })
415 return result.canceled ? null : result.filePaths[0]
416 })
417
418 ipcMain.handle('claw:desktop:save-text-file', async (_event, payload) => {
419 const result = await dialog.showSaveDialog({
420 defaultPath: payload?.defaultPath || 'claw-code-export.json',
421 filters: payload?.filters || [
422 { name: 'JSON', extensions: ['json'] },
423 { name: 'All Files', extensions: ['*'] },
424 ],
425 })
426
427 if (result.canceled || !result.filePath) {
428 return { ok: false, canceled: true }
429 }
430
431 await writeFile(result.filePath, String(payload?.content || ''), 'utf8')
432 return { ok: true, filePath: result.filePath }
433 })
434
435 ipcMain.handle('claw:desktop:restart-launcher', async () => {
436 await restartLauncher('Manual restart requested from the desktop app.')
437 return { ok: true, url: uiUrl }
438 })
439}
440
441const gotLock = app.requestSingleInstanceLock()
442if (!gotLock) {

Callers 1

main.mjsFile · 0.85

Calls 5

loadProductMetaFunction · 0.85
getSecretFunction · 0.85
setSecretFunction · 0.85
writeFileFunction · 0.85
restartLauncherFunction · 0.85

Tested by

no test coverage detected