@@ -12,7 +12,6 @@ import { createServer as createHttpServer, type Server } from 'http';
1212import { WebSocketServer } from 'ws' ;
1313import fs from 'fs' ;
1414import path from 'path' ;
15- import os from 'node:os' ;
1615import { fileURLToPath } from 'url' ;
1716import { registerMockRoutes } from './mocks/routes.js' ;
1817import {
@@ -42,6 +41,7 @@ import {
4241 sendHtmlFileOrFallback ,
4342 getBindHost ,
4443 mapChannelForDashboard ,
44+ safeUsername ,
4545} from './lib/utils.js' ;
4646import {
4747 filterPhantomAgents ,
@@ -210,11 +210,11 @@ export function createServer(options: DashboardServerOptions = {}): DashboardSer
210210 if ( ! inMemoryRelayApiKey ) return null ;
211211
212212 const baseUrl = process . env . RELAYCAST_API_URL || 'https://api.relaycast.dev' ;
213- const projectIdentity = os . userInfo ( ) . username ;
213+ const projectIdentity = safeUsername ( path . basename ( path . resolve ( dataDir , '..' ) ) ) ;
214214 return applyCachedAgentIdentity ( {
215215 apiKey : inMemoryRelayApiKey ,
216216 baseUrl,
217- projectIdentity : projectIdentity ,
217+ projectIdentity,
218218 } ) ;
219219 } ;
220220
@@ -321,8 +321,7 @@ export function createServer(options: DashboardServerOptions = {}): DashboardSer
321321 }
322322
323323 const projectIdentity = config ?. agentName ?. trim ( )
324- || os . userInfo ( ) . username
325- || DASHBOARD_DISPLAY_NAME ;
324+ || safeUsername ( DASHBOARD_DISPLAY_NAME ) ;
326325 const senderInput = params . from ?. trim ( ) ?? '' ;
327326 const senderName = mode === 'proxy'
328327 ? resolveIdentity ( senderInput || projectIdentity , {
0 commit comments