* Get current agent info
()
| 145 | * Get current agent info |
| 146 | */ |
| 147 | function getCurrentAgentInfo(): AgentInfo { |
| 148 | const agentId = getAgentId() ?? getSessionId() |
| 149 | const agentName = getAgentName() ?? 'main' |
| 150 | const parentSessionId = getParentSessionId() |
| 151 | |
| 152 | // Check if we've already registered this agent |
| 153 | const existing = agentRegistry.get(agentId) |
| 154 | if (existing) return existing |
| 155 | |
| 156 | const info: AgentInfo = { |
| 157 | agentId, |
| 158 | agentName, |
| 159 | parentAgentId: parentSessionId, |
| 160 | processId: agentId === getSessionId() ? 1 : getProcessIdForAgent(agentId), |
| 161 | threadId: stringToNumericHash(agentName), |
| 162 | } |
| 163 | |
| 164 | agentRegistry.set(agentId, info) |
| 165 | totalAgentCount++ |
| 166 | return info |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Get timestamp in microseconds relative to trace start |
no test coverage detected