|
1 | 1 | import path from 'node:path' |
| 2 | +import os from 'node:os' |
2 | 3 | import { app, powerSaveBlocker } from 'electron' |
3 | 4 | import { AGENT_SKILLS_DIR } from '../shared/paths' |
4 | 5 | import { |
5 | 6 | MCP_OAUTH_REDIRECT_BASE, |
6 | 7 | PULL_WAKE_OWNER_PRINCIPAL, |
7 | 8 | PULL_WAKE_REGISTER_RUNNER, |
8 | 9 | PULL_WAKE_RUNNER_ID, |
| 10 | + PULL_WAKE_RUNNER_LABEL, |
9 | 11 | RECONNECT_BASE_MS, |
10 | 12 | RECONNECT_MAX_MS, |
11 | 13 | } from '../shared/constants' |
@@ -36,6 +38,7 @@ export type RuntimeLifecycleDeps = { |
36 | 38 | workingDirectory?: string | null |
37 | 39 | mcp?: { servers: Array<McpServerConfig> } |
38 | 40 | pullWakeRunnerId?: string | null |
| 41 | + pullWakeRunnerLabel?: string |
39 | 42 | preventAppSuspension?: boolean |
40 | 43 | enabledModelValues?: Array<string> |
41 | 44 | } |
@@ -266,13 +269,15 @@ export async function startRuntime( |
266 | 269 |
|
267 | 270 | const serverWithPrincipal = deps.injectDevPrincipalHeaders(activeServer) |
268 | 271 | const runtimeHeaders = mergeHeaders(serverWithPrincipal.headers) |
269 | | - const cloudAuthUserId = |
270 | | - activeServer.source === `electric-cloud` |
271 | | - ? (deps.getCloudAuthState()?.userId ?? null) |
272 | | - : null |
| 272 | + const cloudAuthState = |
| 273 | + activeServer.source === `electric-cloud` ? deps.getCloudAuthState() : null |
273 | 274 | const runnerOwnerPrincipal = |
274 | | - runnerOwnerPrincipalFromUserId(cloudAuthUserId) ?? |
| 275 | + runnerOwnerPrincipalFromUserId(cloudAuthState?.userId ?? null) ?? |
275 | 276 | runnerOwnerPrincipalFromHeaders(runtimeHeaders, PULL_WAKE_OWNER_PRINCIPAL) |
| 277 | + const runnerLabelPrefix = |
| 278 | + cloudAuthState?.name?.trim() || |
| 279 | + cloudAuthState?.email?.trim() || |
| 280 | + `Electric Desktop` |
276 | 281 | console.info( |
277 | 282 | `[agents-desktop] Starting built-in agents runtime for server ${activeServer.url}` |
278 | 283 | ) |
@@ -318,7 +323,10 @@ export async function startRuntime( |
318 | 323 | ownerPrincipal: PULL_WAKE_REGISTER_RUNNER |
319 | 324 | ? runnerOwnerPrincipal |
320 | 325 | : undefined, |
321 | | - label: `Electric Agents Desktop`, |
| 326 | + label: |
| 327 | + PULL_WAKE_RUNNER_LABEL ?? |
| 328 | + deps.settings.pullWakeRunnerLabel ?? |
| 329 | + `${runnerLabelPrefix} · ${os.hostname()}`, |
322 | 330 | headers: runtimeHeaders, |
323 | 331 | claimHeaders: runtimeHeaders, |
324 | 332 | claimTokenHeader: |
|
0 commit comments