Skip to content
Merged
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
5 changes: 4 additions & 1 deletion src/main/evalops/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ipcMain } from 'electron'
import { getEvalOpsAuthStatus, loginEvalOps, logoutEvalOps } from './auth'
import { registerKestrelAgentInBackground } from './registration'
import {
getEvalOpsServicesStatus,
ingestEvalOpsSpans,
Expand All @@ -26,7 +27,9 @@ import type {
export function registerEvalOpsHandlers(): void {
ipcMain.handle('evalops:authStatus', async () => getEvalOpsAuthStatus())
ipcMain.handle('evalops:login', async (_event, options?: EvalOpsLoginOptions) => {
return loginEvalOps(options)
const status = await loginEvalOps(options)
if (status.authenticated) registerKestrelAgentInBackground('login')
return status
})
ipcMain.handle('evalops:logout', async () => logoutEvalOps())
ipcMain.handle('evalops:refreshAuth', async () => getEvalOpsAuthStatus())
Expand Down
66 changes: 66 additions & 0 deletions src/main/evalops/registration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { APP_ID, APP_NAME, APP_VERSION } from '../../shared/config'
import { getEvalOpsAuthStatus, getStoredEvalOpsSession } from './auth'
import { getEvalOpsConfig } from './config'
import { getEvalOpsConsumerClient } from './consumer'

const KESTREL_CAPABILITIES = [
'context.capture',
'llm.chat',
'mcp.client',
'meeting.recording',
'memory.recall',
'memory.store',
'trace.ingest',
'approval.request'
]

const KESTREL_SURFACES = ['kestrel', 'desktop', 'chat', 'mcp', 'meetings']

export async function registerKestrelAgent(reason: 'startup' | 'login' = 'startup'): Promise<void> {
const status = await getEvalOpsAuthStatus()
if (!status.authenticated && !status.tokenConfigured) return

const config = getEvalOpsConfig()
const session = getStoredEvalOpsSession()
const client = await getEvalOpsConsumerClient()

const response = await client.agentRegistry.register({
id: config.agentId,
workspaceId: config.workspaceId,
name: `${APP_NAME} Desktop`,
description: 'Context-aware AI desktop assistant for macOS.',
agentType: 'desktop-assistant',
capabilities: KESTREL_CAPABILITIES,
surfaces: KESTREL_SURFACES,
status: 'active',
version: APP_VERSION,
ownerId: session?.organizationId,
labels: cleanLabels({
app_id: APP_ID,
app_name: APP_NAME,
platform: process.platform,
runtime: 'electron',
registration_reason: reason,
organization_id: session?.organizationId,
workspace_id: config.workspaceId
})
})

if (response.offline) {
console.warn('[evalops:registration] Agent registration used offline fallback:', response.reason)
}
}

export function registerKestrelAgentInBackground(reason: 'startup' | 'login' = 'startup'): void {
registerKestrelAgent(reason).catch((err) => {
console.warn('[evalops:registration] Agent registration failed:', err)
})
}

function cleanLabels(labels: Record<string, string | undefined>): Record<string, string> {
const result: Record<string, string> = {}
for (const [key, value] of Object.entries(labels)) {
if (value) result[key] = value
}
return result
}
2 changes: 2 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { registerJournalHandlers } from './journal/handlers'
import { MCPServerManager } from './mcp/manager'
import { registerMCPHandlers } from './mcp/handlers'
import { registerEvalOpsHandlers } from './evalops/handlers'
import { registerKestrelAgentInBackground } from './evalops/registration'
import { registerUpdateHandlers } from './updates'
import { registerKeyboardShortcutHandlers, unregisterKeyboardShortcuts } from './shortcuts'
import { registerPlatformNotificationHandlers, unregisterPlatformNotificationHandlers } from './platform-notifications'
Expand Down Expand Up @@ -106,6 +107,7 @@ if (!gotSingleInstanceLock) {
registerMCPHandlers(mcpManager)
registerPermissionHandlers()
registerEvalOpsHandlers()
registerKestrelAgentInBackground('startup')
registerUpdateHandlers()

// Context IPC handlers
Expand Down
Loading