(value: unknown)
| 110 | } |
| 111 | |
| 112 | function parseCollabAgentStatusesFromMap(value: unknown) { |
| 113 | if (!value || typeof value !== "object" || Array.isArray(value)) { |
| 114 | return []; |
| 115 | } |
| 116 | return Object.entries(value as Record<string, unknown>) |
| 117 | .map(([threadId, state]) => { |
| 118 | const stateRecord = |
| 119 | state && typeof state === "object" |
| 120 | ? (state as Record<string, unknown>) |
| 121 | : null; |
| 122 | const status = asString(stateRecord?.status ?? state ?? "").trim(); |
| 123 | if (!status || !threadId) { |
| 124 | return null; |
| 125 | } |
| 126 | return buildCollabAgentStatus( |
| 127 | threadId, |
| 128 | status, |
| 129 | stateRecord?.agentNickname ?? |
| 130 | stateRecord?.agent_nickname ?? |
| 131 | stateRecord?.nickname, |
| 132 | stateRecord?.agentRole ?? |
| 133 | stateRecord?.agent_role ?? |
| 134 | stateRecord?.agentType ?? |
| 135 | stateRecord?.agent_type ?? |
| 136 | stateRecord?.role, |
| 137 | ); |
| 138 | }) |
| 139 | .filter((entry): entry is CollabAgentStatus => Boolean(entry)); |
| 140 | } |
| 141 | |
| 142 | function mergeCollabAgentStatuses(...lists: CollabAgentStatus[][]) { |
| 143 | const byThreadId = new Map<string, CollabAgentStatus>(); |
no test coverage detected